bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#55267: 29.0.50; Provide customization to save project-find-file arg


From: Juri Linkov
Subject: bug#55267: 29.0.50; Provide customization to save project-find-file arg to savehist
Date: Thu, 12 May 2022 19:38:48 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu)

>> I just noticed that "project-find-file" is ultimately calling
>> "find-file" only. So it should save the file to minibuffer history if
>> savehist-mode is enabled.
>>
>> But this is not happening in my environment right now. Is this a bug
>> (instead of feature request)?
>
> Recently I noticed this problem too.  So project-find-file-in
> needs to specify the same history variable 'file-name-history'
> as used in read-file-name-default.
>
> Then you could add 'file-name-history' to savehist-additional-variables.

BTW, here is another improvement for project-find-file.
If there is no file name under point, it could propose
the current file name for editing in the minibuffer,
to find another file based on the current file
when their names are similar.

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 6c50135358..5eee20e408 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -863,8 +863,12 @@ project-find-file
 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)

reply via email to

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