Mercurial > vim
diff src/evalfunc.c @ 14778:20653d6f3d95 v8.1.0401
patch 8.1.0401: can't get swap name of another buffer
commit https://github.com/vim/vim/commit/110bd60985c31e8978e9b071e2179f4233ef8557
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Sep 16 18:46:59 2018 +0200
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 https://github.com/vim/vim/issues/3441)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 16 Sep 2018 19:00:06 +0200 |
parents | a179e5cfcab7 |
children | 27b9a84395b5 |
line wrap: on
line diff
--- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -399,6 +399,7 @@ static void f_strwidth(typval_T *argvars static void f_submatch(typval_T *argvars, typval_T *rettv); static void f_substitute(typval_T *argvars, typval_T *rettv); static void f_swapinfo(typval_T *argvars, typval_T *rettv); +static void f_swapname(typval_T *argvars, typval_T *rettv); static void f_synID(typval_T *argvars, typval_T *rettv); static void f_synIDattr(typval_T *argvars, typval_T *rettv); static void f_synIDtrans(typval_T *argvars, typval_T *rettv); @@ -865,6 +866,7 @@ static struct fst {"submatch", 1, 2, f_submatch}, {"substitute", 4, 4, f_substitute}, {"swapinfo", 1, 1, f_swapinfo}, + {"swapname", 1, 1, f_swapname}, {"synID", 3, 3, f_synID}, {"synIDattr", 2, 3, f_synIDattr}, {"synIDtrans", 1, 1, f_synIDtrans}, @@ -12342,6 +12344,23 @@ f_swapinfo(typval_T *argvars, typval_T * } /* + * "swapname(expr)" function + */ + static void +f_swapname(typval_T *argvars, typval_T *rettv) +{ + buf_T *buf; + + rettv->v_type = VAR_STRING; + buf = get_buf_tv(&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