Subject: bug#78925: 31.0.50; ffap's filename prompt problem in remote files, [PATCH] Add option 'ffap-prefer-remote-file' (bug#78925)

From: Michael Albinus <[email-masked]>
Date: Mon, 07 Jul 2025 19:17:21 +0200

Liu Hui <[email-masked]> writes:

Hi,

> The attached patch adds an option 'ffap-prefer-remote-file', which
> defaults to nil. A non-nil value means ffap always finds remote files
> for absolute filenames in remote case, instead of finding local files
> first.

Thank you for the patch. I don't use ffap myself, so just some comments
from cursory review.

> +---
> +*** New user option 'ffap-prefer-remote-file'.
> +If non-nil, ffap always finds remote files in buffers with remote
> +'default-directory'.  If nil, ffap finds local files first for absolute
> +filenames in above buffers.  The default is nil.

Please spell it out FFAP.

> -(defun ffap-file-exists-string (file &optional nomodify)
> +(defun ffap-file-exists-string (file &optional nomodify remote-host)

A remote file name is not only the host. There are also, at least, a
method and a user. Please call this argument remote-prefix or alike.

> +     ((or (not file)			; quietly reject nil
> +	  (zerop (length file)))	; and also ""
> +      nil)

aka ((zerop (length file)) nil)

> +     ((and remote-host                  ; prepend remote host to file
> +           (file-name-absolute-p file)
> +           (setq file (concat remote-host file))
> +           nil))

What, if file is already remote? Shouldn't the check be

--8<---------------cut here---------------start------------->8---
     ((and remote-host                  ; prepend remote host to file
           (file-name-absolute-p file)
           (not (file-name-remote-p file))
           (setq file (concat remote-host file))
           nil))
--8<---------------cut here---------------end--------------->8---

>  (require 'cl-lib)
>  (require 'ert)
> +(require 'tramp)
>  (require 'ert-x)
>  (require 'ffap)

Why Tramp? I guess it isn't needed.

> +  (let* ((ffap-prefer-remote-file t)
> +         (default-directory
> +          (expand-file-name ert-remote-temporary-file-directory))
> +         (test-file (expand-file-name "ffap-test" default-directory)))

I would use (make-temp-file "ffap-test")

Best regards, Michael.