Commit c4fcaf5e authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

Make `C-h v' list all aliases a variable has

* lisp/help-fns.el (help-fns--var-aliases): New function (bug#15179).
parent 9aa13cd4
......@@ -1228,6 +1228,30 @@ variable.\n")))
" This variable is an alias for `%s'.\n"
(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)
(lambda (sym)
(when (and (boundp sym)
(setq alias (indirect-variable sym))
(eq alias variable)
(not (eq alias sym)))
(push sym aliases)))
(when aliases
(if (= (length aliases) 1)
" This variable has an alias: `%s'.\n" (car aliases))
" This variable has the following aliases: %s.\n"
(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))
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment