mirror of
https://github.com/neovim/neovim.git
synced 2025-10-17 15:21:47 +00:00
vim-patch:8.1.1610: there is no way to add or load a buffer without side effects
Problem: There is no way to add or load a buffer without side effects.
Solution: Add the bufadd() and bufload() functions.
15e248e37f
This commit is contained in:
@@ -7289,6 +7289,12 @@ static buf_T *find_buffer(typval_T *avar)
|
||||
return buf;
|
||||
}
|
||||
|
||||
// "bufadd(expr)" function
|
||||
static void f_bufadd(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
{
|
||||
rettv->vval.v_number = buflist_add(tv_get_string(&argvars[0]), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* "bufexists(expr)" function
|
||||
*/
|
||||
@@ -7308,6 +7314,21 @@ static void f_buflisted(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
rettv->vval.v_number = (buf != NULL && buf->b_p_bl);
|
||||
}
|
||||
|
||||
// "bufload(expr)" function
|
||||
static void f_bufload(typval_T *argvars, typval_T *rettv unused)
|
||||
{
|
||||
buf_T *buf = get_buf_arg(&argvars[0]);
|
||||
|
||||
if (buf != NULL && buf->b_ml.ml_mfp == NULL) {
|
||||
aco_save_T aco;
|
||||
|
||||
aucmd_prepbuf(&aco, buf);
|
||||
swap_exists_action = SEA_NONE;
|
||||
open_buffer(FALSE, NULL, 0);
|
||||
aucmd_restbuf(&aco);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* "bufloaded(expr)" function
|
||||
*/
|
||||
|
Reference in New Issue
Block a user