]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid signaling an error in 'describe-symbol'
authorEli Zaretskii <eliz@gnu.org>
Sat, 14 Nov 2015 17:27:52 +0000 (19:27 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sat, 14 Nov 2015 17:27:52 +0000 (19:27 +0200)
* lisp/help-fns.el (describe-symbol): Avoid errors when the symbol
exists as a function/variable/face/etc., but is undocumented.

* test/automated/help-fns.el (help-fns-test-describe-symbol): New
test.

lisp/help-fns.el
test/automated/help-fns.el

index 4e0bfee5bf7dae95a7deb21c7f8ee7ac64dcb3c1..e810a26c5a46dc3870cd061cbaf6b5a38ddea4c8 100644 (file)
@@ -1040,15 +1040,17 @@ Will show the info of SYMBOL as a function, variable, and/or face."
         (let ((inhibit-read-only t)
               (name (caar docs))        ;Name of doc currently at BOB.
               (doc (cdr (cadr docs))))  ;Doc to add at BOB.
-          (insert doc)
-          (delete-region (point) (progn (skip-chars-backward " \t\n") (point)))
-          (insert "\n\n"
-                  (eval-when-compile
-                    (propertize "\n" 'face '(:height 0.1 :inverse-video t)))
-                  "\n")
-          (when name
-            (insert (symbol-name symbol)
-                    " is also a " name "." "\n\n")))
+          (when doc
+            (insert doc)
+            (delete-region (point)
+                           (progn (skip-chars-backward " \t\n") (point)))
+            (insert "\n\n"
+                    (eval-when-compile
+                      (propertize "\n" 'face '(:height 0.1 :inverse-video t)))
+                    "\n")
+            (when name
+              (insert (symbol-name symbol)
+                      " is also a " name "." "\n\n"))))
         (setq docs (cdr docs)))
       (unless single
         ;; Don't record the `describe-variable' item in the stack.
index b8772eb84d64cbf3b297c3550cb008e8227f079b..79e90f7819cc513e20915748a898a3b3209eb881 100644 (file)
     (should (search-forward
              "(defgh\\\\\\[universal-argument\\]b\\`c\\'d\\\\e\\\"f X)"))))
 
+(ert-deftest help-fns-test-describe-symbol ()
+  "Test the `describe-symbol' function."
+  ;; 'describe-symbol' would originally signal an error for
+  ;; 'font-lock-comment-face'.
+  (describe-symbol 'font-lock-comment-face)
+  (with-current-buffer "*Help*"
+    (should (> (point-max) 1))
+    (goto-char (point-min))
+    (should (looking-at "^font-lock-comment-face is "))))
+
 ;;; help-fns.el ends here