From 9e522e7db812f38710b6819978a3abb2b1b6cf00 Mon Sep 17 00:00:00 2001 From: 10sr <8.slashes@gmail.com> Date: Mon, 20 Jan 2020 17:05:20 +0900 Subject: [PATCH] Add my--ivy-regex-fuzzy-ignore-order --- emacs.el | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/emacs.el b/emacs.el index 5ee5312..1f9867b 100644 --- a/emacs.el +++ b/emacs.el @@ -2505,11 +2505,24 @@ Any output will be written to current buffer." (defvar ivy-re-builders-alist) (set-variable 'ivy-re-builders-alist - '((t . (lambda (s) - ;; Ignore whitespace - (ivy--regex-fuzzy (replace-regexp-in-string (rx space) - "" - s)))))) + '((t . my--ivy-regex-fuzzy-ignore-order))) + +(defun my--ivy-regex-fuzzy-ignore-order (str) + "Re-build regex from STR for ignore-order fuzzy match." + (let ((re-list (ivy--regex-ignore-order str))) + (if (listp re-list) + (mapcar (lambda (e) + (let ((head (car e)) + (tail (cdr e))) + (if tail + (cons (ivy--regex-fuzzy head) + tail) + (cons head tail)))) + re-list) + (ivy--regex-fuzzy re-list)))) +;; (my--ivy-regex-fuzzy-ignore-order "ab bc !cee") +;; (ivy--regex-fuzzy "ab") +;; (ivy--regex-ignore-order "a b") (with-eval-after-load 'ivy (defvar ivy-minibuffer-map)