275 lines
8.6 KiB
Diff
275 lines
8.6 KiB
Diff
From 6b915c0c0ee7ef82f8d3d310a4345e098cb929b0 Mon Sep 17 00:00:00 2001
|
|
From: Bram Moolenaar <Bram@vim.org>
|
|
Date: Sat, 18 Jan 2020 15:53:19 +0100
|
|
Subject: [PATCH] patch 8.2.0128: cannot list options one per line
|
|
|
|
Problem: Cannot list options one per line.
|
|
Solution: Use ":set!" to list one option per line.
|
|
---
|
|
runtime/doc/options.txt | 12 ++++++++----
|
|
src/ex_cmds.h | 6 +++---
|
|
src/ex_docmd.c | 18 ------------------
|
|
src/option.c | 34 +++++++++++++++++++++++++++++-----
|
|
src/optiondefs.h | 2 +-
|
|
src/proto/option.pro | 1 +
|
|
src/testdir/test_options.vim | 9 ++++++++-
|
|
src/vim.h | 13 +++++++------
|
|
8 files changed, 57 insertions(+), 38 deletions(-)
|
|
|
|
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
|
|
index 2fced50..8f11253 100644
|
|
--- a/runtime/doc/options.txt
|
|
+++ b/runtime/doc/options.txt
|
|
@@ -22,9 +22,13 @@ achieve special effects. These options come in three forms:
|
|
1. Setting options *set-option* *E764*
|
|
|
|
*:se* *:set*
|
|
-:se[t] Show all options that differ from their default value.
|
|
+:se[t][!] Show all options that differ from their default value.
|
|
+ When [!] is present every option is on a separate
|
|
+ line.
|
|
|
|
-:se[t] all Show all but terminal options.
|
|
+:se[t][!] all Show all but terminal options.
|
|
+ When [!] is present every option is on a separate
|
|
+ line.
|
|
|
|
:se[t] termcap Show all terminal options. Note that in the GUI the
|
|
key codes are not shown, because they are generated
|
|
@@ -287,7 +291,7 @@ happens when the buffer is not loaded, but they are lost when the buffer is
|
|
wiped out |:bwipe|.
|
|
|
|
*:setl* *:setlocal*
|
|
-:setl[ocal] ... Like ":set" but set only the value local to the
|
|
+:setl[ocal][!] ... Like ":set" but set only the value local to the
|
|
current buffer or window. Not all options have a
|
|
local value. If the option does not have a local
|
|
value the global value is set.
|
|
@@ -309,7 +313,7 @@ wiped out |:bwipe|.
|
|
{option}, so that the global value will be used.
|
|
|
|
*:setg* *:setglobal*
|
|
-:setg[lobal] ... Like ":set" but set only the global value for a local
|
|
+:setg[lobal][!] ... Like ":set" but set only the global value for a local
|
|
option without changing the local value.
|
|
When displaying an option, the global value is shown.
|
|
With the "all" argument: display global values for all
|
|
diff --git a/src/ex_cmds.h b/src/ex_cmds.h
|
|
index 28ea6ee..605766a 100644
|
|
--- a/src/ex_cmds.h
|
|
+++ b/src/ex_cmds.h
|
|
@@ -1307,16 +1307,16 @@ EXCMD(CMD_scscope, "scscope", ex_scscope,
|
|
EX_EXTRA|EX_NOTRLCOM,
|
|
ADDR_NONE),
|
|
EXCMD(CMD_set, "set", ex_set,
|
|
- EX_TRLBAR|EX_EXTRA|EX_CMDWIN|EX_SBOXOK,
|
|
+ EX_BANG|EX_TRLBAR|EX_EXTRA|EX_CMDWIN|EX_SBOXOK,
|
|
ADDR_NONE),
|
|
EXCMD(CMD_setfiletype, "setfiletype", ex_setfiletype,
|
|
EX_TRLBAR|EX_EXTRA|EX_NEEDARG|EX_CMDWIN,
|
|
ADDR_NONE),
|
|
EXCMD(CMD_setglobal, "setglobal", ex_set,
|
|
- EX_TRLBAR|EX_EXTRA|EX_CMDWIN|EX_SBOXOK,
|
|
+ EX_BANG|EX_TRLBAR|EX_EXTRA|EX_CMDWIN|EX_SBOXOK,
|
|
ADDR_NONE),
|
|
EXCMD(CMD_setlocal, "setlocal", ex_set,
|
|
- EX_TRLBAR|EX_EXTRA|EX_CMDWIN|EX_SBOXOK,
|
|
+ EX_BANG|EX_TRLBAR|EX_EXTRA|EX_CMDWIN|EX_SBOXOK,
|
|
ADDR_NONE),
|
|
EXCMD(CMD_sfind, "sfind", ex_splitview,
|
|
EX_BANG|EX_FILE1|EX_RANGE|EX_CMDARG|EX_ARGOPT|EX_TRLBAR|EX_NEEDARG,
|
|
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
|
|
index b552440..1644573 100644
|
|
--- a/src/ex_docmd.c
|
|
+++ b/src/ex_docmd.c
|
|
@@ -320,7 +320,6 @@ static void ex_setfiletype(exarg_T *eap);
|
|
# define ex_diffupdate ex_ni
|
|
#endif
|
|
static void ex_digraphs(exarg_T *eap);
|
|
-static void ex_set(exarg_T *eap);
|
|
#ifdef FEAT_SEARCH_EXTRA
|
|
static void ex_nohlsearch(exarg_T *eap);
|
|
#else
|
|
@@ -8499,23 +8498,6 @@ ex_digraphs(exarg_T *eap UNUSED)
|
|
#endif
|
|
}
|
|
|
|
- static void
|
|
-ex_set(exarg_T *eap)
|
|
-{
|
|
- int flags = 0;
|
|
-
|
|
- if (eap->cmdidx == CMD_setlocal)
|
|
- flags = OPT_LOCAL;
|
|
- else if (eap->cmdidx == CMD_setglobal)
|
|
- flags = OPT_GLOBAL;
|
|
-#if defined(FEAT_EVAL) && defined(FEAT_BROWSE)
|
|
- if (cmdmod.browse && flags == 0)
|
|
- ex_options(eap);
|
|
- else
|
|
-#endif
|
|
- (void)do_set(eap->arg, flags);
|
|
-}
|
|
-
|
|
#if defined(FEAT_SEARCH_EXTRA) || defined(PROTO)
|
|
void
|
|
set_no_hlsearch(int flag)
|
|
diff --git a/src/option.c b/src/option.c
|
|
index 382b01b..eb610dd 100644
|
|
--- a/src/option.c
|
|
+++ b/src/option.c
|
|
@@ -1066,6 +1066,27 @@ set_title_defaults(void)
|
|
}
|
|
#endif
|
|
|
|
+ void
|
|
+ex_set(exarg_T *eap)
|
|
+{
|
|
+ int flags = 0;
|
|
+
|
|
+ if (eap->cmdidx == CMD_setlocal)
|
|
+ flags = OPT_LOCAL;
|
|
+ else if (eap->cmdidx == CMD_setglobal)
|
|
+ flags = OPT_GLOBAL;
|
|
+#if defined(FEAT_EVAL) && defined(FEAT_BROWSE)
|
|
+ if (cmdmod.browse && flags == 0)
|
|
+ ex_options(eap);
|
|
+ else
|
|
+#endif
|
|
+ {
|
|
+ if (eap->forceit)
|
|
+ flags |= OPT_ONECOLUMN;
|
|
+ (void)do_set(eap->arg, flags);
|
|
+ }
|
|
+}
|
|
+
|
|
/*
|
|
* Parse 'arg' for option settings.
|
|
*
|
|
@@ -4354,7 +4375,7 @@ showoptions(
|
|
#define INC 20
|
|
#define GAP 3
|
|
|
|
- items = ALLOC_MULT(struct vimoption *, PARAM_COUNT);
|
|
+ items = ALLOC_MULT(struct vimoption *, OPTION_COUNT);
|
|
if (items == NULL)
|
|
return;
|
|
|
|
@@ -4369,9 +4390,10 @@ showoptions(
|
|
msg_puts_title(_("\n--- Options ---"));
|
|
|
|
/*
|
|
- * do the loop two times:
|
|
+ * Do the loop two times:
|
|
* 1. display the short items
|
|
* 2. display the long items (only strings and numbers)
|
|
+ * When "opt_flags" has OPT_ONECOLUMN do everything in run 2.
|
|
*/
|
|
for (run = 1; run <= 2 && !got_int; ++run)
|
|
{
|
|
@@ -4382,12 +4404,12 @@ showoptions(
|
|
for (p = &options[0]; p->fullname != NULL; p++)
|
|
{
|
|
// apply :filter /pat/
|
|
- if (message_filtered((char_u *) p->fullname))
|
|
+ if (message_filtered((char_u *)p->fullname))
|
|
continue;
|
|
|
|
varp = NULL;
|
|
isterm = istermoption(p);
|
|
- if (opt_flags != 0)
|
|
+ if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) != 0)
|
|
{
|
|
if (p->indir != PV_NONE && !isterm)
|
|
varp = get_varp_scope(p, opt_flags);
|
|
@@ -4399,7 +4421,9 @@ showoptions(
|
|
|| (all == 1 && !isterm)
|
|
|| (all == 0 && !optval_default(p, varp, p_cp))))
|
|
{
|
|
- if (p->flags & P_BOOL)
|
|
+ if (opt_flags & OPT_ONECOLUMN)
|
|
+ len = Columns;
|
|
+ else if (p->flags & P_BOOL)
|
|
len = 1; // a toggle option fits always
|
|
else
|
|
{
|
|
diff --git a/src/optiondefs.h b/src/optiondefs.h
|
|
index 8fda8bf..3670107 100644
|
|
--- a/src/optiondefs.h
|
|
+++ b/src/optiondefs.h
|
|
@@ -3009,7 +3009,7 @@ static struct vimoption options[] =
|
|
{NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCTX_INIT}
|
|
};
|
|
|
|
-#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
|
|
+#define OPTION_COUNT (sizeof(options) / sizeof(struct vimoption))
|
|
|
|
// The following is needed to make the gen_opt_test.vim script work.
|
|
// {"
|
|
diff --git a/src/proto/option.pro b/src/proto/option.pro
|
|
index dc07ee6..7da2cbf 100644
|
|
--- a/src/proto/option.pro
|
|
+++ b/src/proto/option.pro
|
|
@@ -8,6 +8,7 @@ void set_init_2(void);
|
|
void set_init_3(void);
|
|
void set_helplang_default(char_u *lang);
|
|
void set_title_defaults(void);
|
|
+void ex_set(exarg_T *eap);
|
|
int do_set(char_u *arg, int opt_flags);
|
|
void did_set_option(int opt_idx, int opt_flags, int new_value, int value_checked);
|
|
int string_to_key(char_u *arg, int multi_byte);
|
|
diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim
|
|
index d4213c1..7584465 100644
|
|
--- a/src/testdir/test_options.vim
|
|
+++ b/src/testdir/test_options.vim
|
|
@@ -44,7 +44,7 @@ func Test_wildchar()
|
|
set wildchar&
|
|
endfunc
|
|
|
|
-func Test_options()
|
|
+func Test_options_command()
|
|
let caught = 'ok'
|
|
try
|
|
options
|
|
@@ -383,6 +383,13 @@ func Test_set_all()
|
|
set tw& iskeyword& splitbelow&
|
|
endfunc
|
|
|
|
+func Test_set_one_column()
|
|
+ let out_mult = execute('set all')->split("\n")
|
|
+ let out_one = execute('set! all')->split("\n")
|
|
+ " one column should be two to four times as many lines
|
|
+ call assert_inrange(len(out_mult) * 2, len(out_mult) * 4, len(out_one))
|
|
+endfunc
|
|
+
|
|
func Test_set_values()
|
|
if filereadable('opt_test.vim')
|
|
source opt_test.vim
|
|
diff --git a/src/vim.h b/src/vim.h
|
|
index cd917a3..171b5dc 100644
|
|
--- a/src/vim.h
|
|
+++ b/src/vim.h
|
|
@@ -1227,12 +1227,13 @@ typedef struct {
|
|
* When OPT_GLOBAL and OPT_LOCAL are both missing, set both local and global
|
|
* values, get local value.
|
|
*/
|
|
-#define OPT_FREE 1 // free old value if it was allocated
|
|
-#define OPT_GLOBAL 2 // use global value
|
|
-#define OPT_LOCAL 4 // use local value
|
|
-#define OPT_MODELINE 8 // option in modeline
|
|
-#define OPT_WINONLY 16 // only set window-local options
|
|
-#define OPT_NOWIN 32 // don't set window-local options
|
|
+#define OPT_FREE 0x01 // free old value if it was allocated
|
|
+#define OPT_GLOBAL 0x02 // use global value
|
|
+#define OPT_LOCAL 0x04 // use local value
|
|
+#define OPT_MODELINE 0x08 // option in modeline
|
|
+#define OPT_WINONLY 0x10 // only set window-local options
|
|
+#define OPT_NOWIN 0x20 // don't set window-local options
|
|
+#define OPT_ONECOLUMN 0x40 // list options one per line
|
|
|
|
// Magic chars used in confirm dialog strings
|
|
#define DLG_BUTTON_SEP '\n'
|
|
--
|
|
2.33.0
|
|
|