From: Lars Ingebrigtsen <larsi@gnus.org>
To: Johan Claesson <johanclaesson@bredband.net>
Cc: 17250@debbugs.gnu.org
Subject: bug#17250: 24.3; find-variable gives search-failed error message
Date: Wed, 18 Apr 2018 00:58:39 +0200 [thread overview]
Message-ID: <87zi21e8yo.fsf@mouse.gnus.org> (raw)
In-Reply-To: <87y4zaiuz7.fsf@bredband.net> (Johan Claesson's message of "Sat, 12 Apr 2014 14:38:04 +0200")
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: "\x1fVfoo
> "
>
> 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
next prev parent reply other threads:[~2018-04-17 22:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-12 12:38 bug#17250: 24.3; find-variable gives search-failed error message Johan Claesson
2018-04-17 22:58 ` Lars Ingebrigtsen [this message]
2018-04-18 6:23 ` Eli Zaretskii
2018-04-28 2:27 ` Noam Postavsky
2019-06-26 14:06 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zi21e8yo.fsf@mouse.gnus.org \
--to=larsi@gnus.org \
--cc=17250@debbugs.gnu.org \
--cc=johanclaesson@bredband.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).