GNU bug report logs - #17250
24.3; find-variable gives search-failed error message

Previous Next

Package: emacs;

Reported by: Johan Claesson <johanclaesson <at> bredband.net>

Date: Sat, 12 Apr 2014 12:39:02 UTC

Severity: minor

Tags: confirmed, fixed, patch

Found in version 24.3

Fixed in version 27.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Johan Claesson <johanclaesson <at> bredband.net>
Cc: 17250 <at> debbugs.gnu.org
Subject: bug#17250: 24.3; find-variable gives search-failed error message
Date: Wed, 18 Apr 2018 00:58:39 +0200
Johan Claesson <johanclaesson <at> 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




This bug report was last modified 5 years and 335 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.