]> git.eshelyaron.com Git - emacs.git/commitdiff
project--read-file-cpd-relative: Move out the 'included-cpd' logic
authorDmitry Gutov <dmitry@gutov.dev>
Tue, 29 Oct 2024 01:48:03 +0000 (03:48 +0200)
committerEshel Yaron <me@eshelyaron.com>
Tue, 29 Oct 2024 09:59:49 +0000 (10:59 +0100)
* lisp/progmodes/project.el (project-find-dir):
Use 'project-files-relative-names'.  Include "./" here rather than
(project--read-file-cpd-relative): ...doing it here.

(cherry picked from commit a6626a00dc4b459e57d700e5bb7524cd3e0a55f8)

lisp/progmodes/project.el

index b41e28476476405b937e824d03b96dc5f94265ef..10200c8e27861b304b575f4530f464451080fde7 100644 (file)
@@ -1200,10 +1200,6 @@ by the user at will."
                           (file-name-absolute-p (car all-files)))
                      prompt
                    (concat prompt (format " in %s" common-parent-directory))))
-         (included-cpd (when (member common-parent-directory all-files)
-                         (setq all-files
-                               (delete common-parent-directory all-files))
-                         t))
          (mb-default (mapcar (lambda (mb-default)
                                (if (and common-parent-directory
                                         mb-default
@@ -1213,8 +1209,6 @@ by the user at will."
                                  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))))
          (new-collection (project--file-completion-table substrings))
          (abs-cpd (expand-file-name common-parent-directory))
          (abs-cpd-length (length abs-cpd))
@@ -1325,6 +1319,7 @@ The current buffer's `default-directory' is available as part of
 \"future history\"."
   (interactive)
   (let* ((project (project-current t))
+         (project-files-relative-names t)
          (all-files (project-files project))
          (completion-ignore-case read-file-name-completion-ignore-case)
          ;; FIXME: This misses directories without any files directly
@@ -1332,11 +1327,15 @@ The current buffer's `default-directory' is available as part of
          ;; `project-files-filtered', and see
          ;; https://stackoverflow.com/a/50685235/615245 for possible
          ;; implementation.
-         (all-dirs (mapcar #'file-name-directory all-files))
+         (all-dirs (cons "./"
+                         (delq nil
+                               ;; Some completion UIs show duplicates.
+                               (delete-dups
+                                (mapcar #'file-name-directory all-files)))))
+         (default-directory (project-root project))
          (dir (project--read-file-name
                project "Dired"
-               ;; Some completion UIs show duplicates.
-               (delete-dups all-dirs)
+               all-dirs
                nil 'file-name-history
                (and default-directory
                     (project--find-default-from default-directory project)))))