emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 c8d75046a2: When completing relative project file names, use re


From: Dmitry Gutov
Subject: emacs-29 c8d75046a2: When completing relative project file names, use relative history
Date: Thu, 15 Dec 2022 17:49:51 -0500 (EST)

branch: emacs-29
commit c8d75046a2f1b5d29e073ac2e4a987145343b0b7
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    When completing relative project file names, use relative history
    
    * 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 | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 4fd855255b..559da6dd64 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -174,6 +174,7 @@
 ;;; 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]