[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vertico 0bc58baba1: vertico--history-hash: Improve file
From: |
ELPA Syncer |
Subject: |
[elpa] externals/vertico 0bc58baba1: vertico--history-hash: Improve file name history handling (Fix #242) |
Date: |
Mon, 20 Jun 2022 18:58:00 -0400 (EDT) |
branch: externals/vertico
commit 0bc58baba1904cefefccc1cd5510d2e942c181f1
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
vertico--history-hash: Improve file name history handling (Fix #242)
Directories which contain recently opened files are sorted to the top by
vertico-sort-history-length-alpha. This requires special handling for the
file-name-history minibuffer history variable.
---
vertico.el | 25 +++++++++++--------------
1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/vertico.el b/vertico.el
index d8b304f72d..909eaba0a8 100644
--- a/vertico.el
+++ b/vertico.el
@@ -184,22 +184,19 @@ See `resize-mini-windows' for documentation."
(or (and (equal (car vertico--history-hash) vertico--base) (cdr
vertico--history-hash))
(let* ((base vertico--base)
(base-size (length base))
- ;; History disabled if `minibuffer-history-variable' eq `t'.
- (hist (and (not (eq minibuffer-history-variable t))
+ (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))))
- (if (= base-size 0)
- ;; Put history elements into the hash
- (cl-loop for elem in hist for index from 0 do
- (unless (gethash elem hash)
- (puthash elem index hash)))
- ;; Drop base string from history elements, before putting them into
the hash
- (cl-loop for elem in hist for index from 0 do
- (when (and (>= (length elem) base-size)
- (eq t (compare-strings base 0 base-size elem 0
base-size)))
- (setq elem (substring elem base-size))
- (unless (gethash elem hash)
- (puthash elem index hash)))))
+ (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-match-p "/" 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)))))
+ (unless (gethash elem hash) (puthash elem index hash)))))
(cdr (setq vertico--history-hash (cons base hash))))))
(defun vertico--length-string< (x y)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/vertico 0bc58baba1: vertico--history-hash: Improve file name history handling (Fix #242),
ELPA Syncer <=