GNU bug report logs -
#70996
project-find-file defaults
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Fri, 17 May 2024 06:53:01 UTC
Severity: normal
Fixed in version 30.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
Message #37 received at 70996 <at> debbugs.gnu.org (full text, mbox):
>> It seems to me that we can have the best of both worlds if we match the
>> behavior of find-file, and use something like
>> (run-hook-with-args-until-success 'file-name-at-point-functions) rather
>> than (thing-at-point 'file-name).
>> The default of file-name-at-point-functions is
>> ffap-guess-file-name-at-point, which by default only returns a filename
>> if that file name actually exists in the filesystem.
>> The old behavior of (thing-at-point 'file-name) often got in the way,
>> since it would pick up any random string at point, even if it wasn't
>> referring to an actual file name.
>> Instead we can be like find-file and have:
>> (delq nil (list
>> (run-hook-with-args-until-success 'file-name-at-point-functions)
>> buffer-file-name))
>
> That's an interesting suggestion, but could we rely on
> file-name-at-point-functions acting correctly for any project?
>
> As luck would have it, ffap-guess-file-name-at-point seems to work fine on
> relative file names inside a directory, and even file names without
> extensions, but it could miss them in some odd directory structures.
I tried file-name-at-point-functions with ffap-guess-file-name-at-point,
but it fails to pick a file name when it's not relative neither
to default-directory nor to the project root. It's easy to blame
the design of such languages, but this won't solve the problem.
So I see no way to reliable pick a file name. Therefore the need
to fall back to (thing-at-point 'filename).
>> I personally never use the file-name-at-point behavior of
>> project-find-file, but I'm happy with it being higher-precedence because
>> it will match find-file - as long as it also matches find-file in only
>> including filenames of existing files.
>
> In case you agree with my concerns above (I'm happy to be convinced
> otherwise), we could try to do something like
>
> (completion-try-completion (thing-at-point 'filename)
> TABLE nil LEN)
Unfortunately, this might get a false positive on a short word under point
that with high likelihood will match a file name with a short substring.
This bug report was last modified 1 year and 35 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.