unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#66668: [PATCH] Teach ffap to look for paths under the root of project
@ 2023-10-21 18:37 Spencer Baugh
  2023-10-21 19:06 ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Spencer Baugh @ 2023-10-21 18:37 UTC (permalink / raw)
  To: 66668; +Cc: Dmitry Gutov

[-- Attachment #1: Type: text/plain, Size: 520 bytes --]

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'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Teach-ffap-to-look-for-paths-under-the-root-of-proje.patch --]
[-- Type: text/patch, Size: 1630 bytes --]

From 521116073821c5259130c415640265cb25c03ef3 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh@janestreet.com>
Date: Sat, 21 Oct 2023 14:35:53 -0400
Subject: [PATCH] Teach ffap to look for paths under the root of project

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 path starting 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.
---
 lisp/ffap.el | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lisp/ffap.el b/lisp/ffap.el
index 2c99f88d505..fe0aa16c22f 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,10 @@ ffap-completable
 	 (cmp (file-name-completion (file-name-nondirectory name) dir)))
     (and cmp (concat dir cmp))))
 
+(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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#66668: [PATCH] Teach ffap to look for paths under the root of project
  2023-10-21 18:37 bug#66668: [PATCH] Teach ffap to look for paths under the root of project Spencer Baugh
@ 2023-10-21 19:06 ` Eli Zaretskii
  2023-10-25 15:08   ` Spencer Baugh
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-10-21 19:06 UTC (permalink / raw)
  To: Spencer Baugh; +Cc: dmitry, 66668

> Cc: Dmitry Gutov <dmitry@gutov.dev>
> From: Spencer Baugh <sbaugh@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".





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#66668: [PATCH] Teach ffap to look for paths under the root of project
  2023-10-21 19:06 ` Eli Zaretskii
@ 2023-10-25 15:08   ` Spencer Baugh
  2023-10-29 12:23     ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Spencer Baugh @ 2023-10-25 15:08 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: dmitry, 66668

[-- Attachment #1: Type: text/plain, Size: 441 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:
>> Cc: Dmitry Gutov <dmitry@gutov.dev>
>> From: Spencer Baugh <sbaugh@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)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Teach-ffap-to-look-for-relative-file-names-under-pro.patch --]
[-- Type: text/x-patch, Size: 1736 bytes --]

From 4423e8eb9b54652c114bb9d6b6b3b873a15a24a9 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh@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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#66668: [PATCH] Teach ffap to look for paths under the root of project
  2023-10-25 15:08   ` Spencer Baugh
@ 2023-10-29 12:23     ` Eli Zaretskii
  2023-10-29 12:43       ` Dmitry Gutov
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-10-29 12:23 UTC (permalink / raw)
  To: Spencer Baugh; +Cc: dmitry, 66668

> From: Spencer Baugh <sbaugh@janestreet.com>
> Cc: dmitry@gutov.dev,  66668@debbugs.gnu.org
> Date: Wed, 25 Oct 2023 11:08:12 -0400
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> >> Cc: Dmitry Gutov <dmitry@gutov.dev>
> >> From: Spencer Baugh <sbaugh@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?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#66668: [PATCH] Teach ffap to look for paths under the root of project
  2023-10-29 12:23     ` Eli Zaretskii
@ 2023-10-29 12:43       ` Dmitry Gutov
  2023-10-29 12:56         ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Gutov @ 2023-10-29 12:43 UTC (permalink / raw)
  To: Eli Zaretskii, Spencer Baugh; +Cc: 66668

On 29/10/2023 14:23, Eli Zaretskii wrote:
>> From: Spencer Baugh<sbaugh@janestreet.com>
>> Cc:dmitry@gutov.dev,66668@debbugs.gnu.org
>> Date: Wed, 25 Oct 2023 11:08:12 -0400
>>
>> Eli Zaretskii<eliz@gnu.org>  writes:
>>>> Cc: Dmitry Gutov<dmitry@gutov.dev>
>>>> From: Spencer Baugh<sbaugh@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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#66668: [PATCH] Teach ffap to look for paths under the root of project
  2023-10-29 12:43       ` Dmitry Gutov
@ 2023-10-29 12:56         ` Eli Zaretskii
  2023-10-30  0:59           ` Dmitry Gutov
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2023-10-29 12:56 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: sbaugh, 66668

> Date: Sun, 29 Oct 2023 14:43:32 +0200
> Cc: 66668@debbugs.gnu.org
> From: Dmitry Gutov <dmitry@gutov.dev>
> 
> On 29/10/2023 14:23, Eli Zaretskii wrote:
> >> From: Spencer Baugh<sbaugh@janestreet.com>
> >> Cc:dmitry@gutov.dev,66668@debbugs.gnu.org
> >> Date: Wed, 25 Oct 2023 11:08:12 -0400
> >>
> >> Eli Zaretskii<eliz@gnu.org>  writes:
> >>>> Cc: Dmitry Gutov<dmitry@gutov.dev>
> >>>> From: Spencer Baugh<sbaugh@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?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#66668: [PATCH] Teach ffap to look for paths under the root of project
  2023-10-29 12:56         ` Eli Zaretskii
@ 2023-10-30  0:59           ` Dmitry Gutov
  0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Gutov @ 2023-10-30  0:59 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: sbaugh, 66668-done

Version: 30.1

On 29/10/2023 14:56, Eli Zaretskii wrote:
>> Date: Sun, 29 Oct 2023 14:43:32 +0200
>> Cc: 66668@debbugs.gnu.org
>> From: Dmitry Gutov <dmitry@gutov.dev>
>>
>> On 29/10/2023 14:23, Eli Zaretskii wrote:
>>>> From: Spencer Baugh<sbaugh@janestreet.com>
>>>> Cc:dmitry@gutov.dev,66668@debbugs.gnu.org
>>>> Date: Wed, 25 Oct 2023 11:08:12 -0400
>>>>
>>>> Eli Zaretskii<eliz@gnu.org>  writes:
>>>>>> Cc: Dmitry Gutov<dmitry@gutov.dev>
>>>>>> From: Spencer Baugh<sbaugh@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!





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-10-30  0:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-21 18:37 bug#66668: [PATCH] Teach ffap to look for paths under the root of project Spencer Baugh
2023-10-21 19:06 ` Eli Zaretskii
2023-10-25 15:08   ` Spencer Baugh
2023-10-29 12:23     ` Eli Zaretskii
2023-10-29 12:43       ` Dmitry Gutov
2023-10-29 12:56         ` Eli Zaretskii
2023-10-30  0:59           ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).