neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit c0f222d55b780831382a4034cec5c643d0504f58
parent 04274a417358a4eb9b3b3d1f7e1ea4a4b4419c5c
Author: bfredl <bjorn.linse@gmail.com>
Date:   Wed,  6 Nov 2024 10:19:28 +0100

Merge pull request #31062 from famiu/refactor/options/ff_macro

refactor(options): remove fileformat macros 
Diffstat:
Msrc/nvim/diff.c | 2+-
Msrc/nvim/option.c | 12++++++------
Msrc/nvim/option_vars.h | 15---------------
Msrc/nvim/options.lua | 8++++++--
Msrc/nvim/optionstr.c | 2+-
5 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/src/nvim/diff.c b/src/nvim/diff.c @@ -801,7 +801,7 @@ static int diff_write(buf_T *buf, diffin_T *din) // Always use 'fileformat' set to "unix". char *save_ff = buf->b_p_ff; - buf->b_p_ff = xstrdup(FF_UNIX); + buf->b_p_ff = xstrdup("unix"); const bool save_cmod_flags = cmdmod.cmod_flags; // Writing the buffer is an implementation detail of performing the diff, // so it shouldn't update the '[ and '] marks. diff --git a/src/nvim/option.c b/src/nvim/option.c @@ -5103,13 +5103,13 @@ void buf_copy_options(buf_T *buf, int flags) buf->b_p_fenc = xstrdup(p_fenc); switch (*p_ffs) { case 'm': - buf->b_p_ff = xstrdup(FF_MAC); + buf->b_p_ff = xstrdup("mac"); break; case 'd': - buf->b_p_ff = xstrdup(FF_DOS); + buf->b_p_ff = xstrdup("dos"); break; case 'u': - buf->b_p_ff = xstrdup(FF_UNIX); + buf->b_p_ff = xstrdup("unix"); break; default: buf->b_p_ff = xstrdup(p_ff); @@ -6238,13 +6238,13 @@ void set_fileformat(int eol_style, int opt_flags) switch (eol_style) { case EOL_UNIX: - p = FF_UNIX; + p = "unix"; break; case EOL_MAC: - p = FF_MAC; + p = "mac"; break; case EOL_DOS: - p = FF_DOS; + p = "dos"; break; } diff --git a/src/nvim/option_vars.h b/src/nvim/option_vars.h @@ -31,21 +31,6 @@ #define DFLT_GREPFORMAT "%f:%l:%m,%f:%l%m,%f %l%m" -// default values for b_p_ff 'fileformat' and p_ffs 'fileformats' -#define FF_DOS "dos" -#define FF_MAC "mac" -#define FF_UNIX "unix" - -#ifdef USE_CRNL -# define DFLT_FF "dos" -# define DFLT_FFS_VIM "dos,unix" -# define DFLT_FFS_VI "dos,unix" // also autodetect in compatible mode -#else -# define DFLT_FF "unix" -# define DFLT_FFS_VIM "unix,dos" -# define DFLT_FFS_VI "" -#endif - // Possible values for 'encoding' #define ENC_UCSBOM "ucs-bom" // check for BOM at start of file diff --git a/src/nvim/options.lua b/src/nvim/options.lua @@ -2684,7 +2684,9 @@ return { abbreviation = 'ff', cb = 'did_set_fileformat', defaults = { - if_true = macros('DFLT_FF', 'string'), + condition = 'USE_CRNL', + if_true = 'dos', + if_false = 'unix', doc = 'Windows: "dos", Unix: "unix"', }, desc = [=[ @@ -2717,7 +2719,9 @@ return { abbreviation = 'ffs', cb = 'did_set_fileformats', defaults = { - if_true = macros('DFLT_FFS_VIM', 'string'), + condition = 'USE_CRNL', + if_true = 'dos,unix', + if_false = 'unix,dos', doc = 'Windows: "dos,unix", Unix: "unix,dos"', }, deny_duplicates = true, diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c @@ -84,7 +84,7 @@ static char *(p_dip_values[]) = { "filler", "context:", "iblank", "icase", "indent-heuristic", "linematch:", "algorithm:", NULL }; static char *(p_dip_algorithm_values[]) = { "myers", "minimal", "patience", "histogram", NULL }; static char *(p_nf_values[]) = { "bin", "octal", "hex", "alpha", "unsigned", "blank", NULL }; -static char *(p_ff_values[]) = { FF_UNIX, FF_DOS, FF_MAC, NULL }; +static char *(p_ff_values[]) = { "unix", "dos", "mac", NULL }; static char *(p_cb_values[]) = { "unnamed", "unnamedplus", NULL }; static char *(p_cmp_values[]) = { "internal", "keepascii", NULL }; // Note: Keep this in sync with fill_culopt_flags()