From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#70996: project-find-file defaults Date: Fri, 14 Jun 2024 20:00:20 +0300 Organization: LINKOV.NET Message-ID: <86tthve9y3.fsf@mail.linkov.net> References: <867cft2ggx.fsf@mail.linkov.net> <86cyoqjdcq.fsf@mail.linkov.net> <67beb5e6-8e74-4320-ba2f-7ceca2aae963@gutov.dev> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11747"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: 70996@debbugs.gnu.org, Spencer Baugh To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jun 14 19:03:23 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sIAKh-0002us-Fy for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 14 Jun 2024 19:03:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sIAKO-0003l6-6K; Fri, 14 Jun 2024 13:03:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sIAKM-0003kT-4z for bug-gnu-emacs@gnu.org; Fri, 14 Jun 2024 13:03:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sIAKL-0001O2-Se for bug-gnu-emacs@gnu.org; Fri, 14 Jun 2024 13:03:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sIAKL-0002yL-Oq for bug-gnu-emacs@gnu.org; Fri, 14 Jun 2024 13:03:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 14 Jun 2024 17:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70996 X-GNU-PR-Package: emacs Original-Received: via spool by 70996-submit@debbugs.gnu.org id=B70996.171838454411381 (code B ref 70996); Fri, 14 Jun 2024 17:03:01 +0000 Original-Received: (at 70996) by debbugs.gnu.org; 14 Jun 2024 17:02:24 +0000 Original-Received: from localhost ([127.0.0.1]:40850 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sIAJk-0002xT-Ea for submit@debbugs.gnu.org; Fri, 14 Jun 2024 13:02:24 -0400 Original-Received: from relay4-d.mail.gandi.net ([217.70.183.196]:52525) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sIAJf-0002xA-Ri for 70996@debbugs.gnu.org; Fri, 14 Jun 2024 13:02:23 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 41FA9E000A; Fri, 14 Jun 2024 17:02:10 +0000 (UTC) In-Reply-To: (Dmitry Gutov's message of "Wed, 12 Jun 2024 16:52:21 +0300") X-GND-Sasl: juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:287234 Archived-At: >> 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.