'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.
\f
* New Modes and Packages in Emacs 28.1
: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.
(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)))
(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)
(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)
(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)