mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
refactor(optionstr.c): break up did_set_string_option 26
This commit is contained in:
@@ -2258,14 +2258,14 @@ static void copy_global_to_buflocal_cb(Callback *globcb, Callback *bufcb)
|
||||
/// Invoked when the 'completefunc' option is set. The option value can be a
|
||||
/// name of a function (string), or function(<name>) or funcref(<name>) or a
|
||||
/// lambda expression.
|
||||
int set_completefunc_option(void)
|
||||
void set_completefunc_option(char **errmsg)
|
||||
{
|
||||
int retval = option_set_callback_func(curbuf->b_p_cfu, &cfu_cb);
|
||||
if (retval == OK) {
|
||||
set_buflocal_cfu_callback(curbuf);
|
||||
if (option_set_callback_func(curbuf->b_p_cfu, &cfu_cb) == FAIL) {
|
||||
*errmsg = e_invarg;
|
||||
return;
|
||||
}
|
||||
|
||||
return retval;
|
||||
set_buflocal_cfu_callback(curbuf);
|
||||
}
|
||||
|
||||
/// Copy the global 'completefunc' callback function to the buffer-local
|
||||
@@ -2279,14 +2279,13 @@ void set_buflocal_cfu_callback(buf_T *buf)
|
||||
/// Invoked when the 'omnifunc' option is set. The option value can be a
|
||||
/// name of a function (string), or function(<name>) or funcref(<name>) or a
|
||||
/// lambda expression.
|
||||
int set_omnifunc_option(void)
|
||||
void set_omnifunc_option(buf_T *buf, char **errmsg)
|
||||
{
|
||||
int retval = option_set_callback_func(curbuf->b_p_ofu, &ofu_cb);
|
||||
if (retval == OK) {
|
||||
set_buflocal_ofu_callback(curbuf);
|
||||
if (option_set_callback_func(buf->b_p_ofu, &ofu_cb) == FAIL) {
|
||||
*errmsg = e_invarg;
|
||||
return;
|
||||
}
|
||||
|
||||
return retval;
|
||||
set_buflocal_ofu_callback(buf);
|
||||
}
|
||||
|
||||
/// Copy the global 'omnifunc' callback function to the buffer-local 'omnifunc'
|
||||
@@ -2300,7 +2299,7 @@ void set_buflocal_ofu_callback(buf_T *buf)
|
||||
/// Invoked when the 'thesaurusfunc' option is set. The option value can be a
|
||||
/// name of a function (string), or function(<name>) or funcref(<name>) or a
|
||||
/// lambda expression.
|
||||
int set_thesaurusfunc_option(void)
|
||||
void set_thesaurusfunc_option(char **errmsg)
|
||||
{
|
||||
int retval;
|
||||
|
||||
@@ -2312,7 +2311,9 @@ int set_thesaurusfunc_option(void)
|
||||
retval = option_set_callback_func(p_tsrfu, &tsrfu_cb);
|
||||
}
|
||||
|
||||
return retval;
|
||||
if (retval == FAIL) {
|
||||
*errmsg = e_invarg;
|
||||
}
|
||||
}
|
||||
|
||||
/// Mark the global 'completefunc' 'omnifunc' and 'thesaurusfunc' callbacks with
|
||||
|
@@ -5626,10 +5626,11 @@ static void op_colon(oparg_T *oap)
|
||||
static Callback opfunc_cb;
|
||||
|
||||
/// Process the 'operatorfunc' option value.
|
||||
/// @return OK or FAIL
|
||||
int set_operatorfunc_option(void)
|
||||
void set_operatorfunc_option(char **errmsg)
|
||||
{
|
||||
return option_set_callback_func(p_opfunc, &opfunc_cb);
|
||||
if (option_set_callback_func(p_opfunc, &opfunc_cb) == FAIL) {
|
||||
*errmsg = e_invarg;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(EXITFREE)
|
||||
|
@@ -1728,29 +1728,17 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf
|
||||
|| varp == &p_pex) { // '*expr' options
|
||||
did_set_optexpr(curbuf, curwin, varp, gvarp);
|
||||
} else if (gvarp == &p_cfu) { // 'completefunc'
|
||||
if (set_completefunc_option() == FAIL) {
|
||||
errmsg = e_invarg;
|
||||
}
|
||||
set_completefunc_option(&errmsg);
|
||||
} else if (gvarp == &p_ofu) { // 'omnifunc'
|
||||
if (set_omnifunc_option() == FAIL) {
|
||||
errmsg = e_invarg;
|
||||
}
|
||||
set_omnifunc_option(curbuf, &errmsg);
|
||||
} else if (gvarp == &p_tsrfu) { // 'thesaurusfunc'
|
||||
if (set_thesaurusfunc_option() == FAIL) {
|
||||
errmsg = e_invarg;
|
||||
}
|
||||
set_thesaurusfunc_option(&errmsg);
|
||||
} else if (varp == &p_opfunc) { // 'operatorfunc'
|
||||
if (set_operatorfunc_option() == FAIL) {
|
||||
errmsg = e_invarg;
|
||||
}
|
||||
set_operatorfunc_option(&errmsg);
|
||||
} else if (varp == &p_qftf) { // 'quickfixtextfunc'
|
||||
if (qf_process_qftf_option() == FAIL) {
|
||||
errmsg = e_invarg;
|
||||
}
|
||||
qf_process_qftf_option(&errmsg);
|
||||
} else if (gvarp == &p_tfu) { // 'tagfunc'
|
||||
if (set_tagfunc_option() == FAIL) {
|
||||
errmsg = e_invarg;
|
||||
}
|
||||
set_tagfunc_option(&errmsg);
|
||||
} else {
|
||||
did_set_option_listflags(curbuf, curwin, varp, errbuf, errbuflen, &errmsg);
|
||||
}
|
||||
|
@@ -3854,10 +3854,11 @@ static buf_T *qf_find_buf(qf_info_T *qi)
|
||||
}
|
||||
|
||||
/// Process the 'quickfixtextfunc' option value.
|
||||
/// @return OK or FAIL
|
||||
int qf_process_qftf_option(void)
|
||||
void qf_process_qftf_option(char **errmsg)
|
||||
{
|
||||
return option_set_callback_func(p_qftf, &qftf_cb);
|
||||
if (option_set_callback_func(p_qftf, &qftf_cb) == FAIL) {
|
||||
*errmsg = e_invarg;
|
||||
}
|
||||
}
|
||||
|
||||
/// Update the w:quickfix_title variable in the quickfix/location list window in
|
||||
|
@@ -210,22 +210,20 @@ static Callback tfu_cb; // 'tagfunc' callback function
|
||||
/// Reads the 'tagfunc' option value and convert that to a callback value.
|
||||
/// Invoked when the 'tagfunc' option is set. The option value can be a name of
|
||||
/// a function (string), or function(<name>) or funcref(<name>) or a lambda.
|
||||
int set_tagfunc_option(void)
|
||||
void set_tagfunc_option(char **errmsg)
|
||||
{
|
||||
callback_free(&tfu_cb);
|
||||
callback_free(&curbuf->b_tfu_cb);
|
||||
|
||||
if (*curbuf->b_p_tfu == NUL) {
|
||||
return OK;
|
||||
return;
|
||||
}
|
||||
|
||||
if (option_set_callback_func(curbuf->b_p_tfu, &tfu_cb) == FAIL) {
|
||||
return FAIL;
|
||||
*errmsg = e_invarg;
|
||||
}
|
||||
|
||||
callback_copy(&curbuf->b_tfu_cb, &tfu_cb);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
#if defined(EXITFREE)
|
||||
|
Reference in New Issue
Block a user