diff options
| author | Artur Malabarba | 2015-02-05 15:28:04 -0200 |
|---|---|---|
| committer | Artur Malabarba | 2015-02-05 15:29:49 -0200 |
| commit | 55eb72816b32f5a869e843036fb122065c1ed56f (patch) | |
| tree | e8414da10d82f8ab1d629deb8ca86c1cb394f25b | |
| parent | 649e21fe2f593263db5ddce373cf8ef2150630d2 (diff) | |
| download | emacs-55eb72816b32f5a869e843036fb122065c1ed56f.tar.gz emacs-55eb72816b32f5a869e843036fb122065c1ed56f.zip | |
help-fns.el (describe-function-or-variable): New function on `C-h o'
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/help-fns.el | 31 | ||||
| -rw-r--r-- | lisp/help-mode.el | 9 | ||||
| -rw-r--r-- | lisp/help.el | 2 |
4 files changed, 49 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 694a35be61d..92026c7c10e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2015-02-05 Kelly Dean <kelly@prtime.org> | ||
| 2 | |||
| 3 | * help-mode.el (help-xref-interned): Pass BUFFER and FRAME to | ||
| 4 | `describe-variable'. | ||
| 5 | |||
| 6 | * help-fns.el (describe-function-or-variable): New function. | ||
| 7 | |||
| 8 | * help.el (help-map): Bind `describe-function-or-variable' to o. | ||
| 9 | (help-for-help-internal): Document o key. | ||
| 10 | |||
| 1 | 2015-02-05 Stefan Monnier <monnier@iro.umontreal.ca> | 11 | 2015-02-05 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 12 | ||
| 3 | * delsel.el: Deprecate the `kill' option. Use lexical-binding. | 13 | * delsel.el: Deprecate the `kill' option. Use lexical-binding. |
diff --git a/lisp/help-fns.el b/lisp/help-fns.el index c0d63935035..61e8d54acb3 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el | |||
| @@ -930,6 +930,37 @@ file-local variable.\n") | |||
| 930 | 930 | ||
| 931 | 931 | ||
| 932 | ;;;###autoload | 932 | ;;;###autoload |
| 933 | (defun describe-function-or-variable (symbol &optional buffer frame) | ||
| 934 | "Display the full documentation of the function or variable SYMBOL. | ||
| 935 | If SYMBOL is a variable and has a buffer-local value in BUFFER or FRAME | ||
| 936 | \(default to the current buffer and current frame), it is displayed along | ||
| 937 | with the global value." | ||
| 938 | (interactive | ||
| 939 | (let* ((v-or-f (variable-at-point)) | ||
| 940 | (found (symbolp v-or-f)) | ||
| 941 | (v-or-f (if found v-or-f (function-called-at-point))) | ||
| 942 | (found (or found v-or-f)) | ||
| 943 | (enable-recursive-minibuffers t) | ||
| 944 | val) | ||
| 945 | (setq val (completing-read (if found | ||
| 946 | (format | ||
| 947 | "Describe function or variable (default %s): " v-or-f) | ||
| 948 | "Describe function or variable: ") | ||
| 949 | obarray | ||
| 950 | (lambda (vv) | ||
| 951 | (or (fboundp vv) | ||
| 952 | (get vv 'variable-documentation) | ||
| 953 | (and (boundp vv) (not (keywordp vv))))) | ||
| 954 | t nil nil | ||
| 955 | (if found (symbol-name v-or-f)))) | ||
| 956 | (list (if (equal val "") | ||
| 957 | v-or-f (intern val))))) | ||
| 958 | (if (not (symbolp symbol)) (message "You didn't specify a function or variable") | ||
| 959 | (unless (buffer-live-p buffer) (setq buffer (current-buffer))) | ||
| 960 | (unless (frame-live-p frame) (setq frame (selected-frame))) | ||
| 961 | (help-xref-interned symbol buffer frame))) | ||
| 962 | |||
| 963 | ;;;###autoload | ||
| 933 | (defun describe-syntax (&optional buffer) | 964 | (defun describe-syntax (&optional buffer) |
| 934 | "Describe the syntax specifications in the syntax table of BUFFER. | 965 | "Describe the syntax specifications in the syntax table of BUFFER. |
| 935 | The descriptions are inserted in a help buffer, which is then displayed. | 966 | The descriptions are inserted in a help buffer, which is then displayed. |
diff --git a/lisp/help-mode.el b/lisp/help-mode.el index c62ddc3dcd0..564362a0c43 100644 --- a/lisp/help-mode.el +++ b/lisp/help-mode.el | |||
| @@ -621,10 +621,13 @@ See `help-make-xrefs'." | |||
| 621 | 621 | ||
| 622 | 622 | ||
| 623 | ;; Additional functions for (re-)creating types of help buffers. | 623 | ;; Additional functions for (re-)creating types of help buffers. |
| 624 | (defun help-xref-interned (symbol) | 624 | |
| 625 | ;;;###autoload | ||
| 626 | (defun help-xref-interned (symbol &optional buffer frame) | ||
| 625 | "Follow a hyperlink which appeared to be an arbitrary interned SYMBOL. | 627 | "Follow a hyperlink which appeared to be an arbitrary interned SYMBOL. |
| 626 | Both variable, function and face documentation are extracted into a single | 628 | Both variable, function and face documentation are extracted into a single |
| 627 | help buffer." | 629 | help buffer. If SYMBOL is a variable, include buffer-local value for optional |
| 630 | BUFFER or FRAME." | ||
| 628 | (with-current-buffer (help-buffer) | 631 | (with-current-buffer (help-buffer) |
| 629 | ;; Push the previous item on the stack before clobbering the output buffer. | 632 | ;; Push the previous item on the stack before clobbering the output buffer. |
| 630 | (help-setup-xref nil nil) | 633 | (help-setup-xref nil nil) |
| @@ -640,7 +643,7 @@ help buffer." | |||
| 640 | (get symbol 'variable-documentation)) | 643 | (get symbol 'variable-documentation)) |
| 641 | ;; Don't record the current entry in the stack. | 644 | ;; Don't record the current entry in the stack. |
| 642 | (setq help-xref-stack-item nil) | 645 | (setq help-xref-stack-item nil) |
| 643 | (describe-variable symbol)))) | 646 | (describe-variable symbol buffer frame)))) |
| 644 | (cond | 647 | (cond |
| 645 | (sdoc | 648 | (sdoc |
| 646 | ;; We now have a help buffer on the variable. | 649 | ;; We now have a help buffer on the variable. |
diff --git a/lisp/help.el b/lisp/help.el index bf724252d5a..fb1719ac9c9 100644 --- a/lisp/help.el +++ b/lisp/help.el | |||
| @@ -95,6 +95,7 @@ | |||
| 95 | (define-key map "k" 'describe-key) | 95 | (define-key map "k" 'describe-key) |
| 96 | (define-key map "l" 'view-lossage) | 96 | (define-key map "l" 'view-lossage) |
| 97 | (define-key map "m" 'describe-mode) | 97 | (define-key map "m" 'describe-mode) |
| 98 | (define-key map "o" 'describe-function-or-variable) | ||
| 98 | (define-key map "n" 'view-emacs-news) | 99 | (define-key map "n" 'view-emacs-news) |
| 99 | (define-key map "p" 'finder-by-keyword) | 100 | (define-key map "p" 'finder-by-keyword) |
| 100 | (define-key map "P" 'describe-package) | 101 | (define-key map "P" 'describe-package) |
| @@ -218,6 +219,7 @@ L LANG-ENV Describes a specific language environment, or RET for current. | |||
| 218 | m Display documentation of current minor modes and current major mode, | 219 | m Display documentation of current minor modes and current major mode, |
| 219 | including their special commands. | 220 | including their special commands. |
| 220 | n Display news of recent Emacs changes. | 221 | n Display news of recent Emacs changes. |
| 222 | o SYMBOL Display the given function or variable's documentation and value. | ||
| 221 | p TOPIC Find packages matching a given topic keyword. | 223 | p TOPIC Find packages matching a given topic keyword. |
| 222 | P PACKAGE Describe the given Emacs Lisp package. | 224 | P PACKAGE Describe the given Emacs Lisp package. |
| 223 | r Display the Emacs manual in Info mode. | 225 | r Display the Emacs manual in Info mode. |