ace-isearch.el
provides a minor mode which combines isearch
, ace-jump-mode
or
avy
and
helm-swoop
or swiper
.
The "default" behavior can be summarized as:
- L = 1 :
ace-jump-mode
oravy
- 1 < L < 6 :
isearch
- L >= 6 :
helm-swoop
orswiper
where L is the length of input query string during isearch
. When L is 1, after a
few seconds specified by ace-isearch-jump-delay
, ace-jump-mode
or avy
will
be invoked. Of course you can customize the above behaviour.
- Emacs 24 or higher
- ace-jump-mode or avy
- helm-swoop or swiper
You must install these packages manually.
You can install ace-isearch.el
from MELPA with package.el
M-x package-install ace-isearch
Otherwise you can install it by el-get.
Enable ace-isearch
minor mode:
(ace-isearch-mode +1)
Enable global ace-isearch mode:
(global-ace-isearch-mode +1)
Specify the function name utilized in invoking ace-jump-mode
or avy
.
You should specify ace-jump-word-mode
, ace-jump-char-mode
,
avy-goto-word-1
, avy-goto-subword-1
, or avy-goto-char
.
You can switch the value of ace-isearch-function
interactively.
If this variable is set to nil
, ace-jump-mode
or avy
is never invoked.
If set to t
, it is always invoked if the length of isearch-string
is equal to 1.
If set to printing-char
, it is invoked only if you hit a printing character to search for as a first input.
This prevents it from being invoked when repeating a one character search, yanking a character or calling
isearch-delete-char
leaving only one character.
Delay seconds for invoking ace-jump-mode
or avy
during isearch.
Delay seconds for invoking ace-isearch-function-from-isearch
during isearch, which is described below.
As default behaviour, when the input string length during isearch exceeds ace-isearch-input-length
,
the function specified by ace-isearch-function-from-isearch
will be invoked.
Specify the function name invoked when the input string length during isearch exceeds ace-isearch-input-length
.
If swoop has been installed, swoop can be invoked:
(setq ace-isearch-function-from-isearch 'swoop-from-isearch)
In this case, the following setting would be better.
(define-key swoop-map (kbd "C-s") 'swoop-action-goto-line-next)
(define-key swoop-map (kbd "C-r") 'swoop-action-goto-line-prev)
Of course you can set this variable to helm-occur-from-isearch
.
(setq ace-isearch-function-from-isearch 'helm-occur-from-isearch)
You can also set this variable to use swiper
.
(setq ace-isearch-function-from-isearch 'ace-isearch-swiper-from-isearch)
If you don't want to invoke ace-isearch-function-from-isearch
, set this variable to nil
.
This functionality is optional.
When isearch fails and ace-isearch-use-fallback-function
is non-nil,
ace-isearch-fallback-function
will be invoked as a fallback function.
You should specify the symbol name of function which uses isearch-string
, the query string during isearch.
For a trivial example, you can specify it as follows:
(defun my-fallback-function ()
(message "Your isearch string is %s", isearch-string))
(setq ace-isearch-use-function-from-isearch t)
(setq ace-isearch-fallback-function 'my-fallback-function)
If this variable is set to non-nil, ace-isearch-fallback-function
will be invoked
when isearch fails.
With this function, ace-jump-mode
will be invoked further during isearch, which enables to jump to the one of the isearch candidates.
This helps to reduce many key repeats of C-s
or C-r
.
You can invoke ace-jump-mode-pop-mark
or avy-pop-mark
in accordance with the current ace-isearch-funciton
. With this function, you can jump back to the last location of ace-jump-mode
or avy
.
(require 'ace-isearch)
(global-ace-isearch-mode +1)
(custom-set-variables
'(ace-isearch-input-length 7)
'(ace-isearch-jump-delay 0.25)
'(ace-isearch-function 'avy-goto-char)
'(ace-isearch-use-jump 'printing-char))
(define-key isearch-mode-map (kbd "C-'") 'ace-isearch-jump-during-isearch)