Subject: Re: bug#50279: 28.0.50; ffap-file-finder customization no longer works

From: Bob Rogers <[email-masked]>
Date: Mon, 5 Sep 2022 20:10:03 -0700

From: Lars Ingebrigtsen <[email-masked]>
   Date: Tue, 23 Aug 2022 12:00:51 +0200

   Bob Rogers <[email-masked]> writes:

   > Our furniture delivery has been delayed, so I've started to clean up
   > some software loose ends (and catch up on emacs-devel); with any luck
   > I may have time to look at this again.

   Great!

Having finally gotten around to investigating this properly, I find that
the solution should have been obvious:  dickmao removed the feature in
the following commit:

	commit 253b36bd40d1b342cdda09b0bee183788120f67e
	Author: dickmao <none>
	Date:   Tue Aug 3 12:02:48 2021 -0400

	    ffap ido accommodation

	    Now that ffap-file-finder can be ido-find-file, the
	    noninteractive portion of find-file-at-point cannot
	    assume ffap-file-finder always takes an argument
	    (ido-find-file does not).

	    * lisp/ffap.el (find-file-at-point): Do not call ffap-file-finder.
	    * test/lisp/ffap-tests.el (ffap-ido-mode): Test it.

I no longer understand why we thought it could not be reproduced in
"emacs -Q", as I can do so with the following code:

	(defun rgr-ffap-file-finder (file-name &optional wildcards)
	  (interactive "FFind file: \np")
	  (message "[got %S]" file-name)
	  (find-file file-name wildcards))

	(setq ffap-file-finder 'rgr-ffap-file-finder)

and this recipe:

   1.  "emacs -Q"

   2.  Load the code above.

   3.  Locate a suitable file in dired (I used a JPEG).

   4.  Position point on the file name, and do "M-x ffap".

The JPEG will appear in emacs but the "[got ...]" message will not
appear.  Additionally, find-file-at-point can be instrumented with the
patch below.  That will identify the exact find-file call being used,
and is how I traced it to this commit.

   But of course resolving my issue without breaking dickmao's issue is
beyond my pay grade.  ;-}  Though I do notice that ffap.el already has

	(memq ffap-file-finder '(find-file find-alternate-file))

as a way of testing for arg-handling capability.  But maybe that's
enough of a code smell.

					-- Bob

------------------------------------------------------------------------
diff --git a/lisp/ffap.el b/lisp/ffap.el
index 88b4bce9fd..a4dec5e792 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -1623,6 +1623,7 @@ find-file-at-point
        ((or (not ffap-newfile-prompt)
 	    (file-exists-p filename)
 	    (y-or-n-p "File does not exist, create buffer? "))
+        (message "ffap calling find-file on %S directly" filename)
 	(find-file
          ;; expand-file-name fixes "~/~/.emacs" bug
 	 (expand-file-name filename)))