diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 7cdaba9c07..d7d1740cfb 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -610,6 +610,7 @@ project--vc-list-files (pcase backend (`Git (let* ((default-directory (expand-file-name (file-name-as-directory dir))) + (abbr-dd (abbreviate-file-name default-directory)) (args '("-z")) (vc-git-use-literal-pathspecs nil) (include-untracked (project--value-in-dir @@ -647,7 +648,7 @@ project--vc-list-files extra-ignores))))) (setq files (mapcar - (lambda (file) (concat default-directory file)) + (lambda (file) (concat abbr-dd file)) (split-string (apply #'vc-git--run-command-string nil "ls-files" args) "\0" t))) @@ -670,6 +671,7 @@ project--vc-list-files (delete-consecutive-dups files))) (`Hg (let* ((default-directory (expand-file-name (file-name-as-directory dir))) + (abbr-dd (abbreviate-file-name default-directory)) (include-untracked (project--value-in-dir 'project-vc-include-untracked dir)) @@ -685,7 +687,7 @@ project--vc-list-files (with-temp-buffer (apply #'vc-hg-command t 0 "." "status" args) (mapcar - (lambda (s) (concat default-directory s)) + (lambda (s) (concat abbr-dd s)) (split-string (buffer-string) "\0" t))))))) (defun project--vc-merge-submodules-p (dir) @@ -1042,11 +1044,8 @@ project--read-file-cpd-relative (project--completing-read-strict prompt new-collection predicate - hist mb-default))) - (absname (expand-file-name relname common-parent-directory))) - (when (and hist history-add-new-input) - (add-to-history hist (abbreviate-file-name absname))) - absname)) + hist mb-default)))) + (expand-file-name relname common-parent-directory))) (defun project--read-file-absolute (prompt all-files &optional predicate @@ -1076,9 +1075,16 @@ project-find-file-in dirs) (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 'file-name-history - suggested-filename))) + (file + (let ((file-name-history (seq-filter + (lambda (s) (member s all-files)) + file-name-history)) + (history-add-new-input nil)) + (funcall project-read-file-name-function + "Find file" all-files nil 'file-name-history + suggested-filename)))) + (when history-add-new-input + (add-to-history 'file-name-history (abbreviate-file-name file))) (if (string= file "") (user-error "You didn't specify the file") (find-file file))))