[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vertico afd0abf 41/48: Always pass again through comple
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vertico afd0abf 41/48: Always pass again through completion style for highlighting |
Date: |
Mon, 5 Apr 2021 10:54:46 -0400 (EDT) |
branch: externals/vertico
commit afd0abf0bae92ccfa334a263ff0d1d767c9550b4
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Always pass again through completion style for highlighting
* Calling the completion style on ten candidates is very cheap.
* We avoid the fragile orderless detection
---
minicomp.el | 43 ++++++++++++++++++-------------------------
1 file changed, 18 insertions(+), 25 deletions(-)
diff --git a/minicomp.el b/minicomp.el
index c61d958..bc09332 100644
--- a/minicomp.el
+++ b/minicomp.el
@@ -109,9 +109,6 @@
map)
"Minibuffer keymap.")
-(defvar minicomp--highlight-function (lambda (_input _metadata cands) cands)
- "Highlighting function.")
-
(defvar-local minicomp--history-hash nil
"History hash table.")
@@ -217,6 +214,21 @@
(mapcar (lambda (cand) (list cand (or (funcall ann cand) "")))
candidates)
candidates)))
+(defvar orderless-skip-highlighting)
+(defun minicomp--highlight (input metadata candidates)
+ "Pass CANDIDATES through the completion style specified by METADATA for
highlighting with INPUT string."
+ (let* ((orderless-skip-highlighting)
+ (highlighted (nconc
+ (completion-all-completions input
+ candidates
+ nil
+ (length input)
+ metadata)
+ nil)))
+ ;; Check if everything went alright, all the candidates should still be
present.
+ (if (= (length highlighted) (length candidates))
+ highlighted candidates)))
+
(defun minicomp--recompute-candidates (input metadata)
"Recompute candidates with INPUT string and METADATA."
(let* ((ignore-re (concat "\\(?:\\`\\|/\\)\\.?\\./\\'"
@@ -291,8 +303,7 @@
(ann-candidates
(minicomp--annotate
metadata
- (funcall
- minicomp--highlight-function
+ (minicomp--highlight
(substring input
(car (completion-boundaries input
minibuffer-completion-table
minibuffer-completion-predicate "")))
@@ -461,33 +472,15 @@
(concat (substring content 0 minicomp--base)
(nth minicomp--index minicomp--candidates)))))
-(defvar orderless-skip-highlighting)
(defun minicomp--setup ()
"Setup completion system."
(setq minicomp--input t
minicomp--candidates-ov (make-overlay (point-max) (point-max) nil t t)
minicomp--count-ov (make-overlay (point-min) (point-min) nil t t))
- (setq-local truncate-lines nil
+ (setq-local orderless-skip-highlighting t ;; Orderless optimization
+ truncate-lines nil
resize-mini-windows 'grow-only
max-mini-window-height 1.0)
- ;; Optimize orderless filtering, skip highlighting
- (when (and (boundp 'orderless-skip-highlighting)
- (equal (default-value 'completion-styles) '(orderless)))
- (setq-local orderless-skip-highlighting t
- minicomp--highlight-function
- (lambda (input metadata candidates)
- ;; Pass once again through the completion style for
highlighting
- (let* ((orderless-skip-highlighting nil)
- (highlighted (nconc
- (completion-all-completions input
- candidates
- nil
- (length
input)
- metadata)
- nil)))
- ;; Check if everything went alright, all the candidates
should still be present.
- (if (= (length highlighted) (length candidates))
- highlighted candidates)))))
(use-local-map minicomp-map)
(add-hook 'post-command-hook #'minicomp--exhibit -99 'local))
- [elpa] externals/vertico fa9e8dc 26/48: split functions, (continued)
- [elpa] externals/vertico fa9e8dc 26/48: split functions, Stefan Monnier, 2021/04/05
- [elpa] externals/vertico 27070bb 27/48: truncate long candidate strings, Stefan Monnier, 2021/04/05
- [elpa] externals/vertico 94d9c4c 28/48: use literals, Stefan Monnier, 2021/04/05
- [elpa] externals/vertico 5f64f97 22/48: update readme, Stefan Monnier, 2021/04/05
- [elpa] externals/vertico 308670c 31/48: Fix confirmation: Use ignore-errors+read-char, Stefan Monnier, 2021/04/05
- [elpa] externals/vertico 2cde6fd 40/48: Simplify, Stefan Monnier, 2021/04/05
- [elpa] externals/vertico e429e06 43/48: Rename to vertico, Stefan Monnier, 2021/04/05
- [elpa] externals/vertico eb5d617 47/48: Improve candidate sanitization, Stefan Monnier, 2021/04/05
- [elpa] externals/vertico d57d390 34/48: Support partial completion for files, Stefan Monnier, 2021/04/05
- [elpa] externals/vertico f3c0e7c 35/48: tidy shadowed file names, Stefan Monnier, 2021/04/05
- [elpa] externals/vertico afd0abf 41/48: Always pass again through completion style for highlighting,
Stefan Monnier <=
- [elpa] externals/vertico 06e5dfe 02/48: improve minibuffer resizing, Stefan Monnier, 2021/04/05
- [elpa] externals/vertico b5cfdd7 09/48: Handle completion boundaries, Stefan Monnier, 2021/04/05
- [elpa] externals/vertico 866475c 05/48: increase threshold, Stefan Monnier, 2021/04/05
- [elpa] externals/vertico c0606cf 39/48: Formatting, Stefan Monnier, 2021/04/05
- [elpa] externals/vertico 7fdfd52 45/48: Formatting, Stefan Monnier, 2021/04/05
- [elpa] externals/vertico 708f89d 46/48: Update copyright information, Stefan Monnier, 2021/04/05
- [elpa] externals/vertico cc3ba08 23/48: add screenshot, Stefan Monnier, 2021/04/05
- [elpa] externals/vertico 59538ff 32/48: Configurable truncation faces, Stefan Monnier, 2021/04/05
- [elpa] externals/vertico 406f8b8 44/48: vertico-insert: Insert only if a candidate is selected, Stefan Monnier, 2021/04/05
- [elpa] externals/vertico f4bde3a 36/48: Ensure that orderless highlighting succeeds, Stefan Monnier, 2021/04/05