GNU bug report logs - #66668
[PATCH] Teach ffap to look for paths under the root of project

Previous Next

Package: emacs;

Reported by: Spencer Baugh <sbaugh <at> janestreet.com>

Date: Sat, 21 Oct 2023 18:39:01 UTC

Severity: wishlist

Tags: patch

Fixed in version 30.1

Done: Dmitry Gutov <dmitry <at> gutov.dev>

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 66668 in the body.
You can then email your comments to 66668 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#66668; Package emacs. (Sat, 21 Oct 2023 18:39:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Spencer Baugh <sbaugh <at> janestreet.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 21 Oct 2023 18:39:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: bug-gnu-emacs <at> gnu.org
Cc: Dmitry Gutov <dmitry <at> gutov.dev>
Subject: [PATCH] Teach ffap to look for paths under the root of project
Date: Sat, 21 Oct 2023 14:37:45 -0400
[Message part 1 (text/plain, inline)]
Tags: patch


This is a nice little quality of life feature.

In GNU Emacs 29.1.50 (build 12, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.15.12, Xaw scroll bars) of 2023-10-19 built on
 igm-qws-u22796a
Repository revision: 9163e634e296435aa7a78bc6b77b4ee90666d2ac
Repository branch: emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Rocky Linux 8.8 (Green Obsidian)

Configured using:
 'configure --config-cache --with-x-toolkit=lucid
 --with-gif=ifavailable'

