Subject: bug#17250: 24.3; find-variable gives search-failed error message

From: Noam Postavsky <[email-masked]>
Date: Fri, 27 Apr 2018 22:27:25 -0400

Lars Ingebrigtsen <[email-masked]> writes:

> 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...

I think it's okay.  Here's my analysis of the call-sites found by M-x
rgrep:

./help-fns.el:163:;; (defun help-C-file-name (subr-or-var kind)
./help-fns.el:170:(defun help-C-file-name (subr-or-var kind)
./help-fns.el:319:	  (help-C-file-name type 'subr)
./help-fns.el:325:	  (help-C-file-name object 'var)

These 2 are in the return value position of
`find-lisp-object-file-name', whose docstring says "If no suitable file
is found, return nil".

./emacs-lisp/find-func.el:436:            (help-C-file-name def 'subr))

This one is only called if `def' satisfies `subrp', so I think failing
to find it can't happen anyway.  

./emacs-lisp/find-func.el:555:                       (help-C-file-name variable 'var))))

This one is in find-variable-noselect.  Before your change, it would
throw (search-failed "\037Vfoo\n"), with your change it throws (error
"Don’t know where ‘foo’ is defined") which seems better.

./progmodes/elisp-mode.el:693:              (push (elisp--xref-make-xref nil symbol (help-C-file-name (symbol-function symbol) 'subr)) xrefs))
./progmodes/elisp-mode.el:770:              ;; yet; help-C-file-name does that.  Second call will
./progmodes/elisp-mode.el:772:              (push (elisp--xref-make-xref 'defvar symbol (help-C-file-name symbol 'var)) xrefs))
./ldefs-boot.el:15592:(autoload 'help-C-file-name "help-fns" "\
./help-mode.el:203:                             (help-C-file-name (indirect-function fun) 'fun)))
./help-mode.el:243:		     (setq file (help-C-file-name var 'var)))

As far as I can tell, all of these calls only happen if the symbol has
already been found by `find-lisp-object-file-name', so they won't
trigger the failure case.