mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-28 01:00:28 +03:00
Extend source
command to support parameters.
Parameters are accessible in %arg{n}, as with define-command.
This commit is contained in:
parent
373858f9bf
commit
5238c2d93d
@ -67,8 +67,9 @@ command *q!* has to be used). Aliases are mentionned below each commands.
|
||||
*rename-buffer* <name>::
|
||||
set current buffer name
|
||||
|
||||
*source* <filename>::
|
||||
*source* <filename> <param>...::
|
||||
execute commands in <filename>
|
||||
parameters are avilable in the sourced script through the `arg` values
|
||||
|
||||
== Clients and Sessions
|
||||
|
||||
|
@ -1284,8 +1284,8 @@ const CommandDesc debug_cmd = {
|
||||
const CommandDesc source_cmd = {
|
||||
"source",
|
||||
nullptr,
|
||||
"source <filename>: execute commands contained in <filename>",
|
||||
single_param,
|
||||
"source <filename> <params>...: execute commands contained in <filename>",
|
||||
ParameterDesc{ {}, ParameterDesc::Flags::None, 1, (size_t)-1 },
|
||||
CommandFlags::None,
|
||||
CommandHelper{},
|
||||
filename_completer,
|
||||
@ -1299,8 +1299,9 @@ const CommandDesc source_cmd = {
|
||||
MappedFile file_content{path};
|
||||
try
|
||||
{
|
||||
auto params = parser | skip(1) | gather<Vector<String>>();
|
||||
CommandManager::instance().execute(file_content, context,
|
||||
{{}, {{"source", path}}});
|
||||
{params, {{"source", path}}});
|
||||
}
|
||||
catch (Kakoune::runtime_error& err)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user