diff options
| author | Lars Ingebrigtsen | 2019-10-14 07:47:53 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-10-14 07:47:53 +0200 |
| commit | c4fcaf5e729fe5ff9249a56b1d0f5927ef3932a5 (patch) | |
| tree | bdfd12ac70b0f900c6ff922de595fb5e6cb9fb6c | |
| parent | 9aa13cd4beccfe41e8f4930cb029bd60e7788e93 (diff) | |
| download | emacs-c4fcaf5e729fe5ff9249a56b1d0f5927ef3932a5.tar.gz emacs-c4fcaf5e729fe5ff9249a56b1d0f5927ef3932a5.zip | |
Make `C-h v' list all aliases a variable has
* lisp/help-fns.el (help-fns--var-aliases): New function (bug#15179).
| -rw-r--r-- | lisp/help-fns.el | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 06b15a30f99..bd27ad62605 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el | |||
| @@ -1228,6 +1228,30 @@ variable.\n"))) | |||
| 1228 | " This variable is an alias for `%s'.\n" | 1228 | " This variable is an alias for `%s'.\n" |
| 1229 | alias))))) | 1229 | alias))))) |
| 1230 | 1230 | ||
| 1231 | (add-hook 'help-fns-describe-variable-functions #'help-fns--var-aliases) | ||
| 1232 | (defun help-fns--var-aliases (variable) | ||
| 1233 | ;; Mention if it has any aliases. | ||
| 1234 | (let (aliases) | ||
| 1235 | (mapatoms | ||
| 1236 | (lambda (sym) | ||
| 1237 | (when (and (boundp sym) | ||
| 1238 | (setq alias (indirect-variable sym)) | ||
| 1239 | (eq alias variable) | ||
| 1240 | (not (eq alias sym))) | ||
| 1241 | (push sym aliases))) | ||
| 1242 | obarray) | ||
| 1243 | (when aliases | ||
| 1244 | (princ | ||
| 1245 | (if (= (length aliases) 1) | ||
| 1246 | (format-message | ||
| 1247 | " This variable has an alias: `%s'.\n" (car aliases)) | ||
| 1248 | (format-message | ||
| 1249 | " This variable has the following aliases: %s.\n" | ||
| 1250 | (mapconcat | ||
| 1251 | (lambda (sym) | ||
| 1252 | (format "`%s'" sym)) | ||
| 1253 | aliases ",\n "))))))) | ||
| 1254 | |||
| 1231 | (add-hook 'help-fns-describe-variable-functions #'help-fns--var-bufferlocal) | 1255 | (add-hook 'help-fns-describe-variable-functions #'help-fns--var-bufferlocal) |
| 1232 | (defun help-fns--var-bufferlocal (variable) | 1256 | (defun help-fns--var-bufferlocal (variable) |
| 1233 | (let ((permanent-local (get variable 'permanent-local)) | 1257 | (let ((permanent-local (get variable 'permanent-local)) |