[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#17250: 24.3; find-variable gives search-failed error message
From: |
Lars Ingebrigtsen |
Subject: |
bug#17250: 24.3; find-variable gives search-failed error message |
Date: |
Wed, 18 Apr 2018 00:58:39 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Johan Claesson <johanclaesson@bredband.net> writes:
> emacs -Q
> (defvar foo nil) C-M-x
> M-x find-variable RET foo RET
>
> This gives the following error:
>
> Search failed: "Vfoo
> "
>
> Since foo is defined interactively in the *scratch* buffer emacs does
> not know what file it belongs to. That is expected. I just think it
> should say something like "Don't know where foo is defined" instead of
> the above error message.
The following patch fixes the problem.
Simplest test case: (help-C-file-name 'foo 'var)
But there are several places that use this function without checking the
return value. Are they relying on this function to bug out with a
cryptic error, or are they all confident that the file name can be
found?
So I haven't applied it yet. Perhaps somebody else will weigh in...
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index ec46a479ed..ab3fe3a732 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -169,7 +169,8 @@ describe-function
;;;###autoload
(defun help-C-file-name (subr-or-var kind)
"Return the name of the C file where SUBR-OR-VAR is defined.
-KIND should be `var' for a variable or `subr' for a subroutine."
+KIND should be `var' for a variable or `subr' for a subroutine.
+If we can't find the file name, nil is returned."
(let ((docbuf (get-buffer-create " *DOC*"))
(name (if (eq 'var kind)
(concat "V" (symbol-name subr-or-var))
@@ -181,19 +182,23 @@ help-C-file-name
(expand-file-name internal-doc-file-name doc-directory)))
(let ((file (catch 'loop
(while t
- (let ((pnt (search-forward (concat "\^_" name "\n"))))
- (re-search-backward "\^_S\\(.*\\)")
- (let ((file (match-string 1)))
- (if (member file build-files)
- (throw 'loop file)
- (goto-char pnt))))))))
- (if (string-match "^ns.*\\(\\.o\\|obj\\)\\'" file)
- (setq file (replace-match ".m" t t file 1))
- (if (string-match "\\.\\(o\\|obj\\)\\'" file)
- (setq file (replace-match ".c" t t file))))
- (if (string-match "\\.\\(c\\|m\\)\\'" file)
- (concat "src/" file)
- file)))))
+ (let ((pnt (search-forward (concat "\^_" name "\n") nil
t)))
+ (if (not pnt)
+ (throw 'loop nil)
+ (re-search-backward "\^_S\\(.*\\)")
+ (let ((file (match-string 1)))
+ (if (member file build-files)
+ (throw 'loop file)
+ (goto-char pnt)))))))))
+ (if (not file)
+ nil
+ (if (string-match "^ns.*\\(\\.o\\|obj\\)\\'" file)
+ (setq file (replace-match ".m" t t file 1))
+ (if (string-match "\\.\\(o\\|obj\\)\\'" file)
+ (setq file (replace-match ".c" t t file))))
+ (if (string-match "\\.\\(c\\|m\\)\\'" file)
+ (concat "src/" file)
+ file))))))
(defcustom help-downcase-arguments nil
"If non-nil, argument names in *Help* buffers are downcased."
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
- bug#17250: 24.3; find-variable gives search-failed error message,
Lars Ingebrigtsen <=