]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't consider obsolete commands for completion in some cases
authorStefan Kangas <stefan@marxist.se>
Thu, 13 May 2021 10:17:53 +0000 (12:17 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 13 May 2021 10:17:53 +0000 (12:17 +0200)
* 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).

(There's been some back and forth here.  Obsolete commands used to be
treated normally for completion, and then they were removed.  Then
they were put back again, but annotated with what they were
obsoleting.  There was some pushback on this change, so this latest
changes is a compromise between the last two states.)

etc/NEWS
lisp/simple.el

index 205f43ce5235fcb920bf09d513db815327d8c195..18831e052af06e53dc49547cd0cc407b164ebb9f 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -389,9 +389,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.
 
 +++
index b4e34f1e4cb0e01387e020b6543a214a0f9e5a2e..35bb472be03d4ec84ee59f04e6c6f7d522246ea4 100644 (file)
@@ -2006,7 +2006,24 @@ This function uses the `read-extended-command-predicate' user option."
             '(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 (car 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)
               (cond ((null read-extended-command-predicate))