emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [bug] deleting backward char does not do undo-boundary
@ 2020-08-14 23:18 Samuel Wales
  2020-08-22  4:17 ` Kyle Meyer
  0 siblings, 1 reply; 4+ messages in thread
From: Samuel Wales @ 2020-08-14 23:18 UTC (permalink / raw)
  To: emacs-orgmode

you know that thing in emacs where up to 20 self-insert-command
invocations are undone all at once?  i dislike it and have fixed it
for everything except one command in org.

in org, backspace [org delete backward char] clusters for undo
["amalgamates" in emacs lingo] even when
org-self-insert-cluster-for-undo is nil.  this is not true of delete,
which works ok.

here is my code to try to fix it [note that i fix teh rest of emacs 25
also].  but that one command does not accept the undo-boundary that i
call.  i do not udnerstand why this is the case.

  (defun alpha-wrap-with-undo-boundary (old)
    (interactive)
    ;; (defun (make-symbol (concat "alpha-") old) ()
    ;;   (interactive)
    (call-interactively old)
    (undo-boundary))
  (define-key global-map [remap delete-char] #'alpha-delete-char)
  (define-key global-map [remap delete-forward-char]
#'alpha-delete-forward-char)
  (define-key global-map [remap delete-backward-char]
#'alpha-delete-backward-char)
  (define-key global-map [remap backward-delete-char-untabify]
    #'alpha-backward-delete-char-untabify)
  (defun alpha-delete-char () (interactive)
(alpha-wrap-with-undo-boundary 'delete-char))
  (defun alpha-backward-delete-char-untabify ()
    (interactive)
    (alpha-wrap-with-undo-boundary 'backward-delete-char-untabify))
  (defun alpha-delete-forward-char ()
    (interactive)
    (alpha-wrap-with-undo-boundary 'delete-forward-char))
  (defun alpha-delete-backward-char ()
    (interactive)
    (alpha-wrap-with-undo-boundary 'delete-backward-char))
  ;; ;; not work.   it is an alias.  trying org versions.
  ;; (define-key global-map [remap backward-delete-char]
#'alpha-backward-delete-char)
  ;; (defun alpha-backward-delete-char ()
  ;;   (interactive)
  ;;   (alpha-wrap-with-undo-boundary 'backward-delete-char))
  (define-key org-mode-map [remap org-delete-backward-char]
#'alpha-org-delete-backward-char)
  (define-key org-mode-map [remap org-delete-char] #'alpha-org-delete-char)
  (defun alpha-org-delete-char () (interactive)
(alpha-wrap-with-undo-boundary 'org-delete-char))
  (defun alpha-org-delete-backward-char () (interactive)
(alpha-wrap-with-undo-boundary 'org-delete-backward-char))

-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [bug] deleting backward char does not do undo-boundary
  2020-08-14 23:18 [bug] deleting backward char does not do undo-boundary Samuel Wales
@ 2020-08-22  4:17 ` Kyle Meyer
  2020-08-22  4:38   ` Samuel Wales
  0 siblings, 1 reply; 4+ messages in thread
From: Kyle Meyer @ 2020-08-22  4:17 UTC (permalink / raw)
  To: Samuel Wales, emacs-orgmode

Samuel Wales writes:

> here is my code to try to fix it [note that i fix teh rest of emacs 25
> also].  but that one command does not accept the undo-boundary that i
> call.  i do not udnerstand why this is the case.

Without looking at this too closely, I'd guess it's because ...

>   (define-key org-mode-map [remap org-delete-backward-char]
> #'alpha-org-delete-backward-char)
>   (define-key org-mode-map [remap org-delete-char] #'alpha-org-delete-char)
>   (defun alpha-org-delete-char () (interactive)
> (alpha-wrap-with-undo-boundary 'org-delete-char))
>   (defun alpha-org-delete-backward-char () (interactive)
> (alpha-wrap-with-undo-boundary 'org-delete-backward-char))

... you're trying to remap a command that is itself remapping a command.

  (info "(elisp)remapping commands")

    In addition, remapping only works through a single level; in the
    following example,
    
         (define-key my-mode-map [remap kill-line] 'my-kill-line)
         (define-key my-mode-map [remap my-kill-line] 'my-other-kill-line)
    
    ‘kill-line’ is _not_ remapped to ‘my-other-kill-line’.  Instead, if
    an ordinary key binding specifies ‘kill-line’, it is remapped to
    ‘my-kill-line’; if an ordinary binding specifies ‘my-kill-line’, it
    is remapped to ‘my-other-kill-line’.

Perhaps just bind it directly?

    (define-key org-mode-map (kbd "DEL") #'alpha-org-delete-backward-char)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [bug] deleting backward char does not do undo-boundary
  2020-08-22  4:17 ` Kyle Meyer
