From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#66668: [PATCH] Teach ffap to look for paths under the root of project Date: Wed, 25 Oct 2023 11:08:12 -0400 Message-ID: References: <838r7vre1a.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25942"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: dmitry@gutov.dev, 66668@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 25 17:08:51 2023 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 1qvfV4-0006WT-Se for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 25 Oct 2023 17:08:50 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvfUp-0003rk-Kn; Wed, 25 Oct 2023 11:08:35 -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 1qvfUn-0003r7-2Q for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2023 11:08:33 -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 1qvfUm-0002pj-QH for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2023 11:08:32 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qvfVG-0002Ki-GN for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2023 11:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 Oct 2023 15:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66668 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 66668-submit@debbugs.gnu.org id=B66668.16982465348953 (code B ref 66668); Wed, 25 Oct 2023 15:09:02 +0000 Original-Received: (at 66668) by debbugs.gnu.org; 25 Oct 2023 15:08:54 +0000 Original-Received: from localhost ([127.0.0.1]:59776 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qvfV7-0002KK-6E for submit@debbugs.gnu.org; Wed, 25 Oct 2023 11:08:53 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:40275) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qvfV2-0002K0-8n for 66668@debbugs.gnu.org; Wed, 25 Oct 2023 11:08:51 -0400 In-Reply-To: <838r7vre1a.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 21 Oct 2023 22:06:25 +0300") 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:273188 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> Cc: Dmitry Gutov >> From: Spencer Baugh >> 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) --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Teach-ffap-to-look-for-relative-file-names-under-pro.patch >From 4423e8eb9b54652c114bb9d6b6b3b873a15a24a9 Mon Sep 17 00:00:00 2001 From: Spencer Baugh 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 --=-=-=--