diff options
author | Abdelhakeem <abdelhakeem.osama@hotmail.com> | 2019-07-21 21:41:04 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-07-27 22:14:58 +0200 |
commit | b6278bbf12dd4946095b76f47b7c2ace3f929245 (patch) | |
tree | 37d30921c145e9266535441b7e51959ddbc7b8b2 /src/nvim/eval.c | |
parent | 691deca2e8449ec0c3b5081ed4fe6076fd820913 (diff) | |
download | rneovim-b6278bbf12dd4946095b76f47b7c2ace3f929245.tar.gz rneovim-b6278bbf12dd4946095b76f47b7c2ace3f929245.tar.bz2 rneovim-b6278bbf12dd4946095b76f47b7c2ace3f929245.zip |
API: Context: save/restore
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 33e3cd64f2..cd447d3e0f 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -8064,6 +8064,10 @@ static void f_ctxpush(typval_T *argvars, typval_T *rettv, FunPtr fptr) types |= kCtxBuflist; } else if (strequal((char *)tv_li->vval.v_string, "gvars")) { types |= kCtxGVars; + } else if (strequal((char *)tv_li->vval.v_string, "sfuncs")) { + types |= kCtxSFuncs; + } else if (strequal((char *)tv_li->vval.v_string, "funcs")) { + types |= kCtxFuncs; } } }); @@ -20981,7 +20985,7 @@ void ex_function(exarg_T *eap) continue; } if (!func_name_refcount(fp->uf_name)) { - list_func_head(fp, false); + list_func_head(fp, false, false); } } } @@ -21012,7 +21016,7 @@ void ex_function(exarg_T *eap) fp = HI2UF(hi); if (!isdigit(*fp->uf_name) && vim_regexec(®match, fp->uf_name, 0)) - list_func_head(fp, FALSE); + list_func_head(fp, false, false); } } vim_regfree(regmatch.regprog); @@ -21062,9 +21066,12 @@ void ex_function(exarg_T *eap) saved_did_emsg = did_emsg; did_emsg = FALSE; - /* - * ":function func" with only function name: list function. - */ + // + // ":function func" with only function name: list function. + // If bang is given: + // - include "!" in function head + // - exclude line numbers from function body + // if (!paren) { if (!ends_excmd(*skipwhite(p))) { EMSG(_(e_trailing)); @@ -21076,17 +21083,20 @@ void ex_function(exarg_T *eap) if (!eap->skip && !got_int) { fp = find_func(name); if (fp != NULL) { - list_func_head(fp, TRUE); - for (int j = 0; j < fp->uf_lines.ga_len && !got_int; ++j) { - if (FUNCLINE(fp, j) == NULL) + list_func_head(fp, !eap->forceit, eap->forceit); + for (int j = 0; j < fp->uf_lines.ga_len && !got_int; j++) { + if (FUNCLINE(fp, j) == NULL) { continue; - msg_putchar('\n'); - msg_outnum((long)j + 1); - if (j < 9) { - msg_putchar(' '); } - if (j < 99) { - msg_putchar(' '); + msg_putchar('\n'); + if (!eap->forceit) { + msg_outnum((long)j + 1); + if (j < 9) { + msg_putchar(' '); + } + if (j < 99) { + msg_putchar(' '); + } } msg_prt_line(FUNCLINE(fp, j), false); ui_flush(); // show a line at a time @@ -21094,7 +21104,7 @@ void ex_function(exarg_T *eap) } if (!got_int) { msg_putchar('\n'); - msg_puts(" endfunction"); + msg_puts(eap->forceit ? "endfunction" : " endfunction"); } } else emsg_funcname(N_("E123: Undefined function: %s"), name); @@ -21784,15 +21794,17 @@ static inline bool eval_fname_sid(const char *const name) return *name == 's' || TOUPPER_ASC(name[2]) == 'I'; } -/* - * List the head of the function: "name(arg1, arg2)". - */ -static void list_func_head(ufunc_T *fp, int indent) +/// List the head of the function: "name(arg1, arg2)". +/// +/// @param[in] fp Function pointer. +/// @param[in] indent Indent line. +/// @param[in] force Include bang "!" (i.e.: "function!"). +static void list_func_head(ufunc_T *fp, int indent, bool force) { msg_start(); if (indent) MSG_PUTS(" "); - MSG_PUTS("function "); + MSG_PUTS(force ? "function! " : "function "); if (fp->uf_name[0] == K_SPECIAL) { MSG_PUTS_ATTR("<SNR>", HL_ATTR(HLF_8)); msg_puts((const char *)fp->uf_name + 3); |