aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-12-01 22:26:36 -0800
committerJustin M. Keyes <justinkz@gmail.com>2019-12-01 22:35:15 -0800
commitb1991f66d5845ccb72c73fdf39153a0e1fbb1124 (patch)
treedd62308f90e4282a46094493d5e167aab8526ff1 /src/nvim/api/vim.c
parentbd43e011b5b0feba644ec5feae6c174def31a9e4 (diff)
downloadrneovim-b1991f66d5845ccb72c73fdf39153a0e1fbb1124.tar.gz
rneovim-b1991f66d5845ccb72c73fdf39153a0e1fbb1124.tar.bz2
rneovim-b1991f66d5845ccb72c73fdf39153a0e1fbb1124.zip
API: rename nvim_source => nvim_exec
- Eliminate nvim_source_output(): add boolean `output` param to nvim_exec() instead.
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r--src/nvim/api/vim.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index bf722b4f4e..6763a3a936 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -73,28 +73,29 @@ void api_vim_free_all_mem(void)
map_free(String, handle_T)(namespace_ids);
}
-/// Executes a multiline block of ex-commands from a string.
+/// Executes Vimscript (multiline block of Ex-commands), like anonymous
+/// |:source|.
///
-/// On execution error: fails with VimL error, does not update v:errmsg.
-///
-/// @param src String containing the ex-commands
-/// @param[out] err Error details (Vim error), if any
-void nvim_source(String src, Error *err) FUNC_API_SINCE(7)
-{
- try_start();
- do_source_str(src.data, "nvim_source(..)");
- try_end(err);
-}
-
-/// Executes a multiline block of ex-commands from a string and returns its
-/// (non-error) output. Shell |:!| output is not captured.
+/// Optionally returns (non-error, non-shell |:!|) output.
///
/// On execution error: fails with VimL error, does not update v:errmsg.
///
-/// @param src String containing the ex-commands
+/// @see |execute()|
+/// @see |nvim_command()|
+///
+/// @param src Vimscript code
+/// @param output Capture and return all (non-error, non-shell |:!|) output
/// @param[out] err Error details (Vim error), if any
-String nvim_source_output(String src, Error *err) FUNC_API_SINCE(7)
+String nvim_exec(String src, Boolean output, Error *err)
+ FUNC_API_SINCE(7)
{
+ if (!output) {
+ try_start();
+ do_source_str(src.data, "nvim_exec()");
+ try_end(err);
+ return (String)STRING_INIT;
+ }
+
const int save_msg_silent = msg_silent;
garray_T *const save_capture_ga = capture_ga;
garray_T capture_local;
@@ -103,7 +104,7 @@ String nvim_source_output(String src, Error *err) FUNC_API_SINCE(7)
try_start();
msg_silent++;
capture_ga = &capture_local;
- do_source_str(src.data, "nvim_source_output(..)");
+ do_source_str(src.data, "nvim_exec()");
capture_ga = save_capture_ga;
msg_silent = save_msg_silent;
try_end(err);
@@ -134,6 +135,8 @@ theend:
///
/// On execution error: fails with VimL error, does not update v:errmsg.
///
+/// @see |nvim_exec()|
+///
/// @param command Ex-command string
/// @param[out] err Error details (Vim error), if any
void nvim_command(String command, Error *err)
@@ -436,7 +439,7 @@ theend:
return (String)STRING_INIT;
}
-/// Evaluates a VimL expression (:help expression).
+/// Evaluates a VimL |expression|.
/// Dictionaries and Lists are recursively expanded.
///
/// On execution error: fails with VimL error, does not update v:errmsg.