emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master f38bcf37dc4 3/3: (project-find-file): Allow current file name "ot


From: Dmitry Gutov
Subject: master f38bcf37dc4 3/3: (project-find-file): Allow current file name "other project"'s future history
Date: Wed, 16 Aug 2023 21:17:54 -0400 (EDT)

branch: master
commit f38bcf37dc47ce172c985d1c621df3583eaad46c
Author: Spencer Baugh <sbaugh@janestreet.com>
Commit: Dmitry Gutov <dmitry@gutov.dev>

    (project-find-file): Allow current file name "other project"'s future 
history
    
    * lisp/progmodes/project.el (project-find-file):
    Allow using the relative file name of the current buffer in "other
    project" as well (bug#63829).
---
 lisp/progmodes/project.el | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index d8b12c9c880..e1d14474323 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -994,7 +994,8 @@ pattern to search for."
   "Visit a file (with completion) in the current project.
 
 The filename at point (determined by `thing-at-point'), if any,
-is available as part of \"future history\".
+is available as part of \"future history\".  If none, the current
+buffer's file name is used.
 
 If INCLUDE-ALL is non-nil, or with prefix argument when called
 interactively, include all files under the project root, except
@@ -1005,7 +1006,16 @@ for VCS directories listed in 
`vc-directory-exclusion-list'."
          (dirs (list root)))
     (project-find-file-in
      (or (thing-at-point 'filename)
-         buffer-file-name)
+         (and buffer-file-name
+              (if-let (buffer-proj (and project-current-directory-override
+                                        (project-current nil 
default-directory)))
+                  ;; Allow using the relative file name of the current
+                  ;; buffer in "other project" as well.
+                  (let ((buffer-root (project-root buffer-proj)))
+                    ;; file-name-concat requires Emacs 28+
+                    (concat (file-name-as-directory root)
+                            (file-relative-name buffer-file-name buffer-root)))
+                buffer-file-name)))
      dirs pr include-all)))
 
 ;;;###autoload



reply via email to

[Prev in Thread] Current Thread [Next in Thread]