summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/simple.el19
2 files changed, 21 insertions, 3 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 205f43ce523..18831e052af 100644
--- 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.
+++
diff --git a/lisp/simple.el b/lisp/simple.el
index b4e34f1e4cb..35bb472be03 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -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))