branch: elpa/anzu
commit 09cc87ad9bcaceb4665d7162990aa8d4053d4951
Merge: 6fded24b36 f2aad769c1
Author: Syohei YOSHIDA <[email protected]>
Commit: Syohei YOSHIDA <[email protected]>
Merge pull request #66 from syohex/replace-threshold
Add replacement overlay threshold customize variable
---
README.md | 22 +++++++++++++---------
anzu.el | 15 +++++++++++++--
2 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/README.md b/README.md
index 7abf3912ed..8f6be8f448 100644
--- a/README.md
+++ b/README.md
@@ -14,13 +14,13 @@ information in the mode-line in various search modes.
## Requirements
-* Emacs 24 or higher
-* `cl-lib` 0.5 or higher (you don't need to install `cl-lib` if you use Emacs
24.3 or higher)
+- Emacs 24 or higher
+- `cl-lib` 0.5 or higher (you don't need to install `cl-lib` if you use Emacs
24.3 or higher)
## Installation
-You can install `anzu.el` from [MELPA](http://melpa.org/) with `package.el`
+You can install `anzu.el` from [MELPA](https://melpa.org/) with `package.el`
```
M-x package-install anzu
@@ -29,20 +29,20 @@ You can install `anzu.el` from [MELPA](http://melpa.org/)
with `package.el`
## Basic Usage
-#### `anzu-mode`
+#### `global-anzu-mode`
-Enable anzu minor mode:
+Enable global anzu mode:
```lisp
-(anzu-mode +1)
+(global-anzu-mode +1)
```
-#### `global-anzu-mode`
+#### `anzu-mode`
-Enable global anzu mode:
+Enable anzu minor mode:
```lisp
-(global-anzu-mode +1)
+(anzu-mode +1)
```
#### `anzu-query-replace`
@@ -160,6 +160,9 @@ If this value is `nil`, `anzu.el` counts all words.

+#### `anzu-replace-threshold`(Default is `nil`)
+
+Threshold of replacement overlay. If this value is `nil`,
#### `anzu-minimum-input-length`(Default is 1)
@@ -196,6 +199,7 @@ Separator of `to` string.
'(anzu-mode-lighter "")
'(anzu-deactivate-region t)
'(anzu-search-threshold 1000)
+ '(anzu-replace-threshold 50)
'(anzu-replace-to-string-separator " => "))
```
diff --git a/anzu.el b/anzu.el
index f091ce4355..6b6641f84e 100644
--- a/anzu.el
+++ b/anzu.el
@@ -1,6 +1,6 @@
;;; anzu.el --- Show number of matches in mode-line while searching -*-
lexical-binding: t; -*-
-;; Copyright (C) 2015 by Syohei YOSHIDA
+;; Copyright (C) 2016 by Syohei YOSHIDA
;; Author: Syohei YOSHIDA <[email protected]>
;; URL: https://github.com/syohex/emacs-anzu
@@ -66,6 +66,12 @@
(boolean :tag "No threshold" nil))
:group 'anzu)
+(defcustom anzu-replace-threshold nil
+ "Limit of replacement overlays."
+ :type '(choice (integer :tag "Threshold of replacement overlays")
+ (boolean :tag "No threshold" nil))
+ :group 'anzu)
+
(defcustom anzu-use-migemo nil
"Flag of using migemo"
:type 'boolean
@@ -555,7 +561,12 @@
(cl-loop for ov in (overlays-in beg end)
when (overlay-get ov 'anzu-replace)
collect ov into anzu-overlays
- finally return (sort anzu-overlays 'anzu--overlay-sort)))
+ finally
+ return
+ (let ((sorted (sort anzu-overlays 'anzu--overlay-sort)))
+ (if anzu-replace-threshold
+ (cl-subseq sorted 0 (min (length sorted)
anzu-replace-threshold))
+ sorted))))
(defsubst anzu--propertize-to-string (str)
(let ((separator (or anzu-replace-to-string-separator "")))