This repository has been archived by the owner on Jun 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
searchmarks.kak
53 lines (43 loc) · 1.68 KB
/
searchmarks.kak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
##
## searchmarks.kak for kakoune-extra
## by lenormf
##
declare-option -hidden line-specs searchmarks_flags
set-face global SearchMark LineNumbers
define-command -hidden -params 2 searchmarks-impl %{
try %{
execute-keys -save-regs '' %arg{1} %arg{2} <ret>
evaluate-commands -draft %{
execute-keys \%s <ret>
evaluate-commands %sh{
printf %s "${kak_selections_desc}" | awk -v timestamp="${kak_timestamp}" '
{
for (i = 1; i <= NF; i++) {
split($i, n, /,|\./)
line_begin = n[1]
line_end = n[3]
for (j = line_begin; j <= line_end; j++)
lines[j]++
}
}
END{
specs = ""
for (i in lines)
specs = specs " " i "|{SearchMark}" lines[i]
if (length(specs))
printf "set-option window searchmarks_flags %d%s", timestamp, specs
}
'
}
}
try %{ add-highlighter window/searchmarks flag-lines Default searchmarks_flags }
} catch %{
remove-highlighter window/searchmarks
}
}
define-command -params 1 -docstring %{
search-marks <primitive>: Hint at search matches with markers and match counts
The primitive argument is whatever key spawns a prompt, and search for a given pattern (e.g. `/`)
} search-marks %{
prompt -init %reg{/} "search (%arg{1}):" "searchmarks-impl %arg{1} %%val{text}"
}