emacs-diffs
[Top][All Lists]
Advanced

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

master 935e4da0e1: Display new keybinding in obsolete command warning


From: Stefan Kangas
Subject: master 935e4da0e1: Display new keybinding in obsolete command warning
Date: Fri, 19 Aug 2022 13:00:31 -0400 (EDT)

branch: master
commit 935e4da0e1389fd5a8f836ac81dc53d698f4439f
Author: Stefan Kangas <stefankangas@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>

    Display new keybinding in obsolete command warning
    
    * lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning):
    * lisp/simple.el (command-execute): When warning about an obsolete
    command, display the keybinding for the new command.
---
 lisp/emacs-lisp/macroexp.el |  4 +++-
 lisp/simple.el              | 11 +++++++----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el
index 5ae9d8368f..40ed0344df 100644
--- a/lisp/emacs-lisp/macroexp.el
+++ b/lisp/emacs-lisp/macroexp.el
@@ -187,13 +187,15 @@ It should normally be a symbol with position and it 
defaults to FORM."
                msg))
     form)))
 
-(defun macroexp--obsolete-warning (fun obsolescence-data type)
+(defun macroexp--obsolete-warning (fun obsolescence-data type &optional key)
   (let ((instead (car obsolescence-data))
         (asof (nth 2 obsolescence-data)))
     (format-message
      "`%s' is an obsolete %s%s%s" fun type
      (if asof (concat " (as of " asof ")") "")
      (cond ((stringp instead) (concat "; " (substitute-command-keys instead)))
+           ((and instead key)
+            (format-message "; use `%s' (%s) instead." instead key))
            (instead (format-message "; use `%s' instead." instead))
            (t ".")))))
 
diff --git a/lisp/simple.el b/lisp/simple.el
index 8fb03f3b04..d862c0e9a8 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2716,12 +2716,15 @@ don't clear it."
          (t
           ;; Pass `cmd' rather than `final', for the backtrace's sake.
           (prog1 (call-interactively cmd record-flag keys)
-            (when (and (symbolp cmd)
-                       (get cmd 'byte-obsolete-info)
-                       (not (get cmd 'command-execute-obsolete-warned)))
+            (when-let ((info
+                        (and (symbolp cmd)
+                             (not (get cmd 'command-execute-obsolete-warned))
+                             (get cmd 'byte-obsolete-info))))
               (put cmd 'command-execute-obsolete-warned t)
               (message "%s" (macroexp--obsolete-warning
-                             cmd (get cmd 'byte-obsolete-info) 
"command"))))))))))
+                             cmd info "command"
+                             (help--key-description-fontified
+                              (where-is-internal (car info) nil t))))))))))))
 
 (defun command-execute--query (command)
   "Query the user whether to run COMMAND."



reply via email to

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