Subject: [PATCH] In project-find-file, add absolute file name to history
From: Augusto Stoffel <[email-masked]>
To: [email-masked]
Date: Tue, 11 Oct 2022 20:29:24 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Tags: patch

`project-find-file' and related commands share their history with more
general commands like `find-file', so they should add the absolute file
name to history.  Currently, file names relative to the project root are
added.  The attached patch fixes this.

I've also replaced `concat' with `expand-file-name' at a certain point.
I see no reason why one shouldn't do that, but please have a look.

From 699732687f559c7984e76310971094f251423d5d Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <[email-masked]>
Date: Tue, 11 Oct 2022 20:21:34 +0200
Subject: [PATCH] In project-find-file and the like, add absolute file name to
 history

* lisp/progmodes/project.el (project--read-file-cpd-relative): Add
absolute file name to history.
---
 lisp/progmodes/project.el | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index ee94d0d85d..95087ae6a8 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -931,11 +931,15 @@ project--read-file-cpd-relative
          (_ (when included-cpd
               (setq substrings (cons "./" substrings))))
          (new-collection (project--file-completion-table substrings))
-         (res (project--completing-read-strict prompt
-                                               new-collection
-                                               predicate
-                                               hist mb-default)))
-    (concat common-parent-directory res)))
+         (relname (let ((history-add-new-input nil))
+                    (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 absname))
+    absname))
 
 (defun project--read-file-absolute (prompt
                                     all-files &optional predicate
-- 
2.37.3