1 # zaw source for ack/ag searcher
3 autoload
-U read-from-minibuffer
5 typeset
-g ZAW_SEARCHER_CMD
7 if (( $
+commands
[ag
] )); then
9 elif (( $
+commands
[ack-grep
] )); then
10 ZAW_SEARCHER_CMD
="ack-grep"
11 elif (( $
+commands
[ack
] )); then
12 ZAW_SEARCHER_CMD
="ack"
14 # ack/ag are not found, and disable this source
18 function zaw-src-searcher
() {
20 read-from-minibuffer
"${ZAW_SEARCHER_CMD} "
21 buf
=$
($ZAW_SEARCHER_CMD ${(Q@)${(z)REPLY}})
22 if [[ $?
!= 0 ]]; then
25 : ${(A)candidates::=${(f)buf}}
26 : ${(A)cand_descriptions::=${(f)buf}}
28 zaw-src-searcher-edit \
35 function zaw-src-searcher-edit
() {
36 local filename
=${1%%:*}
37 local line
=${${1#*:}%%:*}
38 if [[ -z $ZAW_EDITOR_JUMP_PARAM ]]; then
39 ZAW_EDITOR_JUMP_PARAM
="+%LINE% %FILE%"
41 BUFFER
="${EDITOR} ${${ZAW_EDITOR_JUMP_PARAM/\%LINE\%/$line}/\%FILE\%/$filename}"
45 zaw-register-src
-n searcher zaw-src-searcher