unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#43300: [PATCH] Make M-x show new commands for obsolete aliases
@ 2020-09-09 23:59 Stefan Kangas
  2020-09-10 21:09 ` Lars Ingebrigtsen
  2020-11-18  9:14 ` Juri Linkov
  0 siblings, 2 replies; 17+ messages in thread
From: Stefan Kangas @ 2020-09-09 23:59 UTC (permalink / raw)
  To: 43300

[-- Attachment #1: Type: text/plain, Size: 986 bytes --]

Severity: wishlist

Please find attached two patches that tweaks how M-x
(execute-extended-command) works:

1. Show obsolete commands, and give their new name as an annotation.

M-x recently got the capability to show the keybindings for commands in
an annotation (in parenthesis after the command name).  This patch makes
it show new names for obsolete aliases in the same way, instead of just
refusing to show them.  This should help users ease into the new name
less abruptly and disruptively, instead of having it just disappearing
from M-x and be nowhere to be found.

As an added bonus, we could more confidently mark an alias such as
`display-time-world' obsolete (without worrying that it will just be
gone in the next release).

(Yes, if you type out the full name, you can still call it, but chances
are that many users are very reliant on tab completion and will assume
that it's just gone if it doesn't show up.)

2. Show the function that aliases point to in the same way.

[-- Attachment #2: 0001-Make-M-x-show-obsolete-commands.patch --]
[-- Type: text/x-diff, Size: 2124 bytes --]

From 870e392fc31da0f1c8a84c3196b16441908a3455 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefan@marxist.se>
Date: Thu, 10 Sep 2020 01:32:24 +0200
Subject: [PATCH 1/2] Make M-x show obsolete commands

* lisp/simple.el (read-extended-command): Don't hide obsolete
commands.
(read-extended-command--annotation): Show an annotation for obsolete
commands that says what their new name is.
---
 lisp/simple.el | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index 3b2b5c92e9..37e9a95bad 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1881,22 +1881,17 @@ read-extended-command
 	   '(metadata
 	     (annotation-function . read-extended-command--annotation)
 	     (category . command))
-         (let ((pred
-                (if (memq action '(nil t))
-                    ;; Exclude obsolete commands from completions.
-                    (lambda (sym)
-                      (and (funcall pred sym)
-                           (or (equal string (symbol-name sym))
-                               (not (get sym 'byte-obsolete-info)))))
-                  pred)))
-           (complete-with-action action obarray string pred))))
+         (complete-with-action action obarray string pred)))
      #'commandp t nil 'extended-command-history)))
 
 (defun read-extended-command--annotation (command-name)
-  (let* ((function (and (stringp command-name) (intern-soft command-name)))
-         (binding (where-is-internal function overriding-local-map t)))
-    (when (and binding (not (stringp binding)))
-      (format " (%s)" (key-description binding)))))
+  (let* ((fun (and (stringp command-name) (intern-soft command-name)))
+         (binding (where-is-internal fun overriding-local-map t))
+         (obsolete (get fun 'byte-obsolete-info)))
+    (cond (obsolete
+           (format " (%s)" (car obsolete)))
+          ((and binding (not (stringp binding)))
+           (format " (%s)" (key-description binding))))))
 
 (defcustom suggest-key-bindings t
   "Non-nil means show the equivalent key-binding when M-x command has one.
-- 
2.28.0


[-- Attachment #3: 0002-Make-M-x-show-what-aliases-point-to.patch --]
[-- Type: text/x-diff, Size: 1180 bytes --]

From c6a60a657f52712d40a80b115484904dc88e4629 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefan@marxist.se>
Date: Thu, 10 Sep 2020 01:42:53 +0200
Subject: [PATCH 2/2] Make M-x show what aliases point to

* lisp/simple.el (read-extended-command--annotation): Show an
annotation for aliases saying what it points to.
---
 lisp/simple.el | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index 37e9a95bad..73dd938e63 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1887,8 +1887,11 @@ read-extended-command
 (defun read-extended-command--annotation (command-name)
   (let* ((fun (and (stringp command-name) (intern-soft command-name)))
          (binding (where-is-internal fun overriding-local-map t))
-         (obsolete (get fun 'byte-obsolete-info)))
-    (cond (obsolete
+         (obsolete (get fun 'byte-obsolete-info))
+         (alias (symbol-function fun)))
+    (cond ((symbolp alias)
+           (format " (%s)" alias))
+          (obsolete
            (format " (%s)" (car obsolete)))
           ((and binding (not (stringp binding)))
            (format " (%s)" (key-description binding))))))
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2021-05-13 10:19 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-09 23:59 bug#43300: [PATCH] Make M-x show new commands for obsolete aliases Stefan Kangas
2020-09-10 21:09 ` Lars Ingebrigtsen
2020-09-13 13:06   ` Stefan Kangas
2020-11-18  9:14 ` Juri Linkov
2020-11-18 12:43   ` Basil L. Contovounesios
2020-11-18 13:49     ` Stefan Kangas
2020-11-18 19:10       ` Juri Linkov
2020-11-18 21:51         ` Drew Adams
2020-11-18 22:06         ` Stefan Kangas
2021-02-16 15:35           ` Stefan Kangas
2021-02-16 16:23             ` Lars Ingebrigtsen
2021-02-16 17:32               ` Stefan Kangas
2021-02-16 17:36                 ` Lars Ingebrigtsen
2021-02-17  9:52                   ` Stefan Kangas
2021-02-17 11:16                     ` Lars Ingebrigtsen
2021-02-17 13:26                     ` Basil L. Contovounesios
2021-05-13 10:19                     ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).