]> code.delx.au - gnu-emacs/blobdiff - lisp/help-fns.el
Fix byte-compiler warnings about looking-back.
[gnu-emacs] / lisp / help-fns.el
index c0d63935035af0d4ce6e979b478c43aaabc3cda3..53f4b38b9ecb1557d47115a500b0726017f92994 100644 (file)
@@ -329,7 +329,7 @@ suitable file is found, return nil."
 
       (with-current-buffer standard-output
         (fill-region-as-paragraph pt2 (point))
-        (unless (looking-back "\n\n")
+        (unless (looking-back "\n\n" (- (point) 2))
           (terpri))))))
 
 (defun help-fns--compiler-macro (function)
@@ -352,7 +352,9 @@ suitable file is found, return nil."
       (insert ".\n"))))
 
 (defun help-fns--signature (function doc real-def real-function)
-  (unless (keymapp function)    ; If definition is a keymap, skip arglist note.
+  "Insert usage at point and return docstring.  With highlighting."
+  (if (keymapp function)
+      doc                       ; If definition is a keymap, skip arglist note.
     (let* ((advertised (gethash real-def advertised-signature-table t))
            (arglist (if (listp advertised)
                         advertised (help-function-arglist real-def)))
@@ -929,6 +931,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.