emacs-diffs
[Top][All Lists]
Advanced

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

master 4132223d89: * lisp/progmodes/project.el: Improve file-reading his


From: Juri Linkov
Subject: master 4132223d89: * lisp/progmodes/project.el: Improve file-reading history and default values.
Date: Mon, 30 May 2022 12:32:01 -0400 (EDT)

branch: master
commit 4132223d897290a5c04791ea1178faa5858a98f0
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    * lisp/progmodes/project.el: Improve file-reading history and default 
values.
    
    (project-find-file): Use relative file name of the
    currently visited file as an alternative default value.
    (project-find-file-in, project-find-dir): Use 'file-name-history' 
(bug#55267).
---
 lisp/progmodes/project.el | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 6c50135358..4dc4762176 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -863,8 +863,12 @@ interactively, include all files under the project root, 
except
 for VCS directories listed in `vc-directory-exclusion-list'."
   (interactive "P")
   (let* ((pr (project-current t))
-         (dirs (list (project-root pr))))
-    (project-find-file-in (thing-at-point 'filename) dirs pr include-all)))
+         (root (project-root pr))
+         (dirs (list root)))
+    (project-find-file-in
+     (or (thing-at-point 'filename)
+         (and buffer-file-name (file-relative-name buffer-file-name root)))
+     dirs pr include-all)))
 
 ;;;###autoload
 (defun project-or-external-find-file (&optional include-all)
@@ -955,7 +959,7 @@ directories listed in `vc-directory-exclusion-list'."
             (project-files project dirs)))
          (completion-ignore-case read-file-name-completion-ignore-case)
          (file (funcall project-read-file-name-function
-                        "Find file" all-files nil nil
+                        "Find file" all-files nil 'file-name-history
                         suggested-filename)))
     (if (string= file "")
         (user-error "You didn't specify the file")
@@ -992,7 +996,7 @@ directories listed in `vc-directory-exclusion-list'."
                        "Dired"
                        ;; Some completion UIs show duplicates.
                        (delete-dups all-dirs)
-                       nil nil)))
+                       nil 'file-name-history)))
     (dired dir)))
 
 ;;;###autoload



reply via email to

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