[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/orderless c9ae65ea16 023/204: Highlight component match
From: |
ELPA Syncer |
Subject: |
[elpa] externals/orderless c9ae65ea16 023/204: Highlight component matches in one of four faces |
Date: |
Tue, 11 Jan 2022 12:58:14 -0500 (EST) |
branch: externals/orderless
commit c9ae65ea165712369d33647a6c636d6bc95bcc29
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>
Highlight component matches in one of four faces
---
orderless.el | 46 ++++++++++++++++++++++++++++++++++++----------
1 file changed, 36 insertions(+), 10 deletions(-)
diff --git a/orderless.el b/orderless.el
index c7b6e1c833..9ad70efcf1 100644
--- a/orderless.el
+++ b/orderless.el
@@ -45,14 +45,40 @@
;;; Code:
-(defun orderless--highlight-match (regexp string)
- ;; only call this when the match has already been checked!
- (string-match regexp string)
- (font-lock-prepend-text-property
- (match-beginning 0)
- (match-end 0)
- 'face 'completions-common-part
- string))
+(require 'cl-lib)
+
+(defgroup orderless nil
+ "Completion method that matches space-separated regexps in any order."
+ :group 'completion)
+
+(defface orderless-match-face-0 '((t :background "#5ada88"))
+ "Face for maches of components numbered 0 mod 4."
+ :group 'orderless)
+
+(defface orderless-match-face-1 '((t :background "#d5baff"))
+ "Face for maches of components numbered 1 mod 4."
+ :group 'orderless)
+
+(defface orderless-match-face-2 '((t :background "#6aaeff"))
+ "Face for maches of components numbered 2 mod 4."
+ :group 'orderless)
+
+(defface orderless-match-face-3 '((t :background "#ff8892"))
+ "Face for maches of components numbered 3 mod 4."
+ :group 'orderless)
+
+(let ((faces [orderless-match-face-0
+ orderless-match-face-1
+ orderless-match-face-2
+ orderless-match-face-3]))
+ (defun orderless--highlight-match (regexp string face)
+ ;; only call this when the match has already been checked!
+ (string-match regexp string)
+ (font-lock-prepend-text-property
+ (match-beginning 0)
+ (match-end 0)
+ 'face (aref faces (mod face 4))
+ string)))
(defun orderless-all-completions (string table pred _point)
(save-match-data
@@ -71,9 +97,9 @@
always (string-match-p regexp original))
collect ; it's a match, copy and highlight
(cl-loop with candidate = (copy-sequence original)
- for regexp in regexps do
+ for regexp in regexps and face from 0 do
(orderless--highlight-match
- regexp candidate)
+ regexp candidate face)
finally (return candidate))))
(when all (nconc all (length prefix))))
(invalid-regexp nil)))))
- [elpa] externals/orderless 436ef98b16 089/204: Add optional argument for dispatches: total number of components, (continued)
- [elpa] externals/orderless 436ef98b16 089/204: Add optional argument for dispatches: total number of components, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless ed37c22902 097/204: Prefer descriptive argument over "mystery t's", ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 9cebf2fc8c 106/204: Escape parenthesis in first column of docstrings, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 93f4bccea1 112/204: Go back to split-string until empty components issue is resolved, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 2d1f68b914 114/204: Fix tiny bug in customization type, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 5c2f44d901 115/204: Allow component separator to be a function, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 43896f3e10 140/204: Accidentally omitted the overview! Bring it back, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless b059c15911 052/204: Make orderless-prefixes more like partial-completion, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless dc3f8da022 076/204: Avoid other cl-pushnes in an autoload, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless a11302737e 018/204: Keep split-string from modifying global match data, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless c9ae65ea16 023/204: Highlight component matches in one of four faces,
ELPA Syncer <=
- [elpa] externals/orderless 044fac0859 029/204: Revert "Better match face defaults (kindly contributed by Protesilaos)", ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 2813ffb2b1 039/204: Optimization: check if first component is string literal, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 25266dfc60 033/204: Update README.org, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 39202177e1 040/204: Undo previous optimization as it is invalid in general :(, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless ecddc3da2e 045/204: Un-nest definition of orderless--highlight-matches, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 582b3a9fa8 031/204: Make all `defface' syntax more efficient+readable, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless c51037b8ef 024/204: Add custom variable for component separator regexp, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 9856eeed32 047/204: Mention prefixes style in overview, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless cacd856f9a 041/204: Leverage completion-regexp-list: simplify code, increase speed!, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 3005cf8ee9 077/204: Merge pull request #12 from noctuid/feature/strict-initialism, ELPA Syncer, 2022/01/11