Remove %rec{...} strings, now "..." strings expand their content

This commit is contained in:
Maxime Coste 2014-11-11 13:53:57 +00:00
parent 414cfabb8c
commit e8b0a98a78
8 changed files with 19 additions and 17 deletions

View File

@ -474,8 +474,11 @@ if you want to give parameters with spaces, you should quote them.
Kakoune support three string syntax:
* +"strings" and \'strings\'+: classic strings, use \' or \" to escape the
separator.
* +\'strings\'+: uninterpreted strings, you can use \' to escape the separator,
every other char is itself.
* +"strings"+: expended strings, % strings (see %sh, %opt or %reg) contained
are expended. Use \% to escape a % inside them, and \\ to escape a slash.
* +%\{strings\}+: these strings are very useful when entering commands

View File

@ -55,7 +55,7 @@ def clang-complete %{
}
def clang-enable-autocomplete %{
set window completers %rec{option=clang_completions:%opt{completers}}
set window completers "option=clang_completions:%opt{completers}"
hook window -group clang-autocomplete InsertIdle .* %{ try %{
exec -draft <a-h><a-k>(\.|->|::).\'<ret>
echo 'completing...'

View File

@ -51,7 +51,7 @@ addhl -group /cpp/comment fill comment
addhl -group /cpp/disabled fill rgb:666666
addhl -group /cpp/macro fill meta
addhl -group /cpp/code regex "\<(this|true|false|NULL|nullptr|)\>|\<-?\d+[fdiu]?|'((\\.)?|[^'\\])'" 0:value
addhl -group /cpp/code regex %{\<(this|true|false|NULL|nullptr|)\>|\<-?\d+[fdiu]?|'((\\.)?|[^'\\])'} 0:value
addhl -group /cpp/code regex "\<(void|int|char|unsigned|float|bool|size_t)\>" 0:type
addhl -group /cpp/code regex "\<(while|for|if|else|do|switch|case|default|goto|break|continue|return|using|try|catch|throw|new|delete|and|or|not|operator|explicit|(?:reinterpret|const|static|dynamic)_cast)\>" 0:keyword
addhl -group /cpp/code regex "\<(const|constexpr|mutable|auto|namespace|inline|static|volatile|class|struct|enum|union|public|protected|private|template|typedef|virtual|friend|extern|typename|override|final)\>" 0:attribute

View File

@ -46,8 +46,8 @@ def funcinfo %{
}
def ctags-enable-autoinfo %{
hook window -group ctags-autoinfo NormalIdle .* funcinfo
hook window -group ctags-autoinfo InsertIdle .* funcinfo
hook window -group ctags-autoinfo NormalKey .* funcinfo
hook window -group ctags-autoinfo InsertKey .* funcinfo
}
def ctags-disable-autoinfo %{ rmhooks window ctags-autoinfo }

View File

@ -41,7 +41,7 @@ def jump %{
def next -docstring 'Jump to next grep match' %{
eval -try-client %opt{jumpclient} %{
buffer '*grep*'
exec %rec{%opt{_grep_current_line}ggl/^[^:]+:\d+:<ret>}
exec "%opt{_grep_current_line}ggl/^[^:]+:\d+:<ret>"
jump
}
}
@ -49,7 +49,7 @@ def next -docstring 'Jump to next grep match' %{
def prev -docstring 'Jump to previous grep match' %{
eval -try-client %opt{jumpclient} %{
buffer '*grep*'
exec %rec{%opt{_grep_current_line}g<a-/>^[^:]+:\d+:<ret>}
exec "%opt{_grep_current_line}g<a-/>^[^:]+:\d+:<ret>"
jump
}
}

View File

@ -34,7 +34,7 @@ def jedi-complete %{
}
def jedi-enable-autocomplete %{
set window completers %rec{option=jedi_completions:%opt{completers}}
set window completers "option=jedi_completions:%opt{completers}"
hook window -group jedi-autocomplete InsertIdle .* %{ try %{
exec -draft <a-h><a-k>\..\'<ret>
echo 'completing...'

View File

@ -33,12 +33,12 @@ def errjump -docstring 'Jump to error location' %{
exec gll<a-?> "Entering directory" <ret>
exec s "Entering directory '([^']+)'.*\n([^:]+):(\d+):(?:(\d+):)?([^\n]+)\'" <ret>l
set buffer _make_current_error_line %val{cursor_line}
eval -try-client %opt{jumpclient} %rec{edit -existing %reg{1}/%reg{2} %reg{3} %reg{4}; echo -color Information '%reg{5}'}
eval -try-client %opt{jumpclient} "edit -existing %reg{1}/%reg{2} %reg{3} %reg{4}; echo -color Information '%reg{5}'"
try %{ focus %opt{jumpclient} }
} catch %{
exec ghgl s "([^:]+):(\d+):(?:(\d+):)?([^\n]+)\'" <ret>l
set buffer _make_current_error_line %val{cursor_line}
eval -try-client %opt{jumpclient} %rec{edit -existing %reg{1} %reg{2} %reg{3}; echo -color Information '%reg{4}'}
eval -try-client %opt{jumpclient} "edit -existing %reg{1} %reg{2} %reg{3}; echo -color Information '%reg{4}'"
try %{ focus %opt{jumpclient} }
}
}
@ -46,7 +46,7 @@ def errjump -docstring 'Jump to error location' %{
def errnext -docstring 'Jump to next error' %{
eval -try-client %opt{jumpclient} %{
buffer '*make*'
exec %rec{%opt{_make_current_error_line}ggl/[0-9]+: (?:fatal )?error:<ret>}
exec "%opt{_make_current_error_line}ggl/[0-9]+: (?:fatal )?error:<ret>"
errjump
}
}
@ -54,7 +54,7 @@ def errnext -docstring 'Jump to next error' %{
def errprev -docstring 'Jump to previous error' %{
eval -try-client %opt{jumpclient} %{
buffer '*make*'
exec %rec{%opt{_make_current_error_line}ggh<a-/>[0-9]+: (?:fatal )?error:<ret>}
exec "%opt{_make_current_error_line}ggh<a-/>[0-9]+: (?:fatal )?error:<ret>"
errjump
}
}

View File

@ -139,8 +139,6 @@ Token::Type token_type(StringView type_name)
return Token::Type::OptionExpand;
else if (type_name == "val")
return Token::Type::ValExpand;
else if (type_name == "rec")
return Token::Type::RawEval;
else if (throw_on_invalid)
throw unknown_expand{type_name};
else
@ -239,8 +237,9 @@ TokenList parse(StringView line)
if (throw_on_unterminated and pos == length)
throw unterminated_string(String{delimiter},
String{delimiter});
result.emplace_back(Token::Type::Raw, token_start,
pos, std::move(token));
result.emplace_back(delimiter == '"' ? Token::Type::RawEval
: Token::Type::Raw,
token_start, pos, std::move(token));
}
else if (line[pos] == '%')
result.push_back(