mirror of
https://github.com/neovim/neovim.git
synced 2025-09-19 09:48:19 +00:00
ex_docmd: replace #define with enum
enum value can be inferred from previous member. Vim was doing this manually via relative #define. It's not needed but it is confusing for me to update an array index after the array value and to configure the array index such that it is dependent on other array indices. One missing #define and everything below breaks.
This commit is contained in:
@@ -8591,6 +8591,24 @@ static void ex_tag_cmd(exarg_T *eap, char_u *name)
|
|||||||
eap->forceit, TRUE);
|
eap->forceit, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SPEC_PERC = 0,
|
||||||
|
SPEC_HASH,
|
||||||
|
SPEC_CWORD,
|
||||||
|
SPEC_CCWORD,
|
||||||
|
SPEC_CEXPR,
|
||||||
|
SPEC_CFILE,
|
||||||
|
SPEC_SFILE,
|
||||||
|
SPEC_SLNUM,
|
||||||
|
SPEC_STACK,
|
||||||
|
SPEC_AFILE,
|
||||||
|
SPEC_ABUF,
|
||||||
|
SPEC_AMATCH,
|
||||||
|
SPEC_SFLNUM,
|
||||||
|
SPEC_SID,
|
||||||
|
// SPEC_CLIENT,
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check "str" for starting with a special cmdline variable.
|
* Check "str" for starting with a special cmdline variable.
|
||||||
* If found return one of the SPEC_ values and set "*usedlen" to the length of
|
* If found return one of the SPEC_ values and set "*usedlen" to the length of
|
||||||
@@ -8601,36 +8619,21 @@ ssize_t find_cmdline_var(const char_u *src, size_t *usedlen)
|
|||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
static char *(spec_str[]) = {
|
static char *(spec_str[]) = {
|
||||||
"%",
|
[SPEC_PERC] = "%",
|
||||||
#define SPEC_PERC 0
|
[SPEC_HASH] = "#",
|
||||||
"#",
|
[SPEC_CWORD] = "<cword>", // cursor word
|
||||||
#define SPEC_HASH (SPEC_PERC + 1)
|
[SPEC_CCWORD] = "<cWORD>", // cursor WORD
|
||||||
"<cword>", // cursor word
|
[SPEC_CEXPR] = "<cexpr>", // expr under cursor
|
||||||
#define SPEC_CWORD (SPEC_HASH + 1)
|
[SPEC_CFILE] = "<cfile>", // cursor path name
|
||||||
"<cWORD>", // cursor WORD
|
[SPEC_SFILE] = "<sfile>", // ":so" file name
|
||||||
#define SPEC_CCWORD (SPEC_CWORD + 1)
|
[SPEC_SLNUM] = "<slnum>", // ":so" file line number
|
||||||
"<cexpr>", // expr under cursor
|
[SPEC_STACK] = "<stack>", // call stack
|
||||||
#define SPEC_CEXPR (SPEC_CCWORD + 1)
|
[SPEC_AFILE] = "<afile>", // autocommand file name
|
||||||
"<cfile>", // cursor path name
|
[SPEC_ABUF] = "<abuf>", // autocommand buffer number
|
||||||
#define SPEC_CFILE (SPEC_CEXPR + 1)
|
[SPEC_AMATCH] = "<amatch>", // autocommand match name
|
||||||
"<sfile>", // ":so" file name
|
[SPEC_SFLNUM] = "<sflnum>", // script file line number
|
||||||
#define SPEC_SFILE (SPEC_CFILE + 1)
|
[SPEC_SID] = "<SID>", // script ID: <SNR>123_
|
||||||
"<slnum>", // ":so" file line number
|
// [SPEC_CLIENT] = "<client>",
|
||||||
#define SPEC_SLNUM (SPEC_SFILE + 1)
|
|
||||||
"<stack>", // call stack
|
|
||||||
#define SPEC_STACK (SPEC_SLNUM + 1)
|
|
||||||
"<afile>", // autocommand file name
|
|
||||||
#define SPEC_AFILE (SPEC_STACK + 1)
|
|
||||||
"<abuf>", // autocommand buffer number
|
|
||||||
#define SPEC_ABUF (SPEC_AFILE + 1)
|
|
||||||
"<amatch>", // autocommand match name
|
|
||||||
#define SPEC_AMATCH (SPEC_ABUF + 1)
|
|
||||||
"<sflnum>", // script file line number
|
|
||||||
#define SPEC_SFLNUM (SPEC_AMATCH + 1)
|
|
||||||
"<SID>", // script ID: <SNR>123_
|
|
||||||
#define SPEC_SID (SPEC_SFLNUM + 1)
|
|
||||||
"<client>"
|
|
||||||
#define SPEC_CLIENT (SPEC_SID + 1)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(spec_str); ++i) {
|
for (size_t i = 0; i < ARRAY_SIZE(spec_str); ++i) {
|
||||||
|
Reference in New Issue
Block a user