summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Antolín <omar.antolin@gmail.com>2020-04-24 16:08:53 -0500
committerOmar Antolín <omar.antolin@gmail.com>2020-04-24 16:08:53 -0500
commit46e4ecdba5883d11a1da7559b0556c5e48e2d64d (patch)
tree048853587cdbc47a26f599c6c03a189e09743901
parent1a4bf2e237e99ecc4bb262261b1c85e2b0905a73 (diff)
Improve ivy integration
-rw-r--r--README.org3
-rw-r--r--orderless.el22
2 files changed, 15 insertions, 10 deletions
diff --git a/README.org b/README.org
index 9439e20..5f67c59 100644
--- a/README.org
+++ b/README.org
@@ -222,9 +222,6 @@ integration.
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
diff --git a/orderless.el b/orderless.el
index 58810d0..aa16cd9 100644
--- a/orderless.el
+++ b/orderless.el
@@ -285,20 +285,28 @@ 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)
+;;; ivy integration
+
+(defvar ivy-regex)
+(defvar ivy-highlight-functions-alist)
+
+;;;###autoload
+(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)) ""))
-(defvar ivy-regex)
-
-(defun orderless--ivy-highlight (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'."
+This function is for integration of orderless with ivy."
(orderless--highlight (mapcar #'car ivy-regex) str) str)
+;;;###autoload
+(eval-after-load 'ivy
+ (cl-pushnew '(orderless-ivy-re-builder . orderless-ivy-highlight)
+ ivy-highlight-functions-alist
+ :test #'equal))
+
(provide 'orderless)
;;; orderless.el ends here