]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/repeat.el (repeat-keep-prefix): New defcustom.
authorJuri Linkov <juri@linkov.net>
Mon, 5 Apr 2021 21:02:43 +0000 (00:02 +0300)
committerJuri Linkov <juri@linkov.net>
Mon, 5 Apr 2021 21:02:43 +0000 (00:02 +0300)
* 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

etc/NEWS
lisp/repeat.el
lisp/window.el

index 1421efcaa076cfebc6ff9d00367a7a58b69bef62..c8400ba8c275bc9ca7ff5d789e1e9a4341f592ed 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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.
 
 \f
 * New Modes and Packages in Emacs 28.1
index a5ab43950c27e2ff637857b41085681c0ae92741..1830bcc04970db413c3e45849dea1fb7fc9a0f0b 100644 (file)
@@ -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)
 
index f27631bb86af9f029cb8c3b405119c22813a4e6e..071761ea50f54fa6af34390ebf3045b1d4ba25e3 100644 (file)
@@ -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)