vim-patch:8.1.0401: can't get swap name of another buffer

Problem:    Can't get swap name of another buffer.
Solution:   Add swapname(). (Ozaki Kiichi, closes vim/vim#3441)
110bd60985
This commit is contained in:
Justin M. Keyes
2019-04-29 19:39:18 +02:00
parent 035a41c218
commit 04f0bc97b7
4 changed files with 52 additions and 4 deletions

View File

@@ -16430,6 +16430,20 @@ static void f_swapinfo(typval_T *argvars, typval_T *rettv, FunPtr fptr)
get_b0_dict(tv_get_string(argvars), rettv->vval.v_dict);
}
/// "swapname(expr)" function
static void f_swapname(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
rettv->v_type = VAR_STRING;
buf_T *buf = tv_get_buf(&argvars[0], false);
if (buf == NULL
|| buf->b_ml.ml_mfp == NULL
|| buf->b_ml.ml_mfp->mf_fname == NULL) {
rettv->vval.v_string = NULL;
} else {
rettv->vval.v_string = vim_strsave(buf->b_ml.ml_mfp->mf_fname);
}
}
/// "synID(lnum, col, trans)" function
static void f_synID(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{