@ 2020-08-22  4:38   ` Samuel Wales
  2020-08-22  5:03     ` Kyle Meyer
  0 siblings, 1 reply; 4+ messages in thread
From: Samuel Wales @ 2020-08-22  4:38 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: emacs-orgmode

ah, so org did the remap and i tried to remap the remap?

my brain is not working right now, but i think you might be right.  in
either case, your solution works and is straightforward.

thank you.


On 8/21/20, Kyle Meyer <kyle@kyleam.com> wrote:
> Samuel Wales writes:
>
>> here is my code to try to fix it [note that i fix teh rest of emacs 25
>> also].  but that one command does not accept the undo-boundary that i
>> call.  i do not udnerstand why this is the case.
>
> Without looking at this too closely, I'd guess it's because ...
>
>>   (define-key org-mode-map [remap org-delete-backward-char]
>> #'alpha-org-delete-backward-char)
>>   (define-key org-mode-map [remap org-delete-char]
>> #'alpha-org-delete-char)
>>   (defun alpha-org-delete-char () (interactive)
>> (alpha-wrap-with-undo-boundary 'org-delete-char))
>>   (defun alpha-org-delete-backward-char () (interactive)
>> (alpha-wrap-with-undo-boundary 'org-delete-backward-char))
>
> ... you're trying to remap a command that is itself remapping a command.
>
>   (info "(elisp)remapping commands")
>
>     In addition, remapping only works through a single level; in the
>     following example,
>
>          (define-key my-mode-map [remap kill-line] 'my-kill-line)
>          (define-key my-mode-map [remap my-kill-line] 'my-other-kill-line)
>
>     ‘kill-line’ is _not_ remapped to ‘my-other-kill-line’.  Instead, if
>     an ordinary key binding specifies ‘kill-line’, it is remapped to
>     ‘my-kill-line’; if an ordinary binding specifies ‘my-kill-line’, it
>     is remapped to ‘my-other-kill-line’.
>
> Perhaps just bind it directly?
>
>     (define-key org-mode-map (kbd "DEL") #'alpha-org-delete-backward-char)
>


-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [bug] deleting backward char does not do undo-boundary
  2020-08-22  4:38   ` Samuel Wales
@ 2020-08-22  5:03     ` Kyle Meyer
  0 siblings, 0 replies; 4+ messages in thread
From: Kyle Meyer @ 2020-08-22  5:03 UTC (permalink / raw)
  To: Samuel Wales; +Cc: emacs-orgmode

Samuel Wales writes:

> ah, so org did the remap and i tried to remap the remap?

Yes, with the standard value for org-mode-map, here's what
describe-variable (C-h v) says:

    (remap keymap
      ...
      (delete-backward-char . org-delete-backward-char)



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-08-22  5:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-14 23:18 [bug] deleting backward char does not do undo-boundary Samuel Wales
2020-08-22  4:17 ` Kyle Meyer
2020-08-22  4:38   ` Samuel Wales
2020-08-22  5:03     ` Kyle Meyer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).