GNU bug report logs -
#78925
31.0.50; ffap's filename prompt problem in remote files
Previous Next
Reported by: Liu Hui <liuhui1610 <at> gmail.com>
Date: Mon, 30 Jun 2025 09:55:02 UTC
Severity: normal
Found in version 31.0.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 78925 in the body.
You can then email your comments to 78925 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78925
; Package
emacs
.
(Mon, 30 Jun 2025 09:55:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Liu Hui <liuhui1610 <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 30 Jun 2025 09:55:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi,
When using ffap in remote files, I find the guess of filename at point
in the prompt, which is mainly determined by ffap-file-at-point, is
not suitable or at least inconsistent.
Case 1:
1. emacs -Q
2. Open a remote file:
C-x C-f /ssh:server:~/test_file
3. type a filename that exists in localhost (e.g. /etc/hosts), and M-x ffap
ffap finds the local file /etc/hosts instead of the remote one. The
reason is that ffap-file-at-point always checks the local file first.
ffap-file-at-point only tries to find remote file if there is no
existing local file.
However, it is more reasonable to first check (or only check) remote
file and always prompt remote filename (i.e. /ssh:server:/etc/hosts)
in remote cases.
Case 2:
1. emacs -Q
2. Open a file in a remote project:
C-x C-f /ssh:server:~/a_git_project/test_file
3. Create a file that exists outside the project in the remote host, e.g.
M-! touch /tmp/abc
4. type the above filename (i.e. /tmp/abc), in test_file, and M-x ffap
ffap prompts /ssh:server:~/a_git_project/tmp/abc, while in Emacs 29
prompts /ssh:server:/tmp/abc correctly. This problem seems to be
related to commit 1eae0e7edf4.
Thanks.
--
Liu Hui
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78925
; Package
emacs
.
(Mon, 30 Jun 2025 12:59:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 78925 <at> debbugs.gnu.org (full text, mbox):
> From: Liu Hui <liuhui1610 <at> gmail.com>
> Date: Mon, 30 Jun 2025 17:54:31 +0800
>
> When using ffap in remote files, I find the guess of filename at point
> in the prompt, which is mainly determined by ffap-file-at-point, is
> not suitable or at least inconsistent.
>
> Case 1:
>
> 1. emacs -Q
> 2. Open a remote file:
> C-x C-f /ssh:server:~/test_file
> 3. type a filename that exists in localhost (e.g. /etc/hosts), and M-x ffap
>
> ffap finds the local file /etc/hosts instead of the remote one. The
> reason is that ffap-file-at-point always checks the local file first.
> ffap-file-at-point only tries to find remote file if there is no
> existing local file.
>
> However, it is more reasonable to first check (or only check) remote
> file and always prompt remote filename (i.e. /ssh:server:/etc/hosts)
> in remote cases.
I don't think I agree. However, perhaps a user option or a prefix
argument could be used to control which behavior is preferred.
> Case 2:
>
> 1. emacs -Q
> 2. Open a file in a remote project:
> C-x C-f /ssh:server:~/a_git_project/test_file
> 3. Create a file that exists outside the project in the remote host, e.g.
> M-! touch /tmp/abc
> 4. type the above filename (i.e. /tmp/abc), in test_file, and M-x ffap
>
> ffap prompts /ssh:server:~/a_git_project/tmp/abc, while in Emacs 29
> prompts /ssh:server:/tmp/abc correctly. This problem seems to be
> related to commit 1eae0e7edf4.
This is a separate issue, please submit a separate bug report for it.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78925
; Package
emacs
.
(Mon, 30 Jun 2025 15:49:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 78925 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
Hi,
>> When using ffap in remote files, I find the guess of filename at point
>> in the prompt, which is mainly determined by ffap-file-at-point, is
>> not suitable or at least inconsistent.
>>
>> Case 1:
>>
>> 1. emacs -Q
>> 2. Open a remote file:
>> C-x C-f /ssh:server:~/test_file
>> 3. type a filename that exists in localhost (e.g. /etc/hosts), and M-x ffap
>>
>> ffap finds the local file /etc/hosts instead of the remote one. The
>> reason is that ffap-file-at-point always checks the local file first.
>> ffap-file-at-point only tries to find remote file if there is no
>> existing local file.
>>
>> However, it is more reasonable to first check (or only check) remote
>> file and always prompt remote filename (i.e. /ssh:server:/etc/hosts)
>> in remote cases.
>
> I don't think I agree. However, perhaps a user option or a prefix
> argument could be used to control which behavior is preferred.
FTR, /etc/hosts is an absolute file name; ffap is right showing the
local file. And changing the default to always prepend the remote prefix
isn't right: there might be use cases, that you have a reference to a
local file /etc/hosts in your buffer, the buffer has a remote default
directory, and you still want to see the local file. It depends on the
context.
A user option might help, but it is all-or-nothing. Either, you will
always see the remote file, or always the local file. Your expectation
might change, case by case.
Another possibility would be a command prefix. If ffap is called with
the universal-argument non-nil (C-u invoked), a local file like
/etc/hosts might be displayed from the remote host. Or vice-versa,
whatever we declare as default.
Best regards, Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78925
; Package
emacs
.
(Tue, 01 Jul 2025 04:46:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 78925 <at> debbugs.gnu.org (full text, mbox):
On Mon, Jun 30, 2025 at 11:48 PM Michael Albinus <michael.albinus <at> gmx.de> wrote:
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> Hi,
>
> >> When using ffap in remote files, I find the guess of filename at point
> >> in the prompt, which is mainly determined by ffap-file-at-point, is
> >> not suitable or at least inconsistent.
> >>
> >> Case 1:
> >>
> >> 1. emacs -Q
> >> 2. Open a remote file:
> >> C-x C-f /ssh:server:~/test_file
> >> 3. type a filename that exists in localhost (e.g. /etc/hosts), and M-x ffap
> >>
> >> ffap finds the local file /etc/hosts instead of the remote one. The
> >> reason is that ffap-file-at-point always checks the local file first.
> >> ffap-file-at-point only tries to find remote file if there is no
> >> existing local file.
> >>
> >> However, it is more reasonable to first check (or only check) remote
> >> file and always prompt remote filename (i.e. /ssh:server:/etc/hosts)
> >> in remote cases.
> >
> > I don't think I agree. However, perhaps a user option or a prefix
> > argument could be used to control which behavior is preferred.
Thanks for your comments.
> FTR, /etc/hosts is an absolute file name; ffap is right showing the
> local file. And changing the default to always prepend the remote prefix
> isn't right: there might be use cases, that you have a reference to a
> local file /etc/hosts in your buffer, the buffer has a remote default
> directory, and you still want to see the local file. It depends on the
> context.
I'm not saying ffap is wrong, after all, it's just guessing. The key
is that we should use the more likely option as the default, while
also providing options for other contexts.
When the buffer's default directory and buffer-file-name are both
remote, without other prior information, I think the filenames in the
buffer are much more likely to be remote files than local ones. If the
user wants to access the corresponding local file, removing the
preceding remote host part manually is quite easy.
> A user option might help, but it is all-or-nothing. Either, you will
> always see the remote file, or always the local file. Your expectation
> might change, case by case.
A user option is useful for file-name-at-point-functions (C-x C-f
M-n), embark-target-file-at-point etc, which cannot use prefix argument.
How about 'ffap-remote-context-preference'? Depending on whether the
file exists on remote and local hosts, current ffap behavior and
possible options are as follows. IMO, perfer-remote or
perfer-remote-exist is more suitable to be the default behavior.
| file | prefer-local-exist | prefer-remote | prefer-remote-exist |
| exist? | (current behavior) | | |
|--------+--------------------+---------------+---------------------|
| both | local | remote | remote |
| remote | remote | remote | remote |
| local | local | remote parent | local |
| none | local parent | remote parent | remote parent |
> Another possibility would be a command prefix. If ffap is called with
> the universal-argument non-nil (C-u invoked), a local file like
> /etc/hosts might be displayed from the remote host. Or vice-versa,
> whatever we declare as default.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78925
; Package
emacs
.
(Mon, 07 Jul 2025 09:59:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 78925 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Mon, Jun 30, 2025 at 8:58 PM Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> > From: Liu Hui <liuhui1610 <at> gmail.com>
> > Date: Mon, 30 Jun 2025 17:54:31 +0800
> >
> > When using ffap in remote files, I find the guess of filename at point
> > in the prompt, which is mainly determined by ffap-file-at-point, is
> > not suitable or at least inconsistent.
> >
> > Case 1:
> >
> > 1. emacs -Q
> > 2. Open a remote file:
> > C-x C-f /ssh:server:~/test_file
> > 3. type a filename that exists in localhost (e.g. /etc/hosts), and M-x ffap
> >
> > ffap finds the local file /etc/hosts instead of the remote one. The
> > reason is that ffap-file-at-point always checks the local file first.
> > ffap-file-at-point only tries to find remote file if there is no
> > existing local file.
> >
> > However, it is more reasonable to first check (or only check) remote
> > file and always prompt remote filename (i.e. /ssh:server:/etc/hosts)
> > in remote cases.
>
> I don't think I agree. However, perhaps a user option or a prefix
> argument could be used to control which behavior is preferred.
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.
[0001-Add-option-ffap-prefer-remote-file-bug-78925.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78925
; Package
emacs
.
(Mon, 07 Jul 2025 17:18:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 78925 <at> debbugs.gnu.org (full text, mbox):
Liu Hui <liuhui1610 <at> gmail.com> 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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78925
; Package
emacs
.
(Tue, 08 Jul 2025 16:37:06 GMT)
Full text and
rfc822 format available.
Message #23 received at 78925 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Tue, Jul 8, 2025 at 1:17 AM Michael Albinus <michael.albinus <at> gmx.de> wrote:
>
> Liu Hui <liuhui1610 <at> gmail.com> 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.
Thanks for your comments!
> > +---
> > +*** 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.
Done.
> > -(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.
Renamed to remote-prefix.
> > + ((or (not file) ; quietly reject nil
> > + (zerop (length file))) ; and also ""
> > + nil)
>
> aka ((zerop (length file)) nil)
Done.
> > + ((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---
I examined the callers (e.g. ffap-file-at-point) and they have ruled
out the possibility that file is remote by ffap-file-remote-p. So it
wasn't checked again here. The docstring has been revised to clarify
the usage of the new argument.
> > (require 'cl-lib)
> > (require 'ert)
> > +(require 'tramp)
> > (require 'ert-x)
> > (require 'ffap)
>
> Why Tramp? I guess it isn't needed.
The comment of ert-remote-temporary-file-directory:
;; If this defvar is used in a test file, `tramp' shall be loaded
;; prior `ert-x'. There is no default value on w32 systems, which
;; could work out of the box.
Otherwise, the remote test is skipped with 'make test/ffap-tests'.
> > + (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")
Done.
[0001-Add-option-ffap-prefer-remote-file-bug-78925.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78925
; Package
emacs
.
(Tue, 08 Jul 2025 16:37:07 GMT)
Full text and
rfc822 format available.
Message #26 received at 78925 <at> debbugs.gnu.org (full text, mbox):
Liu Hui <liuhui1610 <at> gmail.com> writes:
Hi,
>> > (require 'cl-lib)
>> > (require 'ert)
>> > +(require 'tramp)
>> > (require 'ert-x)
>> > (require 'ffap)
>>
>> Why Tramp? I guess it isn't needed.
>
> The comment of ert-remote-temporary-file-directory:
>
> ;; If this defvar is used in a test file, `tramp' shall be loaded
> ;; prior `ert-x'. There is no default value on w32 systems, which
> ;; could work out of the box.
Ah, yes. I wrote this comment myself, but I tend to forget everything :-(
Otherwise, the patch LGTM.
Best regards, Michael.
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Sat, 12 Jul 2025 08:44:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Liu Hui <liuhui1610 <at> gmail.com>
:
bug acknowledged by developer.
(Sat, 12 Jul 2025 08:44:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 78925-done <at> debbugs.gnu.org (full text, mbox):
> From: Liu Hui <liuhui1610 <at> gmail.com>
> Date: Mon, 7 Jul 2025 17:58:17 +0800
> Cc: 78925 <at> debbugs.gnu.org
>
> On Mon, Jun 30, 2025 at 8:58 PM Eli Zaretskii <eliz <at> gnu.org> wrote:
> >
> > > From: Liu Hui <liuhui1610 <at> gmail.com>
> > > Date: Mon, 30 Jun 2025 17:54:31 +0800
> > >
> > > When using ffap in remote files, I find the guess of filename at point
> > > in the prompt, which is mainly determined by ffap-file-at-point, is
> > > not suitable or at least inconsistent.
> > >
> > > Case 1:
> > >
> > > 1. emacs -Q
> > > 2. Open a remote file:
> > > C-x C-f /ssh:server:~/test_file
> > > 3. type a filename that exists in localhost (e.g. /etc/hosts), and M-x ffap
> > >
> > > ffap finds the local file /etc/hosts instead of the remote one. The
> > > reason is that ffap-file-at-point always checks the local file first.
> > > ffap-file-at-point only tries to find remote file if there is no
> > > existing local file.
> > >
> > > However, it is more reasonable to first check (or only check) remote
> > > file and always prompt remote filename (i.e. /ssh:server:/etc/hosts)
> > > in remote cases.
> >
> > I don't think I agree. However, perhaps a user option or a prefix
> > argument could be used to control which behavior is preferred.
>
> 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.
Thanks, installed on master, and closing the bug.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78925
; Package
emacs
.
(Sat, 12 Jul 2025 08:51:01 GMT)
Full text and
rfc822 format available.
Message #34 received at 78925-done <at> debbugs.gnu.org (full text, mbox):
> From: Liu Hui <liuhui1610 <at> gmail.com>
> Date: Tue, 8 Jul 2025 18:19:39 +0800
> Cc: Eli Zaretskii <eliz <at> gnu.org>, 78925 <at> debbugs.gnu.org
>
> On Tue, Jul 8, 2025 at 1:17 AM Michael Albinus <michael.albinus <at> gmx.de> wrote:
> >
> > Liu Hui <liuhui1610 <at> gmail.com> 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.
>
> Thanks for your comments!
>
> > > +---
> > > +*** 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.
>
> Done.
>
> > > -(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.
>
> Renamed to remote-prefix.
>
> > > + ((or (not file) ; quietly reject nil
> > > + (zerop (length file))) ; and also ""
> > > + nil)
> >
> > aka ((zerop (length file)) nil)
>
> Done.
>
> > > + ((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---
>
> I examined the callers (e.g. ffap-file-at-point) and they have ruled
> out the possibility that file is remote by ffap-file-remote-p. So it
> wasn't checked again here. The docstring has been revised to clarify
> the usage of the new argument.
>
> > > (require 'cl-lib)
> > > (require 'ert)
> > > +(require 'tramp)
> > > (require 'ert-x)
> > > (require 'ffap)
> >
> > Why Tramp? I guess it isn't needed.
>
> The comment of ert-remote-temporary-file-directory:
>
> ;; If this defvar is used in a test file, `tramp' shall be loaded
> ;; prior `ert-x'. There is no default value on w32 systems, which
> ;; could work out of the box.
>
> Otherwise, the remote test is skipped with 'make test/ffap-tests'.
>
> > > + (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")
>
> Done.
Installed on master (after reverting the previous one).
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 09 Aug 2025 11:24:09 GMT)
Full text and
rfc822 format available.
This bug report was last modified today.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.