branch: elpa/anzu
commit a52dca6f924c141fe0f7150bd83afe3dae30b3c8
Author: Syohei YOSHIDA <[email protected]>
Commit: Syohei YOSHIDA <[email protected]>
Support migemo(#2)
---
README.md | 5 +++++
anzu.el | 12 ++++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 9edde55fd1..dda869b350 100644
--- a/README.md
+++ b/README.md
@@ -45,6 +45,11 @@ you propertize string by yourself.
(setq anzu-mode-line-update-function 'my/update-func)
```
+#### `anzu-use-migemo`(Default is `nil`)
+
+Set non-nil` if you use [migemo](https://github.com/emacs-jp/migemo).
+
+
## Sample Configuration
```lisp
diff --git a/anzu.el b/anzu.el
index 73f44dfa81..54f691eb80 100644
--- a/anzu.el
+++ b/anzu.el
@@ -35,6 +35,11 @@
:type 'string
:group 'anzu)
+(defcustom anzu-use-migemo nil
+ "Flag of using migemo"
+ :type 'boolean
+ :group 'anzu)
+
(defcustom anzu-mode-line-update-function nil
"Function which return mode-line string"
:type 'function
@@ -54,8 +59,11 @@
(save-excursion
(goto-char (point-min))
(let ((positions '())
- (count 0))
- (while (re-search-forward str nil t)
+ (count 0)
+ (search-func (if (and anzu-use-migemo migemo-isearch-enable-p)
+ 'migemo-forward
+ 're-search-forward)))
+ (while (funcall search-func str nil t)
(push (cons (match-beginning 0) (match-end 0)) positions)
(incf count))
(let ((result (cons count (reverse positions))))