unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Spencer Baugh <sbaugh@janestreet.com>
To: 66668@debbugs.gnu.org
Cc: Dmitry Gutov <dmitry@gutov.dev>
Subject: bug#66668: [PATCH] Teach ffap to look for paths under the root of project
Date: Sat, 21 Oct 2023 14:37:45 -0400	[thread overview]
Message-ID: <ieril6zg6ti.fsf@janestreet.com> (raw)

[-- 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


             reply	other threads:[~2023-10-21 18:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-21 18:37 Spencer Baugh [this message]
2023-10-21 19:06 ` bug#66668: [PATCH] Teach ffap to look for paths under the root of project 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ieril6zg6ti.fsf@janestreet.com \
    --to=sbaugh@janestreet.com \
    --cc=66668@debbugs.gnu.org \
    --cc=dmitry@gutov.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).