]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/progmodes/project.el: Improve file-reading history and default values.
authorJuri Linkov <juri@linkov.net>
Mon, 30 May 2022 16:30:54 +0000 (19:30 +0300)
committerJuri Linkov <juri@linkov.net>
Mon, 30 May 2022 16:30:54 +0000 (19:30 +0300)
(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

index 6c50135358f923f9652b467bfe7ddd1fde20a9e8..4dc4762176a01c77fd567a834ff1e47d41739bdd 100644 (file)
@@ -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