unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: "Basil L. Contovounesios" <contovob@tcd.ie>,
	43300@debbugs.gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>,
	Juri Linkov <juri@linkov.net>
Subject: bug#43300: [PATCH] Make M-x show new commands for obsolete aliases
Date: Wed, 17 Feb 2021 01:52:18 -0800	[thread overview]
Message-ID: <CADwFkm=baXafCxm+QKgNEZvEfoQMcem67e6hGHuMtbEoS-7CEw@mail.gmail.com> (raw)
In-Reply-To: <87eehfvrr8.fsf@gnus.org>

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

Lars Ingebrigtsen <larsi@gnus.org> writes:

>> How about showing only obsolete aliases that are new in this major
>> version?  That could give us almost all the benefits without any of the
>> drawbacks.
>
> Hm!  That's a pretty attractive option.  So commands deprecate faster
> than functions...  makes sense to me.

Here's a patch that does that.

[-- Attachment #2: 0001-Don-t-consider-obsolete-commands-for-obsoletion-in-s.patch --]
[-- Type: text/x-diff, Size: 2786 bytes --]

From 10715922a84d067b838fef82bd8b3ed8782d65ff Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefan@marxist.se>
Date: Wed, 17 Feb 2021 10:45:00 +0100
Subject: [PATCH] Don't consider obsolete commands for obsoletion in some cases

* lisp/simple.el (read-extended-command): Exclude obsolete commands
that are either lacking a 'current-name' or were obsoleted in a
previous major version.  (Bug#43300)
---
 etc/NEWS       |  5 +++--
 lisp/simple.el | 19 ++++++++++++++++++-
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index 943ad6ac59..7b257b9de0 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -323,9 +323,10 @@ setting the variable 'auto-save-visited-mode' buffer-locally to nil.
 description of the properties.  Likewise 'button-describe' does the
 same for a button.
 
-** Obsolete commands are no longer hidden from command completion.
+** Obsolete aliases are no longer hidden from command completion.
 Completion of command names now considers obsolete aliases as
-candidates.  Invoking a command via an obsolete alias now mentions the
+candidates, if they were marked obsolete in the current major version
+of Emacs.  Invoking a command via an obsolete alias now mentions the
 obsolescence fact and shows the new name of the command.
 
 +++
diff --git a/lisp/simple.el b/lisp/simple.el
index 215f4399f4..08155c36db 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1967,7 +1967,24 @@ read-extended-command
 	     '(metadata
 	       (affixation-function . read-extended-command--affixation)
 	       (category . command))
-           (complete-with-action action obarray string pred)))
+           (let ((pred
+                  (if (memq action '(nil t))
+                      ;; Exclude from completions obsolete commands
+                      ;; lacking a `current-name', or where `when' is
+                      ;; not the current major version.
+                      (lambda (sym)
+                        (let ((obsolete (get sym 'byte-obsolete-info)))
+                          (and (funcall pred sym)
+                               (or (equal string (symbol-name sym))
+                                   (not obsolete)
+                                   (and
+                                    ;; has a current-name
+                                    (functionp (cadr obsolete))
+                                    ;; when >= emacs-major-version
+                                    (>= (car (version-to-list (caddr obsolete)))
+                                        emacs-major-version))))))
+                    pred)))
+             (complete-with-action action obarray string pred))))
        (lambda (sym)
          (and (commandp sym)
               (funcall read-extended-command-predicate sym buffer)))
-- 
2.30.0


  reply	other threads:[~2021-02-17  9:52 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2021-02-17 11:16                     ` Lars Ingebrigtsen
2021-02-17 13:26                     ` Basil L. Contovounesios
2021-05-13 10:19                     ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADwFkm=baXafCxm+QKgNEZvEfoQMcem67e6hGHuMtbEoS-7CEw@mail.gmail.com' \
    --to=stefan@marxist.se \
    --cc=43300@debbugs.gnu.org \
    --cc=contovob@tcd.ie \
    --cc=juri@linkov.net \
    --cc=larsi@gnus.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).