mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 9.0.0568: autocmd code is indented more than needed
Problem: Autocmd code is indented more than needed. Solution: Break out sooner. (Yegappan Lakshmanan, closes #11208) Also in user function code.
This commit is contained in:
committed by
Bram Moolenaar
parent
87af60c915
commit
e9dcf13a30
@@ -320,8 +320,9 @@ show_autocmd(AutoPat *ap, event_T event)
|
|||||||
|
|
||||||
for (ac = ap->cmds; ac != NULL; ac = ac->next)
|
for (ac = ap->cmds; ac != NULL; ac = ac->next)
|
||||||
{
|
{
|
||||||
if (ac->cmd != NULL) // skip removed commands
|
if (ac->cmd == NULL) // skip removed commands
|
||||||
{
|
continue;
|
||||||
|
|
||||||
if (msg_col >= 14)
|
if (msg_col >= 14)
|
||||||
msg_putchar('\n');
|
msg_putchar('\n');
|
||||||
msg_col = 14;
|
msg_col = 14;
|
||||||
@@ -341,7 +342,6 @@ show_autocmd(AutoPat *ap, event_T event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -492,9 +492,10 @@ au_new_group(char_u *name)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = au_find_group(name);
|
i = au_find_group(name);
|
||||||
if (i == AUGROUP_ERROR) // the group doesn't exist yet, add it
|
if (i != AUGROUP_ERROR)
|
||||||
{
|
return i;
|
||||||
// First try using a free entry.
|
|
||||||
|
// the group doesn't exist yet, add it. First try using a free entry.
|
||||||
for (i = 0; i < augroups.ga_len; ++i)
|
for (i = 0; i < augroups.ga_len; ++i)
|
||||||
if (AUGROUP_NAME(i) == NULL)
|
if (AUGROUP_NAME(i) == NULL)
|
||||||
break;
|
break;
|
||||||
@@ -506,7 +507,6 @@ au_new_group(char_u *name)
|
|||||||
return AUGROUP_ERROR;
|
return AUGROUP_ERROR;
|
||||||
if (i == augroups.ga_len)
|
if (i == augroups.ga_len)
|
||||||
++augroups.ga_len;
|
++augroups.ga_len;
|
||||||
}
|
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -515,18 +515,23 @@ au_new_group(char_u *name)
|
|||||||
au_del_group(char_u *name)
|
au_del_group(char_u *name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = au_find_group(name);
|
|
||||||
if (i == AUGROUP_ERROR) // the group doesn't exist
|
|
||||||
semsg(_(e_no_such_group_str), name);
|
|
||||||
else if (i == current_augroup)
|
|
||||||
emsg(_(e_cannot_delete_current_group));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
event_T event;
|
event_T event;
|
||||||
AutoPat *ap;
|
AutoPat *ap;
|
||||||
int in_use = FALSE;
|
int in_use = FALSE;
|
||||||
|
|
||||||
|
|
||||||
|
i = au_find_group(name);
|
||||||
|
if (i == AUGROUP_ERROR) // the group doesn't exist
|
||||||
|
{
|
||||||
|
semsg(_(e_no_such_group_str), name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (i == current_augroup)
|
||||||
|
{
|
||||||
|
emsg(_(e_cannot_delete_current_group));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (event = (event_T)0; (int)event < NUM_EVENTS;
|
for (event = (event_T)0; (int)event < NUM_EVENTS;
|
||||||
event = (event_T)((int)event + 1))
|
event = (event_T)((int)event + 1))
|
||||||
{
|
{
|
||||||
@@ -544,7 +549,6 @@ au_del_group(char_u *name)
|
|||||||
AUGROUP_NAME(i) = get_deleted_augroup();
|
AUGROUP_NAME(i) = get_deleted_augroup();
|
||||||
else
|
else
|
||||||
AUGROUP_NAME(i) = NULL;
|
AUGROUP_NAME(i) = NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -768,11 +772,16 @@ au_event_disable(char *what)
|
|||||||
char_u *save_ei;
|
char_u *save_ei;
|
||||||
|
|
||||||
save_ei = vim_strsave(p_ei);
|
save_ei = vim_strsave(p_ei);
|
||||||
if (save_ei != NULL)
|
if (save_ei == NULL)
|
||||||
{
|
return NULL;
|
||||||
|
|
||||||
new_ei = vim_strnsave(p_ei, STRLEN(p_ei) + STRLEN(what));
|
new_ei = vim_strnsave(p_ei, STRLEN(p_ei) + STRLEN(what));
|
||||||
if (new_ei != NULL)
|
if (new_ei == NULL)
|
||||||
{
|
{
|
||||||
|
vim_free(save_ei);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (*what == ',' && *p_ei == NUL)
|
if (*what == ',' && *p_ei == NUL)
|
||||||
STRCPY(new_ei, what + 1);
|
STRCPY(new_ei, what + 1);
|
||||||
else
|
else
|
||||||
@@ -780,8 +789,6 @@ au_event_disable(char *what)
|
|||||||
set_string_option_direct((char_u *)"ei", -1, new_ei,
|
set_string_option_direct((char_u *)"ei", -1, new_ei,
|
||||||
OPT_FREE, SID_NONE);
|
OPT_FREE, SID_NONE);
|
||||||
vim_free(new_ei);
|
vim_free(new_ei);
|
||||||
}
|
|
||||||
}
|
|
||||||
return save_ei;
|
return save_ei;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -908,8 +915,9 @@ do_autocmd(exarg_T *eap, char_u *arg_in, int forceit)
|
|||||||
cmd = skipwhite(cmd);
|
cmd = skipwhite(cmd);
|
||||||
for (i = 0; i < 2; i++)
|
for (i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
if (*cmd != NUL)
|
if (*cmd == NUL)
|
||||||
{
|
continue;
|
||||||
|
|
||||||
// Check for "++once" flag.
|
// Check for "++once" flag.
|
||||||
if (STRNCMP(cmd, "++once", 6) == 0 && VIM_ISWHITE(cmd[6]))
|
if (STRNCMP(cmd, "++once", 6) == 0 && VIM_ISWHITE(cmd[6]))
|
||||||
{
|
{
|
||||||
@@ -951,7 +959,6 @@ do_autocmd(exarg_T *eap, char_u *arg_in, int forceit)
|
|||||||
cmd = skipwhite(cmd + 6);
|
cmd = skipwhite(cmd + 6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the start of the commands.
|
* Find the start of the commands.
|
||||||
@@ -1407,8 +1414,9 @@ ex_doautoall(exarg_T *eap)
|
|||||||
FOR_ALL_BUFFERS(buf)
|
FOR_ALL_BUFFERS(buf)
|
||||||
{
|
{
|
||||||
// Only do loaded buffers and skip the current buffer, it's done last.
|
// Only do loaded buffers and skip the current buffer, it's done last.
|
||||||
if (buf->b_ml.ml_mfp != NULL && buf != curbuf)
|
if (buf->b_ml.ml_mfp == NULL || buf == curbuf)
|
||||||
{
|
continue;
|
||||||
|
|
||||||
// find a window for this buffer and save some values
|
// find a window for this buffer and save some values
|
||||||
aucmd_prepbuf(&aco, buf);
|
aucmd_prepbuf(&aco, buf);
|
||||||
set_bufref(&bufref, buf);
|
set_bufref(&bufref, buf);
|
||||||
@@ -1432,7 +1440,6 @@ ex_doautoall(exarg_T *eap)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Execute autocommands for the current buffer last.
|
// Execute autocommands for the current buffer last.
|
||||||
if (retval == OK)
|
if (retval == OK)
|
||||||
|
@@ -1881,7 +1881,7 @@ eval_fname_sid(char_u *p)
|
|||||||
* In a script change <SID>name() and s:name() to K_SNR 123_name().
|
* In a script change <SID>name() and s:name() to K_SNR 123_name().
|
||||||
* Change <SNR>123_name() to K_SNR 123_name().
|
* Change <SNR>123_name() to K_SNR 123_name().
|
||||||
* Use "fname_buf[FLEN_FIXED + 1]" when it fits, otherwise allocate memory
|
* Use "fname_buf[FLEN_FIXED + 1]" when it fits, otherwise allocate memory
|
||||||
* (slow).
|
* and set "tofree".
|
||||||
*/
|
*/
|
||||||
char_u *
|
char_u *
|
||||||
fname_trans_sid(char_u *name, char_u *fname_buf, char_u **tofree, int *error)
|
fname_trans_sid(char_u *name, char_u *fname_buf, char_u **tofree, int *error)
|
||||||
@@ -1891,8 +1891,9 @@ fname_trans_sid(char_u *name, char_u *fname_buf, char_u **tofree, int *error)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
llen = eval_fname_script(name);
|
llen = eval_fname_script(name);
|
||||||
if (llen > 0)
|
if (llen == 0)
|
||||||
{
|
return name; // no prefix
|
||||||
|
|
||||||
fname_buf[0] = K_SPECIAL;
|
fname_buf[0] = K_SPECIAL;
|
||||||
fname_buf[1] = KS_EXTRA;
|
fname_buf[1] = KS_EXTRA;
|
||||||
fname_buf[2] = (int)KE_SNR;
|
fname_buf[2] = (int)KE_SNR;
|
||||||
@@ -1925,9 +1926,6 @@ fname_trans_sid(char_u *name, char_u *fname_buf, char_u **tofree, int *error)
|
|||||||
STRCPY(fname + i, name + llen);
|
STRCPY(fname + i, name + llen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
fname = name;
|
|
||||||
return fname;
|
return fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -699,6 +699,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
568,
|
||||||
/**/
|
/**/
|
||||||
567,
|
567,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user