]> git.eshelyaron.com Git - emacs.git/commitdiff
Provide a list of default values for M-n of project-find-file (bug#70996)
authorJuri Linkov <juri@linkov.net>
Tue, 28 May 2024 16:31:55 +0000 (19:31 +0300)
committerEshel Yaron <me@eshelyaron.com>
Wed, 29 May 2024 10:12:11 +0000 (12:12 +0200)
* lisp/progmodes/project.el (project-find-file)
(project-or-external-find-file): Provide a list of suggested
filenames for the first arg of project-find-file-in.
Use buffer-file-name first to make it more predictable for M-n.
(project--read-file-cpd-relative): Handle mb-default as a list.

(cherry picked from commit ebac4d4872829c44f65966b3268ceaf7ecbf43d9)

lisp/progmodes/project.el

index 9f246cc1a64dc840c5a2d8acc822c7fc2cc5d0b0..f3574774e8b1eaa7a51e0ebe394eeb65a46520c3 100644 (file)
@@ -1082,8 +1082,9 @@ for VCS directories listed in `vc-directory-exclusion-list'."
          (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
@@ -1105,8 +1106,9 @@ for VCS directories listed in `vc-directory-exclusion-list'."
                 (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
@@ -1168,11 +1170,14 @@ by the user at will."
                          (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))
+                             (if (listp mb-default) mb-default (list mb-default))))
          (substrings (mapcar (lambda (s) (substring s cpd-length)) all-files))
          (_ (when included-cpd
               (setq substrings (cons "./" substrings))))