From e7819074013ac3c2b84abbc05a6f4f6c413d981e Mon Sep 17 00:00:00 2001 From: Alexander Gramiak Date: Tue, 11 Aug 2020 15:26:24 +0200 Subject: [PATCH] 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. --- lisp/help-fns.el | 1 + test/lisp/help-fns-tests.el | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 5a99103f6af..a137c504888 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -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*") diff --git a/test/lisp/help-fns-tests.el b/test/lisp/help-fns-tests.el index d2dc3d24aec..da2b49e6b84 100644 --- a/test/lisp/help-fns-tests.el +++ b/test/lisp/help-fns-tests.el @@ -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 -- 2.39.5