From 94f59fc9be03cf0ee3ac20f2715738f017439502 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Thu, 5 Jun 2014 08:25:53 -0300 Subject: api: Implement vim_command_output function This function can be used by API clients to execute a command and capture the output. --- src/nvim/api/vim.c | 13 +++++++++++++ src/nvim/eval.c | 3 ++- src/nvim/eval.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index c90e7039ce..9afefd6fa3 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -96,6 +96,19 @@ String vim_replace_termcodes(String str, Boolean from_part, Boolean do_lt, return cstr_as_string(ptr); } +String vim_command_output(String str, Error *err) +{ + do_cmdline_cmd((char_u *)"redir => v:command_output"); + vim_command(str, err); + do_cmdline_cmd((char_u *)"redir END"); + + if (err->set) { + return (String) STRING_INIT; + } + + return cstr_to_string((char *)get_vim_var_str(VV_COMMAND_OUTPUT)); +} + /// Evaluates the expression str using the vim internal expression /// evaluator (see |expression|). /// Dictionaries and lists are recursively expanded. diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 61606012ee..59fb82134d 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -424,7 +424,8 @@ static struct vimvar { {VV_NAME("oldfiles", VAR_LIST), 0}, {VV_NAME("windowid", VAR_NUMBER), VV_RO}, {VV_NAME("progpath", VAR_STRING), VV_RO}, - {VV_NAME("job_data", VAR_LIST), 0} + {VV_NAME("job_data", VAR_LIST), 0}, + {VV_NAME("command_output", VAR_STRING), 0} }; /* shorthand */ diff --git a/src/nvim/eval.h b/src/nvim/eval.h index 2f36a46f70..e96106dfb3 100644 --- a/src/nvim/eval.h +++ b/src/nvim/eval.h @@ -64,6 +64,7 @@ enum { VV_WINDOWID, VV_PROGPATH, VV_JOB_DATA, + VV_COMMAND_OUTPUT, VV_LEN, /* number of v: vars */ }; -- cgit From 250298884bb0c86847131cb872dcc9865115f8eb Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 27 Oct 2014 13:29:44 -0700 Subject: fix 'sign unplace id' Since the introduction of the FOR_ALL_BUFFERS macro, 'sign unplace id' without a buffer was only removing the sign from the first buffer rather than all buffers, as described in the documentation. :help sign-unplace -- modeline discussion: https://github.com/akkartik/neovim/commit/7863c247db#commitcomment-8342590 --- src/nvim/ex_cmds.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 5db950f120..f5fa16a139 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -5908,12 +5908,13 @@ void ex_sign(exarg_T *eap) arg = skipwhite(arg); if (idx == SIGNCMD_UNPLACE && *arg == NUL) { - /* ":sign unplace {id}": remove placed sign by number */ - FOR_ALL_BUFFERS(buf) { - if ((lnum = buf_delsign(buf, id)) != 0) - update_debug_sign(buf, lnum); - return; - } + // ":sign unplace {id}": remove placed sign by number + FOR_ALL_BUFFERS(buf) { + if ((lnum = buf_delsign(buf, id)) != 0) { + update_debug_sign(buf, lnum); + } + } + return; } } } @@ -5923,7 +5924,7 @@ void ex_sign(exarg_T *eap) * Leave "arg" pointing to {fname}. */ - buf_T *buf = NULL; + buf_T *buf = NULL; for (;;) { if (STRNCMP(arg, "line=", 5) == 0) @@ -6343,3 +6344,4 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg) } } +// vim: tabstop=8 -- cgit