From 46e4ecdba5883d11a1da7559b0556c5e48e2d64d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20Antol=C3=ADn?= Date: Fri, 24 Apr 2020 16:08:53 -0500 Subject: Improve ivy integration --- README.org | 3 --- orderless.el | 22 +++++++++++++++------- 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 -- cgit v1.0