From 24c51694008351cf33604f5fa06ea49c0d106487 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Wed, 3 Jun 2020 15:17:32 +0300 Subject: [PATCH] src: Introduce a named key Similarly to the key, make it easier to write `:execute-keys` commands by replacing 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. --- doc/pages/keys.asciidoc | 2 +- rc/detection/modeline.kak | 2 +- rc/tools/doc.kak | 12 ++++++------ src/keys.cc | 1 + 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/pages/keys.asciidoc b/doc/pages/keys.asciidoc index 759763b6..e1531e68 100644 --- a/doc/pages/keys.asciidoc +++ b/doc/pages/keys.asciidoc @@ -170,7 +170,7 @@ the Shift modifier and moving will extend each selection instead. trim selections to only contain full lines (not including last end-of-line) -*%*:: +*%*, **:: select whole buffer **:: diff --git a/rc/detection/modeline.kak b/rc/detection/modeline.kak index b9e4bb70..3784a081 100644 --- a/rc/detection/modeline.kak +++ b/rc/detection/modeline.kak @@ -96,7 +96,7 @@ define-command -hidden modeline-parse-impl %{ # [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" %{ try %{ evaluate-commands -draft %{ - execute-keys \%s\A|.\z %opt{modelines}k %opt{modelines}X \ + execute-keys s\A|.\z %opt{modelines}k %opt{modelines}X \ s^\S*?\s+?(vim?|kak(oune)?):\s?[^\n]+ evaluate-commands -draft -itersel modeline-parse-impl } } diff --git a/rc/tools/doc.kak b/rc/tools/doc.kak index de799cdc..0fa7ad32 100644 --- a/rc/tools/doc.kak +++ b/rc/tools/doc.kak @@ -8,7 +8,7 @@ declare-option -hidden range-specs doc_anchors define-command -hidden -params 4 doc-render-regex %{ evaluate-commands -draft %{ try %{ - execute-keys \%s %arg{1} + execute-keys s %arg{1} execute-keys -draft s %arg{2} d execute-keys "%arg{3}" evaluate-commands %sh{ @@ -23,7 +23,7 @@ define-command -hidden -params 4 doc-render-regex %{ define-command -hidden doc-parse-links %{ evaluate-commands -draft %{ try %{ - execute-keys \%s (.*?),.*? + execute-keys s (.*?),.*? execute-keys -draft s .*,| d execute-keys H set-option buffer doc_links %val{timestamp} @@ -39,13 +39,13 @@ define-command -hidden doc-parse-anchors %{ evaluate-commands -draft %{ try %{ set-option buffer doc_anchors %val{timestamp} # Find sections as add them as imlicit anchors - execute-keys \%s ^={2,}\h+([^\n]+)$ + execute-keys s ^={2,}\h+([^\n]+)$ evaluate-commands -itersel %{ 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 - execute-keys \%s \[\[(.*?)\]\]\s* + execute-keys s \[\[(.*?)\]\]\s* evaluate-commands -itersel %{ 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 - try %{ execute-keys -draft \%s \h*(\+|:{2,})$ d } + try %{ execute-keys -draft s \h*(\+|:{2,})$ d } # Setup the doc_render_ranges option set-option buffer doc_render_ranges %val{timestamp} @@ -124,7 +124,7 @@ define-command -params 1 -hidden doc-render %{ doc-parse-links # Remove escaping of * and ` - try %{ execute-keys -draft \%s \\((?=\*)|(?=`)) d } + try %{ execute-keys -draft s \\((?=\*)|(?=`)) d } set-option buffer readonly true add-highlighter buffer/ ranges doc_render_ranges diff --git a/src/keys.cc b/src/keys.cc index 04932832..90cb0310 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -79,6 +79,7 @@ static constexpr KeyAndName keynamemap[] = { { "plus", '+' }, { "minus", '-' }, { "semicolon", ';' }, + { "percent", '%' }, }; KeyList parse_keys(StringView str)