From ed4b51962ea5494b92e0d078916558cab27a836a Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 12 Apr 2021 19:14:45 +0300 Subject: [PATCH] * lisp/repeat.el (repeat-mode-echo): New defcustom. (repeat-post-hook): Use it. (repeat-mode-message): New function (bug#47566). (repeat-post-hook): Use real-this-command instead of this-command to handle e.g. rectangle-exchange-point-and-mark remapped to exchange-point-and-mark (bug#47688). --- lisp/repeat.el | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/lisp/repeat.el b/lisp/repeat.el index b3c58f2f818..f1b20d369bf 100644 --- a/lisp/repeat.el +++ b/lisp/repeat.el @@ -348,6 +348,17 @@ For example, you can set it to like `isearch-exit'." :group 'convenience :version "28.1") +(defcustom repeat-mode-echo #'repeat-mode-message + "Function to display a hint about available keys. +Function is called after every repeatable command with one argument: +a string with a list of keys." + :type '(choice (const :tag "Show hints in the echo area" + repeat-mode-message) + (const :tag "Don't show hints" ignore) + (function :tag "Function")) + :group 'convenience + :version "28.1") + ;;;###autoload (defvar repeat-map nil "The value of the repeating map for the next command. @@ -377,8 +388,8 @@ When Repeat mode is enabled, and the command symbol has the property named "Function run after commands to set transient keymap for repeatable keys." (when repeat-mode (let ((rep-map (or repeat-map - (and (symbolp this-command) - (get this-command 'repeat-map))))) + (and (symbolp real-this-command) + (get real-this-command 'repeat-map))))) (when rep-map (when (boundp rep-map) (setq rep-map (symbol-value rep-map))) @@ -403,9 +414,7 @@ When Repeat mode is enabled, and the command symbol has the property named (format ", or exit with %s" (key-description repeat-exit-key)) "")))) - (if (current-message) - (message "%s [%s]" (current-message) mess) - (message mess)))) + (funcall repeat-mode-echo mess))) ;; Adding an exit key (when repeat-exit-key @@ -417,6 +426,12 @@ When Repeat mode is enabled, and the command symbol has the property named (set-transient-map map)))))) (setq repeat-map nil)) +(defun repeat-mode-message (mess) + "Function that displays available repeating keys in the echo area." + (if (current-message) + (message "%s [%s]" (current-message) mess) + (message mess))) + (provide 'repeat) ;;; repeat.el ends here -- 2.39.2