Commit 15de559d authored by Juri Linkov's avatar Juri Linkov

* lisp/repeat.el (repeat-keep-prefix): New defcustom.

* lisp/repeat.el (repeat-map): New autoloaded global variable.
(repeat-post-hook): Use 'repeat-map' when non-nil
and reset it to nil afterwards.
(repeat-post-hook): Keep the current prefix when
'repeat-keep-prefix' is non-nil.

* lisp/window.el (other-window-repeat-map): Add "O" that sets
'repeat-map' to 'other-window-repeat-map' before calling
'(other-window -1)'.

https://lists.gnu.org/archive/html/emacs-devel/2021-03/msg01387.html
parent 9c51a9d0
Pipeline #10156 passed with stages
in 11 minutes and 5 seconds
......@@ -2251,6 +2251,10 @@ You can type 'C-x u u' instead of 'C-x u C-x u' to undo many changes,
'M-g n n p p' to navigate next-error matches. Any other key exits
transient mode and then is executed normally. 'repeat-exit-key'
defines an additional key to exit mode like 'isearch-exit' ('RET').
With 'repeat-keep-prefix' you can keep the prefix arg of the previous command.
For example, this can help to reverse the window navigation direction
with e.g. 'C-x o M-- o o'. Also it can help to set a new step with
e.g. 'C-x { C-5 { { {' will set the window resizing step to 5 columns.
* New Modes and Packages in Emacs 28.1
......
......@@ -342,6 +342,14 @@ For example, you can set it to <return> like `isearch-exit'."
:group 'convenience
:version "28.1")
(defcustom repeat-keep-prefix t
"Keep the prefix arg of the previous command."
:type 'boolean
:group 'convenience
:version "28.1")
;;;###autoload (defvar repeat-map nil)
;;;###autoload
(define-minor-mode repeat-mode
"Toggle Repeat mode.
......@@ -364,8 +372,9 @@ When Repeat mode is enabled, and the command symbol has the property named
(defun repeat-post-hook ()
"Function run after commands to set transient keymap for repeatable keys."
(when repeat-mode
(let ((rep-map (and (symbolp this-command)
(get this-command 'repeat-map))))
(let ((rep-map (or repeat-map
(and (symbolp this-command)
(get this-command 'repeat-map)))))
(when rep-map
(when (boundp rep-map)
(setq rep-map (symbol-value rep-map)))
......@@ -382,6 +391,9 @@ When Repeat mode is enabled, and the command symbol has the property named
(when (or (lookup-key map (this-single-command-keys) nil)
prefix-command-p)
(when (and repeat-keep-prefix (not prefix-command-p))
(setq prefix-arg current-prefix-arg))
;; Messaging
(unless prefix-command-p
(map-keymap (lambda (key _) (push key keys)) map)
......@@ -402,7 +414,8 @@ When Repeat mode is enabled, and the command symbol has the property named
(when repeat-exit-key
(define-key map repeat-exit-key 'ignore))
(set-transient-map map)))))))
(set-transient-map map))))))
(setq repeat-map nil))
(provide 'repeat)
......
......@@ -10256,6 +10256,10 @@ displaying that processes's buffer."
(defvar other-window-repeat-map
(let ((map (make-sparse-keymap)))
(define-key map "o" 'other-window)
(define-key map "O" (lambda ()
(interactive)
(setq repeat-map 'other-window-repeat-map)
(other-window -1)))
map)
"Keymap to repeat other-window key sequences. Used in `repeat-mode'.")
(put 'other-window 'repeat-map 'other-window-repeat-map)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment