From 4132223d897290a5c04791ea1178faa5858a98f0 Mon Sep 17 00:00:00 2001 From: Juri Linkov Date: Mon, 30 May 2022 19:30:54 +0300 Subject: [PATCH] * 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 6c50135358f..4dc4762176a 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 -- 2.39.2