emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Repeat lambda


From: T.V Raman
Subject: Re: Repeat lambda
Date: Tue, 13 Apr 2021 16:45:37 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Juri Linkov <juri@linkov.net> writes:


You can do all this with a few lines of hydra,
a undo/redo hydra that gets launched with C-x u, and then  -- u and U
trigger the two heads in the hydra.
>>> I see that You bind `C-x u` as a repeat command, but in my case I have
>>> undo-only. The repeat transient map still uses the normal undo BUT maybe
>>> there is a "simple" method (in the user config of course) to make u u u
>>> use the undo-only and (as a plus) make r r r to do undo-redo?
>>>
>>> I suppose that this only needs some define-key like below?
>
> Since there is no key to initiate an undo-redo sequence,
> re the comment in bindings.el:
>
>   ;; Richard said that we should not use C-x <uppercase letter> and I have
>   ;; no idea whereas to bind it.  Any suggestion welcome.  -stef
>   ;; (define-key ctl-x-map "U" 'undo-only)
>
> Maybe 'C-x u u' could start such key sequence with the command 'undo',
> then 'r' could switch to a different keymap
> where 'r' is bound to 'undo-redo' and 'u' to 'undo-only'.
> Perhaps such heuristics makes sense that once the user typed 'r',
> the next 'u' should do 'undo-only'?
>
> #+begin_src emacs-lisp
> (defvar undo-repeat-map
>   (let ((map (make-sparse-keymap)))
>     (define-key map "u" 'undo)
>     (define-key map "r" 'undo-redo)
>     map)
>   "Keymap to repeat undo key sequences `C-x u u'.  Used in `repeat-mode'.")
> (put 'undo 'repeat-map 'undo-repeat-map)
>
> (defvar undo-redo-repeat-map
>   (let ((map (make-sparse-keymap)))
>     (define-key map "r" 'undo-redo)
>     (define-key map "u" 'undo-only)
>     map)
>   "Keymap to repeat undo-redo key sequences.  Used in `repeat-mode'.")
> (put 'undo-redo 'repeat-map 'undo-redo-repeat-map)
> (put 'undo-only 'repeat-map 'undo-redo-repeat-map)
> #+end_src
>

-- 

Thanks,

--Raman
?7?4 Id: kg:/m/0285kf1  ?0?8



reply via email to

[Prev in Thread] Current Thread [Next in Thread]