]> code.delx.au - gnu-emacs/commitdiff
help-fns.el (describe-function-or-variable): New function on `C-h o'
authorArtur Malabarba <bruce.connor.am@gmail.com>
Thu, 5 Feb 2015 17:28:04 +0000 (15:28 -0200)
committerArtur Malabarba <bruce.connor.am@gmail.com>
Thu, 5 Feb 2015 17:29:49 +0000 (15:29 -0200)
lisp/ChangeLog
lisp/help-fns.el
lisp/help-mode.el
lisp/help.el

index 694a35be61df7c8a90c908201e0179ccc99b4b91..92026c7c10e8851d7a74a32e3db0d70a808ee71c 100644 (file)
@@ -1,3 +1,13 @@
+2015-02-05  Kelly Dean <kelly@prtime.org>
+
+       * help-mode.el (help-xref-interned): Pass BUFFER and FRAME to
+       `describe-variable'.
+
+       * help-fns.el (describe-function-or-variable): New function.
+
+       * help.el (help-map): Bind `describe-function-or-variable' to o.
+       (help-for-help-internal): Document o key.
+
 2015-02-05  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * delsel.el: Deprecate the `kill' option.  Use lexical-binding.
index c0d63935035af0d4ce6e979b478c43aaabc3cda3..61e8d54acb3ed267267a33a8a8476ba83bdb6e0f 100644 (file)
@@ -929,6 +929,37 @@ file-local variable.\n")
              (buffer-string))))))))
 
 
+;;;###autoload
+(defun describe-function-or-variable (symbol &optional buffer frame)
+  "Display the full documentation of the function or variable SYMBOL.
+If SYMBOL is a variable and has a buffer-local value in BUFFER or FRAME
+\(default to the current buffer and current frame), it is displayed along
+with the global value."
+  (interactive
+   (let* ((v-or-f (variable-at-point))
+          (found (symbolp v-or-f))
+          (v-or-f (if found v-or-f (function-called-at-point)))
+          (found (or found v-or-f))
+          (enable-recursive-minibuffers t)
+          val)
+     (setq val (completing-read (if found
+                                   (format
+                                        "Describe function or variable (default %s): " v-or-f)
+                                 "Describe function or variable: ")
+                               obarray
+                               (lambda (vv)
+                                 (or (fboundp vv)
+                                     (get vv 'variable-documentation)
+                                     (and (boundp vv) (not (keywordp vv)))))
+                               t nil nil
+                               (if found (symbol-name v-or-f))))
+     (list (if (equal val "")
+              v-or-f (intern val)))))
+  (if (not (symbolp symbol)) (message "You didn't specify a function or variable")
+    (unless (buffer-live-p buffer) (setq buffer (current-buffer)))
+    (unless (frame-live-p frame) (setq frame (selected-frame)))
+    (help-xref-interned symbol buffer frame)))
+
 ;;;###autoload
 (defun describe-syntax (&optional buffer)
   "Describe the syntax specifications in the syntax table of BUFFER.
index c62ddc3dcd01b42b41dbfb11708746d53b851142..564362a0c438a865c79c716b9386a148c72b7fc6 100644 (file)
@@ -621,10 +621,13 @@ See `help-make-xrefs'."
 
 \f
 ;; Additional functions for (re-)creating types of help buffers.
-(defun help-xref-interned (symbol)
+
+;;;###autoload
+(defun help-xref-interned (symbol &optional buffer frame)
   "Follow a hyperlink which appeared to be an arbitrary interned SYMBOL.
 Both variable, function and face documentation are extracted into a single
-help buffer."
+help buffer. If SYMBOL is a variable, include buffer-local value for optional
+BUFFER or FRAME."
   (with-current-buffer (help-buffer)
     ;; Push the previous item on the stack before clobbering the output buffer.
     (help-setup-xref nil nil)
@@ -640,7 +643,7 @@ help buffer."
                          (get symbol 'variable-documentation))
                  ;; Don't record the current entry in the stack.
                  (setq help-xref-stack-item nil)
-                 (describe-variable symbol))))
+                 (describe-variable symbol buffer frame))))
       (cond
        (sdoc
        ;; We now have a help buffer on the variable.
index bf724252d5ac2215b8f0dcf5a3c427d53a8bfd8c..fb1719ac9c9163cb3fd4e93b9ad21ee247288411 100644 (file)
@@ -95,6 +95,7 @@
     (define-key map "k" 'describe-key)
     (define-key map "l" 'view-lossage)
     (define-key map "m" 'describe-mode)
+    (define-key map "o" 'describe-function-or-variable)
     (define-key map "n" 'view-emacs-news)
     (define-key map "p" 'finder-by-keyword)
     (define-key map "P" 'describe-package)
@@ -218,6 +219,7 @@ L LANG-ENV  Describes a specific language environment, or RET for current.
 m           Display documentation of current minor modes and current major mode,
               including their special commands.
 n           Display news of recent Emacs changes.
+o SYMBOL    Display the given function or variable's documentation and value.
 p TOPIC     Find packages matching a given topic keyword.
 P PACKAGE   Describe the given Emacs Lisp package.
 r           Display the Emacs manual in Info mode.