src: Introduce a <percent> named key
Similarly to the <semicolon> key, make it easier to write `:execute-keys` commands by replacing <percent> with `%`. Highlighters can keep escaping the sign when regular expressions are not quoted, but built-in scripts that use `%` as an editing primitive have been modified to use the named key, for clarity.
This commit is contained in:
parent
a56a03c454
commit
24c5169400
|
@ -170,7 +170,7 @@ the Shift modifier and moving will extend each selection instead.
|
||||||
trim selections to only contain full lines (not including last
|
trim selections to only contain full lines (not including last
|
||||||
end-of-line)
|
end-of-line)
|
||||||
|
|
||||||
*%*::
|
*%*, *<percent>*::
|
||||||
select whole buffer
|
select whole buffer
|
||||||
|
|
||||||
*<a-h>*::
|
*<a-h>*::
|
||||||
|
|
|
@ -96,7 +96,7 @@ define-command -hidden modeline-parse-impl %{
|
||||||
# [text]{white}{vi:|vim:|Vim:|ex:}[white]se[t] {options}:[text]
|
# [text]{white}{vi:|vim:|Vim:|ex:}[white]se[t] {options}:[text]
|
||||||
define-command modeline-parse -docstring "Read and interpret vi-format modelines at the beginning/end of the buffer" %{
|
define-command modeline-parse -docstring "Read and interpret vi-format modelines at the beginning/end of the buffer" %{
|
||||||
try %{ evaluate-commands -draft %{
|
try %{ evaluate-commands -draft %{
|
||||||
execute-keys \%s\A|.\z<ret> %opt{modelines}k <a-x> %opt{modelines}X \
|
execute-keys <percent> s\A|.\z<ret> %opt{modelines}k <a-x> %opt{modelines}X \
|
||||||
s^\S*?\s+?(vim?|kak(oune)?):\s?[^\n]+<ret> <a-x>
|
s^\S*?\s+?(vim?|kak(oune)?):\s?[^\n]+<ret> <a-x>
|
||||||
evaluate-commands -draft -itersel modeline-parse-impl
|
evaluate-commands -draft -itersel modeline-parse-impl
|
||||||
} }
|
} }
|
||||||
|
|
|
@ -8,7 +8,7 @@ declare-option -hidden range-specs doc_anchors
|
||||||
|
|
||||||
define-command -hidden -params 4 doc-render-regex %{
|
define-command -hidden -params 4 doc-render-regex %{
|
||||||
evaluate-commands -draft %{ try %{
|
evaluate-commands -draft %{ try %{
|
||||||
execute-keys \%s %arg{1} <ret>
|
execute-keys <percent> s %arg{1} <ret>
|
||||||
execute-keys -draft s %arg{2} <ret> d
|
execute-keys -draft s %arg{2} <ret> d
|
||||||
execute-keys "%arg{3}"
|
execute-keys "%arg{3}"
|
||||||
evaluate-commands %sh{
|
evaluate-commands %sh{
|
||||||
|
@ -23,7 +23,7 @@ define-command -hidden -params 4 doc-render-regex %{
|
||||||
|
|
||||||
define-command -hidden doc-parse-links %{
|
define-command -hidden doc-parse-links %{
|
||||||
evaluate-commands -draft %{ try %{
|
evaluate-commands -draft %{ try %{
|
||||||
execute-keys \%s <lt><lt>(.*?),.*?<gt><gt> <ret>
|
execute-keys <percent> s <lt><lt>(.*?),.*?<gt><gt> <ret>
|
||||||
execute-keys -draft s <lt><lt>.*,|<gt><gt> <ret> d
|
execute-keys -draft s <lt><lt>.*,|<gt><gt> <ret> d
|
||||||
execute-keys H
|
execute-keys H
|
||||||
set-option buffer doc_links %val{timestamp}
|
set-option buffer doc_links %val{timestamp}
|
||||||
|
@ -39,13 +39,13 @@ define-command -hidden doc-parse-anchors %{
|
||||||
evaluate-commands -draft %{ try %{
|
evaluate-commands -draft %{ try %{
|
||||||
set-option buffer doc_anchors %val{timestamp}
|
set-option buffer doc_anchors %val{timestamp}
|
||||||
# Find sections as add them as imlicit anchors
|
# Find sections as add them as imlicit anchors
|
||||||
execute-keys \%s ^={2,}\h+([^\n]+)$ <ret>
|
execute-keys <percent> s ^={2,}\h+([^\n]+)$ <ret>
|
||||||
evaluate-commands -itersel %{
|
evaluate-commands -itersel %{
|
||||||
set-option -add buffer doc_anchors "%val{selection_desc}|%sh{printf '%s' ""$kak_main_reg_1"" | tr '[A-Z ]' '[a-z-]'}"
|
set-option -add buffer doc_anchors "%val{selection_desc}|%sh{printf '%s' ""$kak_main_reg_1"" | tr '[A-Z ]' '[a-z-]'}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Parse explicit anchors and remove their text
|
# Parse explicit anchors and remove their text
|
||||||
execute-keys \%s \[\[(.*?)\]\]\s* <ret>
|
execute-keys <percent> s \[\[(.*?)\]\]\s* <ret>
|
||||||
evaluate-commands -itersel %{
|
evaluate-commands -itersel %{
|
||||||
set-option -add buffer doc_anchors "%val{selection_desc}|%reg{1}"
|
set-option -add buffer doc_anchors "%val{selection_desc}|%reg{1}"
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ define-command -params 1 -hidden doc-render %{
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove some line end markers
|
# Remove some line end markers
|
||||||
try %{ execute-keys -draft \%s \h*(\+|:{2,})$ <ret> d }
|
try %{ execute-keys -draft <percent> s \h*(\+|:{2,})$ <ret> d }
|
||||||
|
|
||||||
# Setup the doc_render_ranges option
|
# Setup the doc_render_ranges option
|
||||||
set-option buffer doc_render_ranges %val{timestamp}
|
set-option buffer doc_render_ranges %val{timestamp}
|
||||||
|
@ -124,7 +124,7 @@ define-command -params 1 -hidden doc-render %{
|
||||||
doc-parse-links
|
doc-parse-links
|
||||||
|
|
||||||
# Remove escaping of * and `
|
# Remove escaping of * and `
|
||||||
try %{ execute-keys -draft \%s \\((?=\*)|(?=`)) <ret> d }
|
try %{ execute-keys -draft <percent> s \\((?=\*)|(?=`)) <ret> d }
|
||||||
|
|
||||||
set-option buffer readonly true
|
set-option buffer readonly true
|
||||||
add-highlighter buffer/ ranges doc_render_ranges
|
add-highlighter buffer/ ranges doc_render_ranges
|
||||||
|
|
|
@ -79,6 +79,7 @@ static constexpr KeyAndName keynamemap[] = {
|
||||||
{ "plus", '+' },
|
{ "plus", '+' },
|
||||||
{ "minus", '-' },
|
{ "minus", '-' },
|
||||||
{ "semicolon", ';' },
|
{ "semicolon", ';' },
|
||||||
|
{ "percent", '%' },
|
||||||
};
|
};
|
||||||
|
|
||||||
KeyList parse_keys(StringView str)
|
KeyList parse_keys(StringView str)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user