Subject: Re: bug#78769: 31.0.50; improve ffap-file-name-with-spaces

From: Madhu <[email-masked]>
Date: Sat, 14 Jun 2025 21:07:38 +0530 (IST)

*  Eli Zaretskii <[email-masked]> <[email-masked]>
Wrote on Fri, 13 Jun 2025 10:21:37 +0300
>> [Unfortunately it is also a limitation in the other implementation I
>> proposed, that of extending
>>  (assq 'file ffap-string-at-point-mode-alist)
>> so that doesn't buy anything.]

> I think this aspect is already in the doc string of the variable:

Yes of course.  I actually forgot to mention a different limitation of
the existing implementation. If the file name doesn't have an
extension you lose. with the spaces flag set

eg. ffap on  ~/.emacs or /etc/profile will only show the directories.

(This limitation isn't there in the alternative I proposed),

just a note. no changes to bug status.

to make ffap use a prefix argument to set ffap-file-name-with-spaces
is pretty hairy because ffap rebinds current-prefix-arg to nil.

With newadvice it can look like this

(defvar ffap-spaces-override nil)

(defun find-file-at-point-munge-cpa-around-advice (orig-fn &optional file-name)
  (let ((ffap-spaces-override current-prefix-arg))
    (funcall orig-fn file-name)))

(defun ffap-string-at-point-force-spaces-around-advice (orig-fn &optional mode)
  (let ((ffap-file-name-with-spaces (if ffap-spaces-override t nil)))
    (funcall orig-fn mode)))

(advice-add 'find-file-at-point :around
	    'find-file-at-point-munge-cpa-around-advice)

(advice-add 'ffap-string-at-point :around
	    'ffap-string-at-point-force-spaces-around-advice)

(when nil
  (advice-remove 'find-file-at-point :around
	       'find-file-at-point-munge-cpa-around-advice))
(when nil
  (advice-remove 'ffap-string-at-point
		 'ffap-string-at-point-force-spaces-around-advice))

;; which gives one a headache