emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master c4fcaf5: Make `C-h v' list all aliases a variable h


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master c4fcaf5: Make `C-h v' list all aliases a variable has
Date: Mon, 14 Oct 2019 01:48:05 -0400 (EDT)

branch: master
commit c4fcaf5e729fe5ff9249a56b1d0f5927ef3932a5
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Make `C-h v' list all aliases a variable has
    
    * lisp/help-fns.el (help-fns--var-aliases): New function (bug#15179).
---
 lisp/help-fns.el | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 06b15a3..bd27ad6 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -1228,6 +1228,30 @@ variable.\n")))
               "  This variable is an alias for `%s'.\n"
               alias)))))
 
+(add-hook 'help-fns-describe-variable-functions #'help-fns--var-aliases)
+(defun help-fns--var-aliases (variable)
+  ;; Mention if it has any aliases.
+  (let (aliases)
+    (mapatoms
+     (lambda (sym)
+       (when (and (boundp sym)
+                 (setq alias (indirect-variable sym))
+                  (eq alias variable)
+                 (not (eq alias sym)))
+        (push sym aliases)))
+     obarray)
+    (when aliases
+      (princ
+       (if (= (length aliases) 1)
+           (format-message
+            "  This variable has an alias: `%s'.\n" (car aliases))
+         (format-message
+          "  This variable has the following aliases: %s.\n"
+          (mapconcat
+           (lambda (sym)
+             (format "`%s'" sym))
+           aliases ",\n    ")))))))
+
 (add-hook 'help-fns-describe-variable-functions #'help-fns--var-bufferlocal)
 (defun help-fns--var-bufferlocal (variable)
   (let ((permanent-local (get variable 'permanent-local))



reply via email to

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