]> git.eshelyaron.com Git - emacs.git/commitdiff
Only search for a variable when instructed
authorAlexander Gramiak <agrambot@gmail.com>
Tue, 11 Aug 2020 13:26:24 +0000 (15:26 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 11 Aug 2020 13:26:24 +0000 (15:26 +0200)
* lisp/help-fns.el (find-lisp-object-file-name): Check for 'defvar
argument before searching for an internal variable (Bug#24697).
* test/lisp/help-fns-tests.el: New tests.

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

index 5a99103f6afc92f6a5122796eef7442d6eeba7ef..a137c5048888b2dc01baf6f604ac5af0e7a20887 100644 (file)
@@ -364,6 +364,7 @@ suitable file is found, return nil."
          (help-C-file-name type 'subr)
        'C-source))
      ((and (not file-name) (symbolp object)
+           (eq type 'defvar)
           (integerp (get object 'variable-documentation)))
       ;; A variable defined in C.  The form is from `describe-variable'.
       (if (get-buffer " *DOC*")
index d2dc3d24aecf5e55686b8a4dff2ba439a38b8914..da2b49e6b842287e26b97965379c40b246da1c3d 100644 (file)
@@ -160,4 +160,15 @@ Return first line of the output of (describe-function-1 FUNC)."
   (with-current-buffer "*Help*"
     (should (looking-at "^help-fns-test--describe-keymap-foo is"))))
 
+;;; Tests for find-lisp-object-file-name
+(ert-deftest help-fns-test-bug24697-function-search ()
+  (should-not (find-lisp-object-file-name 'tab-width 1)))
+
+(ert-deftest help-fns-test-bug24697-non-internal-variable ()
+  (let ((help-fns--test-var (make-symbol "help-fns--test-var")))
+    ;; simulate an internal variable
+    (put help-fns--test-var 'variable-documentation 1)
+    (should-not (find-lisp-object-file-name help-fns--test-var 'defface))
+    (should-not (find-lisp-object-file-name help-fns--test-var 1))))
+
 ;;; help-fns-tests.el ends here