From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#17250: 24.3; find-variable gives search-failed error message Date: Wed, 18 Apr 2018 00:58:39 +0200 Message-ID: <87zi21e8yo.fsf@mouse.gnus.org> References: <87y4zaiuz7.fsf@bredband.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1524005895 5773 195.159.176.226 (17 Apr 2018 22:58:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 17 Apr 2018 22:58:15 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 17250@debbugs.gnu.org To: Johan Claesson Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Apr 18 00:58:10 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f8ZYA-0001Ml-2j for geb-bug-gnu-emacs@m.gmane.org; Wed, 18 Apr 2018 00:58:10 +0200 Original-Received: from localhost ([::1]:40620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8ZaF-0008OT-9W for geb-bug-gnu-emacs@m.gmane.org; Tue, 17 Apr 2018 19:00:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38186) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f8Za3-0008IQ-3c for bug-gnu-emacs@gnu.org; Tue, 17 Apr 2018 19:00:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f8ZZz-0003EJ-6b for bug-gnu-emacs@gnu.org; Tue, 17 Apr 2018 19:00:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50285) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f8ZZz-0003Dy-2i for bug-gnu-emacs@gnu.org; Tue, 17 Apr 2018 19:00:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1f8ZZy-0007xI-Mf for bug-gnu-emacs@gnu.org; Tue, 17 Apr 2018 19:00:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Apr 2018 23:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17250 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 17250-submit@debbugs.gnu.org id=B17250.152400597230512 (code B ref 17250); Tue, 17 Apr 2018 23:00:02 +0000 Original-Received: (at 17250) by debbugs.gnu.org; 17 Apr 2018 22:59:32 +0000 Original-Received: from localhost ([127.0.0.1]:58182 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f8ZZT-0007vz-S0 for submit@debbugs.gnu.org; Tue, 17 Apr 2018 18:59:32 -0400 Original-Received: from hermes.netfonds.no ([80.91.224.195]:40066) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f8ZZR-0007vX-FH for 17250@debbugs.gnu.org; Tue, 17 Apr 2018 18:59:30 -0400 Original-Received: from 46.67.12.60.tmi.telenormobil.no ([46.67.12.60] helo=corrigan) by hermes.netfonds.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1f8ZYj-0001HA-LB; Wed, 18 Apr 2018 00:59:28 +0200 Original-Received: from larsi by corrigan with local (Exim 4.89) (envelope-from ) id 1f8ZYd-0003Eo-R6; Wed, 18 Apr 2018 00:58:39 +0200 In-Reply-To: <87y4zaiuz7.fsf@bredband.net> (Johan Claesson's message of "Sat, 12 Apr 2014 14:38:04 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:145534 Archived-At: Johan Claesson 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