From 601ce9038b2b055c3a6001ee74bdd9da6204f4b4 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Tue, 29 Oct 2024 03:48:03 +0200 Subject: [PATCH] project--read-file-cpd-relative: Move out the 'included-cpd' logic * 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 | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index b41e2847647..10200c8e278 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -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))))) -- 2.39.5