GNU bug report logs -
#70996
project-find-file defaults
Previous Next
Reported by: Juri Linkov <juri <at> linkov.net>
Date: Fri, 17 May 2024 06:53:01 UTC
Severity: normal
Fixed in version 30.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
(thing-at-point 'filename) in project-find-file is a very useful feature
that often helps to use a string under point as a partial file name
to match a project file name as substring. So it's like 'M-.'
that navigates by file names instead of identifiers.
But the problem is that in this case it drops the current file name
as the default value that is also useful in many cases.
Fortunately, the minibuffer supports a list of default values,
like in the following patch:
[project-find-file-at-point.patch (text/x-diff, inline)]
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index a95d1267dd2..5e6516b3b64 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1077,8 +1130,9 @@ project-find-file
(dirs (list root))
(project-files-relative-names t))
(project-find-file-in
- (or (thing-at-point 'filename)
- (and buffer-file-name (project--find-default-from buffer-file-name pr)))
+ (delq nil (list (and buffer-file-name (project--find-default-from
+ buffer-file-name pr))
+ (thing-at-point 'filename)))
dirs pr include-all)))
;;;###autoload
@@ -1100,8 +1154,9 @@ project-or-external-find-file
(project-external-roots pr)))
(project-file-history-behavior t))
(project-find-file-in
- (or (thing-at-point 'filename)
- (and buffer-file-name (project--find-default-from buffer-file-name pr)))
+ (delq nil (list (and buffer-file-name (project--find-default-from
+ buffer-file-name pr))
+ (thing-at-point 'filename)))
dirs pr include-all)))
(defcustom project-read-file-name-function #'project--read-file-cpd-relative
@@ -1163,11 +1218,14 @@ project--read-file-cpd-relative
(setq all-files
(delete common-parent-directory all-files))
t))
- (mb-default (if (and common-parent-directory
- mb-default
- (file-name-absolute-p mb-default))
- (file-relative-name mb-default common-parent-directory)
- mb-default))
+ (mb-default (mapcar (lambda (mb-default)
+ (if (and common-parent-directory
+ mb-default
+ (file-name-absolute-p mb-default))
+ (file-relative-name
+ mb-default common-parent-directory)
+ mb-default))
+ (ensure-list mb-default)))
(substrings (mapcar (lambda (s) (substring s cpd-length)) all-files))
(_ (when included-cpd
(setq substrings (cons "./" substrings))))
This bug report was last modified 1 year and 35 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.