Make the currently sourced file path available through $kak_source
The :source command sets an 'source' value to the real path of the file getting sourced while its commands are executed. Fixes #1112
This commit is contained in:
parent
d2199bc619
commit
f9f11aa762
|
@ -776,6 +776,7 @@ Some of Kakoune state is available through environment variables:
|
|||
* `kak_reg_<r>`: value of register <r>
|
||||
* `kak_session`: name of the current session
|
||||
* `kak_client`: name of current client
|
||||
* `kak_source`: path of the file currently getting executed (through the source command)
|
||||
* `kak_cursor_line`: line of the end of the main selection
|
||||
* `kak_cursor_column`: column of the end of the main selection (in byte)
|
||||
* `kak_cursor_char_column`: column of the end of the main selection (in character)
|
||||
|
|
|
@ -84,6 +84,9 @@ informations about Kakoune's state:
|
|||
name of the current session
|
||||
*kak_client*::
|
||||
name of current client
|
||||
*kak_source*::
|
||||
path of the file currently getting executed (through the source
|
||||
command)
|
||||
*kak_cursor_line*::
|
||||
line of the end of the main selection
|
||||
*kak_cursor_column*::
|
||||
|
|
|
@ -1180,10 +1180,12 @@ const CommandDesc source_cmd = {
|
|||
filename_completer,
|
||||
[](const ParametersParser& parser, Context& context, const ShellContext&)
|
||||
{
|
||||
String file_content = read_file(parse_filename(parser[0]), true);
|
||||
String path = real_path(parse_filename(parser[0]));
|
||||
String file_content = read_file(path, true);
|
||||
try
|
||||
{
|
||||
CommandManager::instance().execute(file_content, context);
|
||||
CommandManager::instance().execute(file_content, context,
|
||||
{{}, {{"source", path}}});
|
||||
}
|
||||
catch (Kakoune::runtime_error& err)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user