emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/vertico 0566f830e1: vertico--history-hash: Deprioritize


From: ELPA Syncer
Subject: [elpa] externals/vertico 0566f830e1: vertico--history-hash: Deprioritize current file (Fix #348)
Date: Tue, 28 Mar 2023 16:01:17 -0400 (EDT)

branch: externals/vertico
commit 0566f830e14ed9e92c75b6a5b0ea33046eee894c
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    vertico--history-hash: Deprioritize current file (Fix #348)
---
 CHANGELOG.org |  1 +
 vertico.el    | 16 ++++++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG.org b/CHANGELOG.org
index 8746a3e6cb..f963bcdbd8 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -6,6 +6,7 @@
 
 - =vertico-buffer-display=: Add more choices for the display action to the
   customizable variable.
+- =vertico--history-hash=: Deprioritize current file when sorting by history.
 
 * Version 1.2 (2023-03-11)
 
diff --git a/vertico.el b/vertico.el
index 5d5676c998..66289f6558 100644
--- a/vertico.el
+++ b/vertico.el
@@ -194,13 +194,17 @@ The value should lie between 0 and vertico-count/2."
              (base-size (length base))
              (hist (and (not (eq minibuffer-history-variable t)) ;; Disabled 
for `t'.
                         (symbol-value minibuffer-history-variable)))
-             (hash (make-hash-table :test #'equal :size (length hist))))
+             (hash (make-hash-table :test #'equal :size (length hist)))
+             (file-hist (eq minibuffer-history-variable 'file-name-history))
+             (curr-file (when-let ((win (and file-hist 
(minibuffer-selected-window)))
+                                   (file (buffer-file-name (window-buffer 
win))))
+                          (abbreviate-file-name file))))
         (cl-loop for elem in hist for index from 0 do
-                 (when (or (= base-size 0)
-                           (and (>= (length elem) base-size)
-                                (eq t (compare-strings base 0 base-size elem 0 
base-size))))
-                   (let ((file-sep (and (eq minibuffer-history-variable 
'file-name-history)
-                                        (string-search "/" elem base-size))))
+                 (when (and (not (equal curr-file elem)) ;; Deprioritize 
current file
+                            (or (= base-size 0)
+                                (and (>= (length elem) base-size)
+                                     (eq t (compare-strings base 0 base-size 
elem 0 base-size)))))
+                   (let ((file-sep (and file-hist (string-search "/" elem 
base-size))))
                      ;; Drop base string from history elements & special file 
handling.
                      (when (or (> base-size 0) file-sep)
                        (setq elem (substring elem base-size (and file-sep (1+ 
file-sep)))))



reply via email to

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