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: Sat, 21 Oct 2023 14:37:45 -0400 Message-ID: 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="18311"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Dmitry Gutov To: 66668@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 21 20:38:54 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 1quGsA-0004Zn-LQ for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 21 Oct 2023 20:38:54 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1quGrr-0002Gl-9s; Sat, 21 Oct 2023 14:38: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 1quGrq-0002Gb-Ac for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 14:38:34 -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 1quGrq-0006nK-1V for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 14:38:34 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1quGsH-0007pQ-Sz for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 14:39:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Oct 2023 18:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 66668 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.169791351330037 (code B ref -1); Sat, 21 Oct 2023 18:39:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 Oct 2023 18:38:33 +0000 Original-Received: from localhost ([127.0.0.1]:45031 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quGrm-0007oL-2n for submit@debbugs.gnu.org; Sat, 21 Oct 2023 14:38:32 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:48858) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quGrf-0007nx-Uq for submit@debbugs.gnu.org; Sat, 21 Oct 2023 14:38:28 -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 1quGr6-0002DO-Kb for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 14:37:49 -0400 Original-Received: from mxout6.mail.janestreet.com ([64.215.233.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1quGr5-0006hs-0m for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 14:37:48 -0400 Received-SPF: pass client-ip=64.215.233.21; envelope-from=sbaugh@janestreet.com; helo=mxout6.mail.janestreet.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:272928 Archived-At: --=-=-= Content-Type: text/plain 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' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Teach-ffap-to-look-for-paths-under-the-root-of-proje.patch >From 521116073821c5259130c415640265cb25c03ef3 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 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 --=-=-=--