Only search for a variable when instructed

* 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.
This commit is contained in:
Alexander Gramiak 2020-08-11 15:26:24 +02:00 committed by Lars Ingebrigtsen
parent 9b01badf7c
commit e781907401
2 changed files with 12 additions and 0 deletions

View 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*")

View 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