[Top][All Lists]

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

Re: Repeat lambda

From: Juri Linkov
Subject: Re: Repeat lambda
Date: Tue, 13 Apr 2021 22:35:25 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>> 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)
  "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)
  "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)

reply via email to

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