>From 2ff6a3417278a5fae3328b1bdae5afcc7094d646 Mon Sep 17 00:00:00 2001 From: Alexander Gramiak Date: Sun, 18 Jun 2017 18:59:11 -0600 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 | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 2c635ffa50..bcf33131fa 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -319,6 +319,7 @@ find-lisp-object-file-name (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 0ab6c3cae7..98898624db 100644 --- a/test/lisp/help-fns-tests.el +++ b/test/lisp/help-fns-tests.el @@ -118,4 +118,16 @@ defgh\\\[universal-argument\]b\`c\'d\\e\"f (goto-char (point-min)) (should (looking-at "^font-lock-comment-face 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.el ends here -- 2.11.0