]> git.eshelyaron.com Git - emacs.git/commitdiff
When completing relative project file names, use relative history
authorDmitry Gutov <dgutov@yandex.ru>
Thu, 15 Dec 2022 22:45:55 +0000 (00:45 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Thu, 15 Dec 2022 22:46:20 +0000 (00:46 +0200)
* lisp/progmodes/project.el: Require 'cl-lib'.

* lisp/progmodes/project.el (project--read-file-cpd-relative):
Pre-process history entries around completing-read (bug#58447).

This includes both filtering by common-parent-directory prefix and
mapping into relative names.

lisp/progmodes/project.el

index 4fd855255b0fecab3ea41cf49f4cf82a4b52b439..559da6dd64902fe13e0fd5bb6042dea5dbd21524 100644 (file)
 ;;; Code:
 
 (require 'cl-generic)
+(require 'cl-lib)
 (require 'seq)
 (eval-when-compile (require 'subr-x))
 
@@ -1038,7 +1039,14 @@ by the user at will."
          (_ (when included-cpd
               (setq substrings (cons "./" substrings))))
          (new-collection (project--file-completion-table substrings))
-         (relname (let ((history-add-new-input nil))
+         (abbr-cpd (abbreviate-file-name common-parent-directory))
+         (relname (cl-letf ((history-add-new-input nil)
+                            ((symbol-value hist)
+                             (mapcan
+                              (lambda (s)
+                                (and (string-prefix-p abbr-cpd s)
+                                     (list (substring s (length abbr-cpd)))))
+                              (symbol-value hist))))
                     (project--completing-read-strict prompt
                                                      new-collection
                                                      predicate