[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/orderless 2750e15c74 065/204: Add ivy integration
From: |
ELPA Syncer |
Subject: |
[elpa] externals/orderless 2750e15c74 065/204: Add ivy integration |
Date: |
Tue, 11 Jan 2022 12:58:18 -0500 (EST) |
branch: externals/orderless
commit 2750e15c742d8460748044522a1286c27e4bfc32
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>
Add ivy integration
---
README.org | 11 +++++++++++
orderless.el | 45 +++++++++++++++++++++++++++++++--------------
2 files changed, 42 insertions(+), 14 deletions(-)
diff --git a/README.org b/README.org
index cb7fd86acf..171d811a73 100644
--- a/README.org
+++ b/README.org
@@ -213,6 +213,17 @@ please file an issue or make a pull request so others can
benefit from
your effort. The functions =orderless-filter= and
=orderless-highlight-matches= are likely to help with the integration.
+** Ivy
+
+To use =orderless= from Ivy add this to your Ivy configuration:
+
+#+begin_src emacs-lisp
+ (require 'orderless)
+ (cl-pushnew '(orderless--ivy-re-builder . orderless--ivy-highlight)
+ ivy-highlight-functions-alist)
+ (setq ivy-re-builders-alist '((t . orderless--ivy-re-builder)))
+#+end_src
+
** Selectrum
To use =orderless= from Selectrum add this to your Selectrum
diff --git a/orderless.el b/orderless.el
index 7bfb1035bf..2d250d1f44 100644
--- a/orderless.el
+++ b/orderless.el
@@ -164,6 +164,21 @@ at a word boundary in the candidate. This is similar to
the
(cl-loop for prefix in (split-string component "\\>" t)
collect `(seq word-boundary ,prefix))))
+(defun orderless--highlight (regexps string)
+ "Propertize STRING to highlight a match of each of the REGEXPS.
+Warning: only use this if you know all REGEXPs match!"
+ (cl-loop with n = (length orderless-match-faces)
+ for regexp in regexps and i from 0 do
+ (string-match regexp string)
+ (cl-loop
+ for (x y) on (or (cddr (match-data)) (match-data)) by #'cddr
+ when x do
+ (font-lock-prepend-text-property
+ x y
+ 'face (aref orderless-match-faces (mod i n))
+ string)))
+ string)
+
;;;###autoload
(defun orderless-highlight-matches (regexps strings)
"Highlight a match of each of the REGEXPS in each of the STRINGS.
@@ -174,26 +189,15 @@ converted to a list of regexps according to the value of
(when (stringp regexps)
(setq regexps (orderless--component-regexps regexps)))
(cl-loop for original in strings
- for string = (copy-sequence original) do
- (cl-loop with n = (length orderless-match-faces)
- for regexp in regexps and i from 0 do
- (string-match regexp string)
- (cl-loop
- for (x y) on (or (cddr (match-data)) (match-data))
- by #'cddr
- when x do
- (font-lock-prepend-text-property
- x y
- 'face (aref orderless-match-faces (mod i n))
- string)))
- collect string))
+ for string = (copy-sequence original)
+ collect (orderless--highlight regexps string)))
(defun orderless--component-regexps (pattern)
"Build regexps to match PATTERN.
Consults `orderless-component-matching-styles' to decide what to
match."
(cl-loop for component in
- (split-string pattern orderless-component-separator t)
+ (split-string pattern orderless-component-separator t)
collect
(rx-to-string
`(or ,@(cl-loop for style in orderless-component-matching-styles
@@ -278,5 +282,18 @@ This function is part of the `orderless' completion style."
(setq orderless-component-separator separator)
(add-to-list 'minibuffer-exit-hook #'orderless--restore-component-separator))
+(defun orderless--ivy-re-builder (str)
+ "Convert STR into regexps for use with ivy.
+This function is for integration of orderless with ivy, use it as
+a value in `ivy-re-builders-alist'."
+ (or (mapcar (lambda (x) (cons x t)) (orderless--component-regexps str)) ""))
+
+(defun orderless--ivy-highlight (str)
+ "Highlight a match in STR of each regexp in `ivy-regex'.
+This function is for integration of orderless with ivy. Add a
+pair with key `orderless--ivy-re-builder' and value
+`orderless--ivy-highlight' to `ivy-highlight-functions-alist'."
+ (orderless--highlight (mapcar #'car ivy-regex) str) str)
+
(provide 'orderless)
;;; orderless.el ends here
- [elpa] externals/orderless df4f29a4f4 183/204: Use minibuffer customization group, (continued)
- [elpa] externals/orderless df4f29a4f4 183/204: Use minibuffer customization group, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 62f71c34ba 191/204: Extend prefix optimization to anchored quoted regexps (fix #81), ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 75d3398056 192/204: Have orderless-try-completion return t for exact match (fix #95), ELPA Syncer, 2022/01/11
- [elpa] externals/orderless c8731aacfa 197/204: Merge pull request #98 from minad/fix-try, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless f22789f358 202/204: Merge pull request #94 from minad/strict-initialism, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 855255eb01 198/204: Mention Corfu and consult-completion-in-region (fix #99), ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 269d7388ab 034/204: Merge pull request #6 from raxod502/patch-1, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless ae466bc4f4 054/204: Rename orderless-regexp-separator to orderless-component-separator, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless aad0aa8a8d 017/204: Copy candidates to avoid permanently changing their face, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 9218343171 043/204: Add command to temporarily change separator, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 2750e15c74 065/204: Add ivy integration,
ELPA Syncer <=
- [elpa] externals/orderless fb6ad592b7 067/204: List more helpful functions for integration, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 50c83f2752 074/204: Avoid using cl-lib in autoloads, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 274c8cbadc 078/204: Declare other ivy variable used, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless b63019aea3 090/204: Add missing (oops!) "forgiving funcall" function, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 74947d0862 092/204: Update dispatchers documentation, and documents pattern compiler, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless c245cb6e9d 091/204: Make dispatchers always take 3 args (to avoid depending on 26.1), ELPA Syncer, 2022/01/11
- [elpa] externals/orderless c1be870f02 101/204: Undocument orderless-temporarily-change-separator in README, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless d0b217512f 104/204: Switch to single variable config, add transient vars, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless 5618c349a6 107/204: Remove global dispatchers, ELPA Syncer, 2022/01/11
- [elpa] externals/orderless e56eeef6e1 126/204: Merge pull request #22 from jcs-PR/badge, ELPA Syncer, 2022/01/11