branch: externals/orderless
commit 2debd96da6f75703ccbca6d852ad994ce84fa529
Author: Omar Antolín <[email protected]>
Commit: Omar Antolín <[email protected]>
Correct case-folding when highlighting matches (fix #127)
Highlighting of matches should be done with the same case-folding that
filtering is done with! This is perhaps most noticeable with
orderless-smart-case on, but was previously incorrect with it off
since filtering used completion-ignore-case and highlighting used
case-fold-search!
---
orderless.el | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/orderless.el b/orderless.el
index c6c6450475..47e3c9939d 100644
--- a/orderless.el
+++ b/orderless.el
@@ -249,16 +249,21 @@ at a word boundary in the candidate. This is similar to
the
string)
(defun orderless-highlight-matches (regexps strings)
- "Highlight a match of each of the REGEXPS in each of the STRINGS.
+ "Highlight a match of each of the REGEXPS in each of the STRINGS.
Warning: only use this if you know all REGEXPs match all STRINGS!
For the user's convenience, if REGEXPS is a string, it is
converted to a list of regexps according to the value of
`orderless-matching-styles'."
- (when (stringp regexps)
- (setq regexps (orderless-pattern-compiler regexps)))
+ (when (stringp regexps)
+ (setq regexps (orderless-pattern-compiler regexps)))
+ (let ((case-fold-search
+ (if orderless-smart-case
+ (cl-loop for regexp in regexps
+ always (isearch-no-upper-case-p regexp t))
+ completion-ignore-case)))
(cl-loop for original in strings
for string = (copy-sequence original)
- collect (orderless--highlight regexps string)))
+ collect (orderless--highlight regexps string))))
;;; Compiling patterns to lists of regexps