summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Antolín <omar.antolin@gmail.com>2020-04-18 23:03:06 -0500
committerOmar Antolín <omar.antolin@gmail.com>2020-04-18 23:03:06 -0500
commitecddc3da2e005d90941410b8b450982283561e38 (patch)
treee84d52cbb2150a93ba36132c803a0d4869936b4d
parentb0913a9c5665e6abee6f6cc09694a4e52cab7e13 (diff)
Un-nest definition of orderless--highlight-matches
The byte compiler complains it can't find it inside the let form... The simple is solution is ... to pollute the global namespace!
-rw-r--r--orderless.el25
1 files changed, 15 insertions, 10 deletions
diff --git a/orderless.el b/orderless.el
index 7d3d7ae..7061764 100644
--- a/orderless.el
+++ b/orderless.el
@@ -92,23 +92,28 @@ component regexps."
(regexp :tag "Custom regexp"))
:group 'orderless)
-(let ((faces '(orderless-match-face-0
- orderless-match-face-1
- orderless-match-face-2
- orderless-match-face-3)))
- (nconc faces faces)
- (defun orderless--highlight-matches (regexps string)
+(defcustom orderless-match-faces
+ [orderless-match-face-0
+ orderless-match-face-1
+ orderless-match-face-2
+ orderless-match-face-3]
+ "Vector of faces used (cyclically) for component matches."
+ :type '(vector 'face)
+ :group 'orderless)
+
+(defun orderless--highlight-matches (regexps string)
"Highlight matches of REGEXPS in STRING.
-Warning: only call this function when you know REGEXP matches STRING!"
+Warning: only call this if you know all REGEXPs match STRING!"
(setq string (copy-sequence string))
- (cl-loop for regexp in regexps and face in faces do
+ (cl-loop with n = (length orderless-match-faces)
+ for regexp in regexps and i from 0 do
(string-match regexp string)
(font-lock-prepend-text-property
(match-beginning 0)
(match-end 0)
- 'face face
+ 'face (aref orderless-match-faces (mod i n))
string))
- string))
+ string)
(defun orderless-all-completions (string table pred _point)
"Split STRING into components and find entries TABLE matching all.