emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-25 7ad01cb: Avoid signaling an error in 'describe-sy


From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-25 7ad01cb: Avoid signaling an error in 'describe-symbol'
Date: Sat, 14 Nov 2015 17:29:00 +0000

branch: emacs-25
commit 7ad01cb68aad3640005d9ff3b0da78c1714c18bd
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Avoid signaling an error in 'describe-symbol'
    
    * 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           |   20 +++++++++++---------
 test/automated/help-fns.el |   10 ++++++++++
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 4e0bfee..e810a26 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -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.
diff --git a/test/automated/help-fns.el b/test/automated/help-fns.el
index b8772eb..79e90f7 100644
--- a/test/automated/help-fns.el
+++ b/test/automated/help-fns.el
@@ -57,4 +57,14 @@
     (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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]