[0001-Teach-ffap-to-look-for-paths-under-the-root-of-proje.patch (text/patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66668; Package emacs. (Sat, 21 Oct 2023 19:08:02 GMT) Full text and rfc822 format available.

Message #8 received at 66668 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: dmitry <at> gutov.dev, 66668 <at> debbugs.gnu.org
Subject: Re: bug#66668: [PATCH] Teach ffap to look for paths under the root of
 project
Date: Sat, 21 Oct 2023 22:06:25 +0300
> Cc: Dmitry Gutov <dmitry <at> gutov.dev>
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Date: Sat, 21 Oct 2023 14:37:45 -0400
> 
> Subject: [PATCH] Teach ffap to look for paths under the root of project

Please don't use "path" when you mean "file name".  The GNU Coding
Standards frown on such uses of "path".




Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 22 Oct 2023 19:42:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66668; Package emacs. (Wed, 25 Oct 2023 15:09:02 GMT) Full text and rfc822 format available.

Message #13 received at 66668 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: dmitry <at> gutov.dev, 66668 <at> debbugs.gnu.org
Subject: Re: bug#66668: [PATCH] Teach ffap to look for paths under the root
 of project
Date: Wed, 25 Oct 2023 11:08:12 -0400
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:
>> Cc: Dmitry Gutov <dmitry <at> gutov.dev>
>> From: Spencer Baugh <sbaugh <at> janestreet.com>
>> Date: Sat, 21 Oct 2023 14:37:45 -0400
>> 
>> Subject: [PATCH] Teach ffap to look for paths under the root of project
>
> Please don't use "path" when you mean "file name".  The GNU Coding
> Standards frown on such uses of "path".

Oops, fixed.

(Also fixed a byte-compiler warning from not declaring project-root)

[0001-Teach-ffap-to-look-for-relative-file-names-under-pro.patch (text/x-patch, inline)]
From 4423e8eb9b54652c114bb9d6b6b3b873a15a24a9 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh <at> janestreet.com>
Date: Sat, 21 Oct 2023 14:35:53 -0400
Subject: [PATCH] Teach ffap to look for relative file names under project-root

Now file-name-at-point-functions, which runs
ffap-guess-file-name-at-point, will pick up on a file name at point if
that file name is a relative file name which exists when looked up
from the root of the project.

For example, in test/lisp/progmodes/eglot-tests.el there is the string
lisp/progmodes/eglot.el; if you put point on that and C-x C-f,
lisp/progmodes/eglot.el under the root of the Emacs repo will now be
part of future history.

* lisp/ffap.el (ffap-alist): Add entry for ffap-in-project.
(ffap-in-project): Add. (bug#66668)
---
 lisp/ffap.el | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lisp/ffap.el b/lisp/ffap.el
index 2c99f88d505..0c9ff8617d6 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -734,6 +734,7 @@ ffap-locate-file
 (defvar ffap-alist
   '(
     ("" . ffap-completable)		; completion, slow on some systems
+    ("" . ffap-in-project)		; maybe in the root of the project
     ("\\.info\\'" . ffap-info)		; gzip.info
     ("\\`info/" . ffap-info-2)		; info/emacs
     ("\\`[-[:lower:]]+\\'" . ffap-info-3) ; (emacs)Top [only in the parentheses]
@@ -797,6 +798,11 @@ ffap-completable
 	 (cmp (file-name-completion (file-name-nondirectory name) dir)))
     (and cmp (concat dir cmp))))
 
+(declare-function project-root "project" (project))
+(defun ffap-in-project (name)
+  (when-let (project (project-current))
+    (file-name-concat (project-root project) name)))
+
 (defun ffap-home (name) (ffap-locate-file name t '("~")))
 
 (defun ffap-info (name)
-- 
2.39.3


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66668; Package emacs. (Sun, 29 Oct 2023 12:25:01 GMT) Full text and rfc822 format available.

Message #16 received at 66668 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: dmitry <at> gutov.dev, 66668 <at> debbugs.gnu.org
Subject: Re: bug#66668: [PATCH] Teach ffap to look for paths under the root
 of project
Date: Sun, 29 Oct 2023 14:23:46 +0200
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Cc: dmitry <at> gutov.dev,  66668 <at> debbugs.gnu.org
> Date: Wed, 25 Oct 2023 11:08:12 -0400
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> >> Cc: Dmitry Gutov <dmitry <at> gutov.dev>
> >> From: Spencer Baugh <sbaugh <at> janestreet.com>
> >> Date: Sat, 21 Oct 2023 14:37:45 -0400
> >> 
> >> Subject: [PATCH] Teach ffap to look for paths under the root of project
> >
> > Please don't use "path" when you mean "file name".  The GNU Coding
> > Standards frown on such uses of "path".
> 
> Oops, fixed.
> 
> (Also fixed a byte-compiler warning from not declaring project-root)

Dmitry, any comments?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66668; Package emacs. (Sun, 29 Oct 2023 12:45:02 GMT) Full text and rfc822 format available.

Message #19 received at 66668 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: Eli Zaretskii <eliz <at> gnu.org>, Spencer Baugh <sbaugh <at> janestreet.com>
Cc: 66668 <at> debbugs.gnu.org
Subject: Re: bug#66668: [PATCH] Teach ffap to look for paths under the root of
 project
Date: Sun, 29 Oct 2023 14:43:32 +0200
On 29/10/2023 14:23, Eli Zaretskii wrote:
>> From: Spencer Baugh<sbaugh <at> janestreet.com>
>> Cc:dmitry <at> gutov.dev,66668 <at> debbugs.gnu.org
>> Date: Wed, 25 Oct 2023 11:08:12 -0400
>>
>> Eli Zaretskii<eliz <at> gnu.org>  writes:
>>>> Cc: Dmitry Gutov<dmitry <at> gutov.dev>
>>>> From: Spencer Baugh<sbaugh <at> janestreet.com>
>>>> Date: Sat, 21 Oct 2023 14:37:45 -0400
>>>>
>>>> Subject: [PATCH] Teach ffap to look for paths under the root of project
>>> Please don't use "path" when you mean "file name".  The GNU Coding
>>> Standards frown on such uses of "path".
>> Oops, fixed.
>>
>> (Also fixed a byte-compiler warning from not declaring project-root)
> Dmitry, any comments?

If the way it works is useful for people (probably will be), I'm good 
with it.

Ideally, it possibly would check whether the file belongs to the 
project-files fileset, but that's going to be slower, and thus probably 
not worth the marginal improvement.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66668; Package emacs. (Sun, 29 Oct 2023 12:58:02 GMT) Full text and rfc822 format available.

Message #22 received at 66668 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Dmitry Gutov <dmitry <at> gutov.dev>
Cc: sbaugh <at> janestreet.com, 66668 <at> debbugs.gnu.org
Subject: Re: bug#66668: [PATCH] Teach ffap to look for paths under the root of
 project
Date: Sun, 29 Oct 2023 14:56:32 +0200
> Date: Sun, 29 Oct 2023 14:43:32 +0200
> Cc: 66668 <at> debbugs.gnu.org
> From: Dmitry Gutov <dmitry <at> gutov.dev>
> 
> On 29/10/2023 14:23, Eli Zaretskii wrote:
> >> From: Spencer Baugh<sbaugh <at> janestreet.com>
> >> Cc:dmitry <at> gutov.dev,66668 <at> debbugs.gnu.org
> >> Date: Wed, 25 Oct 2023 11:08:12 -0400
> >>
> >> Eli Zaretskii<eliz <at> gnu.org>  writes:
> >>>> Cc: Dmitry Gutov<dmitry <at> gutov.dev>
> >>>> From: Spencer Baugh<sbaugh <at> janestreet.com>
> >>>> Date: Sat, 21 Oct 2023 14:37:45 -0400
> >>>>
> >>>> Subject: [PATCH] Teach ffap to look for paths under the root of project
> >>> Please don't use "path" when you mean "file name".  The GNU Coding
> >>> Standards frown on such uses of "path".
> >> Oops, fixed.
> >>
> >> (Also fixed a byte-compiler warning from not declaring project-root)
> > Dmitry, any comments?
> 
> If the way it works is useful for people (probably will be), I'm good 
> with it.
> 
> Ideally, it possibly would check whether the file belongs to the 
> project-files fileset, but that's going to be slower, and thus probably 
> not worth the marginal improvement.

Then I guess we should install this?




Reply sent to Dmitry Gutov <dmitry <at> gutov.dev>:
You have taken responsibility. (Mon, 30 Oct 2023 01:01:02 GMT) Full text and rfc822 format available.

Notification sent to Spencer Baugh <sbaugh <at> janestreet.com>:
bug acknowledged by developer. (Mon, 30 Oct 2023 01:01:02 GMT) Full text and rfc822 format available.

Message #27 received at 66668-done <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: sbaugh <at> janestreet.com, 66668-done <at> debbugs.gnu.org
Subject: Re: bug#66668: [PATCH] Teach ffap to look for paths under the root of
 project
Date: Mon, 30 Oct 2023 02:59:28 +0200
Version: 30.1

On 29/10/2023 14:56, Eli Zaretskii wrote:
>> Date: Sun, 29 Oct 2023 14:43:32 +0200
>> Cc: 66668 <at> debbugs.gnu.org
>> From: Dmitry Gutov <dmitry <at> gutov.dev>
>>
>> On 29/10/2023 14:23, Eli Zaretskii wrote:
>>>> From: Spencer Baugh<sbaugh <at> janestreet.com>
>>>> Cc:dmitry <at> gutov.dev,66668 <at> debbugs.gnu.org
>>>> Date: Wed, 25 Oct 2023 11:08:12 -0400
>>>>
>>>> Eli Zaretskii<eliz <at> gnu.org>  writes:
>>>>>> Cc: Dmitry Gutov<dmitry <at> gutov.dev>
>>>>>> From: Spencer Baugh<sbaugh <at> janestreet.com>
>>>>>> Date: Sat, 21 Oct 2023 14:37:45 -0400
>>>>>>
>>>>>> Subject: [PATCH] Teach ffap to look for paths under the root of project
>>>>> Please don't use "path" when you mean "file name".  The GNU Coding
>>>>> Standards frown on such uses of "path".
>>>> Oops, fixed.
>>>>
>>>> (Also fixed a byte-compiler warning from not declaring project-root)
>>> Dmitry, any comments?
>>
>> If the way it works is useful for people (probably will be), I'm good
>> with it.
>>
>> Ideally, it possibly would check whether the file belongs to the
>> project-files fileset, but that's going to be slower, and thus probably
>> not worth the marginal improvement.
> 
> Then I guess we should install this?

Sure, installed.

Thanks, and closing!




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 27 Nov 2023 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 256 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.