annotate src/option.c @ 32098:39f4126d2a0d v9.0.1380

patch 9.0.1380: CTRL-X on 2**64 subtracts two Commit: https://github.com/vim/vim/commit/5fb78c3fa5c996c08a65431d698bd2c251eef5c7 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 4 20:47:39 2023 +0000 patch 9.0.1380: CTRL-X on 2**64 subtracts two Problem: CTRL-X on 2**64 subtracts two. (James McCoy) Solution: Correct computation for large number. (closes https://github.com/vim/vim/issues/12103)
author Bram Moolenaar <Bram@vim.org>
date Sat, 04 Mar 2023 22:00:03 +0100
parents e7ab58f57ea3
children 97255d909654
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10042
4aead6a9b7a9 commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents: 9959
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * Code to handle user-settable options. This is all pretty much table-
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 * driven. Checklist for adding a new option:
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
13 * - Put it in the options array in optiondefs.h (copy an existing entry).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 * - For a global option: Add a variable for it in option.h.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 * - For a buffer or window local option:
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
16 * - Add a PV_XX macro definition to the optiondefs.h file.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 * - Add a variable to the window or buffer struct in structs.h.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 * - For a window option, add some code to copy_winopt().
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
19 * - For a window string option, add code to check_win_options() and
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
20 * clear_winopt().
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 * - For a buffer option, add some code to buf_copy_options().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 * - For a buffer string option, add code to check_buf_options().
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
23 * - If it's a numeric option, add any necessary bounds checks to
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
24 * set_num_option().
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
25 * - If it's a list of flags, add some code in did_set_string_option(), search
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
26 * for WW_ALL.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 * - When adding an option with expansion (P_EXPAND), but with a different
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 * default for Vi and Vim (no P_VI_DEF), add some code at VIMEXP.
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10205
diff changeset
29 * - Add documentation! One line in doc/quickref.txt, full description in
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 * options.txt, and any other related places.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 * - Add an entry in runtime/optwin.vim.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 * When making changes:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 * - Adjust the help for the option in doc/option.txt.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 * - When an entry has the P_VIM flag, or is lacking the P_VI_DEF flag, add a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 * comment at the help for the 'compatible' option.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 #define IN_OPTION_C
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 #include "vim.h"
18054
88b5c2b4e3d2 patch 8.1.2022: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18047
diff changeset
40 #include "optiondefs.h"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7697
diff changeset
42 static void set_options_default(int opt_flags);
13162
51521b8a370c patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents: 13154
diff changeset
43 static void set_string_default_esc(char *name, char_u *val, int escape);
22234
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
44 static char_u *find_dup_item(char_u *origval, char_u *newval, long_u flags);
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7697
diff changeset
45 static char_u *option_expand(int opt_idx, char_u *val);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7697
diff changeset
46 static void didset_options(void);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7697
diff changeset
47 static void didset_options2(void);
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
48 #if defined(FEAT_EVAL) || defined(PROTO)
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7697
diff changeset
49 static long_u *insecure_flag(int opt_idx, int opt_flags);
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
50 #else
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
51 # define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
52 #endif
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15207
diff changeset
53 static char *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags);
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15207
diff changeset
54 static char *set_num_option(int opt_idx, char_u *varp, long value, char *errbuf, size_t errbuflen, int opt_flags);
14381
d9e6eec551e1 patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents: 14313
diff changeset
55 static int find_key_option(char_u *arg_arg, int has_lt);
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7697
diff changeset
56 static void showoptions(int all, int opt_flags);
16843
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
57 static int optval_default(struct vimoption *, char_u *varp, int compatible);
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7697
diff changeset
58 static void showoneopt(struct vimoption *, int opt_flags);
15613
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
59 static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, long_u flags);
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7697
diff changeset
60 static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7697
diff changeset
61 static int put_setbool(FILE *fd, char *cmd, char *name, int value);
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
62 static int istermoption(struct vimoption *p);
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26400
diff changeset
63 static char_u *get_varp_scope(struct vimoption *p, int scope);
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7697
diff changeset
64 static char_u *get_varp(struct vimoption *);
17789
0f7ae8010787 patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
65 static void check_win_options(win_T *win);
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26400
diff changeset
66 static void option_value2string(struct vimoption *, int scope);
7805
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7697
diff changeset
67 static void check_winopt(winopt_T *wop);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7697
diff changeset
68 static int wc_use_keyname(char_u *varp, long *wcp);
0b6c37dd858d commit https://github.com/vim/vim/commit/baaa7e9ec7398a813e21285c272fa99792642077
Christian Brabandt <cb@256bit.org>
parents: 7697
diff changeset
69 static void compatible_set(void);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 /*
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
72 * Initialize the 'shell' option to a default value.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
73 */
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
74 static void
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
75 set_init_default_shell(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 char_u *p;
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
78
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
79 // Find default value for 'shell' option.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
80 // Don't use it if it is empty.
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 148
diff changeset
81 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
8212
05b88224cea1 commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents: 8182
diff changeset
82 #if defined(MSWIN)
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 148
diff changeset
83 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
8080
b6cb94ad97a4 commit https://github.com/vim/vim/commit/6aa2cd4be287f35f95f35c2cec6d5a24f53c4d3c
Christian Brabandt <cb@256bit.org>
parents: 7829
diff changeset
84 || ((p = (char_u *)default_shell()) != NULL && *p != NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 #endif
161
6df0106fc595 updated for version 7.0049
vimboss
parents: 148
diff changeset
86 )
18241
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
87 #if defined(MSWIN)
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
88 {
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
89 // For MS-Windows put the path in quotes instead of escaping spaces.
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
90 char_u *cmd;
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
91 size_t len;
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
92
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
93 if (vim_strchr(p, ' ') != NULL)
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
94 {
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
95 len = STRLEN(p) + 3; // two quotes and a trailing NUL
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
96 cmd = alloc(len);
18243
463da8586749 patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
97 if (cmd != NULL)
463da8586749 patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
98 {
463da8586749 patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
99 vim_snprintf((char *)cmd, len, "\"%s\"", p);
463da8586749 patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
100 set_string_default("sh", cmd);
463da8586749 patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
101 vim_free(cmd);
463da8586749 patch 8.1.2116: no check for out of memory
Bram Moolenaar <Bram@vim.org>
parents: 18241
diff changeset
102 }
18241
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
103 }
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
104 else
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
105 set_string_default("sh", p);
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
106 }
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
107 #else
13162
51521b8a370c patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents: 13154
diff changeset
108 set_string_default_esc("sh", p, TRUE);
18241
85160a3649b9 patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space
Bram Moolenaar <Bram@vim.org>
parents: 18225
diff changeset
109 #endif
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
110 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
111
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
112 /*
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
113 * Set the default for 'backupskip' to include environment variables for
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
114 * temp files.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
115 */
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
116 static void
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
117 set_init_default_backupskip(void)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
118 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
119 int opt_idx;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
120 long_u n;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
121 char_u *p;
29879
77141226eb2e patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents: 29853
diff changeset
122 #ifdef UNIX
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
123 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
29879
77141226eb2e patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents: 29853
diff changeset
124 #else
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
125 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
126 #endif
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
127 int len;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
128 garray_T ga;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
129 int mustfree;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
130 char_u *item;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
131
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
132 opt_idx = findoption((char_u *)"backupskip");
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
133
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
134 ga_init2(&ga, 1, 100);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
135 for (n = 0; n < (long)ARRAY_LENGTH(names); ++n)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
136 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
137 mustfree = FALSE;
29879
77141226eb2e patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents: 29853
diff changeset
138 #ifdef UNIX
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
139 if (*names[n] == NUL)
29879
77141226eb2e patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents: 29853
diff changeset
140 # ifdef MACOS_X
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
141 p = (char_u *)"/private/tmp";
29879
77141226eb2e patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents: 29853
diff changeset
142 # else
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
143 p = (char_u *)"/tmp";
29879
77141226eb2e patch 9.0.0278: the +wildignore feature is nearly always available
Bram Moolenaar <Bram@vim.org>
parents: 29853
diff changeset
144 # endif
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
145 else
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
146 #endif
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
147 p = vim_getenv((char_u *)names[n], &mustfree);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
148 if (p != NULL && *p != NUL)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
149 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
150 // First time count the NUL, otherwise count the ','.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
151 len = (int)STRLEN(p) + 3;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
152 item = alloc(len);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
153 STRCPY(item, p);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
154 add_pathsep(item);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
155 STRCAT(item, "*");
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
156 if (find_dup_item(ga.ga_data, item, options[opt_idx].flags)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
157 == NULL
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
158 && ga_grow(&ga, len) == OK)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 {
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
160 if (ga.ga_len > 0)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
161 STRCAT(ga.ga_data, ",");
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
162 STRCAT(ga.ga_data, item);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
163 ga.ga_len += len;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 }
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
165 vim_free(item);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
166 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
167 if (mustfree)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
168 vim_free(p);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
169 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
170 if (ga.ga_data != NULL)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
171 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
172 set_string_default("bsk", ga.ga_data);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
173 vim_free(ga.ga_data);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
174 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
175 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
176
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
177 /*
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
178 * Initialize the 'maxmemtot' and 'maxmem' options to a default value.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
179 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
180 */
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
181 static void
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
182 set_init_default_maxmemtot(void)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
183 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
184 int opt_idx;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
185 long_u n;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
186
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 opt_idx = findoption((char_u *)"maxmemtot");
31952
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
188 if (opt_idx < 0)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
189 return;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
190
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
31952
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
192 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
193 #endif
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
194 {
28337
1cd053ebb5fc patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents: 28177
diff changeset
195 #if defined(HAVE_AVAIL_MEM)
31952
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
196 // Use amount of memory available at this moment.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
197 n = (mch_avail_mem(FALSE) >> 1);
28337
1cd053ebb5fc patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents: 28177
diff changeset
198 #elif defined(HAVE_TOTAL_MEM)
31952
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
199 // Use amount of memory available to Vim.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
200 n = (mch_total_mem(FALSE) >> 1);
28337
1cd053ebb5fc patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents: 28177
diff changeset
201 #else
31952
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
202 n = (0x7fffffff >> 11);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
203 #endif
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
204 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
205 opt_idx = findoption((char_u *)"maxmem");
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
206 if (opt_idx >= 0)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
207 {
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
208 #if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
31952
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
209 if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
210 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
211 #endif
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
212 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
213 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214 }
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
215 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
216
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
217 /*
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
218 * Initialize the 'cdpath' option to a default value.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
219 */
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
220 static void
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
221 set_init_default_cdpath(void)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
222 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
223 int opt_idx;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
224 char_u *cdpath;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
225 char_u *buf;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
226 int i;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
227 int j;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
228 int mustfree = FALSE;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
229
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
230 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
231 if (cdpath == NULL)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
232 return;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
233
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
234 buf = alloc((STRLEN(cdpath) << 1) + 2);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
235 if (buf != NULL)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
236 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
237 buf[0] = ','; // start with ",", current dir first
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
238 j = 1;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
239 for (i = 0; cdpath[i] != NUL; ++i)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
240 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
241 if (vim_ispathlistsep(cdpath[i]))
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
242 buf[j++] = ',';
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
243 else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 {
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
245 if (cdpath[i] == ' ' || cdpath[i] == ',')
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
246 buf[j++] = '\\';
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
247 buf[j++] = cdpath[i];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 }
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
249 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
250 buf[j] = NUL;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
251 opt_idx = findoption((char_u *)"cdpath");
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
252 if (opt_idx >= 0)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
253 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
254 options[opt_idx].def_val[VI_DEFAULT] = buf;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
255 options[opt_idx].flags |= P_DEF_ALLOCED;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
256 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
257 else
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
258 vim_free(buf); // cannot happen
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
259 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
260 if (mustfree)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
261 vim_free(cdpath);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
262 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
263
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
264 /*
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
265 * Initialize the 'printencoding' option to a default value.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
266 */
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
267 static void
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
268 set_init_default_printencoding(void)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
269 {
28337
1cd053ebb5fc patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents: 28177
diff changeset
270 #if defined(FEAT_POSTSCRIPT) && \
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
271 (defined(MSWIN) || defined(VMS) || defined(MAC) || defined(hpux))
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
272 // Set print encoding on platforms that don't default to latin1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 set_string_default("penc",
7408
1886f2863437 commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents: 7334
diff changeset
274 # if defined(MSWIN)
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
275 (char_u *)"cp1252"
28337
1cd053ebb5fc patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents: 28177
diff changeset
276 # elif defined(VMS)
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
277 (char_u *)"dec-mcs"
28337
1cd053ebb5fc patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents: 28177
diff changeset
278 # elif defined(MAC)
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
279 (char_u *)"mac-roman"
28337
1cd053ebb5fc patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents: 28177
diff changeset
280 # else // HPUX
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
281 (char_u *)"hp-roman8"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 # endif
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
283 );
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
284 #endif
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
285 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 #ifdef FEAT_POSTSCRIPT
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
288 /*
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
289 * Initialize the 'printexpr' option to a default value.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
290 */
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
291 static void
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
292 set_init_default_printexpr(void)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
293 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
294 // 'printexpr' must be allocated to be able to evaluate it.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 set_string_default("pexpr",
8212
05b88224cea1 commit https://github.com/vim/vim/commit/48e330aff911be1c798c88a973af6437a8141fce
Christian Brabandt <cb@256bit.org>
parents: 8182
diff changeset
296 # if defined(MSWIN)
8
7edf9b6e4c36 Various changes
vimboss
parents: 7
diff changeset
297 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
28337
1cd053ebb5fc patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents: 28177
diff changeset
298 # elif defined(VMS)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300
28337
1cd053ebb5fc patch 8.2.4694: avoidance of #elif causes more preproc nesting
Bram Moolenaar <Bram@vim.org>
parents: 28177
diff changeset
301 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 );
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
305 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
306 #endif
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
307
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
308 #ifdef UNIX
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
309 /*
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
310 * Force restricted-mode on for "nologin" or "false" $SHELL
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
311 */
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
312 static void
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
313 set_init_restricted_mode(void)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
314 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
315 char_u *p;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
316
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
317 p = get_isolated_shell_name();
31952
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
318 if (p == NULL)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
319 return;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
320 if (fnamecmp(p, "nologin") == 0 || fnamecmp(p, "false") == 0)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
321 restricted = TRUE;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
322 vim_free(p);
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
323 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
324 #endif
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
325
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
326 #ifdef CLEAN_RUNTIMEPATH
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
327 /*
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
328 * When Vim is started with the "--clean" argument, set the default value
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
329 * for the 'runtimepath' and 'packpath' options.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
330 */
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
331 static void
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
332 set_init_clean_rtp(void)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
333 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
334 int opt_idx;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
335
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
336 opt_idx = findoption((char_u *)"runtimepath");
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
337 if (opt_idx >= 0)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
338 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
339 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)CLEAN_RUNTIMEPATH;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
340 p_rtp = (char_u *)CLEAN_RUNTIMEPATH;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
341 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
342 opt_idx = findoption((char_u *)"packpath");
31952
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
343 if (opt_idx < 0)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
344 return;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
345 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)CLEAN_RUNTIMEPATH;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
346 p_pp = (char_u *)CLEAN_RUNTIMEPATH;
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
347 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
348 #endif
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
349
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
350 /*
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
351 * Expand environment variables and things like "~" for the defaults.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
352 * If option_expand() returns non-NULL the variable is expanded. This can
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
353 * only happen for non-indirect options.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
354 * Also set the default to the expanded value, so ":set" does not list
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
355 * them.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
356 * Don't set the P_ALLOCED flag, because we don't want to free the
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
357 * default.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
358 */
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
359 static void
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
360 set_init_expand_env(void)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
361 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
362 int opt_idx;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
363 char_u *p;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
364
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
365 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
366 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
367 if ((options[opt_idx].flags & P_GETTEXT)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
368 && options[opt_idx].var != NULL)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
369 p = (char_u *)_(*(char **)options[opt_idx].var);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
370 else
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
371 p = option_expand(opt_idx, NULL);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
372 if (p != NULL && (p = vim_strsave(p)) != NULL)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
373 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
374 *(char_u **)options[opt_idx].var = p;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
375 // VIMEXP
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
376 // Defaults for all expanded options are currently the same for Vi
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
377 // and Vim. When this changes, add some code here! Also need to
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
378 // split P_DEF_ALLOCED in two.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
379 if (options[opt_idx].flags & P_DEF_ALLOCED)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
380 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
381 options[opt_idx].def_val[VI_DEFAULT] = p;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
382 options[opt_idx].flags |= P_DEF_ALLOCED;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
383 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
384 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
385 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
386
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
387 /*
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
388 * Initialize the 'LANG' environment variable to a default value.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
389 */
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
390 static void
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
391 set_init_lang_env(void)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
392 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
393 #if defined(MSWIN) && defined(FEAT_GETTEXT)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
394 // If $LANG isn't set, try to get a good value for it. This makes the
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
395 // right language be used automatically. Don't do this for English.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
396 if (mch_getenv((char_u *)"LANG") == NULL)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
397 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
398 char buf[20];
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
399 long_u n;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
400
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
401 // Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
402 // LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
403 // only the first two.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
404 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
405 (LPTSTR)buf, 20);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
406 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
407 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
408 // There are a few exceptions (probably more)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
409 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
410 STRCPY(buf, "zh_TW");
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
411 else if (STRNICMP(buf, "chs", 3) == 0
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
412 || STRNICMP(buf, "zhc", 3) == 0)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
413 STRCPY(buf, "zh_CN");
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
414 else if (STRNICMP(buf, "jp", 2) == 0)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
415 STRCPY(buf, "ja");
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
416 else
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
417 buf[2] = NUL; // truncate to two-letter code
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
418 vim_setenv((char_u *)"LANG", (char_u *)buf);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
419 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
420 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
421 #elif defined(MACOS_CONVERT)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
422 // Moved to os_mac_conv.c to avoid dependency problems.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
423 mac_lang_init();
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
424 #endif
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
425 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
426
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
427 /*
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
428 * Initialize the 'encoding' option to a default value.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
429 */
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
430 static void
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
431 set_init_default_encoding(void)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
432 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
433 char_u *p;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
434 int opt_idx;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
435
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
436 # ifdef MSWIN
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
437 // MS-Windows has builtin support for conversion to and from Unicode, using
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
438 // "utf-8" for 'encoding' should work best for most users.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
439 p = vim_strsave((char_u *)ENC_DFLT);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
440 # else
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
441 // enc_locale() will try to find the encoding of the current locale.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
442 // This works best for properly configured systems, old and new.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
443 p = enc_locale();
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
444 # endif
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
445 if (p == NULL)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
446 return;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
447
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
448 // Try setting 'encoding' and check if the value is valid.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
449 // If not, go back to the default encoding.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
450 char_u *save_enc = p_enc;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
451 p_enc = p;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
452 if (STRCMP(p_enc, "gb18030") == 0)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
453 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
454 // We don't support "gb18030", but "cp936" is a good substitute
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
455 // for practical purposes, thus use that. It's not an alias to
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
456 // still support conversion between gb18030 and utf-8.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
457 p_enc = vim_strsave((char_u *)"cp936");
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
458 vim_free(p);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
459 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
460 if (mb_init() == NULL)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
461 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
462 opt_idx = findoption((char_u *)"encoding");
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
463 if (opt_idx >= 0)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
464 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
465 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
466 options[opt_idx].flags |= P_DEF_ALLOCED;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
467 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
468
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
469 #if defined(MSWIN) || defined(MACOS_X) || defined(VMS)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
470 if (STRCMP(p_enc, "latin1") == 0 || enc_utf8)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
471 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
472 // Adjust the default for 'isprint' and 'iskeyword' to match
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
473 // latin1. Also set the defaults for when 'nocompatible' is
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
474 // set.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
475 set_string_option_direct((char_u *)"isp", -1,
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
476 ISP_LATIN1, OPT_FREE, SID_NONE);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
477 set_string_option_direct((char_u *)"isk", -1,
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
478 ISK_LATIN1, OPT_FREE, SID_NONE);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
479 opt_idx = findoption((char_u *)"isp");
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
480 if (opt_idx >= 0)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
481 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
482 opt_idx = findoption((char_u *)"isk");
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
483 if (opt_idx >= 0)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
484 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
485 (void)init_chartab();
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
486 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
487 #endif
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
488
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
489 #if defined(MSWIN) && (!defined(FEAT_GUI) || defined(VIMDLL))
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
490 // Win32 console: When GetACP() returns a different value from
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
491 // GetConsoleCP() set 'termencoding'.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
492 if (
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
493 # ifdef VIMDLL
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
494 (!gui.in_use && !gui.starting) &&
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
495 # endif
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
496 GetACP() != GetConsoleCP())
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
497 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
498 char buf[50];
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
499
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
500 // Win32 console: In ConPTY, GetConsoleCP() returns zero.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
501 // Use an alternative value.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
502 if (GetConsoleCP() == 0)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
503 sprintf(buf, "cp%ld", (long)GetACP());
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
504 else
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
505 sprintf(buf, "cp%ld", (long)GetConsoleCP());
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
506 p_tenc = vim_strsave((char_u *)buf);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
507 if (p_tenc != NULL)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
508 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
509 opt_idx = findoption((char_u *)"termencoding");
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
510 if (opt_idx >= 0)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
511 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
512 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
513 options[opt_idx].flags |= P_DEF_ALLOCED;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
514 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
515 convert_setup(&input_conv, p_tenc, p_enc);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
516 convert_setup(&output_conv, p_enc, p_tenc);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
517 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
518 else
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
519 p_tenc = empty_option;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
520 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
521 #endif
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
522 #if defined(MSWIN)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
523 // $HOME may have characters in active code page.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
524 init_homedir();
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
525 #endif
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
526 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
527 else
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
528 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
529 vim_free(p_enc);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
530 p_enc = save_enc;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
531 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
532 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
533
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
534 /*
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
535 * Initialize the options, first part.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
536 *
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
537 * Called only once from main(), just after creating the first buffer.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
538 * If "clean_arg" is TRUE Vim was started with --clean.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
539 */
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
540 void
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
541 set_init_1(int clean_arg)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
542 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
543 #ifdef FEAT_LANGMAP
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
544 langmap_init();
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
545 #endif
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
546
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
547 // Be Vi compatible by default
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
548 p_cp = TRUE;
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
549
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
550 // Use POSIX compatibility when $VIM_POSIX is set.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
551 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
552 {
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
553 set_string_default("cpo", (char_u *)CPO_ALL);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
554 set_string_default("shm", (char_u *)SHM_POSIX);
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
555 }
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
556
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
557 set_init_default_shell();
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
558 set_init_default_backupskip();
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
559 set_init_default_maxmemtot();
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
560 set_init_default_cdpath();
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
561 set_init_default_printencoding();
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
562 #ifdef FEAT_POSTSCRIPT
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
563 set_init_default_printexpr();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 * Set all the options (except the terminal options) to their default
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 * value. Also set the global value for local options.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 set_options_default(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571
27509
ef32ea9fbe6c patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents: 27490
diff changeset
572 #ifdef UNIX
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
573 set_init_restricted_mode();
27509
ef32ea9fbe6c patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents: 27490
diff changeset
574 #endif
ef32ea9fbe6c patch 8.2.4282: restricted mode requires the -Z command line option
Bram Moolenaar <Bram@vim.org>
parents: 27490
diff changeset
575
13361
65c29bd4548b patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents: 13314
diff changeset
576 #ifdef CLEAN_RUNTIMEPATH
65c29bd4548b patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents: 13314
diff changeset
577 if (clean_arg)
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
578 set_init_clean_rtp();
13361
65c29bd4548b patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents: 13314
diff changeset
579 #endif
65c29bd4548b patch 8.0.1554: custom plugins loaded with --clean
Christian Brabandt <cb@256bit.org>
parents: 13314
diff changeset
580
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 if (found_reverse_arg)
28457
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
583 set_option_value_give_err((char_u *)"bg", 0L, (char_u *)"dark", 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 curbuf->b_p_initialized = TRUE;
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
587 curbuf->b_p_ar = -1; // no local 'autoread' value
5446
d0595545e98a updated for version 7.4.073
Bram Moolenaar <bram@vim.org>
parents: 5438
diff changeset
588 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 check_buf_options(curbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 check_win_options(curwin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 check_options();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
593 // Must be before option_expand(), because that one needs vim_isIDc()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 didset_options();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595
744
07f7b4a7755c updated for version 7.0222
vimboss
parents: 731
diff changeset
596 #ifdef FEAT_SPELL
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
597 // Use the current chartab for the generic chartab. This is not in
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
598 // didset_options() because it only depends on 'encoding'.
227
ef254e0f2365 updated for version 7.0063
vimboss
parents: 221
diff changeset
599 init_spell_chartab();
ef254e0f2365 updated for version 7.0063
vimboss
parents: 221
diff changeset
600 #endif
ef254e0f2365 updated for version 7.0063
vimboss
parents: 221
diff changeset
601
31962
4efcb5c68112 patch 9.0.1313: some settings use the current codepage instead of 'encoding'
Bram Moolenaar <Bram@vim.org>
parents: 31958
diff changeset
602 set_init_default_encoding();
4efcb5c68112 patch 9.0.1313: some settings use the current codepage instead of 'encoding'
Bram Moolenaar <Bram@vim.org>
parents: 31958
diff changeset
603
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
604 // Expand environment variables and things like "~" for the defaults.
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
605 set_init_expand_env();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
607 save_file_ff(curbuf); // Buffer is unchanged
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 #if defined(FEAT_ARABIC)
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
610 // Detect use of mlterm.
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
611 // Mlterm is a terminal emulator akin to xterm that has some special
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
612 // abilities (bidi namely).
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
613 // NOTE: mlterm's author is being asked to 'set' a variable
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
614 // instead of an environment variable due to inheritance.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 if (mch_getenv((char_u *)"MLTERM") != NULL)
28457
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
616 set_option_value_give_err((char_u *)"tbidi", 1L, NULL, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618
7040
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
619 didset_options2();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620
31926
6072c1d9fe2a patch 9.0.1295: the option initialization function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31924
diff changeset
621 set_init_lang_env();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 #ifdef FEAT_MULTI_LANG
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
624 // Set the default for 'helplang'.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 set_helplang_default(get_mess_lang());
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628
24912
02fa8d72e4e3 patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
629 static char_u *fencs_utf8_default = (char_u *)"ucs-bom,utf-8,default,latin1";
02fa8d72e4e3 patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
630
02fa8d72e4e3 patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
631 /*
02fa8d72e4e3 patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
632 * Set the "fileencodings" option to the default value for when 'encoding' is
02fa8d72e4e3 patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
633 * utf-8.
02fa8d72e4e3 patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
634 */
02fa8d72e4e3 patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
635 void
31922
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
636 set_fencs_unicode(void)
24912
02fa8d72e4e3 patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
637 {
02fa8d72e4e3 patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
638 set_string_option_direct((char_u *)"fencs", -1, fencs_utf8_default,
02fa8d72e4e3 patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
639 OPT_FREE, 0);
02fa8d72e4e3 patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
640 }
02fa8d72e4e3 patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
641
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 * Set an option to its default value.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 * This does not take care of side effects!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 static void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
647 set_option_default(
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
648 int opt_idx,
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
649 int opt_flags, // OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
650 int compatible) // use Vi default value
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
652 char_u *varp; // pointer to variable for current option
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
653 int dvi; // index in def_val[]
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 long_u flags;
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
655 long_u *flagsp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 flags = options[opt_idx].flags;
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
660 if (varp != NULL) // skip hidden option, nothing to do for it
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 if (flags & P_STRING)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 {
24912
02fa8d72e4e3 patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
665 // 'fencs' default value depends on 'encoding'
02fa8d72e4e3 patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
666 if (options[opt_idx].var == (char_u *)&p_fencs && enc_utf8)
02fa8d72e4e3 patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
667 set_fencs_unicode();
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
668 // Use set_string_option_direct() for local options to handle
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
669 // freeing and allocating the value.
24912
02fa8d72e4e3 patch 8.2.2993: 'fileencodings' default value should depend on 'encoding'
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
670 else if (options[opt_idx].indir != PV_NONE)
13845
f22db93bd887 patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents: 13823
diff changeset
671 set_string_option_direct(NULL, opt_idx,
f22db93bd887 patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents: 13823
diff changeset
672 options[opt_idx].def_val[dvi], opt_flags, 0);
f22db93bd887 patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents: 13823
diff changeset
673 else
f22db93bd887 patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents: 13823
diff changeset
674 {
f22db93bd887 patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents: 13823
diff changeset
675 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
f22db93bd887 patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents: 13823
diff changeset
676 free_string_option(*(char_u **)(varp));
f22db93bd887 patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents: 13823
diff changeset
677 *(char_u **)varp = options[opt_idx].def_val[dvi];
f22db93bd887 patch 8.0.1794: duplicate term options after renaming
Christian Brabandt <cb@256bit.org>
parents: 13823
diff changeset
678 options[opt_idx].flags &= ~P_ALLOCED;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 else if (flags & P_NUM)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 {
1017
0d31f8a78ab3 updated for version 7.0-143
vimboss
parents: 1004
diff changeset
683 if (options[opt_idx].indir == PV_SCROLL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 win_comp_scroll(curwin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 {
15713
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
687 long def_val = (long)(long_i)options[opt_idx].def_val[dvi];
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
688
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
689 if ((long *)varp == &curwin->w_p_so
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
690 || (long *)varp == &curwin->w_p_siso)
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
691 // 'scrolloff' and 'sidescrolloff' local values have a
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
692 // different default value than the global default.
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
693 *(long *)varp = -1;
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
694 else
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
695 *(long *)varp = def_val;
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
696 // May also set global value for local option.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 if (both)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
15713
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
699 def_val;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 }
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
702 else // P_BOOL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
704 // the cast to long is required for Manx C, long_i is needed for
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
705 // MSVC
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 839
diff changeset
706 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
1111
53fd0a213cff updated for version 7.0-237
vimboss
parents: 1110
diff changeset
707 #ifdef UNIX
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
708 // 'modeline' defaults to off for root
1111
53fd0a213cff updated for version 7.0-237
vimboss
parents: 1110
diff changeset
709 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
53fd0a213cff updated for version 7.0-237
vimboss
parents: 1110
diff changeset
710 *(int *)varp = FALSE;
53fd0a213cff updated for version 7.0-237
vimboss
parents: 1110
diff changeset
711 #endif
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
712 // May also set global value for local option.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 if (both)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 *(int *)varp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 }
634
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
717
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
718 // The default value is not insecure.
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
719 flagsp = insecure_flag(opt_idx, opt_flags);
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
720 *flagsp = *flagsp & ~P_INSECURE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 #ifdef FEAT_EVAL
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
724 set_option_sctx_idx(opt_idx, opt_flags, current_sctx);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 * Set all options (except terminal options) to their default value.
7034
e668b160ac68 commit https://github.com/vim/vim/commit/b341dda575899458f7075614dcedf0a80ee9d080
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
730 * When "opt_flags" is non-zero skip 'encoding'.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 static void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
733 set_options_default(
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
734 int opt_flags) // OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 win_T *wp;
671
83a006f81bac updated for version 7.0199
vimboss
parents: 670
diff changeset
738 tabpage_T *tp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
740 for (i = 0; !istermoption_idx(i); i++)
7034
e668b160ac68 commit https://github.com/vim/vim/commit/b341dda575899458f7075614dcedf0a80ee9d080
Christian Brabandt <cb@256bit.org>
parents: 7007
diff changeset
741 if (!(options[i].flags & P_NODEFAULT)
7040
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
742 && (opt_flags == 0
15597
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15555
diff changeset
743 || (options[i].var != (char_u *)&p_enc
7058
64dc5b11ad33 commit https://github.com/vim/vim/commit/5ea87a04964b0ccd017380b8247d04d2a69f6062
Christian Brabandt <cb@256bit.org>
parents: 7052
diff changeset
744 # if defined(FEAT_CRYPT)
7040
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
745 && options[i].var != (char_u *)&p_cm
7052
9ec3329823f9 commit https://github.com/vim/vim/commit/8060687905bdadc46abb68ee6d40e5660e352297
Christian Brabandt <cb@256bit.org>
parents: 7040
diff changeset
746 && options[i].var != (char_u *)&p_key
7058
64dc5b11ad33 commit https://github.com/vim/vim/commit/5ea87a04964b0ccd017380b8247d04d2a69f6062
Christian Brabandt <cb@256bit.org>
parents: 7052
diff changeset
747 # endif
15597
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15555
diff changeset
748 )))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 set_option_default(i, opt_flags, p_cp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
751 // The 'scroll' option must be computed for all windows.
671
83a006f81bac updated for version 7.0199
vimboss
parents: 670
diff changeset
752 FOR_ALL_TAB_WINDOWS(tp, wp)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 win_comp_scroll(wp);
6205
db3b8fe8330e updated for version 7.4.438
Bram Moolenaar <bram@vim.org>
parents: 6162
diff changeset
754 parse_cino(curbuf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 * Set the Vi-default value of a string option.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 * Used for 'sh', 'backupskip' and 'term'.
13162
51521b8a370c patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents: 13154
diff changeset
760 * When "escape" is TRUE escape spaces with a backslash.
51521b8a370c patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents: 13154
diff changeset
761 */
51521b8a370c patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents: 13154
diff changeset
762 static void
51521b8a370c patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents: 13154
diff changeset
763 set_string_default_esc(char *name, char_u *val, int escape)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 int opt_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767
13162
51521b8a370c patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents: 13154
diff changeset
768 if (escape && vim_strchr(val, ' ') != NULL)
51521b8a370c patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents: 13154
diff changeset
769 p = vim_strsave_escaped(val, (char_u *)" ");
51521b8a370c patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents: 13154
diff changeset
770 else
51521b8a370c patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents: 13154
diff changeset
771 p = vim_strsave(val);
31752
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
772 if (p == NULL) // we don't want a NULL
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
773 return;
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
774
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
775 opt_idx = findoption((char_u *)name);
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
776 if (opt_idx < 0)
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
777 return;
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
778
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
779 if (options[opt_idx].flags & P_DEF_ALLOCED)
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
780 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
781 options[opt_idx].def_val[VI_DEFAULT] = p;
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
782 options[opt_idx].flags |= P_DEF_ALLOCED;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784
13162
51521b8a370c patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents: 13154
diff changeset
785 void
51521b8a370c patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents: 13154
diff changeset
786 set_string_default(char *name, char_u *val)
51521b8a370c patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents: 13154
diff changeset
787 {
51521b8a370c patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents: 13154
diff changeset
788 set_string_default_esc(name, val, FALSE);
51521b8a370c patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents: 13154
diff changeset
789 }
51521b8a370c patch 8.0.1455: if $SHELL contains a space then 'shell' is incorrect
Christian Brabandt <cb@256bit.org>
parents: 13154
diff changeset
790
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 /*
22234
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
792 * For an option value that contains comma separated items, find "newval" in
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
793 * "origval". Return NULL if not found.
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
794 */
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
795 static char_u *
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
796 find_dup_item(char_u *origval, char_u *newval, long_u flags)
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
797 {
22242
f7871f02ddcd patch 8.2.1670: a couple of gcc compiler warnings
Bram Moolenaar <Bram@vim.org>
parents: 22234
diff changeset
798 int bs = 0;
22234
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
799 size_t newlen;
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
800 char_u *s;
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
801
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
802 if (origval == NULL)
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
803 return NULL;
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
804
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
805 newlen = STRLEN(newval);
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
806 for (s = origval; *s != NUL; ++s)
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
807 {
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
808 if ((!(flags & P_COMMA)
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
809 || s == origval
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
810 || (s[-1] == ',' && !(bs & 1)))
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
811 && STRNCMP(s, newval, newlen) == 0
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
812 && (!(flags & P_COMMA)
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
813 || s[newlen] == ','
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
814 || s[newlen] == NUL))
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
815 return s;
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
816 // Count backslashes. Only a comma with an even number of backslashes
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
817 // or a single backslash preceded by a comma before it is recognized as
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
818 // a separator.
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
819 if ((s > origval + 1
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
820 && s[-1] == '\\'
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
821 && s[-2] != ',')
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
822 || (s == origval + 1
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
823 && s[-1] == '\\'))
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
824 ++bs;
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
825 else
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
826 bs = 0;
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
827 }
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
828 return NULL;
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
829 }
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
830
b5abb88d5700 patch 8.2.1666: the initial value of 'backupskip' can have duplicate items
Bram Moolenaar <Bram@vim.org>
parents: 21672
diff changeset
831 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 * Set the Vi-default value of a number option.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 * Used for 'lines' and 'columns'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
836 set_number_default(char *name, long val)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 {
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
838 int opt_idx;
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
839
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
840 opt_idx = findoption((char_u *)name);
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
841 if (opt_idx >= 0)
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 839
diff changeset
842 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844
27018
268f6a3511df patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
845 #if defined(FEAT_PROP_POPUP) || defined(PROTO)
16843
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
846 /*
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
847 * Set all window-local and buffer-local options to the Vim default.
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
848 * local-global options will use the global value.
17845
b6acc24df7de patch 8.1.1919: using window options when passing a buffer to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17833
diff changeset
849 * When "do_buffer" is FALSE don't set buffer-local options.
16843
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
850 */
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
851 void
17845
b6acc24df7de patch 8.1.1919: using window options when passing a buffer to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17833
diff changeset
852 set_local_options_default(win_T *wp, int do_buffer)
16843
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
853 {
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
854 win_T *save_curwin = curwin;
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
855 int i;
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
856
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
857 curwin = wp;
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
858 curbuf = curwin->w_buffer;
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
859 block_autocmds();
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
860
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
861 for (i = 0; !istermoption_idx(i); i++)
16843
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
862 {
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
863 struct vimoption *p = &(options[i]);
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
864 char_u *varp = get_varp_scope(p, OPT_LOCAL);
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
865
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
866 if (p->indir != PV_NONE
17845
b6acc24df7de patch 8.1.1919: using window options when passing a buffer to popup_create()
Bram Moolenaar <Bram@vim.org>
parents: 17833
diff changeset
867 && (do_buffer || (p->indir & PV_BUF) == 0)
16843
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
868 && !(options[i].flags & P_NODEFAULT)
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
869 && !optval_default(p, varp, FALSE))
18225
6c3a8312486d patch 8.1.2107: various memory leaks reported by asan
Bram Moolenaar <Bram@vim.org>
parents: 18203
diff changeset
870 set_option_default(i, OPT_FREE|OPT_LOCAL, FALSE);
16843
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
871 }
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
872
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
873 unblock_autocmds();
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
874 curwin = save_curwin;
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
875 curbuf = curwin->w_buffer;
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
876 }
27018
268f6a3511df patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
877 #endif
16843
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
878
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
879 #if defined(EXITFREE) || defined(PROTO)
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
880 /*
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
881 * Free all options.
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
882 */
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
883 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
884 free_all_options(void)
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
885 {
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
886 int i;
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
887
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
888 for (i = 0; !istermoption_idx(i); i++)
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
889 {
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
890 if (options[i].indir == PV_NONE)
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
891 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
892 // global option: free value and default value.
10906
7fc1df5536c9 patch 8.0.0342: double free with EXITFREE and setting 'ttytype'
Christian Brabandt <cb@256bit.org>
parents: 10887
diff changeset
893 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL)
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
894 free_string_option(*(char_u **)options[i].var);
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
895 if (options[i].flags & P_DEF_ALLOCED)
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
896 free_string_option(options[i].def_val[VI_DEFAULT]);
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
897 }
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
898 else if (options[i].var != VAR_WIN
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
899 && (options[i].flags & P_STRING))
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
900 // buffer-local option: free global value
25419
8a0234862ce6 patch 8.2.3246: memory use after free
Bram Moolenaar <Bram@vim.org>
parents: 25380
diff changeset
901 clear_string_option((char_u **)options[i].var);
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
902 }
26175
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
903 free_operatorfunc_option();
26268
3aa48d4e3dc8 patch 8.2.3665: cannot use a lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26193
diff changeset
904 free_tagfunc_option();
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
905 }
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
906 #endif
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
907
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
908
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 * Initialize the options, part two: After getting Rows and Columns and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 * setting 'term'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
914 set_init_2(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 {
164
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 161
diff changeset
916 int idx;
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 161
diff changeset
917
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
918 // 'scroll' defaults to half the window height. The stored default is zero,
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
919 // which results in the actual value computed from the window height.
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
920 idx = findoption((char_u *)"scroll");
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
921 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
922 set_option_default(idx, OPT_LOCAL, p_cp);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 comp_col();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
925 // 'window' is only for backwards compatibility with Vi.
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
926 // Default is Rows - 1.
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 842
diff changeset
927 if (!option_was_set((char_u *)"window"))
164
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 161
diff changeset
928 p_window = Rows - 1;
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 161
diff changeset
929 set_number_default("window", Rows - 1);
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 161
diff changeset
930
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
931 // For DOS console the default is always black.
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15858
diff changeset
932 #if !((defined(MSWIN)) && !defined(FEAT_GUI))
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
933 // If 'background' wasn't set by the user, try guessing the value,
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
934 // depending on the terminal name. Only need to check for terminals
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
935 // with a dark background, that can handle color.
671
83a006f81bac updated for version 7.0199
vimboss
parents: 670
diff changeset
936 idx = findoption((char_u *)"bg");
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
937 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
938 && *term_bg_default() == 'd')
671
83a006f81bac updated for version 7.0199
vimboss
parents: 670
diff changeset
939 {
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
940 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
941 // don't mark it as set, when starting the GUI it may be
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
942 // changed again
671
83a006f81bac updated for version 7.0199
vimboss
parents: 670
diff changeset
943 options[idx].flags &= ~P_WAS_SET;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945 #endif
440
eb531146be0e updated for version 7.0114
vimboss
parents: 419
diff changeset
946
eb531146be0e updated for version 7.0114
vimboss
parents: 419
diff changeset
947 #ifdef CURSOR_SHAPE
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
948 parse_shape_opt(SHAPE_CURSOR); // set cursor shapes from 'guicursor'
440
eb531146be0e updated for version 7.0114
vimboss
parents: 419
diff changeset
949 #endif
eb531146be0e updated for version 7.0114
vimboss
parents: 419
diff changeset
950 #ifdef FEAT_MOUSESHAPE
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
951 parse_shape_opt(SHAPE_MOUSE); // set mouse shapes from 'mouseshape'
440
eb531146be0e updated for version 7.0114
vimboss
parents: 419
diff changeset
952 #endif
eb531146be0e updated for version 7.0114
vimboss
parents: 419
diff changeset
953 #ifdef FEAT_PRINTER
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
954 (void)parse_printoptions(NULL); // parse 'printoptions' default value
440
eb531146be0e updated for version 7.0114
vimboss
parents: 419
diff changeset
955 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 * Initialize the options, part three: After reading the .vimrc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
962 set_init_3(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 {
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15858
diff changeset
964 #if defined(UNIX) || defined(MSWIN)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 * This is done after other initializations, where 'shell' might have been
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 * set, but only if they have not been set before.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 int idx_srr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 int do_srr;
7408
1886f2863437 commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents: 7334
diff changeset
973 # ifdef FEAT_QUICKFIX
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 int idx_sp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 int do_sp;
7408
1886f2863437 commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents: 7334
diff changeset
976 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 idx_srr = findoption((char_u *)"srr");
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
979 if (idx_srr < 0)
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
980 do_srr = FALSE;
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
981 else
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
982 do_srr = !(options[idx_srr].flags & P_WAS_SET);
7408
1886f2863437 commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents: 7334
diff changeset
983 # ifdef FEAT_QUICKFIX
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 idx_sp = findoption((char_u *)"sp");
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
985 if (idx_sp < 0)
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
986 do_sp = FALSE;
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
987 else
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
988 do_sp = !(options[idx_sp].flags & P_WAS_SET);
7408
1886f2863437 commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents: 7334
diff changeset
989 # endif
5867
a6b59ee633a3 updated for version 7.4.276
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
990 p = get_isolated_shell_name();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 if (p != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992 {
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
993 // Default for p_sp is "| tee", for p_srr is ">".
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
994 // For known shells it is changed here to include stderr.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995 if ( fnamecmp(p, "csh") == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 || fnamecmp(p, "tcsh") == 0
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15858
diff changeset
997 # if defined(MSWIN) // also check with .exe extension
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 || fnamecmp(p, "csh.exe") == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 || fnamecmp(p, "tcsh.exe") == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 {
7408
1886f2863437 commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents: 7334
diff changeset
1003 # if defined(FEAT_QUICKFIX)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 if (do_sp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 {
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15858
diff changeset
1006 # ifdef MSWIN
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 p_sp = (char_u *)">&";
7408
1886f2863437 commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents: 7334
diff changeset
1008 # else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 p_sp = (char_u *)"|& tee";
7408
1886f2863437 commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents: 7334
diff changeset
1010 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 }
7408
1886f2863437 commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents: 7334
diff changeset
1013 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 if (do_srr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 p_srr = (char_u *)">&";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 }
25068
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1020 # ifdef MSWIN
25084
beff72446e2e patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents: 25068
diff changeset
1021 // Windows PowerShell output is UTF-16 with BOM so re-encode to the
beff72446e2e patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents: 25068
diff changeset
1022 // current codepage.
25068
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1023 else if ( fnamecmp(p, "powershell") == 0
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1024 || fnamecmp(p, "powershell.exe") == 0
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1025 )
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1026 {
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1027 # if defined(FEAT_QUICKFIX)
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1028 if (do_sp)
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1029 {
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1030 p_sp = (char_u *)"2>&1 | Out-File -Encoding default";
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1031 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1032 }
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1033 # endif
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1034 if (do_srr)
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1035 {
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1036 p_srr = (char_u *)"2>&1 | Out-File -Encoding default";
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1037 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1038 }
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1039 }
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1040 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 else
24600
cb4cb3ff5736 patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents: 24476
diff changeset
1042 // Always use POSIX shell style redirection if we reach this
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 if ( fnamecmp(p, "sh") == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 || fnamecmp(p, "ksh") == 0
2774
e8f012b00187 updated for version 7.3.163
Bram Moolenaar <bram@vim.org>
parents: 2726
diff changeset
1045 || fnamecmp(p, "mksh") == 0
e8f012b00187 updated for version 7.3.163
Bram Moolenaar <bram@vim.org>
parents: 2726
diff changeset
1046 || fnamecmp(p, "pdksh") == 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047 || fnamecmp(p, "zsh") == 0
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 835
diff changeset
1048 || fnamecmp(p, "zsh-beta") == 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 || fnamecmp(p, "bash") == 0
5867
a6b59ee633a3 updated for version 7.4.276
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
1050 || fnamecmp(p, "fish") == 0
24600
cb4cb3ff5736 patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents: 24476
diff changeset
1051 || fnamecmp(p, "ash") == 0
cb4cb3ff5736 patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents: 24476
diff changeset
1052 || fnamecmp(p, "dash") == 0
25084
beff72446e2e patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents: 25068
diff changeset
1053 || fnamecmp(p, "pwsh") == 0
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15858
diff changeset
1054 # ifdef MSWIN
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 || fnamecmp(p, "cmd") == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 || fnamecmp(p, "sh.exe") == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057 || fnamecmp(p, "ksh.exe") == 0
2774
e8f012b00187 updated for version 7.3.163
Bram Moolenaar <bram@vim.org>
parents: 2726
diff changeset
1058 || fnamecmp(p, "mksh.exe") == 0
e8f012b00187 updated for version 7.3.163
Bram Moolenaar <bram@vim.org>
parents: 2726
diff changeset
1059 || fnamecmp(p, "pdksh.exe") == 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060 || fnamecmp(p, "zsh.exe") == 0
836
5a7843c57316 updated for version 7.0e02
vimboss
parents: 835
diff changeset
1061 || fnamecmp(p, "zsh-beta.exe") == 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 || fnamecmp(p, "bash.exe") == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 || fnamecmp(p, "cmd.exe") == 0
24600
cb4cb3ff5736 patch 8.2.2839: default redirection missing "ash" and "dash"
Bram Moolenaar <Bram@vim.org>
parents: 24476
diff changeset
1064 || fnamecmp(p, "dash.exe") == 0
25084
beff72446e2e patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents: 25068
diff changeset
1065 || fnamecmp(p, "pwsh.exe") == 0
7408
1886f2863437 commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents: 7334
diff changeset
1066 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1067 )
7408
1886f2863437 commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents: 7334
diff changeset
1068 {
1886f2863437 commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents: 7334
diff changeset
1069 # if defined(FEAT_QUICKFIX)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 if (do_sp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071 {
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15858
diff changeset
1072 # ifdef MSWIN
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073 p_sp = (char_u *)">%s 2>&1";
7408
1886f2863437 commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents: 7334
diff changeset
1074 # else
25084
beff72446e2e patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents: 25068
diff changeset
1075 if (fnamecmp(p, "pwsh") == 0)
beff72446e2e patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents: 25068
diff changeset
1076 p_sp = (char_u *)">%s 2>&1";
beff72446e2e patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents: 25068
diff changeset
1077 else
beff72446e2e patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents: 25068
diff changeset
1078 p_sp = (char_u *)"2>&1| tee";
7408
1886f2863437 commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents: 7334
diff changeset
1079 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1081 }
7408
1886f2863437 commit https://github.com/vim/vim/commit/e7fedb6ebe72d9a475aa65109b77d5ed4667067a
Christian Brabandt <cb@256bit.org>
parents: 7334
diff changeset
1082 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 if (do_srr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 p_srr = (char_u *)">%s 2>&1";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 vim_free(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1092
15868
7fad90423bd2 patch 8.1.0941: macros for MS-Windows are inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15858
diff changeset
1093 #if defined(MSWIN)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1094 /*
3352
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1095 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1096 * 'shell' option.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097 * This is done after other initializations, where 'shell' might have been
25068
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1098 * set, but only if they have not been set before.
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1099 * Default values depend on shell (cmd.exe is default shell):
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1100 *
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1101 * p_shcf p_sxq
28809
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28804
diff changeset
1102 * cmd.exe - "/c" "("
25068
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1103 * powershell.exe - "-Command" "\""
25084
beff72446e2e patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents: 25068
diff changeset
1104 * pwsh.exe - "-c" "\""
25068
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1105 * "sh" like shells - "-c" "\""
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1106 *
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1107 * For Win32 p_sxq is set instead of p_shq to include shell redirection.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 */
25068
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1109 if (strstr((char *)gettail(p_sh), "powershell") != NULL)
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1110 {
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1111 int idx_opt;
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1112
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1113 idx_opt = findoption((char_u *)"shcf");
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1114 if (idx_opt >= 0 && !(options[idx_opt].flags & P_WAS_SET))
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1115 {
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1116 p_shcf = (char_u*)"-Command";
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1117 options[idx_opt].def_val[VI_DEFAULT] = p_shcf;
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1118 }
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1119
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1120 idx_opt = findoption((char_u *)"sxq");
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1121 if (idx_opt >= 0 && !(options[idx_opt].flags & P_WAS_SET))
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1122 {
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1123 p_sxq = (char_u*)"\"";
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1124 options[idx_opt].def_val[VI_DEFAULT] = p_sxq;
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1125 }
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1126 }
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 24970
diff changeset
1127 else if (strstr((char *)gettail(p_sh), "sh") != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 int idx3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 idx3 = findoption((char_u *)"shcf");
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
1132 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 p_shcf = (char_u *)"-c";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
1138 // Somehow Win32 requires the quotes around the redirection too
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 idx3 = findoption((char_u *)"sxq");
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
1140 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 p_sxq = (char_u *)"\"";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 }
3352
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1146 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1147 {
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1148 int idx3;
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1149
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1150 /*
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1151 * cmd.exe on Windows will strip the first and last double quote given
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1152 * on the command line, e.g. most of the time things like:
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1153 * cmd /c "my path/to/echo" "my args to echo"
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1154 * become:
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1155 * my path/to/echo" "my args to echo
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1156 * when executed.
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1157 *
3357
397e7e49bb0b updated for version 7.3.445
Bram Moolenaar <bram@vim.org>
parents: 3352
diff changeset
1158 * To avoid this, set shellxquote to surround the command in
397e7e49bb0b updated for version 7.3.445
Bram Moolenaar <bram@vim.org>
parents: 3352
diff changeset
1159 * parenthesis. This appears to make most commands work, without
397e7e49bb0b updated for version 7.3.445
Bram Moolenaar <bram@vim.org>
parents: 3352
diff changeset
1160 * breaking commands that worked previously, such as
397e7e49bb0b updated for version 7.3.445
Bram Moolenaar <bram@vim.org>
parents: 3352
diff changeset
1161 * '"path with spaces/cmd" "a&b"'.
3352
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1162 */
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1163 idx3 = findoption((char_u *)"sxq");
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1164 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1165 {
3357
397e7e49bb0b updated for version 7.3.445
Bram Moolenaar <bram@vim.org>
parents: 3352
diff changeset
1166 p_sxq = (char_u *)"(";
3352
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1167 options[idx3].def_val[VI_DEFAULT] = p_sxq;
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1168 }
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1169
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1170 idx3 = findoption((char_u *)"shcf");
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1171 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1172 {
3357
397e7e49bb0b updated for version 7.3.445
Bram Moolenaar <bram@vim.org>
parents: 3352
diff changeset
1173 p_shcf = (char_u *)"/c";
3352
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1174 options[idx3].def_val[VI_DEFAULT] = p_shcf;
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1175 }
de050fcc24cf updated for version 7.3.443
Bram Moolenaar <bram@vim.org>
parents: 3308
diff changeset
1176 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1178
11121
778c10516955 patch 8.0.0448: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11107
diff changeset
1179 if (BUFEMPTY())
8659
72e2f387466f commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1180 {
72e2f387466f commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1181 int idx_ffs = findoption((char_u *)"ffs");
72e2f387466f commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1182
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
1183 // Apply the first entry of 'fileformats' to the initial buffer.
8659
72e2f387466f commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1184 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET))
72e2f387466f commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1185 set_fileformat(default_fileformat(), OPT_LOCAL);
72e2f387466f commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1186 }
72e2f387466f commit https://github.com/vim/vim/commit/364fa5c7ec2a99a791c8f8b66fe70b0bf1dd9a41
Christian Brabandt <cb@256bit.org>
parents: 8643
diff changeset
1187
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188 set_title_defaults();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 #if defined(FEAT_MULTI_LANG) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193 * When 'helplang' is still at its default value, set it to "lang".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194 * Only the first two characters of "lang" are used.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1197 set_helplang_default(char_u *lang)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
1201 if (lang == NULL || STRLEN(lang) < 2) // safety check
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203 idx = findoption((char_u *)"hlg");
31752
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1204 if (idx < 0 || (options[idx].flags & P_WAS_SET))
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1205 return;
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1206
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1207 if (options[idx].flags & P_ALLOCED)
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1208 free_string_option(p_hlg);
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1209 p_hlg = vim_strsave(lang);
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1210 if (p_hlg == NULL)
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1211 p_hlg = empty_option;
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1212 else
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1213 {
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1214 // zh_CN becomes "cn", zh_TW becomes "tw"
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1215 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1216 {
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1217 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1218 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1219 }
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1220 // any C like setting, such as C.UTF-8, becomes "en"
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1221 else if (STRLEN(p_hlg) >= 1 && *p_hlg == 'C')
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1222 {
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1223 p_hlg[0] = 'e';
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1224 p_hlg[1] = 'n';
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1225 }
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1226 p_hlg[2] = NUL;
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1227 }
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1228 options[idx].flags |= P_ALLOCED;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 * 'title' and 'icon' only default to true if they have not been set or reset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234 * in .vimrc and we can read the old value.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1236 * they can be reset. This reduces startup time when using X on a remote
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1237 * machine.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
1240 set_title_defaults(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 int idx1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 long val;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
1245 // If GUI is (going to be) used, we can always set the window title and
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
1246 // icon name. Saves a bit of time, because the X11 display server does
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
1247 // not need to be contacted.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 idx1 = findoption((char_u *)"title");
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
1249 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 if (gui.starting || gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253 val = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 val = mch_can_restore_title();
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 839
diff changeset
1257 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 p_title = val;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 idx1 = findoption((char_u *)"icon");
31752
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1261 if (idx1 < 0 || (options[idx1].flags & P_WAS_SET))
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1262 {
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1263 return;
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1264 }
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1265
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 #ifdef FEAT_GUI
31752
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1267 if (gui.starting || gui.in_use)
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1268 val = TRUE;
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1269 else
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1270 #endif
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1271 val = mch_can_restore_icon();
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1272 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
1273 p_icon = val;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275
19137
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1276 void
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1277 ex_set(exarg_T *eap)
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1278 {
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1279 int flags = 0;
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1280
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1281 if (eap->cmdidx == CMD_setlocal)
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1282 flags = OPT_LOCAL;
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1283 else if (eap->cmdidx == CMD_setglobal)
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1284 flags = OPT_GLOBAL;
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1285 #if defined(FEAT_EVAL) && defined(FEAT_BROWSE)
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22242
diff changeset
1286 if ((cmdmod.cmod_flags & CMOD_BROWSE) && flags == 0)
19137
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1287 ex_options(eap);
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1288 else
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1289 #endif
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1290 {
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1291 if (eap->forceit)
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1292 flags |= OPT_ONECOLUMN;
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1293 (void)do_set(eap->arg, flags);
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1294 }
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1295 }
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
1296
31902
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1297 /*
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1298 * :set operator types
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1299 */
30403
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1300 typedef enum {
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1301 OP_NONE = 0,
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1302 OP_ADDING, // "opt+=arg"
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1303 OP_PREPENDING, // "opt^=arg"
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1304 OP_REMOVING, // "opt-=arg"
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1305 } set_op_T;
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1306
31902
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1307 typedef enum {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1308 PREFIX_NO = 0, // "no" prefix
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1309 PREFIX_NONE, // no prefix
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1310 PREFIX_INV, // "inv" prefix
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1311 } set_prefix_T;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1312
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1313 /*
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1314 * Return the prefix type for the option name in *argp.
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1315 */
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1316 static set_prefix_T
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1317 get_option_prefix(char_u **argp)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1318 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1319 int prefix = PREFIX_NONE;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1320 char_u *arg = *argp;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1321
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1322 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1323 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1324 prefix = PREFIX_NO;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1325 arg += 2;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1326 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1327 else if (STRNCMP(arg, "inv", 3) == 0)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1328 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1329 prefix = PREFIX_INV;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1330 arg += 3;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1331 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1332
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1333 *argp = arg;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1334 return prefix;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1335 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1336
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1337 /*
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1338 * Parse the option name in "arg" and return the option index in "*opt_idxp",
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1339 * and the option name length in "*lenp". For a <t_xx> option, return the key
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1340 * number in "*keyp".
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1341 *
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1342 * Returns FAIL if an option starting with "<" doesn't end with a ">",
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1343 * otherwise returns OK.
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1344 */
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1345 static int
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1346 parse_option_name(char_u *arg, int *opt_idxp, int *lenp, int *keyp)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1347 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1348 int key = 0;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1349 int len;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1350 int opt_idx;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1351
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1352 if (*arg == '<')
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1353 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1354 opt_idx = -1;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1355 // look out for <t_>;>
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1356 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1357 len = 5;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1358 else
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1359 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1360 len = 1;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1361 while (arg[len] != NUL && arg[len] != '>')
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1362 ++len;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1363 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1364 if (arg[len] != '>')
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1365 return FAIL;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1366
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1367 arg[len] = NUL; // put NUL after name
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1368 if (arg[1] == 't' && arg[2] == '_') // could be term code
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1369 opt_idx = findoption(arg + 1);
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1370 arg[len++] = '>'; // restore '>'
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1371 if (opt_idx == -1)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1372 key = find_key_option(arg + 1, TRUE);
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1373 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1374 else
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1375 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1376 int nextchar; // next non-white char after option name
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1377
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1378 len = 0;
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
1379 // The two characters after "t_" may not be alphanumeric.
31902
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1380 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1381 len = 4;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1382 else
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1383 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1384 ++len;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1385 nextchar = arg[len];
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1386 arg[len] = NUL; // put NUL after name
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1387 opt_idx = findoption(arg);
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1388 arg[len] = nextchar; // restore nextchar
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1389 if (opt_idx == -1)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1390 key = find_key_option(arg, FALSE);
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1391 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1392
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1393 *keyp = key;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1394 *lenp = len;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1395 *opt_idxp = opt_idx;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1396
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1397 return OK;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1398 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1399
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1400 /*
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1401 * Get the option operator (+=, ^=, -=).
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1402 */
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1403 static set_op_T
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1404 get_opt_op(char_u *arg)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1405 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1406 set_op_T op = OP_NONE;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1407
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1408 if (*arg != NUL && *(arg + 1) == '=')
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1409 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1410 if (*arg == '+')
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1411 op = OP_ADDING; // "+="
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1412 else if (*arg == '^')
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1413 op = OP_PREPENDING; // "^="
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1414 else if (*arg == '-')
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1415 op = OP_REMOVING; // "-="
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1416 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1417
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1418 return op;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1419 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1420
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1421 /*
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1422 * Validate whether the value of the option in "opt_idx" can be changed.
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1423 * Returns FAIL if the option can be skipped or cannot be changed. Returns OK
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1424 * if it can be changed.
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1425 */
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1426 static int
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1427 validate_opt_idx(int opt_idx, int opt_flags, long_u flags, char **errmsg)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1428 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1429 // Skip all options that are not window-local (used when showing
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1430 // an already loaded buffer in a window).
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1431 if ((opt_flags & OPT_WINONLY)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1432 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1433 return FAIL;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1434
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1435 // Skip all options that are window-local (used for :vimgrep).
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1436 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1437 && options[opt_idx].var == VAR_WIN)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1438 return FAIL;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1439
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1440 // Disallow changing some options from modelines.
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1441 if (opt_flags & OPT_MODELINE)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1442 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1443 if (flags & (P_SECURE | P_NO_ML))
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1444 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1445 *errmsg = e_not_allowed_in_modeline;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1446 return FAIL;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1447 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1448 if ((flags & P_MLE) && !p_mle)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1449 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1450 *errmsg = e_not_allowed_in_modeline_when_modelineexpr_is_off;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1451 return FAIL;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1452 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1453 #ifdef FEAT_DIFF
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1454 // In diff mode some options are overruled. This avoids that
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1455 // 'foldmethod' becomes "marker" instead of "diff" and that
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1456 // "wrap" gets set.
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1457 if (curwin->w_p_diff
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1458 && opt_idx >= 0 // shut up coverity warning
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1459 && (
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1460 # ifdef FEAT_FOLDING
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1461 options[opt_idx].indir == PV_FDM ||
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1462 # endif
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1463 options[opt_idx].indir == PV_WRAP))
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1464 return FAIL;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1465 #endif
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1466 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1467
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1468 #ifdef HAVE_SANDBOX
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1469 // Disallow changing some options in the sandbox
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1470 if (sandbox != 0 && (flags & P_SECURE))
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1471 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1472 *errmsg = e_not_allowed_in_sandbox;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1473 return FAIL;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1474 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1475 #endif
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1476
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1477 return OK;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1478 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
1479
30403
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1480 /*
31952
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1481 * Get the Vim/Vi default value for a string option.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1482 */
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1483 static char_u *
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1484 stropt_get_default_val(
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1485 int opt_idx,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1486 char_u *varp,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1487 int flags,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1488 int cp_val)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1489 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1490 char_u *newval;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1491
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1492 newval = options[opt_idx].def_val[((flags & P_VI_DEF) || cp_val)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1493 ? VI_DEFAULT : VIM_DEFAULT];
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1494 if ((char_u **)varp == &p_bg)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1495 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1496 // guess the value of 'background'
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1497 #ifdef FEAT_GUI
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1498 if (gui.in_use)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1499 newval = gui_bg_default();
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1500 else
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1501 #endif
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1502 newval = term_bg_default();
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1503 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1504 else if ((char_u **)varp == &p_fencs && enc_utf8)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1505 newval = fencs_utf8_default;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1506
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1507 // expand environment variables and ~ since the default value was
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1508 // already expanded, only required when an environment variable was set
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1509 // later
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1510 if (newval == NULL)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1511 newval = empty_option;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1512 else
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1513 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1514 char_u *s = option_expand(opt_idx, newval);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1515 if (s == NULL)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1516 s = newval;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1517 newval = vim_strsave(s);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1518 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1519
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1520 return newval;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1521 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1522
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1523 /*
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1524 * Convert the 'backspace' option number value to a string: for adding,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1525 * prepending and removing string.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1526 */
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1527 static void
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1528 opt_backspace_nr2str(
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1529 char_u *varp,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1530 char_u **origval_p,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1531 char_u **origval_l_p,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1532 char_u **origval_g_p,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1533 char_u **oldval_p)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1534 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1535 int i = getdigits((char_u **)varp);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1536
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1537 switch (i)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1538 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1539 case 0:
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1540 *(char_u **)varp = empty_option;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1541 break;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1542 case 1:
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1543 *(char_u **)varp = vim_strsave((char_u *)"indent,eol");
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1544 break;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1545 case 2:
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1546 *(char_u **)varp = vim_strsave((char_u *)"indent,eol,start");
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1547 break;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1548 case 3:
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1549 *(char_u **)varp = vim_strsave((char_u *)"indent,eol,nostop");
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1550 break;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1551 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1552 vim_free(*oldval_p);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1553 if (*origval_p == *oldval_p)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1554 *origval_p = *(char_u **)varp;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1555 if (*origval_l_p == *oldval_p)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1556 *origval_l_p = *(char_u **)varp;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1557 if (*origval_g_p == *oldval_p)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1558 *origval_g_p = *(char_u **)varp;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1559 *oldval_p = *(char_u **)varp;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1560 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1561
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1562 /*
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1563 * Convert the 'whichwrap' option number value to a string, for backwards
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1564 * compatibility with Vim 3.0.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1565 * Note: 'argp' is a pointer to a char_u pointer and is updated.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1566 */
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1567 static char_u *
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1568 opt_whichwrap_nr2str(char_u **argp, char_u *whichwrap)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1569 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1570 *whichwrap = NUL;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1571 int i = getdigits(argp);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1572 if (i & 1)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1573 STRCAT(whichwrap, "b,");
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1574 if (i & 2)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1575 STRCAT(whichwrap, "s,");
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1576 if (i & 4)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1577 STRCAT(whichwrap, "h,l,");
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1578 if (i & 8)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1579 STRCAT(whichwrap, "<,>,");
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1580 if (i & 16)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1581 STRCAT(whichwrap, "[,],");
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1582 if (*whichwrap != NUL) // remove trailing ,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1583 whichwrap[STRLEN(whichwrap) - 1] = NUL;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1584
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1585 return whichwrap;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1586 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1587
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1588 /*
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1589 * Copy the new string value into allocated memory for the option.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1590 * Can't use set_string_option_direct(), because we need to remove the
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1591 * backslashes.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1592 */
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1593 static char_u *
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1594 stropt_copy_value(
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1595 char_u *origval,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1596 char_u **argp,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1597 set_op_T op,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1598 int flags UNUSED)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1599 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1600 char_u *arg = *argp;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1601 unsigned newlen;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1602 char_u *newval;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1603 char_u *s = NULL;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1604
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1605 // get a bit too much
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1606 newlen = (unsigned)STRLEN(arg) + 1;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1607 if (op != OP_NONE)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1608 newlen += (unsigned)STRLEN(origval) + 1;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1609 newval = alloc(newlen);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1610 if (newval == NULL) // out of mem, don't change
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1611 return NULL;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1612 s = newval;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1613
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1614 // Copy the string, skip over escaped chars.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1615 // For MS-DOS and WIN32 backslashes before normal file name characters
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1616 // are not removed, and keep backslash at start, for "\\machine\path",
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1617 // but do remove it for "\\\\machine\\path".
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1618 // The reverse is found in ExpandOldSetting().
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1619 while (*arg != NUL && !VIM_ISWHITE(*arg))
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1620 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1621 int i;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1622
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1623 if (*arg == '\\' && arg[1] != NUL
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1624 #ifdef BACKSLASH_IN_FILENAME
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1625 && !((flags & P_EXPAND)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1626 && vim_isfilec(arg[1])
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1627 && !VIM_ISWHITE(arg[1])
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1628 && (arg[1] != '\\'
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1629 || (s == newval && arg[2] != '\\')))
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1630 #endif
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1631 )
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1632 ++arg; // remove backslash
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1633 if (has_mbyte && (i = (*mb_ptr2len)(arg)) > 1)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1634 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1635 // copy multibyte char
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1636 mch_memmove(s, arg, (size_t)i);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1637 arg += i;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1638 s += i;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1639 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1640 else
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1641 *s++ = *arg++;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1642 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1643 *s = NUL;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1644
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1645 *argp = arg;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1646 return newval;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1647 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1648
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1649 /*
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1650 * Expand environment variables and ~ in string option value 'newval'.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1651 */
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1652 static char_u *
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1653 stropt_expand_envvar(
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1654 int opt_idx,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1655 char_u *origval,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1656 char_u *newval,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1657 set_op_T op)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1658 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1659 char_u *s = option_expand(opt_idx, newval);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1660 if (s == NULL)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1661 return newval;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1662
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1663 vim_free(newval);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1664 unsigned newlen = (unsigned)STRLEN(s) + 1;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1665 if (op != OP_NONE)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1666 newlen += (unsigned)STRLEN(origval) + 1;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1667
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1668 newval = alloc(newlen);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1669 if (newval == NULL)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1670 return NULL;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1671
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1672 STRCPY(newval, s);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1673
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1674 return newval;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1675 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1676
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1677 /*
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1678 * Concatenate the original and new values of a string option, adding a "," if
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1679 * needed.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1680 */
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1681 static void
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1682 stropt_concat_with_comma(
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1683 char_u *origval,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1684 char_u *newval,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1685 set_op_T op,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1686 int flags)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1687 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1688 int len = 0;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1689
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1690 int comma = ((flags & P_COMMA) && *origval != NUL && *newval != NUL);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1691 if (op == OP_ADDING)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1692 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1693 len = (int)STRLEN(origval);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1694 // strip a trailing comma, would get 2
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1695 if (comma && len > 1
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1696 && (flags & P_ONECOMMA) == P_ONECOMMA
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1697 && origval[len - 1] == ','
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1698 && origval[len - 2] != '\\')
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1699 len--;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1700 mch_memmove(newval + len + comma, newval, STRLEN(newval) + 1);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1701 mch_memmove(newval, origval, (size_t)len);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1702 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1703 else
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1704 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1705 len = (int)STRLEN(newval);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1706 STRMOVE(newval + len + comma, origval);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1707 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1708 if (comma)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1709 newval[len] = ',';
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1710 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1711
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1712 /*
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1713 * Remove a value from a string option. Copy string option value in "origval"
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1714 * to "newval" and then remove the string "strval" of length "len".
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1715 */
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1716 static void
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1717 stropt_remove_val(
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1718 char_u *origval,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1719 char_u *newval,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1720 int flags,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1721 char_u *strval,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1722 int len)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1723 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1724 // Remove newval[] from origval[]. (Note: "len" has been set above
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1725 // and is used here).
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1726 STRCPY(newval, origval);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1727 if (*strval)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1728 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1729 // may need to remove a comma
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1730 if (flags & P_COMMA)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1731 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1732 if (strval == origval)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1733 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1734 // include comma after string
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1735 if (strval[len] == ',')
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1736 ++len;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1737 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1738 else
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1739 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1740 // include comma before string
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1741 --strval;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1742 ++len;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1743 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1744 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1745 STRMOVE(newval + (strval - origval), strval + len);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1746 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1747 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1748
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1749 /*
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1750 * Remove flags that appear twice in the string option value 'newval'.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1751 */
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1752 static void
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1753 stropt_remove_dupflags(char_u *newval, int flags)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1754 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1755 char_u *s = newval;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1756
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1757 // Remove flags that appear twice.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1758 while (*s)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1759 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1760 // if options have P_FLAGLIST and P_ONECOMMA such as 'whichwrap'
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1761 if (flags & P_ONECOMMA)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1762 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1763 if (*s != ',' && *(s + 1) == ',' && vim_strchr(s + 2, *s) != NULL)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1764 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1765 // Remove the duplicated value and the next comma.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1766 STRMOVE(s, s + 2);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1767 continue;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1768 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1769 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1770 else
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1771 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1772 if ((!(flags & P_COMMA) || *s != ',')
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1773 && vim_strchr(s + 1, *s) != NULL)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1774 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1775 STRMOVE(s, s + 1);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1776 continue;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1777 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1778 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1779 ++s;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1780 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1781 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1782
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1783 /*
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1784 * Get the string value specified for a ":set" command. The following set
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1785 * options are supported:
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1786 * set {opt}&
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1787 * set {opt}<
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1788 * set {opt}={val}
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1789 * set {opt}:{val}
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1790 */
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1791 static char_u *
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1792 stropt_get_newval(
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1793 int nextchar,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1794 int opt_idx,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1795 char_u **argp,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1796 char_u *varp,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1797 char_u **origval_arg,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1798 char_u **origval_l_arg,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1799 char_u **origval_g_arg,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1800 char_u **oldval_arg,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1801 set_op_T *op_arg,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1802 int flags,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1803 int cp_val)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1804 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1805 char_u *arg = *argp;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1806 char_u *origval = *origval_arg;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1807 char_u *origval_l = *origval_l_arg;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1808 char_u *origval_g = *origval_g_arg;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1809 char_u *oldval = *oldval_arg;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1810 set_op_T op = *op_arg;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1811 char_u *save_arg = NULL;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1812 char_u *newval;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1813 char_u *s = NULL;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1814 char_u whichwrap[80];
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1815
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1816 if (nextchar == '&') // set to default val
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1817 newval = stropt_get_default_val(opt_idx, varp, flags, cp_val);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1818 else if (nextchar == '<') // set to global val
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1819 newval = vim_strsave(*(char_u **)get_varp_scope(
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1820 &(options[opt_idx]), OPT_GLOBAL));
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1821 else
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1822 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1823 ++arg; // jump to after the '=' or ':'
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1824
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1825 // Set 'keywordprg' to ":help" if an empty
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1826 // value was passed to :set by the user.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1827 if (varp == (char_u *)&p_kp && (*arg == NUL || *arg == ' '))
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1828 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1829 save_arg = arg;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1830 arg = (char_u *)":help";
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1831 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1832 // Convert 'backspace' number to string
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1833 else if (varp == (char_u *)&p_bs && VIM_ISDIGIT(**(char_u **)varp))
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1834 opt_backspace_nr2str(varp, &origval, &origval_l, &origval_g,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1835 &oldval);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1836 else if (varp == (char_u *)&p_ww && VIM_ISDIGIT(*arg))
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1837 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1838 // Convert 'whichwrap' number to string, for backwards
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1839 // compatibility with Vim 3.0.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1840 char_u *t = opt_whichwrap_nr2str(&arg, whichwrap);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1841 save_arg = arg;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1842 arg = t;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1843 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1844 // Remove '>' before 'dir' and 'bdir', for backwards compatibility with
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1845 // version 3.0
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1846 else if (*arg == '>' && (varp == (char_u *)&p_dir
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1847 || varp == (char_u *)&p_bdir))
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1848 ++arg;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1849
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1850 // Copy the new string into allocated memory.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1851 newval = stropt_copy_value(origval, &arg, op, flags);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1852 if (newval == NULL)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1853 goto done;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1854
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1855 // Expand environment variables and ~.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1856 // Don't do it when adding without inserting a comma.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1857 if (op == OP_NONE || (flags & P_COMMA))
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1858 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1859 newval = stropt_expand_envvar(opt_idx, origval, newval, op);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1860 if (newval == NULL)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1861 goto done;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1862 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1863
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1864 // locate newval[] in origval[] when removing it and when adding to
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1865 // avoid duplicates
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1866 int len = 0;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1867 if (op == OP_REMOVING || (flags & P_NODUP))
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1868 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1869 len = (int)STRLEN(newval);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1870 s = find_dup_item(origval, newval, flags);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1871
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1872 // do not add if already there
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1873 if ((op == OP_ADDING || op == OP_PREPENDING) && s != NULL)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1874 {
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1875 op = OP_NONE;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1876 STRCPY(newval, origval);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1877 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1878
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1879 // if no duplicate, move pointer to end of original value
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1880 if (s == NULL)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1881 s = origval + (int)STRLEN(origval);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1882 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1883
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1884 // concatenate the two strings; add a ',' if needed
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1885 if (op == OP_ADDING || op == OP_PREPENDING)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1886 stropt_concat_with_comma(origval, newval, op, flags);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1887 else if (op == OP_REMOVING)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1888 // Remove newval[] from origval[]. (Note: "len" has been set above
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1889 // and is used here).
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1890 stropt_remove_val(origval, newval, flags, s, len);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1891
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1892 if (flags & P_FLAGLIST)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1893 // Remove flags that appear twice.
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1894 stropt_remove_dupflags(newval, flags);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1895 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1896
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1897 done:
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1898 if (save_arg != NULL)
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1899 arg = save_arg; // arg was temporarily changed, restore it
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1900 *argp = arg;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1901 *origval_arg = origval;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1902 *origval_l_arg = origval_l;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1903 *origval_g_arg = origval_g;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1904 *oldval_arg = oldval;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1905 *op_arg = op;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1906
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1907 return newval;
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1908 }
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1909
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1910 /*
30403
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1911 * Part of do_set() for string options.
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1912 * Returns FAIL on failure, do not process further options.
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1913 */
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1914 static int
31952
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1915 do_set_option_string(
30403
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1916 int opt_idx,
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1917 int opt_flags,
30409
aea53db7eeec patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents: 30403
diff changeset
1918 char_u **argp,
30403
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1919 int nextchar,
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1920 set_op_T op_arg,
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1921 int flags,
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1922 int cp_val,
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1923 char_u *varp_arg,
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1924 char *errbuf,
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1925 int *value_checked,
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1926 char **errmsg)
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1927 {
30409
aea53db7eeec patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents: 30403
diff changeset
1928 char_u *arg = *argp;
30403
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1929 set_op_T op = op_arg;
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1930 char_u *varp = varp_arg;
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1931 char_u *oldval = NULL; // previous value if *varp
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1932 char_u *newval;
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1933 char_u *origval = NULL;
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1934 char_u *origval_l = NULL;
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1935 char_u *origval_g = NULL;
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1936 #if defined(FEAT_EVAL)
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1937 char_u *saved_origval = NULL;
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1938 char_u *saved_origval_l = NULL;
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1939 char_u *saved_origval_g = NULL;
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1940 char_u *saved_newval = NULL;
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1941 #endif
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1942
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1943 // When using ":set opt=val" for a global option
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1944 // with a local value the local value will be
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1945 // reset, use the global value here.
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1946 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1947 && ((int)options[opt_idx].indir & PV_BOTH))
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1948 varp = options[opt_idx].var;
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1949
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1950 // The old value is kept until we are sure that the new value is valid.
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1951 oldval = *(char_u **)varp;
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1952
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1953 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1954 {
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1955 origval_l = *(char_u **)get_varp_scope(
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1956 &(options[opt_idx]), OPT_LOCAL);
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1957 origval_g = *(char_u **)get_varp_scope(
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1958 &(options[opt_idx]), OPT_GLOBAL);
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1959
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1960 // A global-local string option might have an empty option as value to
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1961 // indicate that the global value should be used.
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1962 if (((int)options[opt_idx].indir & PV_BOTH)
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1963 && origval_l == empty_option)
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1964 origval_l = origval_g;
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1965 }
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1966
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1967 // When setting the local value of a global option, the old value may be
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1968 // the global value.
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1969 if (((int)options[opt_idx].indir & PV_BOTH) && (opt_flags & OPT_LOCAL))
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1970 origval = *(char_u **)get_varp(&options[opt_idx]);
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1971 else
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1972 origval = oldval;
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1973
31952
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1974 // Get the new value for the option
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1975 newval = stropt_get_newval(nextchar, opt_idx, &arg, varp, &origval,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1976 &origval_l, &origval_g, &oldval, &op, flags,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1977 cp_val);
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1978
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
1979 // Set the new value.
30403
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1980 *(char_u **)(varp) = newval;
31958
b08c410578a5 patch 9.0.1311: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 31952
diff changeset
1981 if (newval == NULL)
b08c410578a5 patch 9.0.1311: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 31952
diff changeset
1982 *(char_u **)(varp) = empty_option;
30403
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1983
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1984 #if defined(FEAT_EVAL)
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1985 if (!starting
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1986 # ifdef FEAT_CRYPT
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1987 && options[opt_idx].indir != PV_KEY
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1988 # endif
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1989 && origval != NULL && newval != NULL)
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1990 {
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1991 // origval may be freed by did_set_string_option(), make a copy.
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1992 saved_origval = vim_strsave(origval);
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1993 // newval (and varp) may become invalid if the buffer is closed by
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1994 // autocommands.
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1995 saved_newval = vim_strsave(newval);
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1996 if (origval_l != NULL)
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1997 saved_origval_l = vim_strsave(origval_l);
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1998 if (origval_g != NULL)
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
1999 saved_origval_g = vim_strsave(origval_g);
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2000 }
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2001 #endif
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2002
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2003 {
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2004 long_u *p = insecure_flag(opt_idx, opt_flags);
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2005 int secure_saved = secure;
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2006
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2007 // When an option is set in the sandbox, from a modeline or in secure
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2008 // mode, then deal with side effects in secure mode. Also when the
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2009 // value was set with the P_INSECURE flag and is not completely
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2010 // replaced.
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2011 if ((opt_flags & OPT_MODELINE)
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2012 #ifdef HAVE_SANDBOX
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2013 || sandbox != 0
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2014 #endif
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2015 || (op != OP_NONE && (*p & P_INSECURE)))
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2016 secure = 1;
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2017
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2018 // Handle side effects, and set the global value for ":set" on local
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2019 // options. Note: when setting 'syntax' or 'filetype' autocommands may
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2020 // be triggered that can cause havoc.
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2021 *errmsg = did_set_string_option(
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
2022 opt_idx, (char_u **)varp, oldval, newval, errbuf,
30403
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2023 opt_flags, value_checked);
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2024
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2025 secure = secure_saved;
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2026 }
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2027
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2028 #if defined(FEAT_EVAL)
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2029 if (*errmsg == NULL)
31259
a7dba627a21b patch 9.0.0963: function name does not match autocmd event name
Bram Moolenaar <Bram@vim.org>
parents: 31174
diff changeset
2030 trigger_optionset_string(opt_idx, opt_flags, saved_origval,
30403
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2031 saved_origval_l, saved_origval_g, saved_newval);
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2032 vim_free(saved_origval);
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2033 vim_free(saved_origval_l);
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2034 vim_free(saved_origval_g);
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2035 vim_free(saved_newval);
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2036 #endif
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2037
30409
aea53db7eeec patch 9.0.0540: assigning stack variable to argument confuses Coverity
Bram Moolenaar <Bram@vim.org>
parents: 30403
diff changeset
2038 *argp = arg;
30403
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2039 return *errmsg == NULL ? OK : FAIL;
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2040 }
42d592459521 patch 9.0.0537: the do_set() function is much too long
Bram Moolenaar <Bram@vim.org>
parents: 30226
diff changeset
2041
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2042 /*
31908
1ae3ad2e3d03 patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 31904
diff changeset
2043 * Set a boolean option.
1ae3ad2e3d03 patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 31904
diff changeset
2044 * Returns an untranslated error message or NULL.
31902
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2045 */
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2046 static char *
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2047 do_set_option_bool(
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2048 int opt_idx,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2049 int opt_flags,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2050 set_prefix_T prefix,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2051 long_u flags,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2052 char_u *varp,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2053 int nextchar,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2054 int afterchar,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2055 int cp_val)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2056
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2057 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2058 varnumber_T value;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2059
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2060 if (nextchar == '=' || nextchar == ':')
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2061 return e_invalid_argument;
31908
1ae3ad2e3d03 patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 31904
diff changeset
2062 if (opt_idx < 0 || varp == NULL)
1ae3ad2e3d03 patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 31904
diff changeset
2063 return NULL; // "cannot happen"
31902
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2064
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
2065 // ":set opt!": invert
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
2066 // ":set opt&": reset to default value
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
2067 // ":set opt<": reset to global value
31902
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2068 if (nextchar == '!')
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2069 value = *(int *)(varp) ^ 1;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2070 else if (nextchar == '&')
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2071 value = (int)(long)(long_i)options[opt_idx].def_val[
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2072 ((flags & P_VI_DEF) || cp_val) ? VI_DEFAULT : VIM_DEFAULT];
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2073 else if (nextchar == '<')
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2074 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2075 // For 'autoread' -1 means to use global value.
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2076 if ((int *)varp == &curbuf->b_p_ar && opt_flags == OPT_LOCAL)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2077 value = -1;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2078 else
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2079 value = *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2080 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2081 else
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2082 {
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
2083 // ":set invopt": invert
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
2084 // ":set opt" or ":set noopt": set or reset
31902
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2085 if (nextchar != NUL && !VIM_ISWHITE(afterchar))
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2086 return e_trailing_characters;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2087 if (prefix == PREFIX_INV)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2088 value = *(int *)(varp) ^ 1;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2089 else
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2090 value = prefix == PREFIX_NO ? 0 : 1;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2091 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2092
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2093 return set_bool_option(opt_idx, varp, (int)value, opt_flags);
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2094 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2095
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2096 /*
31908
1ae3ad2e3d03 patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 31904
diff changeset
2097 * Set a numeric option.
1ae3ad2e3d03 patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 31904
diff changeset
2098 * Returns an untranslated error message or NULL.
31902
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2099 */
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2100 static char *
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2101 do_set_option_numeric(
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2102 int opt_idx,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2103 int opt_flags,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2104 char_u **argp,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2105 int nextchar,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2106 set_op_T op,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2107 long_u flags,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2108 int cp_val,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2109 char_u *varp,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2110 char *errbuf,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2111 size_t errbuflen)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2112 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2113 char_u *arg = *argp;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2114 varnumber_T value;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2115 int i;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2116 char *errmsg = NULL;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2117
31908
1ae3ad2e3d03 patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 31904
diff changeset
2118 if (opt_idx < 0 || varp == NULL)
1ae3ad2e3d03 patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 31904
diff changeset
2119 return NULL; // "cannot happen"
1ae3ad2e3d03 patch 9.0.1286: Coverity warns for using a NULL pointer
Bram Moolenaar <Bram@vim.org>
parents: 31904
diff changeset
2120 //
31902
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2121 /*
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2122 * Different ways to set a number option:
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2123 * & set to default value
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2124 * < set to global value
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2125 * <xx> accept special key codes for 'wildchar'
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2126 * c accept any non-digit for 'wildchar'
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2127 * [-]0-9 set number
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2128 * other error
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2129 */
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2130 ++arg;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2131 if (nextchar == '&')
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2132 value = (long)(long_i)options[opt_idx].def_val[
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2133 ((flags & P_VI_DEF) || cp_val) ? VI_DEFAULT : VIM_DEFAULT];
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2134 else if (nextchar == '<')
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2135 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2136 // For 'undolevels' NO_LOCAL_UNDOLEVEL means to
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2137 // use the global value.
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2138 if ((long *)varp == &curbuf->b_p_ul && opt_flags == OPT_LOCAL)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2139 value = NO_LOCAL_UNDOLEVEL;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2140 else
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2141 value = *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2142 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2143 else if (((long *)varp == &p_wc || (long *)varp == &p_wcm)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2144 && (*arg == '<'
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2145 || *arg == '^'
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2146 || (*arg != NUL
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2147 && (!arg[1] || VIM_ISWHITE(arg[1]))
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2148 && !VIM_ISDIGIT(*arg))))
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2149 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2150 value = string_to_key(arg, FALSE);
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2151 if (value == 0 && (long *)varp != &p_wcm)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2152 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2153 errmsg = e_invalid_argument;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2154 goto skip;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2155 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2156 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2157 else if (*arg == '-' || VIM_ISDIGIT(*arg))
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2158 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2159 // Allow negative (for 'undolevels'), octal and hex numbers.
32098
39f4126d2a0d patch 9.0.1380: CTRL-X on 2**64 subtracts two
Bram Moolenaar <Bram@vim.org>
parents: 32096
diff changeset
2160 vim_str2nr(arg, NULL, &i, STR2NR_ALL, &value, NULL, 0, TRUE, NULL);
31902
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2161 if (i == 0 || (arg[i] != NUL && !VIM_ISWHITE(arg[i])))
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2162 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2163 errmsg = e_number_required_after_equal;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2164 goto skip;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2165 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2166 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2167 else
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2168 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2169 errmsg = e_number_required_after_equal;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2170 goto skip;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2171 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2172
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2173 if (op == OP_ADDING)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2174 value = *(long *)varp + value;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2175 else if (op == OP_PREPENDING)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2176 value = *(long *)varp * value;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2177 else if (op == OP_REMOVING)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2178 value = *(long *)varp - value;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2179
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2180 errmsg = set_num_option(opt_idx, varp, value, errbuf, errbuflen,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2181 opt_flags);
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2182
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2183 skip:
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2184 *argp = arg;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2185 return errmsg;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2186 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2187
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2188 /*
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2189 * Set a key code (t_xx) option
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2190 */
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2191 static char *
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2192 do_set_option_keycode(char_u **argp, char_u *key_name, int nextchar)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2193 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2194 char_u *arg = *argp;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2195 char_u *p;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2196
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2197 if (nextchar == '&')
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2198 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2199 if (add_termcap_entry(key_name, TRUE) == FAIL)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2200 return e_not_found_in_termcap;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2201 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2202 else
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2203 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2204 ++arg; // jump to after the '=' or ':'
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2205 for (p = arg; *p && !VIM_ISWHITE(*p); ++p)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2206 if (*p == '\\' && p[1] != NUL)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2207 ++p;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2208 nextchar = *p;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2209 *p = NUL;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2210 add_termcode(key_name, arg, FALSE);
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2211 *p = nextchar;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2212 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2213 if (full_screen)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2214 ttest(FALSE);
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2215 redraw_all_later(UPD_CLEAR);
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2216
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2217 *argp = arg;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2218 return NULL;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2219 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2220
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2221 /*
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2222 * Set an option to a new value.
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2223 */
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2224 static char *
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2225 do_set_option_value(
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2226 int opt_idx,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2227 int opt_flags,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2228 char_u **argp,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2229 set_prefix_T prefix,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2230 set_op_T op,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2231 long_u flags,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2232 char_u *varp,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2233 char_u *key_name,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2234 int nextchar,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2235 int afterchar,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2236 int cp_val,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2237 int *stopopteval,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2238 char *errbuf,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2239 size_t errbuflen)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2240 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2241 int value_checked = FALSE;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2242 char *errmsg = NULL;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2243 char_u *arg = *argp;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2244
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2245 if (flags & P_BOOL)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2246 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2247 // boolean option
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2248 errmsg = do_set_option_bool(opt_idx, opt_flags, prefix, flags, varp,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2249 nextchar, afterchar, cp_val);
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2250 if (errmsg != NULL)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2251 goto skip;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2252 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2253 else
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2254 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2255 // numeric or string option
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2256 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2257 || prefix != PREFIX_NONE)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2258 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2259 errmsg = e_invalid_argument;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2260 goto skip;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2261 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2262
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2263 if (flags & P_NUM)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2264 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2265 // numeric option
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2266 errmsg = do_set_option_numeric(opt_idx, opt_flags, &arg, nextchar,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2267 op, flags, cp_val, varp,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2268 errbuf, errbuflen);
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2269 if (errmsg != NULL)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2270 goto skip;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2271 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2272 else if (opt_idx >= 0)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2273 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2274 // string option
31952
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
2275 if (do_set_option_string(opt_idx, opt_flags, &arg, nextchar, op,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
2276 flags, cp_val, varp, errbuf,
360efef7e5df patch 9.0.1308: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31950
diff changeset
2277 &value_checked, &errmsg) == FAIL)
31902
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2278 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2279 if (errmsg != NULL)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2280 goto skip;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2281 *stopopteval = TRUE;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2282 goto skip;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2283 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2284 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2285 else
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2286 {
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2287 // key code option
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2288 errmsg = do_set_option_keycode(&arg, key_name, nextchar);
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2289 if (errmsg != NULL)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2290 goto skip;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2291 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2292 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2293
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2294 if (opt_idx >= 0)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2295 did_set_option(opt_idx, opt_flags, op == OP_NONE, value_checked);
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2296
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2297 skip:
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2298 *argp = arg;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2299 return errmsg;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2300 }
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2301
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2302 /*
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2303 * Set an option to a new value.
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2304 * Return NULL if OK, return an untranslated error message when something is
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2305 * wrong. "errbuf[errbuflen]" can be used to create the error message.
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2306 */
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2307 static char *
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2308 do_set_option(
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2309 int opt_flags,
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2310 char_u **argp,
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2311 char_u *arg_start,
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2312 char_u **startarg,
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2313 int *did_show,
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2314 int *stopopteval,
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2315 char *errbuf,
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2316 size_t errbuflen)
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2317 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2318 int opt_idx;
31902
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2319 char_u *arg;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2320 set_prefix_T prefix; // no prefix, "no" prefix or "inv" prefix
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2321 set_op_T op;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2322 long_u flags; // flags for current option
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2323 char_u *varp; // pointer to variable for current option
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2324 char_u key_name[2];
31902
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2325 int nextchar; // next non-white char after option name
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2326 int afterchar; // character just after option name
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2327 char *errmsg = NULL;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2328 int key;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2329 int len;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2330
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2331 prefix = get_option_prefix(argp);
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2332 arg = *argp;
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2333
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2334 // find end of name
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2335 key = 0;
31902
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2336 if (parse_option_name(arg, &opt_idx, &len, &key) == FAIL)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2337 return e_invalid_argument;
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2338
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2339 // remember character after option name
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2340 afterchar = arg[len];
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2341
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2342 if (in_vim9script())
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2343 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2344 char_u *p = skipwhite(arg + len);
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2345
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2346 // disallow white space before =val, +=val, -=val, ^=val
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2347 if (p > arg + len && (p[0] == '='
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2348 || (vim_strchr((char_u *)"+-^", p[0]) != NULL
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2349 && p[1] == '=')))
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2350 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2351 errmsg = e_no_white_space_allowed_between_option_and;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2352 arg = p;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2353 *startarg = p;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2354 goto skip;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2355 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2356 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2357 else
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2358 // skip white space, allow ":set ai ?", ":set hlsearch !"
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2359 while (VIM_ISWHITE(arg[len]))
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2360 ++len;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2361
31902
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2362 op = get_opt_op(arg + len);
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2363 if (op != OP_NONE)
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2364 len++;
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2365
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2366 nextchar = arg[len];
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2367
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2368 if (opt_idx == -1 && key == 0) // found a mismatch: skip
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2369 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2370 if (in_vim9script() && arg > arg_start
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2371 && vim_strchr((char_u *)"!&<", *arg) != NULL)
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2372 errmsg = e_no_white_space_allowed_between_option_and;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2373 else
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2374 errmsg = e_unknown_option;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2375 goto skip;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2376 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2377
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2378 if (opt_idx >= 0)
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2379 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2380 if (options[opt_idx].var == NULL) // hidden option: skip
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2381 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2382 // Only give an error message when requesting the value of
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2383 // a hidden option, ignore setting it.
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2384 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2385 && (!(options[opt_idx].flags & P_BOOL)
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2386 || nextchar == '?'))
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2387 errmsg = e_option_not_supported;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2388 goto skip;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2389 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2390
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2391 flags = options[opt_idx].flags;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2392 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2393 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2394 else
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2395 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2396 flags = P_STRING;
31904
a4358b58d3fb patch 9.0.1284: compiler warnings for uninitialized variables
Bram Moolenaar <Bram@vim.org>
parents: 31902
diff changeset
2397 varp = NULL;
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2398 if (key < 0)
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2399 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2400 key_name[0] = KEY2TERMCAP0(key);
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2401 key_name[1] = KEY2TERMCAP1(key);
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2402 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2403 else
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2404 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2405 key_name[0] = KS_KEY;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2406 key_name[1] = (key & 0xff);
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2407 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2408 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2409
31902
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2410 // Make sure the option value can be changed.
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2411 if (validate_opt_idx(opt_idx, opt_flags, flags, &errmsg) == FAIL)
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2412 goto skip;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2413
31904
a4358b58d3fb patch 9.0.1284: compiler warnings for uninitialized variables
Bram Moolenaar <Bram@vim.org>
parents: 31902
diff changeset
2414 int cp_val = p_cp;
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2415 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2416 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2417 arg += len;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2418 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2419 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2420 if (arg[3] == 'm') // "opt&vim": set to Vim default
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2421 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2422 cp_val = FALSE;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2423 arg += 3;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2424 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2425 else // "opt&vi": set to Vi default
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2426 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2427 cp_val = TRUE;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2428 arg += 2;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2429 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2430 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2431 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2432 && arg[1] != NUL && !VIM_ISWHITE(arg[1]))
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2433 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2434 errmsg = e_trailing_characters;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2435 goto skip;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2436 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2437 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2438
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
2439 // Allow '=' and ':' for historical reasons (MSDOS command.com).
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
2440 // Allows only one '=' character per "set" command line. grrr. (jw)
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2441 if (nextchar == '?'
31902
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2442 || (prefix == PREFIX_NONE
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2443 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2444 && !(flags & P_BOOL)))
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2445 {
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
2446 // print value
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2447 if (*did_show)
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2448 msg_putchar('\n'); // cursor below last one
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2449 else
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2450 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2451 gotocmdline(TRUE); // cursor at status line
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2452 *did_show = TRUE; // remember that we did a line
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2453 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2454 if (opt_idx >= 0)
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2455 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2456 showoneopt(&options[opt_idx], opt_flags);
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2457 #ifdef FEAT_EVAL
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2458 if (p_verbose > 0)
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2459 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2460 // Mention where the option was last set.
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2461 if (varp == options[opt_idx].var)
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2462 last_set_msg(options[opt_idx].script_ctx);
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2463 else if ((int)options[opt_idx].indir & PV_WIN)
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2464 last_set_msg(curwin->w_p_script_ctx[
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2465 (int)options[opt_idx].indir & PV_MASK]);
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2466 else if ((int)options[opt_idx].indir & PV_BUF)
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2467 last_set_msg(curbuf->b_p_script_ctx[
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2468 (int)options[opt_idx].indir & PV_MASK]);
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2469 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2470 #endif
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2471 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2472 else
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2473 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2474 char_u *p;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2475
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2476 p = find_termcode(key_name);
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2477 if (p == NULL)
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2478 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2479 errmsg = e_key_code_not_set;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2480 goto skip;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2481 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2482 else
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2483 (void)show_one_termcode(key_name, p, TRUE);
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2484 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2485 if (nextchar != '?'
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2486 && nextchar != NUL && !VIM_ISWHITE(afterchar))
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2487 errmsg = e_trailing_characters;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2488 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2489 else
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2490 {
31902
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2491 errmsg = do_set_option_value(opt_idx, opt_flags, &arg, prefix, op,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2492 flags, varp, key_name, nextchar,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2493 afterchar, cp_val, stopopteval, errbuf,
1c5ef864fe4c patch 9.0.1283: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31886
diff changeset
2494 errbuflen);
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2495 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2496
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2497 skip:
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2498 *argp = arg;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2499 return errmsg;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2500 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2501
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2502 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2503 * Parse 'arg' for option settings.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2504 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2505 * 'arg' may be IObuff, but only when no errors can be present and option
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2506 * does not need to be expanded with option_expand().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2507 * "opt_flags":
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2508 * 0 for ":set"
26400
d26bab4f6aca patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents: 26388
diff changeset
2509 * OPT_GLOBAL for ":setglobal"
d26bab4f6aca patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents: 26388
diff changeset
2510 * OPT_LOCAL for ":setlocal" and a modeline
d26bab4f6aca patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents: 26388
diff changeset
2511 * OPT_MODELINE for a modeline
d26bab4f6aca patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents: 26388
diff changeset
2512 * OPT_WINONLY to only set window-local options
d26bab4f6aca patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents: 26388
diff changeset
2513 * OPT_NOWIN to skip setting window-local options
d26bab4f6aca patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents: 26388
diff changeset
2514 * OPT_ONECOLUMN do not use multiple columns
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2515 *
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2516 * Returns FAIL if an error is detected, OK otherwise.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2517 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2518 int
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2519 do_set(
25174
b32c83317492 patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents: 25084
diff changeset
2520 char_u *arg_start, // option string (may be written to!)
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2521 int opt_flags)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2522 {
25174
b32c83317492 patch 8.2.3123: Vim9: confusing error when using white space after option
Bram Moolenaar <Bram@vim.org>
parents: 25084
diff changeset
2523 char_u *arg = arg_start;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2524 int i;
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2525 int did_show = FALSE; // already showed one value
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2526
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2527 if (*arg == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2528 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2529 showoptions(0, opt_flags);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
2530 did_show = TRUE;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
2531 goto theend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2532 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2533
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2534 while (*arg != NUL) // loop to process all options
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2535 {
31766
9f1504e36ae9 patch 9.0.1215: using isalpha() adds dependency on current locale
Bram Moolenaar <Bram@vim.org>
parents: 31752
diff changeset
2536 if (STRNCMP(arg, "all", 3) == 0 && !ASCII_ISALPHA(arg[3])
36
125e80798a85 updated for version 7.0021
vimboss
parents: 29
diff changeset
2537 && !(opt_flags & OPT_MODELINE))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2538 {
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
2539 // ":set all" show all options.
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
2540 // ":set all&" set all options to their default value.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2541 arg += 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2542 if (*arg == '&')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2543 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2544 ++arg;
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2545 // Only for :set command set global value of local options.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2546 set_options_default(OPT_FREE | opt_flags);
7040
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
2547 didset_options();
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
2548 didset_options2();
29732
89e1d67814a9 patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents: 29546
diff changeset
2549 redraw_all_later(UPD_CLEAR);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2550 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2551 else
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
2552 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2553 showoptions(1, opt_flags);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
2554 did_show = TRUE;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
2555 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2556 }
36
125e80798a85 updated for version 7.0021
vimboss
parents: 29
diff changeset
2557 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2558 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2559 showoptions(2, opt_flags);
26400
d26bab4f6aca patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents: 26388
diff changeset
2560 show_termcodes(opt_flags);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
2561 did_show = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2562 arg += 7;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2563 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2564 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2565 {
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2566 int stopopteval = FALSE;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2567 char *errmsg = NULL;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2568 char errbuf[80];
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2569 char_u *startarg = arg;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2570
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2571 errmsg = do_set_option(opt_flags, &arg, arg_start, &startarg,
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2572 &did_show, &stopopteval, errbuf,
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2573 sizeof(errbuf));
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2574 if (stopopteval)
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2575 break;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2576
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
2577 // Advance to next argument.
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
2578 // - skip until a blank found, taking care of backslashes
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
2579 // - skip blanks
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
2580 // - skip one "=val" argument (for hidden options ":set gfn =xx")
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2581 for (i = 0; i < 2 ; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2582 {
11129
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11127
diff changeset
2583 while (*arg != NUL && !VIM_ISWHITE(*arg))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2584 if (*arg++ == '\\' && *arg != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2585 ++arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2586 arg = skipwhite(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2587 if (*arg != '=')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2588 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2589 }
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2590
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2591 if (errmsg != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2592 {
31886
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2593 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2594 i = (int)STRLEN(IObuff) + 2;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2595 if (i + (arg - startarg) < IOSIZE)
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2596 {
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2597 // append the argument with the error
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2598 STRCAT(IObuff, ": ");
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2599 mch_memmove(IObuff + i, startarg, (arg - startarg));
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2600 IObuff[i + (arg - startarg)] = NUL;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2601 }
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2602 // make sure all characters are printable
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2603 trans_characters(IObuff, IOSIZE);
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2604
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2605 ++no_wait_return; // wait_return() done later
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2606 emsg((char *)IObuff); // show error highlighted
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2607 --no_wait_return;
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2608
b741e5243e58 patch 9.0.1275: the code for setting options is too complicated
Bram Moolenaar <Bram@vim.org>
parents: 31819
diff changeset
2609 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2610 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2611 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2612
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2613 arg = skipwhite(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2614 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2615
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
2616 theend:
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
2617 if (silent_mode && did_show)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
2618 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2619 // After displaying option values in silent mode.
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
2620 silent_mode = FALSE;
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2621 info_message = TRUE; // use mch_msg(), not mch_errmsg()
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
2622 msg_putchar('\n');
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2623 cursor_on(); // msg_start() switches it off
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
2624 out_flush();
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
2625 silent_mode = TRUE;
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2626 info_message = FALSE; // use mch_msg(), not mch_errmsg()
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
2627 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
2628
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2629 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2630 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2631
634
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2632 /*
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2633 * Call this when an option has been given a new value through a user command.
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2634 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2635 */
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
2636 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2637 did_set_option(
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2638 int opt_idx,
15066
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 15062
diff changeset
2639 int opt_flags, // possibly with OPT_MODELINE
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 15062
diff changeset
2640 int new_value, // value was replaced completely
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 15062
diff changeset
2641 int value_checked) // value was checked to be safe, no need to set the
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 15062
diff changeset
2642 // P_INSECURE flag.
634
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2643 {
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2644 long_u *p;
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2645
634
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2646 options[opt_idx].flags |= P_WAS_SET;
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2647
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2648 // When an option is set in the sandbox, from a modeline or in secure mode
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2649 // set the P_INSECURE flag. Otherwise, if a new value is stored reset the
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2650 // flag.
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2651 p = insecure_flag(opt_idx, opt_flags);
15066
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 15062
diff changeset
2652 if (!value_checked && (secure
634
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2653 #ifdef HAVE_SANDBOX
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2654 || sandbox != 0
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2655 #endif
15066
40d9218b2b12 patch 8.1.0544: setting 'filetype' in a modeline causes an error
Bram Moolenaar <Bram@vim.org>
parents: 15062
diff changeset
2656 || (opt_flags & OPT_MODELINE)))
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2657 *p = *p | P_INSECURE;
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2658 else if (new_value)
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2659 *p = *p & ~P_INSECURE;
634
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2660 }
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2661
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2662 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2663 * Convert a key name or string into a key value.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2664 * Used for 'wildchar' and 'cedit' options.
11764
b82dad3fa176 patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents: 11757
diff changeset
2665 * When "multi_byte" is TRUE allow for multi-byte characters.
b82dad3fa176 patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents: 11757
diff changeset
2666 */
b82dad3fa176 patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents: 11757
diff changeset
2667 int
b82dad3fa176 patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents: 11757
diff changeset
2668 string_to_key(char_u *arg, int multi_byte)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2669 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2670 if (*arg == '<')
14381
d9e6eec551e1 patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents: 14313
diff changeset
2671 return find_key_option(arg + 1, TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2672 if (*arg == '^')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2673 return Ctrl_chr(arg[1]);
11764
b82dad3fa176 patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents: 11757
diff changeset
2674 if (multi_byte)
b82dad3fa176 patch 8.0.0764: 'termkey' does not work yet
Christian Brabandt <cb@256bit.org>
parents: 11757
diff changeset
2675 return PTR2CHAR(arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2676 return *arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2677 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2678
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2679 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2680 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2681 * maketitle() to create and display it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2682 * When switching the title or icon off, call mch_restore_title() to get
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2683 * the old value back.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2684 */
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
2685 void
14087
1d25a3e8e03c patch 8.1.0061: window title is wrong after resetting and setting 'title'
Christian Brabandt <cb@256bit.org>
parents: 14057
diff changeset
2686 did_set_title(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2687 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2688 if (starting != NO_SCREEN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2689 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2690 && !gui.starting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2691 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2692 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2693 maketitle();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2694 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2695
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2696 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2697 * set_options_bin - called when 'bin' changes value.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2698 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2699 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2700 set_options_bin(
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2701 int oldval,
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2702 int newval,
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2703 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2704 {
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
2705 // The option values that are changed when 'bin' changes are
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
2706 // copied when 'bin is set and restored when 'bin' is reset.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2707 if (newval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2708 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2709 if (!oldval) // switched on
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2710 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2711 if (!(opt_flags & OPT_GLOBAL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2712 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2713 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2714 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2715 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2716 curbuf->b_p_et_nobin = curbuf->b_p_et;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2717 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2718 if (!(opt_flags & OPT_LOCAL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2719 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2720 p_tw_nobin = p_tw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2721 p_wm_nobin = p_wm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2722 p_ml_nobin = p_ml;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2723 p_et_nobin = p_et;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2724 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2725 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2726
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2727 if (!(opt_flags & OPT_GLOBAL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2728 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2729 curbuf->b_p_tw = 0; // no automatic line wrap
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2730 curbuf->b_p_wm = 0; // no automatic line wrap
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2731 curbuf->b_p_ml = 0; // no modelines
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2732 curbuf->b_p_et = 0; // no expandtab
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2733 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2734 if (!(opt_flags & OPT_LOCAL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2735 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2736 p_tw = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2737 p_wm = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2738 p_ml = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2739 p_et = FALSE;
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2740 p_bin = TRUE; // needed when called for the "-b" argument
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2741 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2742 }
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2743 else if (oldval) // switched off
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2744 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2745 if (!(opt_flags & OPT_GLOBAL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2746 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2747 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2748 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2749 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2750 curbuf->b_p_et = curbuf->b_p_et_nobin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2751 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2752 if (!(opt_flags & OPT_LOCAL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2753 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2754 p_tw = p_tw_nobin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2755 p_wm = p_wm_nobin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2756 p_ml = p_ml_nobin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2757 p_et = p_et_nobin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2758 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2759 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2760 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2761
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2762 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2763 * Expand environment variables for some string options.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2764 * These string options cannot be indirect!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2765 * If "val" is NULL expand the current value of the option.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2766 * Return pointer to NameBuff, or NULL when not expanded.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2767 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2768 static char_u *
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2769 option_expand(int opt_idx, char_u *val)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2770 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2771 // if option doesn't need expansion nothing to do
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2772 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2773 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2774
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2775 // If val is longer than MAXPATHL no meaningful expansion can be done,
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2776 // expand_env() would truncate the string.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2777 if (val != NULL && STRLEN(val) > MAXPATHL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2778 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2779
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2780 if (val == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2781 val = *(char_u **)options[opt_idx].var;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2782
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2783 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2784 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2785 * Escape spaces when expanding 'tags', they are used to separate file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2786 * names.
374
575dacb554d8 updated for version 7.0096
vimboss
parents: 359
diff changeset
2787 * For 'spellsuggest' expand after "file:".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2788 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2789 expand_env_esc(val, NameBuff, MAXPATHL,
1408
db8309865794 updated for version 7.1-123
vimboss
parents: 1404
diff changeset
2790 (char_u **)options[opt_idx].var == &p_tags, FALSE,
744
07f7b4a7755c updated for version 7.0222
vimboss
parents: 731
diff changeset
2791 #ifdef FEAT_SPELL
374
575dacb554d8 updated for version 7.0096
vimboss
parents: 359
diff changeset
2792 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
575dacb554d8 updated for version 7.0096
vimboss
parents: 359
diff changeset
2793 #endif
575dacb554d8 updated for version 7.0096
vimboss
parents: 359
diff changeset
2794 NULL);
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2795 if (STRCMP(NameBuff, val) == 0) // they are the same
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2796 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2797
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2798 return NameBuff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2799 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2800
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2801 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2802 * After setting various option values: recompute variables that depend on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2803 * option values.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2804 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2805 static void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2806 didset_options(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2807 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2808 // initialize the table for 'iskeyword' et.al.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2809 (void)init_chartab();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2810
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
2811 didset_string_options();
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
2812
744
07f7b4a7755c updated for version 7.0222
vimboss
parents: 731
diff changeset
2813 #ifdef FEAT_SPELL
484
f012c4ed8c38 updated for version 7.0132
vimboss
parents: 480
diff changeset
2814 (void)spell_check_msm();
374
575dacb554d8 updated for version 7.0096
vimboss
parents: 359
diff changeset
2815 (void)spell_check_sps();
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2248
diff changeset
2816 (void)compile_cap_prog(curwin->w_s);
7040
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
2817 (void)did_set_spell_option(TRUE);
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 323
diff changeset
2818 #endif
18156
c81370b3ede4 patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents: 18100
diff changeset
2819 // set cedit_key
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
2820 (void)did_set_cedit(NULL);
5995
ef83b423ebf7 updated for version 7.4.338
Bram Moolenaar <bram@vim.org>
parents: 5991
diff changeset
2821 #ifdef FEAT_LINEBREAK
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2822 // initialize the table for 'breakat'.
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
2823 did_set_breakat(NULL);
7040
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
2824 #endif
18156
c81370b3ede4 patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents: 18100
diff changeset
2825 after_copy_winopt(curwin);
7040
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
2826 }
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
2827
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
2828 /*
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
2829 * More side effects of setting options.
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
2830 */
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
2831 static void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2832 didset_options2(void)
7040
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
2833 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2834 // Initialize the highlight_attr[] table.
7040
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
2835 (void)highlight_changed();
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
2836
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2837 // Parse default for 'wildmode'
7040
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
2838 check_opt_wim();
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
2839
23952
44be09b25619 patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents: 23821
diff changeset
2840 // Parse default for 'listchars'.
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
2841 (void)set_listchars_option(curwin, curwin->w_p_lcs, TRUE);
23952
44be09b25619 patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents: 23821
diff changeset
2842
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2843 // Parse default for 'fillchars'.
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
2844 (void)set_fillchars_option(curwin, curwin->w_p_fcs, TRUE);
7040
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
2845
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
2846 #ifdef FEAT_CLIPBOARD
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2847 // Parse default for 'clipboard'
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
2848 (void)did_set_clipboard(NULL);
7040
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
2849 #endif
14175
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
2850 #ifdef FEAT_VARTABS
15858
3a45b89639fb patch 8.1.0936: may leak memory when using 'vartabstop'
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
2851 vim_free(curbuf->b_p_vsts_array);
25733
4b2616ffe32b patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents: 25487
diff changeset
2852 (void)tabstop_set(curbuf->b_p_vsts, &curbuf->b_p_vsts_array);
15858
3a45b89639fb patch 8.1.0936: may leak memory when using 'vartabstop'
Bram Moolenaar <Bram@vim.org>
parents: 15850
diff changeset
2853 vim_free(curbuf->b_p_vts_array);
25733
4b2616ffe32b patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents: 25487
diff changeset
2854 (void)tabstop_set(curbuf->b_p_vts, &curbuf->b_p_vts_array);
14175
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
2855 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2856 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2857
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2858 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2859 * Check for string options that are NULL (normally only termcap options).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2860 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2861 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2862 check_options(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2863 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2864 int opt_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2865
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2866 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2867 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2868 check_string_option((char_u **)get_varp(&(options[opt_idx])));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2869 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2870
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2871 /*
14867
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2872 * Return the option index found by a pointer into term_strings[].
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2873 * Return -1 if not found.
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2874 */
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2875 int
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2876 get_term_opt_idx(char_u **p)
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2877 {
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2878 int opt_idx;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2879
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2880 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2881 if (options[opt_idx].var == (char_u *)p)
14867
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2882 return opt_idx;
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2883 return -1; // cannot happen: didn't find it!
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2884 }
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2885
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2886 /*
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2887 * Mark a terminal option as allocated, found by a pointer into term_strings[].
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2888 * Return the option index or -1 if not found.
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2889 */
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2890 int
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2891 set_term_option_alloced(char_u **p)
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2892 {
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2893 int opt_idx = get_term_opt_idx(p);
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2894
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2895 if (opt_idx >= 0)
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2896 options[opt_idx].flags |= P_ALLOCED;
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
2897 return opt_idx;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2898 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2899
634
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2900 #if defined(FEAT_EVAL) || defined(PROTO)
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2901 /*
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2902 * Return TRUE when option "opt" was set from a modeline or in secure mode.
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2903 * Return FALSE when it wasn't.
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2904 * Return -1 for an unknown option.
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2905 */
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2906 int
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2907 was_set_insecurely(char_u *opt, int opt_flags)
634
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2908 {
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2909 int idx = findoption(opt);
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2910 long_u *flagp;
634
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2911
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2912 if (idx >= 0)
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2913 {
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2914 flagp = insecure_flag(idx, opt_flags);
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2915 return (*flagp & P_INSECURE) != 0;
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2916 }
10359
66f1b5bf3fa6 commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents: 10357
diff changeset
2917 internal_error("was_set_insecurely()");
634
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2918 return -1;
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2919 }
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2920
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2921 /*
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2922 * Get a pointer to the flags used for the P_INSECURE flag of option
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2923 * "opt_idx". For some local options a local flags field is used.
23821
bfc1ae959d9d patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents: 23505
diff changeset
2924 * NOTE: Caller must make sure that "curwin" is set to the window from which
bfc1ae959d9d patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents: 23505
diff changeset
2925 * the option is used.
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2926 */
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2927 static long_u *
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
2928 insecure_flag(int opt_idx, int opt_flags)
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2929 {
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2930 if (opt_flags & OPT_LOCAL)
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2931 switch ((int)options[opt_idx].indir)
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2932 {
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2933 #ifdef FEAT_STL_OPT
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
2934 case PV_STL: return &curwin->w_p_stl_flags;
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2935 #endif
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2936 #ifdef FEAT_EVAL
885
2548cf0a5f62 updated for version 7.0-011
vimboss
parents: 875
diff changeset
2937 # ifdef FEAT_FOLDING
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
2938 case PV_FDE: return &curwin->w_p_fde_flags;
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
2939 case PV_FDT: return &curwin->w_p_fdt_flags;
885
2548cf0a5f62 updated for version 7.0-011
vimboss
parents: 875
diff changeset
2940 # endif
790
c8680debe1cc updated for version 7.0230
vimboss
parents: 786
diff changeset
2941 # ifdef FEAT_BEVAL
c8680debe1cc updated for version 7.0230
vimboss
parents: 786
diff changeset
2942 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
c8680debe1cc updated for version 7.0230
vimboss
parents: 786
diff changeset
2943 # endif
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
2944 case PV_INDE: return &curbuf->b_p_inde_flags;
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
2945 case PV_FEX: return &curbuf->b_p_fex_flags;
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2946 # ifdef FEAT_FIND_ID
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
2947 case PV_INEX: return &curbuf->b_p_inex_flags;
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2948 # endif
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2949 #endif
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2950 }
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2951
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2952 // Nothing special, return global flags field.
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2953 return &options[opt_idx].flags;
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2954 }
634
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2955 #endif
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
2956
1805
a5e1d6526ac7 updated for version 7.2-103
vimboss
parents: 1801
diff changeset
2957 /*
a5e1d6526ac7 updated for version 7.2-103
vimboss
parents: 1801
diff changeset
2958 * Redraw the window title and/or tab page text later.
a5e1d6526ac7 updated for version 7.2-103
vimboss
parents: 1801
diff changeset
2959 */
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
2960 void redraw_titles(void)
1805
a5e1d6526ac7 updated for version 7.2-103
vimboss
parents: 1801
diff changeset
2961 {
a5e1d6526ac7 updated for version 7.2-103
vimboss
parents: 1801
diff changeset
2962 need_maketitle = TRUE;
a5e1d6526ac7 updated for version 7.2-103
vimboss
parents: 1801
diff changeset
2963 redraw_tabline = TRUE;
a5e1d6526ac7 updated for version 7.2-103
vimboss
parents: 1801
diff changeset
2964 }
a5e1d6526ac7 updated for version 7.2-103
vimboss
parents: 1801
diff changeset
2965
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2966 /*
16277
5ef25fa57f71 patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
2967 * Return TRUE if "val" is a valid name: only consists of alphanumeric ASCII
5ef25fa57f71 patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
2968 * characters or characters in "allowed".
5ef25fa57f71 patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
2969 */
17940
079e10a49ea1 patch 8.1.1966: some code in options.c fits better elsewhere
Bram Moolenaar <Bram@vim.org>
parents: 17845
diff changeset
2970 int
16277
5ef25fa57f71 patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
2971 valid_name(char_u *val, char *allowed)
5ef25fa57f71 patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
2972 {
5ef25fa57f71 patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
2973 char_u *s;
5ef25fa57f71 patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
2974
5ef25fa57f71 patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
2975 for (s = val; *s != NUL; ++s)
5ef25fa57f71 patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
2976 if (!ASCII_ISALNUM(*s) && vim_strchr((char_u *)allowed, *s) == NULL)
5ef25fa57f71 patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
2977 return FALSE;
5ef25fa57f71 patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
2978 return TRUE;
5ef25fa57f71 patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
2979 }
5ef25fa57f71 patch 8.1.1143: may pass weird strings to file name expansion
Bram Moolenaar <Bram@vim.org>
parents: 16223
diff changeset
2980
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2981 #if defined(FEAT_EVAL) || defined(PROTO)
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2982 /*
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
2983 * Set the script_ctx for an option, taking care of setting the buffer- or
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
2984 * window-local value.
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
2985 */
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
2986 void
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
2987 set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx)
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
2988 {
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
2989 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
2990 int indir = (int)options[opt_idx].indir;
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
2991 sctx_T new_script_ctx = script_ctx;
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
2992
20269
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 20237
diff changeset
2993 // Modeline already has the line number set.
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 20237
diff changeset
2994 if (!(opt_flags & OPT_MODELINE))
246101db63a4 patch 8.2.0690: line number of option set by modeline is wrong
Bram Moolenaar <Bram@vim.org>
parents: 20237
diff changeset
2995 new_script_ctx.sc_lnum += SOURCING_LNUM;
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
2996
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2997 // Remember where the option was set. For local options need to do that
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
2998 // in the buffer or window structure.
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
2999 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3000 options[opt_idx].script_ctx = new_script_ctx;
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
3001 if (both || (opt_flags & OPT_LOCAL))
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
3002 {
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
3003 if (indir & PV_BUF)
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3004 curbuf->b_p_script_ctx[indir & PV_MASK] = new_script_ctx;
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
3005 else if (indir & PV_WIN)
27289
e11682ba8c80 patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents: 27285
diff changeset
3006 {
14700
0a3b9ecf7cb8 patch 8.1.0362: cannot get the script line number when executing a function
Christian Brabandt <cb@256bit.org>
parents: 14479
diff changeset
3007 curwin->w_p_script_ctx[indir & PV_MASK] = new_script_ctx;
27289
e11682ba8c80 patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents: 27285
diff changeset
3008 if (both)
e11682ba8c80 patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents: 27285
diff changeset
3009 // also setting the "all buffers" value
e11682ba8c80 patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents: 27285
diff changeset
3010 curwin->w_allbuf_opt.wo_script_ctx[indir & PV_MASK] =
e11682ba8c80 patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents: 27285
diff changeset
3011 new_script_ctx;
e11682ba8c80 patch 8.2.4173: cannot use an import in 'foldexpr'
Bram Moolenaar <Bram@vim.org>
parents: 27285
diff changeset
3012 }
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
3013 }
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
3014 }
14867
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3015
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3016 /*
27303
9e0ac05f579a patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents: 27289
diff changeset
3017 * Get the script context of global option "name".
9e0ac05f579a patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents: 27289
diff changeset
3018 *
9e0ac05f579a patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents: 27289
diff changeset
3019 */
9e0ac05f579a patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents: 27289
diff changeset
3020 sctx_T *
9e0ac05f579a patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents: 27289
diff changeset
3021 get_option_sctx(char *name)
9e0ac05f579a patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents: 27289
diff changeset
3022 {
9e0ac05f579a patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents: 27289
diff changeset
3023 int idx = findoption((char_u *)name);
9e0ac05f579a patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents: 27289
diff changeset
3024
9e0ac05f579a patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents: 27289
diff changeset
3025 if (idx >= 0)
9e0ac05f579a patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents: 27289
diff changeset
3026 return &options[idx].script_ctx;
9e0ac05f579a patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents: 27289
diff changeset
3027 siemsg("no such option: %s", name);
9e0ac05f579a patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents: 27289
diff changeset
3028 return NULL;
9e0ac05f579a patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents: 27289
diff changeset
3029 }
9e0ac05f579a patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents: 27289
diff changeset
3030
9e0ac05f579a patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents: 27289
diff changeset
3031 /*
14867
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3032 * Set the script_ctx for a termcap option.
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3033 * "name" must be the two character code, e.g. "RV".
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3034 * When "name" is NULL use "opt_idx".
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3035 */
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3036 void
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3037 set_term_option_sctx_idx(char *name, int opt_idx)
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3038 {
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3039 char_u buf[5];
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3040 int idx;
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3041
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3042 if (name == NULL)
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3043 idx = opt_idx;
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3044 else
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3045 {
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3046 buf[0] = 't';
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3047 buf[1] = '_';
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3048 buf[2] = name[0];
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3049 buf[3] = name[1];
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3050 buf[4] = 0;
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3051 idx = findoption(buf);
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3052 }
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3053 if (idx >= 0)
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3054 set_option_sctx_idx(idx, OPT_GLOBAL, current_sctx);
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
3055 }
681
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
3056 #endif
9364d114ed8d updated for version 7.0204
vimboss
parents: 680
diff changeset
3057
19405
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3058 #if defined(FEAT_EVAL)
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3059 /*
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3060 * Apply the OptionSet autocommand.
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3061 */
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3062 static void
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3063 apply_optionset_autocmd(
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3064 int opt_idx,
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3065 long opt_flags,
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3066 long oldval,
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3067 long oldval_g,
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3068 long newval,
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3069 char *errmsg)
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3070 {
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3071 char_u buf_old[12], buf_old_global[12], buf_new[12], buf_type[12];
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3072
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3073 // Don't do this while starting up, failure or recursively.
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3074 if (starting || errmsg != NULL || *get_vim_var_str(VV_OPTION_TYPE) != NUL)
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3075 return;
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3076
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3077 vim_snprintf((char *)buf_old, sizeof(buf_old), "%ld", oldval);
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3078 vim_snprintf((char *)buf_old_global, sizeof(buf_old_global), "%ld",
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3079 oldval_g);
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3080 vim_snprintf((char *)buf_new, sizeof(buf_new), "%ld", newval);
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3081 vim_snprintf((char *)buf_type, sizeof(buf_type), "%s",
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3082 (opt_flags & OPT_LOCAL) ? "local" : "global");
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3083 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3084 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3085 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3086 if (opt_flags & OPT_LOCAL)
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3087 {
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3088 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setlocal", -1);
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3089 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1);
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3090 }
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3091 if (opt_flags & OPT_GLOBAL)
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3092 {
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3093 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"setglobal", -1);
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3094 set_vim_var_string(VV_OPTION_OLDGLOBAL, buf_old, -1);
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3095 }
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3096 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3097 {
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3098 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"set", -1);
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3099 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1);
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3100 set_vim_var_string(VV_OPTION_OLDGLOBAL, buf_old_global, -1);
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3101 }
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3102 if (opt_flags & OPT_MODELINE)
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3103 {
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3104 set_vim_var_string(VV_OPTION_COMMAND, (char_u *)"modeline", -1);
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3105 set_vim_var_string(VV_OPTION_OLDLOCAL, buf_old, -1);
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3106 }
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3107 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname,
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3108 NULL, FALSE, NULL);
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3109 reset_v_option_vars();
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3110 }
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3111 #endif
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
3112
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
3113 #if defined(FEAT_ARABIC) || defined(PROTO)
31924
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3114 /*
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3115 * Process the updated 'arabic' option value.
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3116 */
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
3117 char *
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
3118 did_set_arabic(optset_T *args UNUSED)
31924
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3119 {
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3120 char *errmsg = NULL;
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3121
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3122 if (curwin->w_p_arab)
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3123 {
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
3124 // 'arabic' is set, handle various sub-settings.
31924
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3125 if (!p_tbidi)
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3126 {
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3127 // set rightleft mode
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3128 if (!curwin->w_p_rl)
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3129 {
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3130 curwin->w_p_rl = TRUE;
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3131 changed_window_setting();
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3132 }
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3133
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3134 // Enable Arabic shaping (major part of what Arabic requires)
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3135 if (!p_arshape)
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3136 {
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3137 p_arshape = TRUE;
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3138 redraw_later_clear();
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3139 }
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3140 }
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3141
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3142 // Arabic requires a utf-8 encoding, inform the user if it's not
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3143 // set.
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3144 if (STRCMP(p_enc, "utf-8") != 0)
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3145 {
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3146 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3147
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3148 msg_source(HL_ATTR(HLF_W));
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3149 msg_attr(_(w_arabic), HL_ATTR(HLF_W));
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3150 #ifdef FEAT_EVAL
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3151 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3152 #endif
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3153 }
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3154
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3155 // set 'delcombine'
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3156 p_deco = TRUE;
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3157
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3158 # ifdef FEAT_KEYMAP
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3159 // Force-set the necessary keymap for arabic
32096
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3160 errmsg = set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3161 OPT_LOCAL);
31924
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3162 # endif
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3163 }
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3164 else
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3165 {
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
3166 // 'arabic' is reset, handle various sub-settings.
31924
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3167 if (!p_tbidi)
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3168 {
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3169 // reset rightleft mode
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3170 if (curwin->w_p_rl)
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3171 {
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3172 curwin->w_p_rl = FALSE;
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3173 changed_window_setting();
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3174 }
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3175
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3176 // 'arabicshape' isn't reset, it is a global option and
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3177 // another window may still need it "on".
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3178 }
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3179
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3180 // 'delcombine' isn't reset, it is a global option and another
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3181 // window may still want it "on".
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3182
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3183 # ifdef FEAT_KEYMAP
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3184 // Revert to the default keymap
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3185 curbuf->b_p_iminsert = B_IMODE_NONE;
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3186 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3187 # endif
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3188 }
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3189
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3190 return errmsg;
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3191 }
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3192 #endif
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3193
32096
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3194 #if defined(FEAT_AUTOCHDIR) || defined(PROTO)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3195 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3196 * Process the updated 'autochdir' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3197 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3198 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3199 did_set_autochdir(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3200 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3201 // Change directories when the 'acd' option is set now.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3202 DO_AUTOCHDIR;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3203 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3204 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3205 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3206
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3207 #if defined(FEAT_BEVAL_GUI) || defined(PROTO)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3208 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3209 * Process the updated 'ballooneval' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3210 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3211 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3212 did_set_ballooneval(optset_T *args)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3213 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3214 if (balloonEvalForTerm)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3215 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3216
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3217 if (p_beval && !args->os_oldval.boolean)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3218 gui_mch_enable_beval_area(balloonEval);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3219 else if (!p_beval && args->os_oldval.boolean)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3220 gui_mch_disable_beval_area(balloonEval);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3221
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3222 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3223 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3224 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3225
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3226 #if defined(FEAT_BEVAL_TERM) || defined(PROTO)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3227 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3228 * Process the updated 'balloonevalterm' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3229 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3230 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3231 did_set_balloonevalterm(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3232 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3233 mch_bevalterm_changed();
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3234 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3235 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3236 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3237
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3238 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3239 * Process the updated 'binary' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3240 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3241 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3242 did_set_binary(optset_T *args)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3243 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3244 // when 'bin' is set also set some other options
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3245 set_options_bin(args->os_oldval.boolean, curbuf->b_p_bin, args->os_flags);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3246 redraw_titles();
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3247
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3248 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3249 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3250
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3251 #if defined(FEAT_LINEBREAK) || defined(PROTO)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3252 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3253 * Called when the 'breakat' option changes value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3254 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3255 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3256 did_set_breakat(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3257 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3258 char_u *p;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3259 int i;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3260
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3261 for (i = 0; i < 256; i++)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3262 breakat_flags[i] = FALSE;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3263
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3264 if (p_breakat != NULL)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3265 for (p = p_breakat; *p; p++)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3266 breakat_flags[*p] = TRUE;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3267
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3268 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3269 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3270 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3271
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3272 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3273 * Process the updated 'buflisted' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3274 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3275 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3276 did_set_buflisted(optset_T *args)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3277 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3278 // when 'buflisted' changes, trigger autocommands
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3279 if (args->os_oldval.boolean != curbuf->b_p_bl)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3280 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3281 NULL, NULL, TRUE, curbuf);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3282 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3283 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3284
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3285 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3286 * Process the new 'cmdheight' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3287 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3288 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3289 did_set_cmdheight(optset_T *args)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3290 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3291 long old_value = args->os_oldval.number;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3292 char *errmsg = NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3293
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3294 // if p_ch changed value, change the command line height
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3295 if (p_ch < 1)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3296 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3297 errmsg = e_argument_must_be_positive;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3298 p_ch = 1;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3299 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3300 if (p_ch > Rows - min_rows() + 1)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3301 p_ch = Rows - min_rows() + 1;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3302
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3303 // Only compute the new window layout when startup has been
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3304 // completed. Otherwise the frame sizes may be wrong.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3305 if ((p_ch != old_value
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3306 || tabline_height() + topframe->fr_height != Rows - p_ch)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3307 && full_screen
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3308 #ifdef FEAT_GUI
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3309 && !gui.starting
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3310 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3311 )
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3312 command_height();
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3313
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3314 return errmsg;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3315 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3316
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3317 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3318 * Process the updated 'compatible' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3319 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3320 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3321 did_set_compatible(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3322 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3323 compatible_set();
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3324 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3325 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3326
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3327 #if defined(FEAT_CONCEAL) || defined(PROTO)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3328 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3329 * Process the new 'conceallevel' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3330 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3331 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3332 did_set_conceallevel(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3333 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3334 char *errmsg = NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3335
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3336 if (curwin->w_p_cole < 0)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3337 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3338 errmsg = e_argument_must_be_positive;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3339 curwin->w_p_cole = 0;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3340 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3341 else if (curwin->w_p_cole > 3)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3342 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3343 errmsg = e_invalid_argument;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3344 curwin->w_p_cole = 3;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3345 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3346
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3347 return errmsg;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3348 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3349 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3350
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3351 #if defined(FEAT_DIFF) || defined(PROTO)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3352 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3353 * Process the updated 'diff' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3354 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3355 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3356 did_set_diff(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3357 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3358 // May add or remove the buffer from the list of diff buffers.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3359 diff_buf_adjust(curwin);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3360 # ifdef FEAT_FOLDING
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3361 if (foldmethodIsDiff(curwin))
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3362 foldUpdateAll(curwin);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3363 # endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3364 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3365 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3366 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3367
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3368 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3369 * Process the updated 'endoffile' or 'endofline' or 'fixendofline' or 'bomb'
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3370 * option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3371 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3372 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3373 did_set_eof_eol_fixeol_bomb(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3374 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3375 // redraw the window title and tab page text
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3376 redraw_titles();
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3377 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3378 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3379
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3380 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3381 * Process the updated 'equalalways' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3382 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3383 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3384 did_set_equalalways(optset_T *args)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3385 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3386 if (p_ea && !args->os_oldval.boolean)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3387 win_equal(curwin, FALSE, 0);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3388
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3389 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3390 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3391
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3392 #if defined(FEAT_FOLDING) || defined(PROTO)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3393 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3394 * Process the new 'foldcolumn' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3395 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3396 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3397 did_set_foldcolumn(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3398 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3399 char *errmsg = NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3400
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3401 if (curwin->w_p_fdc < 0)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3402 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3403 errmsg = e_argument_must_be_positive;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3404 curwin->w_p_fdc = 0;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3405 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3406 else if (curwin->w_p_fdc > 12)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3407 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3408 errmsg = e_invalid_argument;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3409 curwin->w_p_fdc = 12;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3410 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3411
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3412 return errmsg;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3413 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3414
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3415 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3416 * Process the new 'foldlevel' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3417 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3418 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3419 did_set_foldlevel(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3420 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3421 if (curwin->w_p_fdl < 0)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3422 curwin->w_p_fdl = 0;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3423 newFoldLevel();
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3424 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3425 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3426
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3427 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3428 * Process the new 'foldminlines' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3429 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3430 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3431 did_set_foldminlines(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3432 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3433 foldUpdateAll(curwin);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3434 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3435 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3436
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3437 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3438 * Process the new 'foldnestmax' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3439 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3440 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3441 did_set_foldnestmax(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3442 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3443 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3444 foldUpdateAll(curwin);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3445 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3446 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3447 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3448
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3449 #if defined(FEAT_SEARCH_EXTRA) || defined(PROTO)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3450 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3451 * Process the updated 'hlsearch' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3452 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3453 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3454 did_set_hlsearch(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3455 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3456 // when 'hlsearch' is set or reset: reset no_hlsearch
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3457 set_no_hlsearch(FALSE);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3458 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3459 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3460 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3461
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3462 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3463 * Process the updated 'ignorecase' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3464 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3465 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3466 did_set_ignorecase(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3467 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3468 // when 'ignorecase' is set or reset and 'hlsearch' is set, redraw
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3469 if (p_hls)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3470 redraw_all_later(UPD_SOME_VALID);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3471 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3472 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3473
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3474 #if defined(HAVE_INPUT_METHOD) || defined(PROTO)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3475 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3476 * Process the updated 'imdisable' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3477 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3478 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3479 did_set_imdisable(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3480 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3481 // Only de-activate it here, it will be enabled when changing mode.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3482 if (p_imdisable)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3483 im_set_active(FALSE);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3484 else if (State & MODE_INSERT)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3485 // When the option is set from an autocommand, it may need to take
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3486 // effect right away.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3487 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3488 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3489 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3490 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3491
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3492 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3493 * Process the new 'iminsert' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3494 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3495 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3496 did_set_iminsert(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3497 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3498 char *errmsg = NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3499
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3500 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3501 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3502 errmsg = e_invalid_argument;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3503 curbuf->b_p_iminsert = B_IMODE_NONE;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3504 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3505 p_iminsert = curbuf->b_p_iminsert;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3506 if (termcap_active) // don't do this in the alternate screen
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3507 showmode();
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3508 #if defined(FEAT_KEYMAP)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3509 // Show/unshow value of 'keymap' in status lines.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3510 status_redraw_curbuf();
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3511 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3512
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3513 return errmsg;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3514 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3515
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3516 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3517 * Process the new 'imsearch' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3518 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3519 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3520 did_set_imsearch(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3521 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3522 char *errmsg = NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3523
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3524 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3525 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3526 errmsg = e_invalid_argument;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3527 curbuf->b_p_imsearch = B_IMODE_NONE;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3528 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3529 p_imsearch = curbuf->b_p_imsearch;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3530
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3531 return errmsg;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3532 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3533
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3534 #if (defined(FEAT_XIM) && defined(FEAT_GUI_GTK)) || defined(PROTO)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3535 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3536 * Process the new 'imstyle' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3537 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3538 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3539 did_set_imstyle(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3540 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3541 char *errmsg = NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3542
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3543 if (p_imst != IM_ON_THE_SPOT && p_imst != IM_OVER_THE_SPOT)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3544 errmsg = e_invalid_argument;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3545
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3546 return errmsg;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3547 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3548 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3549
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3550 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3551 * Process the updated 'insertmode' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3552 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3553 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3554 did_set_insertmode(optset_T *args)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3555 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3556 // when 'insertmode' is set from an autocommand need to do work here
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3557 if (p_im)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3558 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3559 if ((State & MODE_INSERT) == 0)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3560 need_start_insertmode = TRUE;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3561 stop_insert_mode = FALSE;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3562 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3563 // only reset if it was set previously
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3564 else if (args->os_oldval.boolean)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3565 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3566 need_start_insertmode = FALSE;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3567 stop_insert_mode = TRUE;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3568 if (restart_edit != 0 && mode_displayed)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3569 clear_cmdline = TRUE; // remove "(insert)"
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3570 restart_edit = 0;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3571 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3572
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3573 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3574 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3575
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3576 #if defined(FEAT_LANGMAP) || defined(PROTO)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3577 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3578 * Process the updated 'langnoremap' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3579 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3580 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3581 did_set_langnoremap(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3582 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3583 // 'langnoremap' -> !'langremap'
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3584 p_lrm = !p_lnr;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3585 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3586 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3587
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3588 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3589 * Process the updated 'langremap' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3590 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3591 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3592 did_set_langremap(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3593 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3594 // 'langremap' -> !'langnoremap'
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3595 p_lnr = !p_lrm;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3596 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3597 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3598 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3599
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3600 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3601 * Process the new 'laststatus' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3602 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3603 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3604 did_set_laststatus(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3605 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3606 last_status(FALSE); // (re)set last window status line
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3607 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3608 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3609
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3610 #if defined(FEAT_GUI) || defined(PROTO)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3611 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3612 * Process the new 'linespace' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3613 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3614 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3615 did_set_linespace(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3616 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3617 // Recompute gui.char_height and resize the Vim window to keep the
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3618 // same number of lines.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3619 if (gui.in_use && gui_mch_adjust_charheight() == OK)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3620 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3621 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3622 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3623 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3624
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3625 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3626 * Process the updated 'lisp' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3627 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3628 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3629 did_set_lisp(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3630 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3631 // When 'lisp' option changes include/exclude '-' in keyword characters.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3632 (void)buf_init_chartab(curbuf, FALSE); // ignore errors
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3633 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3634 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3635
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3636 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3637 * Process the new 'maxcombine' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3638 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3639 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3640 did_set_maxcombine(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3641 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3642 if (p_mco > MAX_MCO)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3643 p_mco = MAX_MCO;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3644 else if (p_mco < 0)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3645 p_mco = 0;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3646 screenclear(); // will re-allocate the screen
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3647 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3648 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3649
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3650 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3651 * Process the updated 'modifiable' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3652 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3653 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3654 did_set_modifiable(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3655 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3656 // when 'modifiable' is changed, redraw the window title
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3657
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3658 # ifdef FEAT_TERMINAL
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3659 // Cannot set 'modifiable' when in Terminal mode.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3660 if (curbuf->b_p_ma && (term_in_normal_mode() || (bt_terminal(curbuf)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3661 && curbuf->b_term != NULL && !term_is_finished(curbuf))))
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3662 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3663 curbuf->b_p_ma = FALSE;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3664 args->os_doskip = TRUE;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3665 return e_cannot_make_terminal_with_running_job_modifiable;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3666 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3667 # endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3668 redraw_titles();
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3669
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3670 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3671 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3672
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3673 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3674 * Process the updated 'modified' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3675 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3676 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3677 did_set_modified(optset_T *args)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3678 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3679 if (!args->os_newval.boolean)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3680 save_file_ff(curbuf); // Buffer is unchanged
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3681 redraw_titles();
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3682 modified_was_set = args->os_newval.boolean;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3683 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3684 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3685
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3686 #if defined(FEAT_GUI) || defined(PROTO)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3687 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3688 * Process the updated 'mousehide' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3689 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3690 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3691 did_set_mousehide(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3692 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3693 if (!p_mh)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3694 gui_mch_mousehide(FALSE);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3695 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3696 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3697 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3698
31924
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3699 /*
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3700 * Process the updated 'number' or 'relativenumber' option value.
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3701 */
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
3702 char *
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
3703 did_set_number_relativenumber(optset_T *args UNUSED)
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
3704 {
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
3705 #if (defined(FEAT_SIGNS) && defined(FEAT_GUI)) || defined(PROTO)
31924
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3706 if (gui.in_use
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3707 && (*curwin->w_p_scl == 'n' && *(curwin->w_p_scl + 1) == 'u')
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3708 && curbuf->b_signlist != NULL)
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3709 {
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3710 // If the 'number' or 'relativenumber' options are modified and
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3711 // 'signcolumn' is set to 'number', then clear the screen for a full
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3712 // refresh. Otherwise the sign icons are not displayed properly in the
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3713 // number column. If the 'number' option is set and only the
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3714 // 'relativenumber' option is toggled, then don't refresh the screen
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3715 // (optimization).
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
3716 if (!(curwin->w_p_nu && ((int *)args->os_varp == &curwin->w_p_rnu)))
31924
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3717 redraw_all_later(UPD_CLEAR);
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3718 }
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
3719 #endif
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
3720 return NULL;
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
3721 }
31924
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
3722
32096
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3723 #if defined(FEAT_LINEBREAK) || defined(PROTO)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3724 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3725 * Process the new 'numberwidth' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3726 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3727 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3728 did_set_numberwidth(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3729 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3730 char *errmsg = NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3731
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3732 // 'numberwidth' must be positive
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3733 if (curwin->w_p_nuw < 1)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3734 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3735 errmsg = e_argument_must_be_positive;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3736 curwin->w_p_nuw = 1;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3737 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3738 if (curwin->w_p_nuw > 20)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3739 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3740 errmsg = e_invalid_argument;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3741 curwin->w_p_nuw = 20;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3742 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3743 curwin->w_nrwidth_line_count = 0; // trigger a redraw
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3744
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3745 return errmsg;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3746 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3747 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3748
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3749 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3750 * Process the updated 'paste' option value. Called after p_paste was set or
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3751 * reset. When 'paste' is set or reset also change other options.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3752 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3753 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3754 did_set_paste(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3755 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3756 static int old_p_paste = FALSE;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3757 static int save_sm = 0;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3758 static int save_sta = 0;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3759 static int save_ru = 0;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3760 #ifdef FEAT_RIGHTLEFT
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3761 static int save_ri = 0;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3762 static int save_hkmap = 0;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3763 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3764 buf_T *buf;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3765
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3766 if (p_paste)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3767 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3768 // Paste switched from off to on.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3769 // Save the current values, so they can be restored later.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3770 if (!old_p_paste)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3771 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3772 // save options for each buffer
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3773 FOR_ALL_BUFFERS(buf)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3774 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3775 buf->b_p_tw_nopaste = buf->b_p_tw;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3776 buf->b_p_wm_nopaste = buf->b_p_wm;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3777 buf->b_p_sts_nopaste = buf->b_p_sts;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3778 buf->b_p_ai_nopaste = buf->b_p_ai;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3779 buf->b_p_et_nopaste = buf->b_p_et;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3780 #ifdef FEAT_VARTABS
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3781 if (buf->b_p_vsts_nopaste)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3782 vim_free(buf->b_p_vsts_nopaste);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3783 buf->b_p_vsts_nopaste =
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3784 buf->b_p_vsts && buf->b_p_vsts != empty_option
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3785 ? vim_strsave(buf->b_p_vsts) : NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3786 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3787 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3788
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3789 // save global options
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3790 save_sm = p_sm;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3791 save_sta = p_sta;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3792 save_ru = p_ru;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3793 #ifdef FEAT_RIGHTLEFT
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3794 save_ri = p_ri;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3795 save_hkmap = p_hkmap;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3796 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3797 // save global values for local buffer options
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3798 p_ai_nopaste = p_ai;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3799 p_et_nopaste = p_et;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3800 p_sts_nopaste = p_sts;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3801 p_tw_nopaste = p_tw;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3802 p_wm_nopaste = p_wm;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3803 #ifdef FEAT_VARTABS
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3804 if (p_vsts_nopaste)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3805 vim_free(p_vsts_nopaste);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3806 p_vsts_nopaste = p_vsts && p_vsts != empty_option
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3807 ? vim_strsave(p_vsts) : NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3808 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3809 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3810
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3811 // Always set the option values, also when 'paste' is set when it is
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3812 // already on. Set options for each buffer.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3813 FOR_ALL_BUFFERS(buf)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3814 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3815 buf->b_p_tw = 0; // textwidth is 0
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3816 buf->b_p_wm = 0; // wrapmargin is 0
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3817 buf->b_p_sts = 0; // softtabstop is 0
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3818 buf->b_p_ai = 0; // no auto-indent
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3819 buf->b_p_et = 0; // no expandtab
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3820 #ifdef FEAT_VARTABS
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3821 if (buf->b_p_vsts)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3822 free_string_option(buf->b_p_vsts);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3823 buf->b_p_vsts = empty_option;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3824 VIM_CLEAR(buf->b_p_vsts_array);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3825 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3826 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3827
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3828 // set global options
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3829 p_sm = 0; // no showmatch
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3830 p_sta = 0; // no smarttab
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3831 if (p_ru)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3832 status_redraw_all(); // redraw to remove the ruler
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3833 p_ru = 0; // no ruler
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3834 #ifdef FEAT_RIGHTLEFT
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3835 p_ri = 0; // no reverse insert
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3836 p_hkmap = 0; // no Hebrew keyboard
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3837 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3838 // set global values for local buffer options
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3839 p_tw = 0;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3840 p_wm = 0;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3841 p_sts = 0;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3842 p_ai = 0;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3843 #ifdef FEAT_VARTABS
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3844 if (p_vsts)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3845 free_string_option(p_vsts);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3846 p_vsts = empty_option;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3847 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3848 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3849
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3850 // Paste switched from on to off: Restore saved values.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3851 else if (old_p_paste)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3852 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3853 // restore options for each buffer
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3854 FOR_ALL_BUFFERS(buf)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3855 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3856 buf->b_p_tw = buf->b_p_tw_nopaste;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3857 buf->b_p_wm = buf->b_p_wm_nopaste;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3858 buf->b_p_sts = buf->b_p_sts_nopaste;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3859 buf->b_p_ai = buf->b_p_ai_nopaste;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3860 buf->b_p_et = buf->b_p_et_nopaste;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3861 #ifdef FEAT_VARTABS
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3862 if (buf->b_p_vsts)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3863 free_string_option(buf->b_p_vsts);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3864 buf->b_p_vsts = buf->b_p_vsts_nopaste
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3865 ? vim_strsave(buf->b_p_vsts_nopaste) : empty_option;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3866 vim_free(buf->b_p_vsts_array);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3867 if (buf->b_p_vsts && buf->b_p_vsts != empty_option)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3868 (void)tabstop_set(buf->b_p_vsts, &buf->b_p_vsts_array);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3869 else
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3870 buf->b_p_vsts_array = NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3871 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3872 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3873
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3874 // restore global options
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3875 p_sm = save_sm;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3876 p_sta = save_sta;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3877 if (p_ru != save_ru)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3878 status_redraw_all(); // redraw to draw the ruler
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3879 p_ru = save_ru;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3880 #ifdef FEAT_RIGHTLEFT
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3881 p_ri = save_ri;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3882 p_hkmap = save_hkmap;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3883 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3884 // set global values for local buffer options
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3885 p_ai = p_ai_nopaste;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3886 p_et = p_et_nopaste;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3887 p_sts = p_sts_nopaste;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3888 p_tw = p_tw_nopaste;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3889 p_wm = p_wm_nopaste;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3890 #ifdef FEAT_VARTABS
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3891 if (p_vsts)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3892 free_string_option(p_vsts);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3893 p_vsts = p_vsts_nopaste ? vim_strsave(p_vsts_nopaste) : empty_option;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3894 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3895 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3896
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3897 old_p_paste = p_paste;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3898
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3899 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3900 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3901
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3902
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3903 #ifdef FEAT_QUICKFIX
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3904 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3905 * Process the updated 'previewwindow' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3906 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3907 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3908 did_set_previewwindow(optset_T *args)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3909 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3910 if (!curwin->w_p_pvw)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3911 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3912
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3913 // There can be only one window with 'previewwindow' set.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3914 win_T *win;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3915
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3916 FOR_ALL_WINDOWS(win)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3917 if (win->w_p_pvw && win != curwin)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3918 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3919 curwin->w_p_pvw = FALSE;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3920 args->os_doskip = TRUE;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3921 return e_preview_window_already_exists;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3922 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3923
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3924 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3925 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3926 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3927
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3928 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3929 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3930 * Process the new 'pyxversion' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3931 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3932 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3933 did_set_pyxversion(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3934 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3935 char *errmsg = NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3936
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3937 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3938 errmsg = e_invalid_argument;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3939
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3940 return errmsg;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3941 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3942 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3943
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3944 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3945 * Process the updated 'readonly' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3946 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3947 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3948 did_set_readonly(optset_T *args)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3949 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3950 // when 'readonly' is reset globally, also reset readonlymode
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3951 if (!curbuf->b_p_ro && (args->os_flags & OPT_LOCAL) == 0)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3952 readonlymode = FALSE;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3953
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3954 // when 'readonly' is set may give W10 again
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3955 if (curbuf->b_p_ro)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3956 curbuf->b_did_warn = FALSE;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3957
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3958 redraw_titles();
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3959
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3960 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3961 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3962
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3963 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3964 * Process the updated 'scrollbind' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3965 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3966 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3967 did_set_scrollbind(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3968 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3969 // when 'scrollbind' is set: snapshot the current position to avoid a jump
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3970 // at the end of normal_cmd()
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3971 if (!curwin->w_p_scb)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3972 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3973
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3974 do_check_scrollbind(FALSE);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3975 curwin->w_scbind_pos = curwin->w_topline;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3976 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3977 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3978
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3979 #if defined(BACKSLASH_IN_FILENAME) || defined(PROTO)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3980 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3981 * Process the updated 'shellslash' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3982 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3983 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3984 did_set_shellslash(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3985 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3986 if (p_ssl)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3987 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3988 psepc = '/';
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3989 psepcN = '\\';
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3990 pseps[0] = '/';
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3991 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3992 else
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3993 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3994 psepc = '\\';
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3995 psepcN = '/';
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3996 pseps[0] = '\\';
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3997 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3998
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
3999 // need to adjust the file name arguments and buffer names.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4000 buflist_slash_adjust();
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4001 alist_slash_adjust();
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4002 # ifdef FEAT_EVAL
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4003 scriptnames_slash_adjust();
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4004 # endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4005 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4006 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4007 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4008
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4009 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4010 * Process the new 'shiftwidth' or the 'tabstop' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4011 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4012 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4013 did_set_shiftwidth_tabstop(optset_T *args)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4014 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4015 long *pp = (long *)args->os_varp;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4016 char *errmsg = NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4017
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4018 if (curbuf->b_p_sw < 0)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4019 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4020 errmsg = e_argument_must_be_positive;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4021 #ifdef FEAT_VARTABS
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4022 // Use the first 'vartabstop' value, or 'tabstop' if vts isn't in use.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4023 curbuf->b_p_sw = tabstop_count(curbuf->b_p_vts_array) > 0
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4024 ? tabstop_first(curbuf->b_p_vts_array)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4025 : curbuf->b_p_ts;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4026 #else
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4027 curbuf->b_p_sw = curbuf->b_p_ts;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4028 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4029 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4030
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4031 #ifdef FEAT_FOLDING
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4032 if (foldmethodIsIndent(curwin))
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4033 foldUpdateAll(curwin);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4034 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4035 // When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4036 // parse 'cinoptions'.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4037 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4038 parse_cino(curbuf);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4039
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4040 return errmsg;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4041 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4042
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4043 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4044 * Process the new 'showtabline' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4045 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4046 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4047 did_set_showtabline(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4048 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4049 shell_new_rows(); // recompute window positions and heights
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4050 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4051 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4052
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4053 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4054 * Process the updated 'smoothscroll' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4055 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4056 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4057 did_set_smoothscroll(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4058 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4059 if (curwin->w_p_sms)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4060 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4061
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4062 curwin->w_skipcol = 0;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4063 changed_line_abv_curs();
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4064 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4065 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4066
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4067 #if defined(FEAT_SPELL) || defined(PROTO)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4068 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4069 * Process the updated 'spell' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4070 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4071 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4072 did_set_spell(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4073 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4074 if (curwin->w_p_spell)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4075 return parse_spelllang(curwin);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4076
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4077 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4078 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4079 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4080
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4081 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4082 * Process the updated 'swapfile' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4083 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4084 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4085 did_set_swapfile(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4086 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4087 // when 'swf' is set, create swapfile, when reset remove swapfile
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4088 if (curbuf->b_p_swf && p_uc)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4089 ml_open_file(curbuf); // create the swap file
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4090 else
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4091 // no need to reset curbuf->b_may_swap, ml_open_file() will check
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4092 // buf->b_p_swf
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4093 mf_close_file(curbuf, TRUE); // remove the swap file
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4094 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4095 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4096
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4097 #if defined(FEAT_TERMGUICOLORS) || defined(PROTO)
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4098 char *
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4099 did_set_termguicolors(optset_T *args UNUSED)
31924
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4100 {
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4101 # ifdef FEAT_VTP
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4102 // Do not turn on 'tgc' when 24-bit colors are not supported.
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4103 if (
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4104 # ifdef VIMDLL
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4105 !gui.in_use && !gui.starting &&
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4106 # endif
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4107 !has_vtp_working())
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4108 {
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4109 p_tgc = 0;
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4110 args->os_doskip = TRUE;
31924
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4111 return e_24_bit_colors_are_not_supported_on_this_environment;
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4112 }
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4113 if (is_term_win32())
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4114 swap_tcap();
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4115 # endif
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4116 # ifdef FEAT_GUI
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4117 if (!gui.in_use && !gui.starting)
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4118 # endif
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4119 highlight_gui_started();
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4120 # ifdef FEAT_VTP
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4121 // reset t_Co
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4122 if (is_term_win32())
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4123 {
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4124 control_console_color_rgb();
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4125 set_termname(T_NAME);
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4126 init_highlight(TRUE, FALSE);
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4127 }
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4128 # endif
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4129 # ifdef FEAT_TERMINAL
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4130 term_update_colors_all();
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4131 term_update_palette_all();
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4132 term_update_wincolor_all();
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4133 # endif
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4134
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4135 return NULL;
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4136 }
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4137 #endif
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4138
4789a9d20e7c patch 9.0.1294: the set_bool_option() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 31922
diff changeset
4139 /*
32096
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4140 * Process the updated 'terse' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4141 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4142 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4143 did_set_terse(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4144 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4145 char_u *p;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4146
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4147 // when 'terse' is set change 'shortmess'
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4148 p = vim_strchr(p_shm, SHM_SEARCH);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4149
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4150 // insert 's' in p_shm
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4151 if (p_terse && p == NULL)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4152 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4153 STRCPY(IObuff, p_shm);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4154 STRCAT(IObuff, "s");
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4155 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4156 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4157 // remove 's' from p_shm
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4158 else if (!p_terse && p != NULL)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4159 STRMOVE(p, p + 1);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4160 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4161 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4162
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4163 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4164 * Process the updated 'textauto' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4165 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4166 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4167 did_set_textauto(optset_T *args)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4168 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4169 // when 'textauto' is set or reset also change 'fileformats'
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4170 set_string_option_direct((char_u *)"ffs", -1,
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4171 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4172 OPT_FREE | args->os_flags, 0);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4173
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4174 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4175 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4176
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4177 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4178 * Process the updated 'textmode' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4179 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4180 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4181 did_set_textmode(optset_T *args)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4182 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4183 // when 'textmode' is set or reset also change 'fileformat'
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4184 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, args->os_flags);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4185
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4186 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4187 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4188
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4189 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4190 * Process the new 'textwidth' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4191 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4192 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4193 did_set_textwidth(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4194 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4195 char *errmsg = NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4196
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4197 if (curbuf->b_p_tw < 0)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4198 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4199 errmsg = e_argument_must_be_positive;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4200 curbuf->b_p_tw = 0;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4201 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4202 #ifdef FEAT_SYN_HL
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4203 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4204 win_T *wp;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4205 tabpage_T *tp;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4206
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4207 FOR_ALL_TAB_WINDOWS(tp, wp)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4208 check_colorcolumn(wp);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4209 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4210 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4211
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4212 return errmsg;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4213 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4214
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4215 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4216 * Process the updated 'title' or the 'icon' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4217 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4218 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4219 did_set_title_icon(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4220 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4221 // when 'title' changed, may need to change the title; same for 'icon'
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4222 did_set_title();
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4223 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4224 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4225
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4226 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4227 * Process the new 'titlelen' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4228 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4229 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4230 did_set_titlelen(optset_T *args)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4231 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4232 long old_value = args->os_oldval.number;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4233 char *errmsg = NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4234
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4235 // if 'titlelen' has changed, redraw the title
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4236 if (p_titlelen < 0)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4237 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4238 errmsg = e_argument_must_be_positive;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4239 p_titlelen = 85;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4240 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4241 if (starting != NO_SCREEN && old_value != p_titlelen)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4242 need_maketitle = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4243
28457
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
4244 return errmsg;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4245 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4246
32096
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4247 #if defined(FEAT_PERSISTENT_UNDO) || defined(PROTO)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4248 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4249 * Process the updated 'undofile' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4250 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4251 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4252 did_set_undofile(optset_T *args)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4253 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4254 // Only take action when the option was set.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4255 if (!curbuf->b_p_udf && !p_udf)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4256 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4257
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4258 // When reset we do not delete the undo file, the option may be set again
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4259 // without making any changes in between.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4260 char_u hash[UNDO_HASH_SIZE];
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4261 buf_T *save_curbuf = curbuf;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4262
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4263 FOR_ALL_BUFFERS(curbuf)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4264 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4265 // When 'undofile' is set globally: for every buffer, otherwise
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4266 // only for the current buffer: Try to read in the undofile,
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4267 // if one exists, the buffer wasn't changed and the buffer was
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4268 // loaded
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4269 if ((curbuf == save_curbuf
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4270 || (args->os_flags & OPT_GLOBAL)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4271 || args->os_flags == 0)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4272 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4273 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4274 #ifdef FEAT_CRYPT
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4275 if (crypt_get_method_nr(curbuf) == CRYPT_M_SOD)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4276 continue;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4277 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4278 u_compute_hash(hash);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4279 u_read_undo(NULL, hash, curbuf->b_fname);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4280 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4281 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4282 curbuf = save_curbuf;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4283
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4284 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4285 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4286 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4287
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4288 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4289 * Process the new global 'undolevels' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4290 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4291 static void
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4292 update_global_undolevels(long value, long old_value)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4293 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4294 // sync undo before 'undolevels' changes
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4295
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4296 // use the old value, otherwise u_sync() may not work properly
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4297 p_ul = old_value;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4298 u_sync(TRUE);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4299 p_ul = value;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4300 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4301
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4302 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4303 * Process the new buffer local 'undolevels' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4304 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4305 static void
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4306 update_buflocal_undolevels(long value, long old_value)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4307 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4308 // use the old value, otherwise u_sync() may not work properly
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4309 curbuf->b_p_ul = old_value;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4310 u_sync(TRUE);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4311 curbuf->b_p_ul = value;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4312 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4313
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4314 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4315 * Process the new 'undolevels' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4316 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4317 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4318 did_set_undolevels(optset_T *args)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4319 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4320 long *pp = (long *)args->os_varp;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4321
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4322 if (pp == &p_ul) // global 'undolevels'
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4323 update_global_undolevels(args->os_newval.number,
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4324 args->os_oldval.number);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4325 else if (pp == &curbuf->b_p_ul) // buffer local 'undolevels'
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4326 update_buflocal_undolevels(args->os_newval.number,
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4327 args->os_oldval.number);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4328
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4329 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4330 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4331
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4332 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4333 * Process the new 'updatecount' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4334 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4335 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4336 did_set_updatecount(optset_T *args)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4337 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4338 long old_value = args->os_oldval.number;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4339 char *errmsg = NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4340
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4341 // when 'updatecount' changes from zero to non-zero, open swap files
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4342 if (p_uc < 0)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4343 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4344 errmsg = e_argument_must_be_positive;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4345 p_uc = 100;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4346 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4347 if (p_uc && !old_value)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4348 ml_open_files();
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4349
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4350 return errmsg;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4351 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4352
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4353 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4354 * Process the updated 'weirdinvert' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4355 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4356 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4357 did_set_weirdinvert(optset_T *args)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4358 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4359 // When 'weirdinvert' changed, set/reset 't_xs'.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4360 // Then set 'weirdinvert' according to value of 't_xs'.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4361 if (p_wiv && !args->os_oldval.boolean)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4362 T_XS = (char_u *)"y";
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4363 else if (!p_wiv && args->os_oldval.boolean)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4364 T_XS = empty_option;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4365 p_wiv = (*T_XS != NUL);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4366
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4367 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4368 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4369
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4370 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4371 * Process the new 'window' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4372 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4373 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4374 did_set_window(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4375 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4376 if (p_window < 1)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4377 p_window = 1;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4378 else if (p_window >= Rows)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4379 p_window = Rows - 1;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4380 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4381 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4382
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4383 /*
31922
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4384 * Process the new 'winheight' or the 'helpheight' option value.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4385 */
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4386 char *
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4387 did_set_winheight_helpheight(optset_T *args)
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4388 {
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4389 long *pp = (long *)args->os_varp;
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4390 char *errmsg = NULL;
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4391
31922
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4392 if (p_wh < 1)
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4393 {
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4394 errmsg = e_argument_must_be_positive;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4395 p_wh = 1;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4396 }
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4397 if (p_wmh > p_wh)
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4398 {
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4399 errmsg = e_winheight_cannot_be_smaller_than_winminheight;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4400 p_wh = p_wmh;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4401 }
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4402 if (p_hh < 0)
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4403 {
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4404 errmsg = e_argument_must_be_positive;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4405 p_hh = 0;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4406 }
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4407
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4408 // Change window height NOW
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4409 if (!ONE_WINDOW)
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4410 {
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4411 if (pp == &p_wh && curwin->w_height < p_wh)
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4412 win_setheight((int)p_wh);
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4413 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4414 win_setheight((int)p_hh);
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4415 }
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4416
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4417 return errmsg;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4418 }
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4419
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4420 /*
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4421 * Process the new 'winminheight' option value.
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4422 */
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4423 char *
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4424 did_set_winminheight(optset_T *args UNUSED)
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4425 {
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4426 char *errmsg = NULL;
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4427
31922
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4428 if (p_wmh < 0)
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4429 {
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4430 errmsg = e_argument_must_be_positive;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4431 p_wmh = 0;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4432 }
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4433 if (p_wmh > p_wh)
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4434 {
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4435 errmsg = e_winheight_cannot_be_smaller_than_winminheight;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4436 p_wmh = p_wh;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4437 }
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4438 win_setminheight();
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4439
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4440 return errmsg;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4441 }
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4442
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4443 /*
32096
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4444 * Process the new 'winminwidth' option value.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4445 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4446 char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4447 did_set_winminwidth(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4448 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4449 char *errmsg = NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4450
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4451 if (p_wmw < 0)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4452 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4453 errmsg = e_argument_must_be_positive;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4454 p_wmw = 0;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4455 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4456 if (p_wmw > p_wiw)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4457 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4458 errmsg = e_winwidth_cannot_be_smaller_than_winminwidth;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4459 p_wmw = p_wiw;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4460 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4461 win_setminwidth();
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4462
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4463 return errmsg;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4464 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4465
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4466 /*
31922
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4467 * Process the new 'winwidth' option value.
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4468 */
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4469 char *
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4470 did_set_winwidth(optset_T *args UNUSED)
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4471 {
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4472 char *errmsg = NULL;
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4473
31922
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4474 if (p_wiw < 1)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4475 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
4476 errmsg = e_argument_must_be_positive;
31922
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4477 p_wiw = 1;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4478 }
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4479 if (p_wmw > p_wiw)
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4480 {
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4481 errmsg = e_winwidth_cannot_be_smaller_than_winminwidth;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4482 p_wiw = p_wmw;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4483 }
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4484
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4485 // Change window width NOW
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4486 if (!ONE_WINDOW && curwin->w_width < p_wiw)
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4487 win_setwidth((int)p_wiw);
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4488
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4489 return errmsg;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4490 }
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4491
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4492 /*
32096
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4493 * Process the updated 'wrap' option value.
31922
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4494 */
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4495 char *
32096
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4496 did_set_wrap(optset_T *args UNUSED)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4497 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4498 // If 'wrap' is set, set w_leftcol to zero.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4499 if (curwin->w_p_wrap)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4500 curwin->w_leftcol = 0;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4501 return NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4502 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4503
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4504 /*
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4505 * Set the value of a boolean option, and take care of side effects.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4506 * Returns NULL for success, or an error message for an error.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4507 */
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4508 static char *
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4509 set_bool_option(
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4510 int opt_idx, // index in options[] table
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4511 char_u *varp, // pointer to the option variable
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4512 int value, // new value
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4513 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4514 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4515 int old_value = *(int *)varp;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4516 #if defined(FEAT_EVAL)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4517 int old_global_value = 0;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4518 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4519 char *errmsg = NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4520
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4521 // Disallow changing some options from secure mode
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4522 if ((secure
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4523 #ifdef HAVE_SANDBOX
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4524 || sandbox != 0
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4525 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4526 ) && (options[opt_idx].flags & P_SECURE))
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4527 return e_not_allowed_here;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4528
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4529 #if defined(FEAT_EVAL)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4530 // Save the global value before changing anything. This is needed as for
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4531 // a global-only option setting the "local value" in fact sets the global
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4532 // value (since there is only one value).
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4533 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4534 old_global_value = *(int *)get_varp_scope(&(options[opt_idx]),
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4535 OPT_GLOBAL);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4536 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4537
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4538 *(int *)varp = value; // set the new value
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4539 #ifdef FEAT_EVAL
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4540 // Remember where the option was set.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4541 set_option_sctx_idx(opt_idx, opt_flags, current_sctx);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4542 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4543
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4544 #ifdef FEAT_GUI
32096
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4545 need_mouse_correct = TRUE;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4546 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4547
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4548 // May set global value for local option.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4549 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4550 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4551
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4552 // Handle side effects of changing a bool option.
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4553 if (options[opt_idx].opt_did_set_cb != NULL)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4554 {
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4555 optset_T args;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4556
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4557 CLEAR_FIELD(args);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4558 args.os_varp = varp;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4559 args.os_flags = opt_flags;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4560 args.os_oldval.boolean = old_value;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4561 args.os_newval.boolean = value;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4562 args.os_errbuf = NULL;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4563 errmsg = options[opt_idx].opt_did_set_cb(&args);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4564 if (args.os_doskip)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4565 return errmsg;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4566 }
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4567
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4568 // after handling side effects, call autocommand
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4569
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4570 options[opt_idx].flags |= P_WAS_SET;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4571
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4572 #if defined(FEAT_EVAL)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4573 apply_optionset_autocmd(opt_idx, opt_flags,
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4574 (long)(old_value ? TRUE : FALSE),
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4575 (long)(old_global_value ? TRUE : FALSE),
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4576 (long)(value ? TRUE : FALSE), NULL);
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4577 #endif
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4578
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4579 comp_col(); // in case 'ruler' or 'showcmd' changed
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4580 if (curwin->w_curswant != MAXCOL
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4581 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4582 curwin->w_set_curswant = TRUE;
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4583
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4584 if ((opt_flags & OPT_NO_REDRAW) == 0)
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4585 check_redraw(options[opt_idx].flags);
31922
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4586
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4587 return errmsg;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4588 }
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4589
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4590 /*
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4591 * Check the bounds of numeric options.
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4592 */
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4593 static char *
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4594 check_num_option_bounds(
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4595 long *pp,
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4596 long old_value,
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4597 long old_Rows,
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4598 long old_Columns,
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4599 char *errbuf,
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4600 size_t errbuflen,
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4601 char *errmsg)
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4602 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4603 if (Rows < min_rows() && full_screen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4604 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4605 if (errbuf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4606 {
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 27303
diff changeset
4607 vim_snprintf(errbuf, errbuflen,
31922
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4608 _(e_need_at_least_nr_lines), min_rows());
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4609 errmsg = errbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4610 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4611 Rows = min_rows();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4612 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4613 if (Columns < MIN_COLUMNS && full_screen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4614 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4615 if (errbuf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4616 {
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 27303
diff changeset
4617 vim_snprintf(errbuf, errbuflen,
31922
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4618 _(e_need_at_least_nr_columns), MIN_COLUMNS);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4619 errmsg = errbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4620 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4621 Columns = MIN_COLUMNS;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4622 }
5070
cf52d2a8c05c updated for version 7.3.1278
Bram Moolenaar <bram@vim.org>
parents: 5039
diff changeset
4623 limit_screen_size();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4624
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
4625 // If the screen (shell) height has been changed, assume it is the
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
4626 // physical screenheight.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4627 if (old_Rows != Rows || old_Columns != Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4628 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
4629 // Changing the screen size is not allowed while updating the screen.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4630 if (updating_screen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4631 *pp = old_value;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4632 else if (full_screen
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4633 #ifdef FEAT_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4634 && !gui.starting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4635 #endif
31922
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4636 )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4637 set_shellsize((int)Columns, (int)Rows, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4638 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4639 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
4640 // Postpone the resizing; check the size and cmdline position for
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
4641 // messages.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4642 check_shellsize();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4643 if (cmdline_row > Rows - p_ch && Rows > p_ch)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4644 cmdline_row = Rows - p_ch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4645 }
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 842
diff changeset
4646 if (p_window >= Rows || !option_was_set((char_u *)"window"))
164
8b0ee9d57d7f updated for version 7.0050
vimboss
parents: 161
diff changeset
4647 p_window = Rows - 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4648 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4649
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4650 if (curbuf->b_p_ts <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4651 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
4652 errmsg = e_argument_must_be_positive;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4653 curbuf->b_p_ts = 8;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4654 }
27434
c1702fd7e716 patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents: 27426
diff changeset
4655 else if (curbuf->b_p_ts > TABSTOP_MAX)
c1702fd7e716 patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents: 27426
diff changeset
4656 {
c1702fd7e716 patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents: 27426
diff changeset
4657 errmsg = e_invalid_argument;
c1702fd7e716 patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents: 27426
diff changeset
4658 curbuf->b_p_ts = 8;
c1702fd7e716 patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents: 27426
diff changeset
4659 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4660 if (p_tm < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4661 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
4662 errmsg = e_argument_must_be_positive;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4663 p_tm = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4664 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4665 if ((curwin->w_p_scr <= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4666 || (curwin->w_p_scr > curwin->w_height
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4667 && curwin->w_height > 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4668 && full_screen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4669 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4670 if (pp == &(curwin->w_p_scr))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4671 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4672 if (curwin->w_p_scr != 0)
25320
1e6da8364a02 patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25176
diff changeset
4673 errmsg = e_invalid_scroll_size;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4674 win_comp_scroll(curwin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4675 }
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
4676 // If 'scroll' became invalid because of a side effect silently adjust
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
4677 // it.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4678 else if (curwin->w_p_scr <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4679 curwin->w_p_scr = 1;
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
4680 else // curwin->w_p_scr > curwin->w_height
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4681 curwin->w_p_scr = curwin->w_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4682 }
1726
1e25b58fbf7b updated for version 7.2-024
vimboss
parents: 1683
diff changeset
4683 if (p_hi < 0)
1e25b58fbf7b updated for version 7.2-024
vimboss
parents: 1683
diff changeset
4684 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
4685 errmsg = e_argument_must_be_positive;
1726
1e25b58fbf7b updated for version 7.2-024
vimboss
parents: 1683
diff changeset
4686 p_hi = 0;
1e25b58fbf7b updated for version 7.2-024
vimboss
parents: 1683
diff changeset
4687 }
5991
a42ba1e50992 updated for version 7.4.336
Bram Moolenaar <bram@vim.org>
parents: 5883
diff changeset
4688 else if (p_hi > 10000)
a42ba1e50992 updated for version 7.4.336
Bram Moolenaar <bram@vim.org>
parents: 5883
diff changeset
4689 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26802
diff changeset
4690 errmsg = e_invalid_argument;
5991
a42ba1e50992 updated for version 7.4.336
Bram Moolenaar <bram@vim.org>
parents: 5883
diff changeset
4691 p_hi = 10000;
a42ba1e50992 updated for version 7.4.336
Bram Moolenaar <bram@vim.org>
parents: 5883
diff changeset
4692 }
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents: 4367
diff changeset
4693 if (p_re < 0 || p_re > 2)
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents: 4367
diff changeset
4694 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26802
diff changeset
4695 errmsg = e_invalid_argument;
4444
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents: 4367
diff changeset
4696 p_re = 0;
ccecb03e5e8b updated for version 7.3.970
Bram Moolenaar <bram@vim.org>
parents: 4367
diff changeset
4697 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4698 if (p_report < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4699 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
4700 errmsg = e_argument_must_be_positive;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4701 p_report = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4702 }
532
7052f11a3dc9 updated for version 7.0150
vimboss
parents: 523
diff changeset
4703 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4704 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
4705 if (Rows != old_Rows) // Rows changed, just adjust p_sj
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4706 p_sj = Rows / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4707 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4708 {
25320
1e6da8364a02 patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25176
diff changeset
4709 errmsg = e_invalid_scroll_size;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4710 p_sj = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4711 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4712 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4713 if (p_so < 0 && full_screen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4714 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
4715 errmsg = e_argument_must_be_positive;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4716 p_so = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4717 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4718 if (p_siso < 0 && full_screen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4719 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
4720 errmsg = e_argument_must_be_positive;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4721 p_siso = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4722 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4723 if (p_cwh < 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4724 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
4725 errmsg = e_argument_must_be_positive;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4726 p_cwh = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4727 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4728 if (p_ut < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4729 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
4730 errmsg = e_argument_must_be_positive;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4731 p_ut = 2000;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4732 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4733 if (p_ss < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4734 {
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
4735 errmsg = e_argument_must_be_positive;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4736 p_ss = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4737 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4738
31922
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4739 return errmsg;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4740 }
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4741
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4742 /*
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4743 * Set the value of a number option, and take care of side effects.
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4744 * Returns NULL for success, or an error message for an error.
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4745 */
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4746 static char *
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4747 set_num_option(
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4748 int opt_idx, // index in options[] table
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4749 char_u *varp, // pointer to the option variable
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4750 long value, // new value
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4751 char *errbuf, // buffer for error messages
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4752 size_t errbuflen, // length of "errbuf"
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4753 int opt_flags) // OPT_LOCAL, OPT_GLOBAL,
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4754 // OPT_MODELINE, etc.
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4755 {
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4756 char *errmsg = NULL;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4757 long old_value = *(long *)varp;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4758 #if defined(FEAT_EVAL)
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4759 long old_global_value = 0; // only used when setting a local and
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4760 // global option
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4761 #endif
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4762 long old_Rows = Rows; // remember old Rows
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4763 long old_Columns = Columns; // remember old Columns
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4764 long *pp = (long *)varp;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4765
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4766 // Disallow changing some options from secure mode.
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4767 if ((secure
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4768 #ifdef HAVE_SANDBOX
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4769 || sandbox != 0
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4770 #endif
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4771 ) && (options[opt_idx].flags & P_SECURE))
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4772 return e_not_allowed_here;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4773
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4774 #if defined(FEAT_EVAL)
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4775 // Save the global value before changing anything. This is needed as for
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4776 // a global-only option setting the "local value" in fact sets the global
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4777 // value (since there is only one value).
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4778 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4779 old_global_value = *(long *)get_varp_scope(&(options[opt_idx]),
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4780 OPT_GLOBAL);
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4781 #endif
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4782
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4783 *pp = value;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4784 #ifdef FEAT_EVAL
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4785 // Remember where the option was set.
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4786 set_option_sctx_idx(opt_idx, opt_flags, current_sctx);
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4787 #endif
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4788 #ifdef FEAT_GUI
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4789 need_mouse_correct = TRUE;
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4790 #endif
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4791
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4792 // Invoke the option specific callback function to validate and apply the
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4793 // new value.
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4794 if (options[opt_idx].opt_did_set_cb != NULL)
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4795 {
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4796 optset_T args;
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4797
32096
e7ab58f57ea3 patch 9.0.1379: functions for handling options are not ordered
Bram Moolenaar <Bram@vim.org>
parents: 32076
diff changeset
4798 CLEAR_FIELD(args);
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4799 args.os_varp = varp;
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4800 args.os_flags = opt_flags;
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4801 args.os_oldval.number = old_value;
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4802 args.os_newval.number = value;
32043
6095218c9056 patch 9.0.1353: too many "else if" statements to handle option values
Bram Moolenaar <Bram@vim.org>
parents: 31996
diff changeset
4803 args.os_errbuf = NULL;
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4804 errmsg = options[opt_idx].opt_did_set_cb(&args);
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4805 }
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4806
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
4807 // Check the bounds for numeric options here
31922
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4808 errmsg = check_num_option_bounds(pp, old_value, old_Rows, old_Columns,
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4809 errbuf, errbuflen, errmsg);
440256d03990 patch 9.0.1293: the set_num_option() is too long
Bram Moolenaar <Bram@vim.org>
parents: 31908
diff changeset
4810
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
4811 // May set global value for local option.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4812 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4813 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4814
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4815 options[opt_idx].flags |= P_WAS_SET;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4816
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13361
diff changeset
4817 #if defined(FEAT_EVAL)
19405
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
4818 apply_optionset_autocmd(opt_idx, opt_flags, old_value, old_global_value,
08f4dc2ba716 patch 8.2.0260: several lines of code are duplicated
Bram Moolenaar <Bram@vim.org>
parents: 19195
diff changeset
4819 value, errmsg);
6935
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents: 6933
diff changeset
4820 #endif
4db70c94226b patch 7.4.786
Bram Moolenaar <bram@vim.org>
parents: 6933
diff changeset
4821
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
4822 comp_col(); // in case 'columns' or 'ls' changed
3443
21219ffc9790 updated for version 7.3.487
Bram Moolenaar <bram@vim.org>
parents: 3427
diff changeset
4823 if (curwin->w_curswant != MAXCOL
6669
5a12a6861367 updated for version 7.4.659
Bram Moolenaar <bram@vim.org>
parents: 6602
diff changeset
4824 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
3443
21219ffc9790 updated for version 7.3.487
Bram Moolenaar <bram@vim.org>
parents: 3427
diff changeset
4825 curwin->w_set_curswant = TRUE;
24079
a9ff8368d35f patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents: 23952
diff changeset
4826 if ((opt_flags & OPT_NO_REDRAW) == 0)
a9ff8368d35f patch 8.2.2581: Vim9: sourcing Vim9 script triggers a redraw
Bram Moolenaar <Bram@vim.org>
parents: 23952
diff changeset
4827 check_redraw(options[opt_idx].flags);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4828
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4829 return errmsg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4830 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4831
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4832 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4833 * Called after an option changed: check if something needs to be redrawn.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4834 */
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
4835 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4836 check_redraw(long_u flags)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4837 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
4838 // Careful: P_RCLR and P_RALL are a combination of other P_ flags
3263
320cc46d0eb0 updated for version 7.3.400
Bram Moolenaar <bram@vim.org>
parents: 3246
diff changeset
4839 int doclear = (flags & P_RCLR) == P_RCLR;
320cc46d0eb0 updated for version 7.3.400
Bram Moolenaar <bram@vim.org>
parents: 3246
diff changeset
4840 int all = ((flags & P_RALL) == P_RALL || doclear);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4841
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
4842 if ((flags & P_RSTAT) || all) // mark all status lines dirty
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4843 status_redraw_all();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4844
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4845 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4846 changed_window_setting();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4847 if (flags & P_RBUF)
29732
89e1d67814a9 patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents: 29546
diff changeset
4848 redraw_curbuf_later(UPD_NOT_VALID);
10456
536a7d49249c commit https://github.com/vim/vim/commit/a2477fd3490c1166522631eee53c57d34321086a
Christian Brabandt <cb@256bit.org>
parents: 10424
diff changeset
4849 if (flags & P_RWINONLY)
29732
89e1d67814a9 patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents: 29546
diff changeset
4850 redraw_later(UPD_NOT_VALID);
3263
320cc46d0eb0 updated for version 7.3.400
Bram Moolenaar <bram@vim.org>
parents: 3246
diff changeset
4851 if (doclear)
29732
89e1d67814a9 patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents: 29546
diff changeset
4852 redraw_all_later(UPD_CLEAR);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4853 else if (all)
29732
89e1d67814a9 patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents: 29546
diff changeset
4854 redraw_all_later(UPD_NOT_VALID);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4855 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4856
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4857 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4858 * Find index for option 'arg'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4859 * Return -1 if not found.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4860 */
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
4861 int
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4862 findoption(char_u *arg)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4863 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4864 int opt_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4865 char *s, *p;
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
4866 static short quick_tab[27] = {0, 0}; // quick access table
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4867 int is_term_opt;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4868
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
4869 // For first call: Initialize the quick-access table.
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
4870 // It contains the index for the first option that starts with a certain
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
4871 // letter. There are 26 letters, plus the first "t_" option.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4872 if (quick_tab[1] == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4873 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4874 p = options[0].fullname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4875 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4876 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4877 if (s[0] != p[0])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4878 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4879 if (s[0] == 't' && s[1] == '_')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4880 quick_tab[26] = opt_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4881 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4882 quick_tab[CharOrdLow(s[0])] = opt_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4883 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4884 p = s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4885 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4886 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4887
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
4888 // Check for name starting with an illegal character.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4889 if (arg[0] < 'a' || arg[0] > 'z')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4890 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4891
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4892 is_term_opt = (arg[0] == 't' && arg[1] == '_');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4893 if (is_term_opt)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4894 opt_idx = quick_tab[26];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4895 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4896 opt_idx = quick_tab[CharOrdLow(arg[0])];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4897 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4898 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
4899 if (STRCMP(arg, s) == 0) // match full name
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4900 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4901 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4902 if (s == NULL && !is_term_opt)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4903 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4904 opt_idx = quick_tab[CharOrdLow(arg[0])];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4905 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4906 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4907 s = options[opt_idx].shortname;
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
4908 if (s != NULL && STRCMP(arg, s) == 0) // match short name
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4909 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4910 s = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4911 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4912 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4913 if (s == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4914 opt_idx = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4915 return opt_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4916 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4917
31174
1d00fa720007 patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 31000
diff changeset
4918 #if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME) \
1d00fa720007 patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 31000
diff changeset
4919 || defined(FEAT_SPELL) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4920 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4921 * Get the value for an option.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4922 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4923 * Returns:
23422
bb0c53f4ef8b patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents: 23272
diff changeset
4924 * Number option: gov_number, *numval gets value.
23467
826a6406ea7b patch 8.2.2276: list of distributed files is outdated
Bram Moolenaar <Bram@vim.org>
parents: 23422
diff changeset
4925 * Toggle option: gov_bool, *numval gets value.
23422
bb0c53f4ef8b patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents: 23272
diff changeset
4926 * String option: gov_string, *stringval gets allocated string.
bb0c53f4ef8b patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents: 23272
diff changeset
4927 * Hidden Number option: gov_hidden_number.
bb0c53f4ef8b patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents: 23272
diff changeset
4928 * Hidden Toggle option: gov_hidden_bool.
bb0c53f4ef8b patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents: 23272
diff changeset
4929 * Hidden String option: gov_hidden_string.
bb0c53f4ef8b patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents: 23272
diff changeset
4930 * Unknown option: gov_unknown.
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26400
diff changeset
4931 *
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26400
diff changeset
4932 * "flagsp" (if not NULL) is set to the option flags (P_xxxx).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4933 */
23422
bb0c53f4ef8b patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents: 23272
diff changeset
4934 getoption_T
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4935 get_option_value(
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4936 char_u *name,
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
4937 long *numval,
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
4938 char_u **stringval, // NULL when only checking existence
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26400
diff changeset
4939 int *flagsp,
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26400
diff changeset
4940 int scope)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4941 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4942 int opt_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4943 char_u *varp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4944
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4945 opt_idx = findoption(name);
23422
bb0c53f4ef8b patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents: 23272
diff changeset
4946 if (opt_idx < 0) // option not in the table
10825
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4947 {
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4948 int key;
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4949
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4950 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
23422
bb0c53f4ef8b patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents: 23272
diff changeset
4951 && (key = find_key_option(name, FALSE)) != 0)
10825
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4952 {
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4953 char_u key_name[2];
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4954 char_u *p;
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4955
26802
f6b10a501a0e patch 8.2.3929: using unititialized variable
Bram Moolenaar <Bram@vim.org>
parents: 26771
diff changeset
4956 if (flagsp != NULL)
f6b10a501a0e patch 8.2.3929: using unititialized variable
Bram Moolenaar <Bram@vim.org>
parents: 26771
diff changeset
4957 *flagsp = 0; // terminal option has no flags
f6b10a501a0e patch 8.2.3929: using unititialized variable
Bram Moolenaar <Bram@vim.org>
parents: 26771
diff changeset
4958
23422
bb0c53f4ef8b patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents: 23272
diff changeset
4959 // check for a terminal option
10825
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4960 if (key < 0)
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4961 {
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4962 key_name[0] = KEY2TERMCAP0(key);
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4963 key_name[1] = KEY2TERMCAP1(key);
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4964 }
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4965 else
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4966 {
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4967 key_name[0] = KS_KEY;
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4968 key_name[1] = (key & 0xff);
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4969 }
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4970 p = find_termcode(key_name);
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4971 if (p != NULL)
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4972 {
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4973 if (stringval != NULL)
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4974 *stringval = vim_strsave(p);
23422
bb0c53f4ef8b patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents: 23272
diff changeset
4975 return gov_string;
10825
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4976 }
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4977 }
23422
bb0c53f4ef8b patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents: 23272
diff changeset
4978 return gov_unknown;
10825
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
4979 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4980
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26400
diff changeset
4981 varp = get_varp_scope(&(options[opt_idx]), scope);
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26400
diff changeset
4982
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26400
diff changeset
4983 if (flagsp != NULL)
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26400
diff changeset
4984 // Return the P_xxxx option flags.
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26400
diff changeset
4985 *flagsp = options[opt_idx].flags;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4986
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4987 if (options[opt_idx].flags & P_STRING)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4988 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
4989 if (varp == NULL) // hidden option
23422
bb0c53f4ef8b patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents: 23272
diff changeset
4990 return gov_hidden_string;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4991 if (stringval != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4992 {
28804
12bbd8a31cac patch 8.2.4926: #ifdef for crypt feature around too many lines
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
4993 if ((char_u **)varp == &p_pt) // 'pastetoggle'
30226
b6b803ed4a53 patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents: 30005
diff changeset
4994 *stringval = str2special_save(*(char_u **)(varp), FALSE,
b6b803ed4a53 patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents: 30005
diff changeset
4995 FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4996 #ifdef FEAT_CRYPT
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
4997 // never return the value of the crypt key
28804
12bbd8a31cac patch 8.2.4926: #ifdef for crypt feature around too many lines
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
4998 else if ((char_u **)varp == &curbuf->b_p_key
1622
149d8b46404c updated for version 7.2a
vimboss
parents: 1601
diff changeset
4999 && **(char_u **)(varp) != NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5000 *stringval = vim_strsave((char_u *)"*****");
28804
12bbd8a31cac patch 8.2.4926: #ifdef for crypt feature around too many lines
Bram Moolenaar <Bram@vim.org>
parents: 28800
diff changeset
5001 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5002 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5003 *stringval = vim_strsave(*(char_u **)(varp));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5004 }
23422
bb0c53f4ef8b patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents: 23272
diff changeset
5005 return gov_string;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5006 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5007
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5008 if (varp == NULL) // hidden option
23422
bb0c53f4ef8b patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents: 23272
diff changeset
5009 return (options[opt_idx].flags & P_NUM)
bb0c53f4ef8b patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents: 23272
diff changeset
5010 ? gov_hidden_number : gov_hidden_bool;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5011 if (options[opt_idx].flags & P_NUM)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5012 *numval = *(long *)varp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5013 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5014 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5015 // Special case: 'modified' is b_changed, but we also want to consider
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5016 // it set when 'ff' or 'fenc' changed.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5017 if ((int *)varp == &curbuf->b_changed)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5018 *numval = curbufIsChanged();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5019 else
9395
beab399e3883 commit https://github.com/vim/vim/commit/2acfbed9dbea990f129535de7ff3df360365130b
Christian Brabandt <cb@256bit.org>
parents: 9389
diff changeset
5020 *numval = (long) *(int *)varp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5021 }
23422
bb0c53f4ef8b patch 8.2.2254: Vim9: bool option type is number
Bram Moolenaar <Bram@vim.org>
parents: 23272
diff changeset
5022 return (options[opt_idx].flags & P_NUM) ? gov_number : gov_bool;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5023 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5024 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5025
5610
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5026 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5027 /*
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5028 * Returns the option attributes and its value. Unlike the above function it
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5029 * will return either global value or local value of the option depending on
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5030 * what was requested, but it will never return global value if it was
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5031 * requested to return local one and vice versa. Neither it will return
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5032 * buffer-local value if it was requested to return window-local one.
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5033 *
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5034 * Pretends that option is absent if it is not present in the requested scope
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5035 * (i.e. has no global, window-local or buffer-local value depending on
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5036 * opt_type). Uses
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5037 *
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5038 * Returned flags:
5867
a6b59ee633a3 updated for version 7.4.276
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
5039 * 0 hidden or unknown option, also option that does not have requested
a6b59ee633a3 updated for version 7.4.276
Bram Moolenaar <bram@vim.org>
parents: 5735
diff changeset
5040 * type (see SREQ_* in vim.h)
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5041 * see SOPT_* in vim.h for other flags
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5042 *
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5043 * Possible opt_type values: see SREQ_* in vim.h
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5044 */
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5045 int
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5046 get_option_value_strict(
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5047 char_u *name,
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5048 long *numval,
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5049 char_u **stringval, // NULL when only obtaining attributes
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5050 int opt_type,
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5051 void *from)
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5052 {
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5053 int opt_idx;
4367
b7f2d97ae2b7 updated for version 7.3.932
Bram Moolenaar <bram@vim.org>
parents: 4361
diff changeset
5054 char_u *varp = NULL;
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5055 struct vimoption *p;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5056 int r = 0;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5057
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5058 opt_idx = findoption(name);
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5059 if (opt_idx < 0)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5060 return 0;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5061
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5062 p = &(options[opt_idx]);
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5063
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5064 // Hidden option
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5065 if (p->var == NULL)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5066 return 0;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5067
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5068 if (p->flags & P_BOOL)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5069 r |= SOPT_BOOL;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5070 else if (p->flags & P_NUM)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5071 r |= SOPT_NUM;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5072 else if (p->flags & P_STRING)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5073 r |= SOPT_STRING;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5074
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5075 if (p->indir == PV_NONE)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5076 {
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5077 if (opt_type == SREQ_GLOBAL)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5078 r |= SOPT_GLOBAL;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5079 else
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5080 return 0; // Did not request global-only option
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5081 }
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5082 else
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5083 {
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5084 if (p->indir & PV_BOTH)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5085 r |= SOPT_GLOBAL;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5086 else if (opt_type == SREQ_GLOBAL)
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5087 return 0; // Requested global option
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5088
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5089 if (p->indir & PV_WIN)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5090 {
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5091 if (opt_type == SREQ_BUF)
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5092 return 0; // Did not request window-local option
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5093 else
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5094 r |= SOPT_WIN;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5095 }
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5096 else if (p->indir & PV_BUF)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5097 {
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5098 if (opt_type == SREQ_WIN)
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5099 return 0; // Did not request buffer-local option
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5100 else
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5101 r |= SOPT_BUF;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5102 }
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5103 }
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5104
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5105 if (stringval == NULL)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5106 return r;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5107
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5108 if (opt_type == SREQ_GLOBAL)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5109 varp = p->var;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5110 else
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5111 {
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5112 if (opt_type == SREQ_BUF)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5113 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5114 // Special case: 'modified' is b_changed, but we also want to
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5115 // consider it set when 'ff' or 'fenc' changed.
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5116 if (p->indir == PV_MOD)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5117 {
14179
ab64a4fb5edd patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents: 14175
diff changeset
5118 *numval = bufIsChanged((buf_T *)from);
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5119 varp = NULL;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5120 }
31174
1d00fa720007 patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 31000
diff changeset
5121 # ifdef FEAT_CRYPT
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5122 else if (p->indir == PV_KEY)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5123 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5124 // never return the value of the crypt key
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5125 *stringval = NULL;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5126 varp = NULL;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5127 }
31174
1d00fa720007 patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 31000
diff changeset
5128 # endif
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5129 else
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5130 {
14179
ab64a4fb5edd patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents: 14175
diff changeset
5131 buf_T *save_curbuf = curbuf;
ab64a4fb5edd patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents: 14175
diff changeset
5132
ab64a4fb5edd patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents: 14175
diff changeset
5133 // only getting a pointer, no need to use aucmd_prepbuf()
ab64a4fb5edd patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents: 14175
diff changeset
5134 curbuf = (buf_T *)from;
ab64a4fb5edd patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents: 14175
diff changeset
5135 curwin->w_buffer = curbuf;
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5136 varp = get_varp(p);
14179
ab64a4fb5edd patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents: 14175
diff changeset
5137 curbuf = save_curbuf;
ab64a4fb5edd patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents: 14175
diff changeset
5138 curwin->w_buffer = curbuf;
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5139 }
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5140 }
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5141 else if (opt_type == SREQ_WIN)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5142 {
14179
ab64a4fb5edd patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents: 14175
diff changeset
5143 win_T *save_curwin = curwin;
ab64a4fb5edd patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents: 14175
diff changeset
5144
ab64a4fb5edd patch 8.1.0107: Python: getting buffer option clears message
Christian Brabandt <cb@256bit.org>
parents: 14175
diff changeset
5145 curwin = (win_T *)from;
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5146 curbuf = curwin->w_buffer;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5147 varp = get_varp(p);
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5148 curwin = save_curwin;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5149 curbuf = curwin->w_buffer;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5150 }
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5151 if (varp == p->var)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5152 return (r | SOPT_UNSET);
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5153 }
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5154
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5155 if (varp != NULL)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5156 {
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5157 if (p->flags & P_STRING)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5158 *stringval = vim_strsave(*(char_u **)(varp));
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5159 else if (p->flags & P_NUM)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5160 *numval = *(long *) varp;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5161 else
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5162 *numval = *(int *)varp;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5163 }
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5164
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5165 return r;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5166 }
5610
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5167
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5168 /*
6243
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
5169 * Iterate over options. First argument is a pointer to a pointer to a
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
5170 * structure inside options[] array, second is option type like in the above
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
5171 * function.
5610
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5172 *
6243
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
5173 * If first argument points to NULL it is assumed that iteration just started
5610
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5174 * and caller needs the very first value.
6243
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
5175 * If first argument points to the end marker function returns NULL and sets
5610
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5176 * first argument to NULL.
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5177 *
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5178 * Returns full option name for current option on each call.
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5179 */
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5180 char_u *
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5181 option_iter_next(void **option, int opt_type)
5610
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5182 {
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5183 struct vimoption *ret = NULL;
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5184 do
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5185 {
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5186 if (*option == NULL)
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5187 *option = (void *) options;
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5188 else if (((struct vimoption *) (*option))->fullname == NULL)
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5189 {
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5190 *option = NULL;
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5191 return NULL;
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5192 }
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5193 else
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5194 *option = (void *) (((struct vimoption *) (*option)) + 1);
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5195
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5196 ret = ((struct vimoption *) (*option));
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5197
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5198 // Hidden option
5610
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5199 if (ret->var == NULL)
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5200 {
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5201 ret = NULL;
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5202 continue;
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5203 }
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5204
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5205 switch (opt_type)
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5206 {
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5207 case SREQ_GLOBAL:
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5208 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5209 ret = NULL;
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5210 break;
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5211 case SREQ_BUF:
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5212 if (!(ret->indir & PV_BUF))
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5213 ret = NULL;
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5214 break;
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5215 case SREQ_WIN:
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5216 if (!(ret->indir & PV_WIN))
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5217 ret = NULL;
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5218 break;
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5219 default:
10359
66f1b5bf3fa6 commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents: 10357
diff changeset
5220 internal_error("option_iter_next()");
5610
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5221 return NULL;
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5222 }
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5223 }
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5224 while (ret == NULL);
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5225
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5226 return (char_u *)ret->fullname;
2ace11abcfb5 updated for version 7.4.152
Bram Moolenaar <bram@vim.org>
parents: 5477
diff changeset
5227 }
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5228 #endif
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
5229
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5230 /*
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5231 * Return the flags for the option at 'opt_idx'.
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5232 */
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5233 long_u
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5234 get_option_flags(int opt_idx)
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5235 {
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5236 return options[opt_idx].flags;
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5237 }
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5238
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5239 /*
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5240 * Set a flag for the option at 'opt_idx'.
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5241 */
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5242 void
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5243 set_option_flag(int opt_idx, long_u flag)
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5244 {
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5245 options[opt_idx].flags |= flag;
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5246 }
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5247
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5248 /*
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5249 * Clear a flag for the option at 'opt_idx'.
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5250 */
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5251 void
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5252 clear_option_flag(int opt_idx, long_u flag)
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5253 {
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5254 options[opt_idx].flags &= ~flag;
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5255 }
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5256
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5257 /*
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5258 * Returns TRUE if the option at 'opt_idx' is a global option
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5259 */
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5260 int
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5261 is_global_option(int opt_idx)
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5262 {
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5263 return options[opt_idx].indir == PV_NONE;
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5264 }
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5265
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5266 /*
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5267 * Returns TRUE if the option at 'opt_idx' is a global option which also has a
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5268 * local value.
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5269 */
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5270 int
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5271 is_global_local_option(int opt_idx)
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5272 {
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5273 return options[opt_idx].indir & PV_BOTH;
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5274 }
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5275
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5276 /*
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5277 * Returns TRUE if the option at 'opt_idx' is a window-local option
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5278 */
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5279 int
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5280 is_window_local_option(int opt_idx)
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5281 {
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5282 return options[opt_idx].var == VAR_WIN;
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5283 }
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5284
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5285 /*
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5286 * Returns TRUE if the option at 'opt_idx' is a hidden option
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5287 */
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5288 int
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5289 is_hidden_option(int opt_idx)
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5290 {
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5291 return options[opt_idx].var == NULL;
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5292 }
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5293
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5294 #if defined(FEAT_CRYPT) || defined(PROTO)
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5295 /*
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5296 * Returns TRUE if the option at 'opt_idx' is a crypt key option
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5297 */
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5298 int
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5299 is_crypt_key_option(int opt_idx)
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5300 {
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5301 return options[opt_idx].indir == PV_KEY;
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5302 }
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5303 #endif
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5304
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
5305 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5306 * Set the value of option "name".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5307 * Use "string" for string options, use "number" for other options.
4513
cadb57fbb781 updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents: 4444
diff changeset
5308 *
28457
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
5309 * Returns NULL on success or an untranslated error message on error.
4513
cadb57fbb781 updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents: 4444
diff changeset
5310 */
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15207
diff changeset
5311 char *
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5312 set_option_value(
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5313 char_u *name,
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5314 long number,
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5315 char_u *string,
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5316 int opt_flags) // OPT_LOCAL or 0 (both)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5317 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5318 int opt_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5319 char_u *varp;
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 828
diff changeset
5320 long_u flags;
31950
b0717fcca5eb patch 9.0.1307: setting 'formatoptions' with :let doesn't check for errors
Bram Moolenaar <Bram@vim.org>
parents: 31926
diff changeset
5321 static char errbuf[80];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5322
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5323 opt_idx = findoption(name);
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
5324 if (opt_idx < 0)
10825
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5325 {
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5326 int key;
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5327
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5328 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
14381
d9e6eec551e1 patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents: 14313
diff changeset
5329 && (key = find_key_option(name, FALSE)) != 0)
10825
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5330 {
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5331 char_u key_name[2];
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5332
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5333 if (key < 0)
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5334 {
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5335 key_name[0] = KEY2TERMCAP0(key);
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5336 key_name[1] = KEY2TERMCAP1(key);
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5337 }
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5338 else
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5339 {
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5340 key_name[0] = KS_KEY;
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5341 key_name[1] = (key & 0xff);
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5342 }
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5343 add_termcode(key_name, string, FALSE);
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5344 if (full_screen)
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5345 ttest(FALSE);
29732
89e1d67814a9 patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents: 29546
diff changeset
5346 redraw_all_later(UPD_CLEAR);
10825
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5347 return NULL;
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5348 }
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5349
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26883
diff changeset
5350 semsg(_(e_unknown_option_str_2), name);
10825
4dea7c96fc82 patch 8.0.0302: cannot set terminal key codes with :let
Christian Brabandt <cb@256bit.org>
parents: 10722
diff changeset
5351 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5352 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5353 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5354 flags = options[opt_idx].flags;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5355 #ifdef HAVE_SANDBOX
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5356 // Disallow changing some options in the sandbox
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5357 if (sandbox > 0 && (flags & P_SECURE))
634
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
5358 {
25320
1e6da8364a02 patch 8.2.3197: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 25176
diff changeset
5359 emsg(_(e_not_allowed_in_sandbox));
4513
cadb57fbb781 updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents: 4444
diff changeset
5360 return NULL;
634
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
5361 }
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
5362 #endif
1c586ee8dd45 updated for version 7.0183
vimboss
parents: 593
diff changeset
5363 if (flags & P_STRING)
31950
b0717fcca5eb patch 9.0.1307: setting 'formatoptions' with :let doesn't check for errors
Bram Moolenaar <Bram@vim.org>
parents: 31926
diff changeset
5364 return set_string_option(opt_idx, string, opt_flags, errbuf);
28357
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5365
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5366 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5367 if (varp != NULL) // hidden option is not changed
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5368 {
28357
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5369 if (number == 0 && string != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5370 {
28357
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5371 int idx;
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5372
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5373 // Either we are given a string or we are setting option
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5374 // to zero.
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5375 for (idx = 0; string[idx] == '0'; ++idx)
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5376 ;
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5377 if (string[idx] != NUL || idx == 0)
1298
f4c7b5da017a updated for version 7.1-012
vimboss
parents: 1157
diff changeset
5378 {
28357
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5379 // There's another character after zeros or the string
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5380 // is empty. In both cases, we are trying to set a
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5381 // num option using a string.
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5382 semsg(_(e_number_required_after_str_equal_str),
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5383 name, string);
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5384 return NULL; // do nothing as we hit an error
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5385
1298
f4c7b5da017a updated for version 7.1-012
vimboss
parents: 1157
diff changeset
5386 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5387 }
28357
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5388 if (flags & P_NUM)
31950
b0717fcca5eb patch 9.0.1307: setting 'formatoptions' with :let doesn't check for errors
Bram Moolenaar <Bram@vim.org>
parents: 31926
diff changeset
5389 {
28357
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5390 return set_num_option(opt_idx, varp, number,
31950
b0717fcca5eb patch 9.0.1307: setting 'formatoptions' with :let doesn't check for errors
Bram Moolenaar <Bram@vim.org>
parents: 31926
diff changeset
5391 errbuf, sizeof(errbuf), opt_flags);
b0717fcca5eb patch 9.0.1307: setting 'formatoptions' with :let doesn't check for errors
Bram Moolenaar <Bram@vim.org>
parents: 31926
diff changeset
5392 }
28357
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5393 else
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5394 return set_bool_option(opt_idx, varp, (int)number, opt_flags);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5395 }
28357
86b6432aa1d8 patch 8.2.4704: using "else" after return or break increases indent
Bram Moolenaar <Bram@vim.org>
parents: 28353
diff changeset
5396
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5397 }
4513
cadb57fbb781 updated for version 7.3.1004
Bram Moolenaar <bram@vim.org>
parents: 4444
diff changeset
5398 return NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5399 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5400
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5401 /*
28457
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
5402 * Call set_option_value() and when an error is returned report it.
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
5403 */
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
5404 void
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
5405 set_option_value_give_err(
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
5406 char_u *name,
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
5407 long number,
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
5408 char_u *string,
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
5409 int opt_flags) // OPT_LOCAL or 0 (both)
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
5410 {
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
5411 char *errmsg = set_option_value(name, number, string, opt_flags);
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
5412
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
5413 if (errmsg != NULL)
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
5414 emsg(_(errmsg));
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
5415 }
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
5416
4dcccb2673fe patch 8.2.4753: error from setting an option is silently ignored
Bram Moolenaar <Bram@vim.org>
parents: 28405
diff changeset
5417 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5418 * Get the terminal code for a terminal option.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5419 * Returns NULL when not found.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5420 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5421 char_u *
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5422 get_term_code(char_u *tname)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5423 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5424 int opt_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5425 char_u *varp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5426
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5427 if (tname[0] != 't' || tname[1] != '_' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5428 tname[2] == NUL || tname[3] == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5429 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5430 if ((opt_idx = findoption(tname)) >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5431 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5432 varp = get_varp(&(options[opt_idx]));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5433 if (varp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5434 varp = *(char_u **)(varp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5435 return varp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5436 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5437 return find_termcode(tname + 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5438 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5439
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5440 char_u *
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5441 get_highlight_default(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5442 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5443 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5444
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5445 i = findoption((char_u *)"hl");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5446 if (i >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5447 return options[i].def_val[VI_DEFAULT];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5448 return (char_u *)NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5449 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5450
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
5451 char_u *
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5452 get_encoding_default(void)
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
5453 {
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
5454 int i;
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
5455
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
5456 i = findoption((char_u *)"enc");
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
5457 if (i >= 0)
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
5458 return options[i].def_val[VI_DEFAULT];
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
5459 return (char_u *)NULL;
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
5460 }
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
5461
28405
473cfd79bcd8 patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents: 28357
diff changeset
5462 #if defined(FEAT_QUICKFIX) || defined(PROTO)
27855
44a552776007 patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents: 27659
diff changeset
5463 int
44a552776007 patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents: 27659
diff changeset
5464 is_option_allocated(char *name)
44a552776007 patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents: 27659
diff changeset
5465 {
44a552776007 patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents: 27659
diff changeset
5466 int idx = findoption((char_u *)name);
44a552776007 patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents: 27659
diff changeset
5467
44a552776007 patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents: 27659
diff changeset
5468 return idx >= 0 && (options[idx].flags & P_ALLOCED);
44a552776007 patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents: 27659
diff changeset
5469 }
28405
473cfd79bcd8 patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents: 28357
diff changeset
5470 #endif
27855
44a552776007 patch 8.2.4453: :helpgrep may free an option that was not allocated
Bram Moolenaar <Bram@vim.org>
parents: 27659
diff changeset
5471
29497
9908c07ccb56 patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents: 29395
diff changeset
5472 #if defined(FEAT_EVAL) || defined(PROTO)
9908c07ccb56 patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents: 29395
diff changeset
5473 /*
9908c07ccb56 patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents: 29395
diff changeset
5474 * Return TRUE if "name" is a string option.
9908c07ccb56 patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents: 29395
diff changeset
5475 * Returns FALSE if option "name" does not exist.
9908c07ccb56 patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents: 29395
diff changeset
5476 */
9908c07ccb56 patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents: 29395
diff changeset
5477 int
9908c07ccb56 patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents: 29395
diff changeset
5478 is_string_option(char_u *name)
9908c07ccb56 patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents: 29395
diff changeset
5479 {
9908c07ccb56 patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents: 29395
diff changeset
5480 int idx = findoption(name);
9908c07ccb56 patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents: 29395
diff changeset
5481
9908c07ccb56 patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents: 29395
diff changeset
5482 return idx >= 0 && (options[idx].flags & P_STRING);
9908c07ccb56 patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents: 29395
diff changeset
5483 }
9908c07ccb56 patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents: 29395
diff changeset
5484 #endif
9908c07ccb56 patch 9.0.0090: no error when assigning bool to a string option
Bram Moolenaar <Bram@vim.org>
parents: 29395
diff changeset
5485
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5486 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5487 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
14381
d9e6eec551e1 patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents: 14313
diff changeset
5488 * When "has_lt" is true there is a '<' before "*arg_arg".
d9e6eec551e1 patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents: 14313
diff changeset
5489 * Returns 0 when the key is not recognized.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5490 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5491 static int
14381
d9e6eec551e1 patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents: 14313
diff changeset
5492 find_key_option(char_u *arg_arg, int has_lt)
d9e6eec551e1 patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents: 14313
diff changeset
5493 {
d9e6eec551e1 patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents: 14313
diff changeset
5494 int key = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5495 int modifiers;
14381
d9e6eec551e1 patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents: 14313
diff changeset
5496 char_u *arg = arg_arg;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5497
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
5498 // Don't use get_special_key_code() for t_xx, we don't want it to call
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
5499 // add_termcap_entry().
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5500 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5501 key = TERMCAP2KEY(arg[2], arg[3]);
14381
d9e6eec551e1 patch 8.1.0205: invalid memory access with invalid modeline
Christian Brabandt <cb@256bit.org>
parents: 14313
diff changeset
5502 else if (has_lt)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5503 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5504 --arg; // put arg at the '<'
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5505 modifiers = 0;
20603
c2570baa2e4c patch 8.2.0855: GUI tests fail because the test doesn't use a modifier
Bram Moolenaar <Bram@vim.org>
parents: 20269
diff changeset
5506 key = find_special_key(&arg, &modifiers,
c2570baa2e4c patch 8.2.0855: GUI tests fail because the test doesn't use a modifier
Bram Moolenaar <Bram@vim.org>
parents: 20269
diff changeset
5507 FSK_KEYCODE | FSK_KEEP_X_KEY | FSK_SIMPLIFY, NULL);
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5508 if (modifiers) // can't handle modifiers here
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5509 key = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5510 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5511 return key;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5512 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5513
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5514 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5515 * if 'all' == 0: show changed options
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5516 * if 'all' == 1: show all normal options
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5517 * if 'all' == 2: show all terminal options
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5518 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5519 static void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5520 showoptions(
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5521 int all,
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5522 int opt_flags) // OPT_LOCAL and/or OPT_GLOBAL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5523 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5524 struct vimoption *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5525 int col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5526 int isterm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5527 char_u *varp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5528 struct vimoption **items;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5529 int item_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5530 int run;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5531 int row, rows;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5532 int cols;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5533 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5534 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5535
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5536 #define INC 20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5537 #define GAP 3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5538
19137
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
5539 items = ALLOC_MULT(struct vimoption *, OPTION_COUNT);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5540 if (items == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5541 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5542
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5543 // Highlight title
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5544 if (all == 2)
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15502
diff changeset
5545 msg_puts_title(_("\n--- Terminal codes ---"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5546 else if (opt_flags & OPT_GLOBAL)
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15502
diff changeset
5547 msg_puts_title(_("\n--- Global option values ---"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5548 else if (opt_flags & OPT_LOCAL)
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15502
diff changeset
5549 msg_puts_title(_("\n--- Local option values ---"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5550 else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15502
diff changeset
5551 msg_puts_title(_("\n--- Options ---"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5552
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
5553 // Do the loop two times:
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
5554 // 1. display the short items
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
5555 // 2. display the long items (only strings and numbers)
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
5556 // When "opt_flags" has OPT_ONECOLUMN do everything in run 2.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5557 for (run = 1; run <= 2 && !got_int; ++run)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5558 {
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
5559 // collect the items in items[]
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5560 item_count = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5561 for (p = &options[0]; p->fullname != NULL; p++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5562 {
14968
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14935
diff changeset
5563 // apply :filter /pat/
19137
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
5564 if (message_filtered((char_u *)p->fullname))
14968
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14935
diff changeset
5565 continue;
c5ec5ddbe814 patch 8.1.0495: :filter only supports some commands
Bram Moolenaar <Bram@vim.org>
parents: 14935
diff changeset
5566
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5567 varp = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5568 isterm = istermoption(p);
19137
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
5569 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5570 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5571 if (p->indir != PV_NONE && !isterm)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5572 varp = get_varp_scope(p, opt_flags);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5573 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5574 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5575 varp = get_varp(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5576 if (varp != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5577 && ((all == 2 && isterm)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5578 || (all == 1 && !isterm)
16843
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
5579 || (all == 0 && !optval_default(p, varp, p_cp))))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5580 {
19137
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
5581 if (opt_flags & OPT_ONECOLUMN)
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
5582 len = Columns;
69f0e9b5c107 patch 8.2.0128: cannot list options one per line
Bram Moolenaar <Bram@vim.org>
parents: 18991
diff changeset
5583 else if (p->flags & P_BOOL)
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5584 len = 1; // a toggle option fits always
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5585 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5586 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5587 option_value2string(p, opt_flags);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5588 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5589 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5590 if ((len <= INC - GAP && run == 1) ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5591 (len > INC - GAP && run == 2))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5592 items[item_count++] = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5593 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5594 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5595
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
5596 // display the items
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5597 if (run == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5598 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5599 cols = (Columns + GAP - 3) / INC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5600 if (cols == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5601 cols = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5602 rows = (item_count + cols - 1) / cols;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5603 }
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5604 else // run == 2
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5605 rows = item_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5606 for (row = 0; row < rows && !got_int; ++row)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5607 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5608 msg_putchar('\n'); // go to next line
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5609 if (got_int) // 'q' typed in more
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5610 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5611 col = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5612 for (i = row; i < item_count; i += rows)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5613 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5614 msg_col = col; // make columns
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5615 showoneopt(items[i], opt_flags);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5616 col += INC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5617 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5618 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5619 ui_breakcheck();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5620 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5621 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5622 vim_free(items);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5623 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5624
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5625 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5626 * Return TRUE if option "p" has its default value.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5627 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5628 static int
16843
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
5629 optval_default(struct vimoption *p, char_u *varp, int compatible)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5630 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5631 int dvi;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5632
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5633 if (varp == NULL)
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5634 return TRUE; // hidden option is always at default
16843
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
5635 dvi = ((p->flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5636 if (p->flags & P_NUM)
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 839
diff changeset
5637 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5638 if (p->flags & P_BOOL)
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5639 // the cast to long is required for Manx C, long_i is
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5640 // needed for MSVC
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 839
diff changeset
5641 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5642 // P_STRING
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5643 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5644 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5645
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5646 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5647 * showoneopt: show the value of one option
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5648 * must not be called with a hidden option!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5649 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5650 static void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5651 showoneopt(
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5652 struct vimoption *p,
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5653 int opt_flags) // OPT_LOCAL or OPT_GLOBAL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5654 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
5655 char_u *varp;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
5656 int save_silent = silent_mode;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
5657
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
5658 silent_mode = FALSE;
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5659 info_message = TRUE; // use mch_msg(), not mch_errmsg()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5660
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5661 varp = get_varp_scope(p, opt_flags);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5662
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5663 // for 'modified' we also need to check if 'ff' or 'fenc' changed.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5664 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5665 ? !curbufIsChanged() : !*(int *)varp))
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15502
diff changeset
5666 msg_puts("no");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5667 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15502
diff changeset
5668 msg_puts("--");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5669 else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15502
diff changeset
5670 msg_puts(" ");
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15502
diff changeset
5671 msg_puts(p->fullname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5672 if (!(p->flags & P_BOOL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5673 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5674 msg_putchar('=');
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5675 // put value string in NameBuff
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5676 option_value2string(p, opt_flags);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5677 msg_outtrans(NameBuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5678 }
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
5679
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
5680 silent_mode = save_silent;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 164
diff changeset
5681 info_message = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5682 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5683
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5684 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5685 * Write modified options as ":set" commands to a file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5686 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5687 * There are three values for "opt_flags":
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5688 * OPT_GLOBAL: Write global option values and fresh values of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5689 * buffer-local options (used for start of a session
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5690 * file).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5691 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5692 * curwin (used for a vimrc file).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5693 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5694 * and local values for window-local options of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5695 * curwin. Local values are also written when at the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5696 * default value, because a modeline or autocommand
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5697 * may have set them when doing ":edit file" and the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5698 * user has set them back at the default or fresh
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5699 * value.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5700 * When "local_only" is TRUE, don't write fresh
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5701 * values, only local values (for ":mkview").
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5702 * (fresh value = value used for a new buffer or window for a local option).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5703 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5704 * Return FAIL on error, OK otherwise.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5705 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5706 int
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5707 makeset(FILE *fd, int opt_flags, int local_only)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5708 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5709 struct vimoption *p;
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5710 char_u *varp; // currently used value
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5711 char_u *varp_fresh; // local value
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5712 char_u *varp_local = NULL; // fresh value
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5713 char *cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5714 int round;
1384
5ef53a1677ee updated for version 7.1-099
vimboss
parents: 1382
diff changeset
5715 int pri;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5716
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5717 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5718 * The options that don't have a default (terminal name, columns, lines)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5719 * are never written. Terminal options are also not written.
1384
5ef53a1677ee updated for version 7.1-099
vimboss
parents: 1382
diff changeset
5720 * Do the loop over "options[]" twice: once for options with the
5ef53a1677ee updated for version 7.1-099
vimboss
parents: 1382
diff changeset
5721 * P_PRI_MKRC flag and once without.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5722 */
1384
5ef53a1677ee updated for version 7.1-099
vimboss
parents: 1382
diff changeset
5723 for (pri = 1; pri >= 0; --pri)
5ef53a1677ee updated for version 7.1-099
vimboss
parents: 1382
diff changeset
5724 {
5ef53a1677ee updated for version 7.1-099
vimboss
parents: 1382
diff changeset
5725 for (p = &options[0]; !istermoption(p); p++)
5ef53a1677ee updated for version 7.1-099
vimboss
parents: 1382
diff changeset
5726 if (!(p->flags & P_NO_MKRC)
5ef53a1677ee updated for version 7.1-099
vimboss
parents: 1382
diff changeset
5727 && !istermoption(p)
5ef53a1677ee updated for version 7.1-099
vimboss
parents: 1382
diff changeset
5728 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5729 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5730 // skip global option when only doing locals
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5731 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5732 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5733
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5734 // Do not store options like 'bufhidden' and 'syntax' in a vimrc
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5735 // file, they are always buffer-specific.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5736 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5737 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5738
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5739 // Global values are only written when not at the default value.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5740 varp = get_varp_scope(p, opt_flags);
16843
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
5741 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp, p_cp))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5742 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5743
24476
e79d1475fc89 patch 8.2.2778: problem restoring 'packpath' in session
Bram Moolenaar <Bram@vim.org>
parents: 24464
diff changeset
5744 if ((opt_flags & OPT_SKIPRTP) && (p->var == (char_u *)&p_rtp
e79d1475fc89 patch 8.2.2778: problem restoring 'packpath' in session
Bram Moolenaar <Bram@vim.org>
parents: 24464
diff changeset
5745 || p->var == (char_u *)&p_pp))
24464
a56f9c2ba51c patch 8.2.2772: problems when restoring 'runtimepath' from a session file
Bram Moolenaar <Bram@vim.org>
parents: 24079
diff changeset
5746 continue;
a56f9c2ba51c patch 8.2.2772: problems when restoring 'runtimepath' from a session file
Bram Moolenaar <Bram@vim.org>
parents: 24079
diff changeset
5747
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5748 round = 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5749 if (p->indir != PV_NONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5750 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5751 if (p->var == VAR_WIN)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5752 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5753 // skip window-local option when only doing globals
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5754 if (!(opt_flags & OPT_LOCAL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5755 continue;
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5756 // When fresh value of window-local option is not at the
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5757 // default, need to write it too.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5758 if (!(opt_flags & OPT_GLOBAL) && !local_only)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5759 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5760 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
16843
283037126560 patch 8.1.1423: popup windows use options from current window and buffer
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
5761 if (!optval_default(p, varp_fresh, p_cp))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5762 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5763 round = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5764 varp_local = varp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5765 varp = varp_fresh;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5766 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5767 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5768 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5769 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5770
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5771 // Round 1: fresh value for window-local options.
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5772 // Round 2: other values
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5773 for ( ; round <= 2; varp = varp_local, ++round)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5774 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5775 if (round == 1 || (opt_flags & OPT_GLOBAL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5776 cmd = "set";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5777 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5778 cmd = "setlocal";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5779
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5780 if (p->flags & P_BOOL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5781 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5782 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5783 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5784 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5785 else if (p->flags & P_NUM)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5786 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5787 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5788 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5789 }
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5790 else // P_STRING
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5791 {
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
5792 int do_endif = FALSE;
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
5793
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5794 // Don't set 'syntax' and 'filetype' again if the value is
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5795 // already right, avoids reloading the syntax file.
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
5796 if (
13380
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13361
diff changeset
5797 #if defined(FEAT_SYN_HL)
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13361
diff changeset
5798 p->indir == PV_SYN ||
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13361
diff changeset
5799 #endif
69517d67421f patch 8.0.1564: too many #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 13361
diff changeset
5800 p->indir == PV_FT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5801 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5802 if (fprintf(fd, "if &%s != '%s'", p->fullname,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5803 *(char_u **)(varp)) < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5804 || put_eol(fd) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5805 return FAIL;
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
5806 do_endif = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5807 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5808 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
15613
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5809 p->flags) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5810 return FAIL;
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
5811 if (do_endif)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5812 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5813 if (put_line(fd, "endif") == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5814 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5815 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5816 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5817 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5818 }
1384
5ef53a1677ee updated for version 7.1-099
vimboss
parents: 1382
diff changeset
5819 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5820 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5821 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5822
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5823 #if defined(FEAT_FOLDING) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5824 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5825 * Generate set commands for the local fold options only. Used when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5826 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5827 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5828 int
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5829 makefoldset(FILE *fd)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5830 {
15613
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5831 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, 0) == FAIL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5832 # ifdef FEAT_EVAL
15613
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5833 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5834 == FAIL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5835 # endif
15613
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5836 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5837 == FAIL
15613
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5838 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5839 == FAIL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5840 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5841 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5842 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5843 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5844 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5845 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5846
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5847 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5848 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5849 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5850
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5851 static int
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5852 put_setstring(
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5853 FILE *fd,
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5854 char *cmd,
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5855 char *name,
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5856 char_u **valuep,
15613
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5857 long_u flags)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5858 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5859 char_u *s;
15613
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5860 char_u *buf = NULL;
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5861 char_u *part = NULL;
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5862 char_u *p;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5863
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5864 if (fprintf(fd, "%s %s=", cmd, name) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5865 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5866 if (*valuep != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5867 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5868 // Output 'pastetoggle' as key names. For other
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5869 // options some characters have to be escaped with
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5870 // CTRL-V or backslash
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5871 if (valuep == &p_pt)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5872 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5873 s = *valuep;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5874 while (*s != NUL)
30226
b6b803ed4a53 patch 9.0.0449: there is no easy way to translate a key code into a string
Bram Moolenaar <Bram@vim.org>
parents: 30005
diff changeset
5875 if (put_escstr(fd, str2special(&s, FALSE, FALSE), 2) == FAIL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5876 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5877 }
15613
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5878 // expand the option value, replace $HOME by ~
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5879 else if ((flags & P_EXPAND) != 0)
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5880 {
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5881 int size = (int)STRLEN(*valuep) + 1;
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5882
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5883 // replace home directory in the whole option value into "buf"
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5884 buf = alloc(size);
2780
5ddb68c2a845 updated for version 7.3.166
Bram Moolenaar <bram@vim.org>
parents: 2774
diff changeset
5885 if (buf == NULL)
15613
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5886 goto fail;
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5887 home_replace(NULL, *valuep, buf, size, FALSE);
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5888
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5889 // If the option value is longer than MAXPATHL, we need to append
18498
9e6d5a4abb1c patch 8.1.2243: typos in comments
Bram Moolenaar <Bram@vim.org>
parents: 18463
diff changeset
5890 // each comma separated part of the option separately, so that it
15613
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5891 // can be expanded when read back.
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5892 if (size >= MAXPATHL && (flags & P_COMMA) != 0
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5893 && vim_strchr(*valuep, ',') != NULL)
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5894 {
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5895 part = alloc(size);
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5896 if (part == NULL)
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5897 goto fail;
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5898
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5899 // write line break to clear the option, e.g. ':set rtp='
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5900 if (put_eol(fd) == FAIL)
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5901 goto fail;
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5902
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5903 p = buf;
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5904 while (*p != NUL)
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5905 {
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5906 // for each comma separated option part, append value to
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5907 // the option, :set rtp+=value
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5908 if (fprintf(fd, "%s %s+=", cmd, name) < 0)
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5909 goto fail;
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5910 (void)copy_option_part(&p, part, size, ",");
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5911 if (put_escstr(fd, part, 2) == FAIL || put_eol(fd) == FAIL)
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5912 goto fail;
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5913 }
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5914 vim_free(buf);
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5915 vim_free(part);
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5916 return OK;
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5917 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5918 if (put_escstr(fd, buf, 2) == FAIL)
2780
5ddb68c2a845 updated for version 7.3.166
Bram Moolenaar <bram@vim.org>
parents: 2774
diff changeset
5919 {
5ddb68c2a845 updated for version 7.3.166
Bram Moolenaar <bram@vim.org>
parents: 2774
diff changeset
5920 vim_free(buf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5921 return FAIL;
2780
5ddb68c2a845 updated for version 7.3.166
Bram Moolenaar <bram@vim.org>
parents: 2774
diff changeset
5922 }
5ddb68c2a845 updated for version 7.3.166
Bram Moolenaar <bram@vim.org>
parents: 2774
diff changeset
5923 vim_free(buf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5924 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5925 else if (put_escstr(fd, *valuep, 2) == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5926 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5927 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5928 if (put_eol(fd) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5929 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5930 return OK;
15613
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5931 fail:
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5932 vim_free(buf);
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5933 vim_free(part);
90f01701ecad patch 8.1.0814: :mksession cannot handle a very long 'runtimepath'
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
5934 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5935 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5936
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5937 static int
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5938 put_setnum(
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5939 FILE *fd,
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5940 char *cmd,
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5941 char *name,
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5942 long *valuep)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5943 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5944 long wc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5945
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5946 if (fprintf(fd, "%s %s=", cmd, name) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5947 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5948 if (wc_use_keyname((char_u *)valuep, &wc))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5949 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5950 // print 'wildchar' and 'wildcharm' as a key name
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5951 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5952 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5953 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5954 else if (fprintf(fd, "%ld", *valuep) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5955 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5956 if (put_eol(fd) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5957 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5958 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5959 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5960
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5961 static int
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5962 put_setbool(
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5963 FILE *fd,
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5964 char *cmd,
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5965 char *name,
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5966 int value)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5967 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5968 if (value < 0) // global/local option using global value
1416
0a80dc6d7804 updated for version 7.1-131
vimboss
parents: 1408
diff changeset
5969 return OK;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5970 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5971 || put_eol(fd) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5972 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5973 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5974 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5975
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5976 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5977 * Clear all the terminal options.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5978 * If the option has been allocated, free the memory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5979 * Terminal options are never hidden or indirect.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5980 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5981 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
5982 clear_termoptions(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5983 {
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
5984 // Reset a few things before clearing the old options. This may cause
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
5985 // outputting a few things that the terminal doesn't understand, but the
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
5986 // screen will be cleared later, so this is OK.
18354
9f51d0cef8da patch 8.1.2171: mouse support not always available
Bram Moolenaar <Bram@vim.org>
parents: 18301
diff changeset
5987 mch_setmouse(FALSE); // switch mouse off
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5988 mch_restore_title(SAVE_RESTORE_BOTH); // restore window titles
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5989 #if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5990 // When starting the GUI close the display opened for the clipboard.
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5991 // After restoring the title, because that will need the display.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5992 if (gui.starting)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5993 clear_xterm_clip();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5994 #endif
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
5995 stoptermcap(); // stop termcap mode
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5996
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
5997 free_termoptions();
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
5998 }
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
5999
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
6000 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
6001 free_termoptions(void)
359
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
6002 {
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
6003 struct vimoption *p;
6c62b9b939bd updated for version 7.0093
vimboss
parents: 344
diff changeset
6004
14867
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
6005 for (p = options; p->fullname != NULL; p++)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6006 if (istermoption(p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6007 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6008 if (p->flags & P_ALLOCED)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6009 free_string_option(*(char_u **)(p->var));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6010 if (p->flags & P_DEF_ALLOCED)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6011 free_string_option(p->def_val[VI_DEFAULT]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6012 *(char_u **)(p->var) = empty_option;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6013 p->def_val[VI_DEFAULT] = empty_option;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6014 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
14867
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
6015 #ifdef FEAT_EVAL
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
6016 // remember where the option was cleared
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
6017 set_option_sctx_idx((int)(p - options), OPT_GLOBAL, current_sctx);
cf4d6489c9eb patch 8.1.0445: setting 'term' does not store location for termcap options
Christian Brabandt <cb@256bit.org>
parents: 14862
diff changeset
6018 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6019 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6020 clear_termcodes();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6021 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6022
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6023 /*
1941
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6024 * Free the string for one term option, if it was allocated.
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6025 * Set the string to empty_option and clear allocated flag.
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6026 * "var" points to the option value.
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6027 */
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6028 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
6029 free_one_termoption(char_u *var)
1941
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6030 {
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6031 struct vimoption *p;
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6032
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6033 for (p = &options[0]; p->fullname != NULL; p++)
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6034 if (p->var == var)
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6035 {
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6036 if (p->flags & P_ALLOCED)
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6037 free_string_option(*(char_u **)(p->var));
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6038 *(char_u **)(p->var) = empty_option;
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6039 p->flags &= ~P_ALLOCED;
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6040 break;
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6041 }
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6042 }
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6043
d92358c7d621 updated for version 7.2-238
vimboss
parents: 1911
diff changeset
6044 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6045 * Set the terminal option defaults to the current value.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6046 * Used after setting the terminal name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6047 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6048 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
6049 set_term_defaults(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6050 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6051 struct vimoption *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6052
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6053 for (p = &options[0]; p->fullname != NULL; p++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6054 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6055 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6056 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6057 if (p->flags & P_DEF_ALLOCED)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6058 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6059 free_string_option(p->def_val[VI_DEFAULT]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6060 p->flags &= ~P_DEF_ALLOCED;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6061 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6062 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6063 if (p->flags & P_ALLOCED)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6064 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6065 p->flags |= P_DEF_ALLOCED;
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
6066 p->flags &= ~P_ALLOCED; // don't free the value now
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6067 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6068 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6069 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6070 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6071
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6072 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6073 * return TRUE if 'p' starts with 't_'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6074 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6075 static int
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
6076 istermoption(struct vimoption *p)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6077 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6078 return (p->fullname[0] == 't' && p->fullname[1] == '_');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6079 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6080
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6081 /*
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6082 * Returns TRUE if the option at 'opt_idx' starts with 't_'
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6083 */
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6084 int
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6085 istermoption_idx(int opt_idx)
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6086 {
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6087 return istermoption(&options[opt_idx]);
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6088 }
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6089
15555
d89c5b339c2a patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents: 15543
diff changeset
6090 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6091 /*
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6092 * Unset local option value, similar to ":set opt<".
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6093 */
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6094 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
6095 unset_global_local_option(char_u *name, void *from)
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6096 {
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6097 struct vimoption *p;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6098 int opt_idx;
4361
94aa0d30a3ea updated for version 7.3.929
Bram Moolenaar <bram@vim.org>
parents: 4350
diff changeset
6099 buf_T *buf = (buf_T *)from;
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6100
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6101 opt_idx = findoption(name);
7007
5ea5bd9c18d2 patch 7.4.821
Bram Moolenaar <bram@vim.org>
parents: 6954
diff changeset
6102 if (opt_idx < 0)
5ea5bd9c18d2 patch 7.4.821
Bram Moolenaar <bram@vim.org>
parents: 6954
diff changeset
6103 return;
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6104 p = &(options[opt_idx]);
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6105
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6106 switch ((int)p->indir)
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6107 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
6108 // global option with local value: use local value if it's been set
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6109 case PV_EP:
4361
94aa0d30a3ea updated for version 7.3.929
Bram Moolenaar <bram@vim.org>
parents: 4350
diff changeset
6110 clear_string_option(&buf->b_p_ep);
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6111 break;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6112 case PV_KP:
4361
94aa0d30a3ea updated for version 7.3.929
Bram Moolenaar <bram@vim.org>
parents: 4350
diff changeset
6113 clear_string_option(&buf->b_p_kp);
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6114 break;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6115 case PV_PATH:
4361
94aa0d30a3ea updated for version 7.3.929
Bram Moolenaar <bram@vim.org>
parents: 4350
diff changeset
6116 clear_string_option(&buf->b_p_path);
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6117 break;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6118 case PV_AR:
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6119 buf->b_p_ar = -1;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6120 break;
6243
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
6121 case PV_BKC:
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
6122 clear_string_option(&buf->b_p_bkc);
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
6123 buf->b_bkc_flags = 0;
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
6124 break;
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6125 case PV_TAGS:
4361
94aa0d30a3ea updated for version 7.3.929
Bram Moolenaar <bram@vim.org>
parents: 4350
diff changeset
6126 clear_string_option(&buf->b_p_tags);
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6127 break;
7266
6ba7182fb7bd commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents: 7218
diff changeset
6128 case PV_TC:
6ba7182fb7bd commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents: 7218
diff changeset
6129 clear_string_option(&buf->b_p_tc);
6ba7182fb7bd commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents: 7218
diff changeset
6130 buf->b_tc_flags = 0;
6ba7182fb7bd commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents: 7218
diff changeset
6131 break;
28809
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28804
diff changeset
6132 case PV_SISO:
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28804
diff changeset
6133 curwin->w_p_siso = -1;
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28804
diff changeset
6134 break;
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28804
diff changeset
6135 case PV_SO:
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28804
diff changeset
6136 curwin->w_p_so = -1;
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28804
diff changeset
6137 break;
31174
1d00fa720007 patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 31000
diff changeset
6138 # ifdef FEAT_FIND_ID
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6139 case PV_DEF:
4361
94aa0d30a3ea updated for version 7.3.929
Bram Moolenaar <bram@vim.org>
parents: 4350
diff changeset
6140 clear_string_option(&buf->b_p_def);
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6141 break;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6142 case PV_INC:
4361
94aa0d30a3ea updated for version 7.3.929
Bram Moolenaar <bram@vim.org>
parents: 4350
diff changeset
6143 clear_string_option(&buf->b_p_inc);
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6144 break;
31174
1d00fa720007 patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 31000
diff changeset
6145 # endif
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6146 case PV_DICT:
4361
94aa0d30a3ea updated for version 7.3.929
Bram Moolenaar <bram@vim.org>
parents: 4350
diff changeset
6147 clear_string_option(&buf->b_p_dict);
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6148 break;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6149 case PV_TSR:
4361
94aa0d30a3ea updated for version 7.3.929
Bram Moolenaar <bram@vim.org>
parents: 4350
diff changeset
6150 clear_string_option(&buf->b_p_tsr);
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6151 break;
31174
1d00fa720007 patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 31000
diff changeset
6152 # ifdef FEAT_COMPL_FUNC
25990
ac330e2fecc4 patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents: 25984
diff changeset
6153 case PV_TSRFU:
ac330e2fecc4 patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents: 25984
diff changeset
6154 clear_string_option(&buf->b_p_tsrfu);
ac330e2fecc4 patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents: 25984
diff changeset
6155 break;
31174
1d00fa720007 patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 31000
diff changeset
6156 # endif
10579
688b97124d23 patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents: 10456
diff changeset
6157 case PV_FP:
688b97124d23 patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents: 10456
diff changeset
6158 clear_string_option(&buf->b_p_fp);
688b97124d23 patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents: 10456
diff changeset
6159 break;
31174
1d00fa720007 patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 31000
diff changeset
6160 # ifdef FEAT_QUICKFIX
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6161 case PV_EFM:
4361
94aa0d30a3ea updated for version 7.3.929
Bram Moolenaar <bram@vim.org>
parents: 4350
diff changeset
6162 clear_string_option(&buf->b_p_efm);
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6163 break;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6164 case PV_GP:
4361
94aa0d30a3ea updated for version 7.3.929
Bram Moolenaar <bram@vim.org>
parents: 4350
diff changeset
6165 clear_string_option(&buf->b_p_gp);
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6166 break;
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6167 case PV_MP:
4361
94aa0d30a3ea updated for version 7.3.929
Bram Moolenaar <bram@vim.org>
parents: 4350
diff changeset
6168 clear_string_option(&buf->b_p_mp);
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6169 break;
31174
1d00fa720007 patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 31000
diff changeset
6170 # endif
1d00fa720007 patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 31000
diff changeset
6171 # if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6172 case PV_BEXPR:
4361
94aa0d30a3ea updated for version 7.3.929
Bram Moolenaar <bram@vim.org>
parents: 4350
diff changeset
6173 clear_string_option(&buf->b_p_bexpr);
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6174 break;
31174
1d00fa720007 patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 31000
diff changeset
6175 # endif
1d00fa720007 patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 31000
diff changeset
6176 # if defined(FEAT_CRYPT)
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6177 case PV_CM:
4361
94aa0d30a3ea updated for version 7.3.929
Bram Moolenaar <bram@vim.org>
parents: 4350
diff changeset
6178 clear_string_option(&buf->b_p_cm);
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6179 break;
31174
1d00fa720007 patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 31000
diff changeset
6180 # endif
1d00fa720007 patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 31000
diff changeset
6181 # ifdef FEAT_LINEBREAK
18574
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6182 case PV_SBR:
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6183 clear_string_option(&((win_T *)from)->w_p_sbr);
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6184 break;
31174
1d00fa720007 patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 31000
diff changeset
6185 # endif
1d00fa720007 patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 31000
diff changeset
6186 # ifdef FEAT_STL_OPT
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6187 case PV_STL:
4361
94aa0d30a3ea updated for version 7.3.929
Bram Moolenaar <bram@vim.org>
parents: 4350
diff changeset
6188 clear_string_option(&((win_T *)from)->w_p_stl);
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6189 break;
31174
1d00fa720007 patch 9.0.0921: missing defined(PROTO) in #ifdef
Bram Moolenaar <Bram@vim.org>
parents: 31000
diff changeset
6190 # endif
5446
d0595545e98a updated for version 7.4.073
Bram Moolenaar <bram@vim.org>
parents: 5438
diff changeset
6191 case PV_UL:
d0595545e98a updated for version 7.4.073
Bram Moolenaar <bram@vim.org>
parents: 5438
diff changeset
6192 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
d0595545e98a updated for version 7.4.073
Bram Moolenaar <bram@vim.org>
parents: 5438
diff changeset
6193 break;
5712
06e5f65c34d8 updated for version 7.4.201
Bram Moolenaar <bram@vim.org>
parents: 5610
diff changeset
6194 case PV_LW:
06e5f65c34d8 updated for version 7.4.201
Bram Moolenaar <bram@vim.org>
parents: 5610
diff changeset
6195 clear_string_option(&buf->b_p_lw);
06e5f65c34d8 updated for version 7.4.201
Bram Moolenaar <bram@vim.org>
parents: 5610
diff changeset
6196 break;
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10968
diff changeset
6197 case PV_MENC:
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10968
diff changeset
6198 clear_string_option(&buf->b_p_menc);
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10968
diff changeset
6199 break;
23952
44be09b25619 patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents: 23821
diff changeset
6200 case PV_LCS:
44be09b25619 patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents: 23821
diff changeset
6201 clear_string_option(&((win_T *)from)->w_p_lcs);
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
6202 set_listchars_option((win_T *)from, ((win_T *)from)->w_p_lcs, TRUE);
29732
89e1d67814a9 patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents: 29546
diff changeset
6203 redraw_later(UPD_NOT_VALID);
23952
44be09b25619 patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents: 23821
diff changeset
6204 break;
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6205 case PV_FCS:
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6206 clear_string_option(&((win_T *)from)->w_p_fcs);
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
6207 set_fillchars_option((win_T *)from, ((win_T *)from)->w_p_fcs, TRUE);
29732
89e1d67814a9 patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents: 29546
diff changeset
6208 redraw_later(UPD_NOT_VALID);
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6209 break;
25380
ac88cd21ae88 patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
6210 case PV_VE:
25487
c26ff3203b43 patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents: 25419
diff changeset
6211 clear_string_option(&((win_T *)from)->w_p_ve);
c26ff3203b43 patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents: 25419
diff changeset
6212 ((win_T *)from)->w_ve_flags = 0;
25380
ac88cd21ae88 patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
6213 break;
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6214 }
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6215 }
15555
d89c5b339c2a patch 8.1.0785: depending on the configuration some functions are unused
Bram Moolenaar <Bram@vim.org>
parents: 15543
diff changeset
6216 #endif
4350
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6217
7eaccdaa5304 updated for version 7.3.924
Bram Moolenaar <bram@vim.org>
parents: 4242
diff changeset
6218 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6219 * Get pointer to option variable, depending on local or global scope.
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26400
diff changeset
6220 * "scope" can be OPT_LOCAL, OPT_GLOBAL or a combination.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6221 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6222 static char_u *
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26400
diff changeset
6223 get_varp_scope(struct vimoption *p, int scope)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6224 {
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26400
diff changeset
6225 if ((scope & OPT_GLOBAL) && p->indir != PV_NONE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6226 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6227 if (p->var == VAR_WIN)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6228 return (char_u *)GLOBAL_WO(get_varp(p));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6229 return p->var;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6230 }
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26400
diff changeset
6231 if ((scope & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6232 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6233 switch ((int)p->indir)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6234 {
10579
688b97124d23 patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents: 10456
diff changeset
6235 case PV_FP: return (char_u *)&(curbuf->b_p_fp);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6236 #ifdef FEAT_QUICKFIX
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6237 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6238 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6239 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6240 #endif
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6241 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6242 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6243 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
692
a28f83d37113 updated for version 7.0208
vimboss
parents: 688
diff changeset
6244 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6245 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
7266
6ba7182fb7bd commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents: 7218
diff changeset
6246 case PV_TC: return (char_u *)&(curbuf->b_p_tc);
28809
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28804
diff changeset
6247 case PV_SISO: return (char_u *)&(curwin->w_p_siso);
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28804
diff changeset
6248 case PV_SO: return (char_u *)&(curwin->w_p_so);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6249 #ifdef FEAT_FIND_ID
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6250 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6251 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6252 #endif
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6253 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6254 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
25990
ac330e2fecc4 patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents: 25984
diff changeset
6255 #ifdef FEAT_COMPL_FUNC
ac330e2fecc4 patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents: 25984
diff changeset
6256 case PV_TSRFU: return (char_u *)&(curbuf->b_p_tsrfu);
ac330e2fecc4 patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents: 25984
diff changeset
6257 #endif
790
c8680debe1cc updated for version 7.0230
vimboss
parents: 786
diff changeset
6258 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
c8680debe1cc updated for version 7.0230
vimboss
parents: 786
diff changeset
6259 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
c8680debe1cc updated for version 7.0230
vimboss
parents: 786
diff changeset
6260 #endif
2360
d8e4b27cef80 Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents: 2348
diff changeset
6261 #if defined(FEAT_CRYPT)
d8e4b27cef80 Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents: 2348
diff changeset
6262 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
d8e4b27cef80 Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents: 2348
diff changeset
6263 #endif
18574
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6264 #ifdef FEAT_LINEBREAK
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6265 case PV_SBR: return (char_u *)&(curwin->w_p_sbr);
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6266 #endif
40
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
6267 #ifdef FEAT_STL_OPT
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6268 case PV_STL: return (char_u *)&(curwin->w_p_stl);
40
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
6269 #endif
5446
d0595545e98a updated for version 7.4.073
Bram Moolenaar <bram@vim.org>
parents: 5438
diff changeset
6270 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
5712
06e5f65c34d8 updated for version 7.4.201
Bram Moolenaar <bram@vim.org>
parents: 5610
diff changeset
6271 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
6243
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
6272 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10968
diff changeset
6273 case PV_MENC: return (char_u *)&(curbuf->b_p_menc);
25380
ac88cd21ae88 patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
6274 case PV_LCS: return (char_u *)&(curwin->w_p_lcs);
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6275 case PV_FCS: return (char_u *)&(curwin->w_p_fcs);
25487
c26ff3203b43 patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents: 25419
diff changeset
6276 case PV_VE: return (char_u *)&(curwin->w_p_ve);
23952
44be09b25619 patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents: 23821
diff changeset
6277
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6278 }
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
6279 return NULL; // "cannot happen"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6280 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6281 return get_varp(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6282 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6283
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6284 /*
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6285 * Get pointer to option variable at 'opt_idx', depending on local or global
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6286 * scope.
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6287 */
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6288 char_u *
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26400
diff changeset
6289 get_option_varp_scope(int opt_idx, int scope)
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6290 {
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26400
diff changeset
6291 return get_varp_scope(&(options[opt_idx]), scope);
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6292 }
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6293
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6294 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6295 * Get pointer to option variable.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6296 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6297 static char_u *
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
6298 get_varp(struct vimoption *p)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6299 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
6300 // hidden option, always return NULL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6301 if (p->var == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6302 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6303
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6304 switch ((int)p->indir)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6305 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6306 case PV_NONE: return p->var;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6307
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
6308 // global option with local value: use local value if it's been set
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6309 case PV_EP: return *curbuf->b_p_ep != NUL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6310 ? (char_u *)&curbuf->b_p_ep : p->var;
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6311 case PV_KP: return *curbuf->b_p_kp != NUL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6312 ? (char_u *)&curbuf->b_p_kp : p->var;
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6313 case PV_PATH: return *curbuf->b_p_path != NUL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6314 ? (char_u *)&(curbuf->b_p_path) : p->var;
692
a28f83d37113 updated for version 7.0208
vimboss
parents: 688
diff changeset
6315 case PV_AR: return curbuf->b_p_ar >= 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6316 ? (char_u *)&(curbuf->b_p_ar) : p->var;
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6317 case PV_TAGS: return *curbuf->b_p_tags != NUL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6318 ? (char_u *)&(curbuf->b_p_tags) : p->var;
7266
6ba7182fb7bd commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents: 7218
diff changeset
6319 case PV_TC: return *curbuf->b_p_tc != NUL
6ba7182fb7bd commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents: 7218
diff changeset
6320 ? (char_u *)&(curbuf->b_p_tc) : p->var;
6243
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
6321 case PV_BKC: return *curbuf->b_p_bkc != NUL
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
6322 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
15713
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
6323 case PV_SISO: return curwin->w_p_siso >= 0
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
6324 ? (char_u *)&(curwin->w_p_siso) : p->var;
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
6325 case PV_SO: return curwin->w_p_so >= 0
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
6326 ? (char_u *)&(curwin->w_p_so) : p->var;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6327 #ifdef FEAT_FIND_ID
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6328 case PV_DEF: return *curbuf->b_p_def != NUL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6329 ? (char_u *)&(curbuf->b_p_def) : p->var;
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6330 case PV_INC: return *curbuf->b_p_inc != NUL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6331 ? (char_u *)&(curbuf->b_p_inc) : p->var;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6332 #endif
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6333 case PV_DICT: return *curbuf->b_p_dict != NUL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6334 ? (char_u *)&(curbuf->b_p_dict) : p->var;
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6335 case PV_TSR: return *curbuf->b_p_tsr != NUL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6336 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
25990
ac330e2fecc4 patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents: 25984
diff changeset
6337 #ifdef FEAT_COMPL_FUNC
ac330e2fecc4 patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents: 25984
diff changeset
6338 case PV_TSRFU: return *curbuf->b_p_tsrfu != NUL
ac330e2fecc4 patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents: 25984
diff changeset
6339 ? (char_u *)&(curbuf->b_p_tsrfu) : p->var;
ac330e2fecc4 patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents: 25984
diff changeset
6340 #endif
10579
688b97124d23 patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents: 10456
diff changeset
6341 case PV_FP: return *curbuf->b_p_fp != NUL
688b97124d23 patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents: 10456
diff changeset
6342 ? (char_u *)&(curbuf->b_p_fp) : p->var;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6343 #ifdef FEAT_QUICKFIX
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6344 case PV_EFM: return *curbuf->b_p_efm != NUL
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6345 ? (char_u *)&(curbuf->b_p_efm) : p->var;
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6346 case PV_GP: return *curbuf->b_p_gp != NUL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6347 ? (char_u *)&(curbuf->b_p_gp) : p->var;
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6348 case PV_MP: return *curbuf->b_p_mp != NUL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6349 ? (char_u *)&(curbuf->b_p_mp) : p->var;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6350 #endif
790
c8680debe1cc updated for version 7.0230
vimboss
parents: 786
diff changeset
6351 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
c8680debe1cc updated for version 7.0230
vimboss
parents: 786
diff changeset
6352 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
c8680debe1cc updated for version 7.0230
vimboss
parents: 786
diff changeset
6353 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
c8680debe1cc updated for version 7.0230
vimboss
parents: 786
diff changeset
6354 #endif
2360
d8e4b27cef80 Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents: 2348
diff changeset
6355 #if defined(FEAT_CRYPT)
d8e4b27cef80 Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents: 2348
diff changeset
6356 case PV_CM: return *curbuf->b_p_cm != NUL
d8e4b27cef80 Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents: 2348
diff changeset
6357 ? (char_u *)&(curbuf->b_p_cm) : p->var;
d8e4b27cef80 Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents: 2348
diff changeset
6358 #endif
18574
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6359 #ifdef FEAT_LINEBREAK
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6360 case PV_SBR: return *curwin->w_p_sbr != NUL
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6361 ? (char_u *)&(curwin->w_p_sbr) : p->var;
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6362 #endif
40
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
6363 #ifdef FEAT_STL_OPT
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6364 case PV_STL: return *curwin->w_p_stl != NUL
40
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
6365 ? (char_u *)&(curwin->w_p_stl) : p->var;
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
6366 #endif
5446
d0595545e98a updated for version 7.4.073
Bram Moolenaar <bram@vim.org>
parents: 5438
diff changeset
6367 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
d0595545e98a updated for version 7.4.073
Bram Moolenaar <bram@vim.org>
parents: 5438
diff changeset
6368 ? (char_u *)&(curbuf->b_p_ul) : p->var;
5712
06e5f65c34d8 updated for version 7.4.201
Bram Moolenaar <bram@vim.org>
parents: 5610
diff changeset
6369 case PV_LW: return *curbuf->b_p_lw != NUL
06e5f65c34d8 updated for version 7.4.201
Bram Moolenaar <bram@vim.org>
parents: 5610
diff changeset
6370 ? (char_u *)&(curbuf->b_p_lw) : p->var;
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10968
diff changeset
6371 case PV_MENC: return *curbuf->b_p_menc != NUL
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10968
diff changeset
6372 ? (char_u *)&(curbuf->b_p_menc) : p->var;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6373 #ifdef FEAT_ARABIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6374 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6375 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6376 case PV_LIST: return (char_u *)&(curwin->w_p_list);
23952
44be09b25619 patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents: 23821
diff changeset
6377 case PV_LCS: return *curwin->w_p_lcs != NUL
44be09b25619 patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents: 23821
diff changeset
6378 ? (char_u *)&(curwin->w_p_lcs) : p->var;
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6379 case PV_FCS: return *curwin->w_p_fcs != NUL
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6380 ? (char_u *)&(curwin->w_p_fcs) : p->var;
25487
c26ff3203b43 patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents: 25419
diff changeset
6381 case PV_VE: return *curwin->w_p_ve != NUL
c26ff3203b43 patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents: 25419
diff changeset
6382 ? (char_u *)&(curwin->w_p_ve) : p->var;
744
07f7b4a7755c updated for version 7.0222
vimboss
parents: 731
diff changeset
6383 #ifdef FEAT_SPELL
07f7b4a7755c updated for version 7.0222
vimboss
parents: 731
diff changeset
6384 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
07f7b4a7755c updated for version 7.0222
vimboss
parents: 731
diff changeset
6385 #endif
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 190
diff changeset
6386 #ifdef FEAT_SYN_HL
744
07f7b4a7755c updated for version 7.0222
vimboss
parents: 731
diff changeset
6387 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
07f7b4a7755c updated for version 7.0222
vimboss
parents: 731
diff changeset
6388 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
18047
6650e3dff8d4 patch 8.1.2019: 'cursorline' always highlights the whole line
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
6389 case PV_CULOPT: return (char_u *)&(curwin->w_p_culopt);
2314
233eb4412f5d Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
6390 case PV_CC: return (char_u *)&(curwin->w_p_cc);
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 190
diff changeset
6391 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6392 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6393 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6394 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6395 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6396 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6397 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6398 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6399 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6400 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6401 case PV_FML: return (char_u *)&(curwin->w_p_fml);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6402 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6403 # ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6404 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6405 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6406 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6407 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6408 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6409 case PV_NU: return (char_u *)&(curwin->w_p_nu);
2178
c6f1aa1e9f32 Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents: 2144
diff changeset
6410 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
6411 #ifdef FEAT_LINEBREAK
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
6412 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
6413 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6414 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
782
d20041a02ee5 updated for version 7.0228
vimboss
parents: 767
diff changeset
6415 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12469
diff changeset
6416 #if defined(FEAT_QUICKFIX)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6417 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6418 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6419 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6420 case PV_RL: return (char_u *)&(curwin->w_p_rl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6421 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6422 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6423 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
30610
6c6ac189a05f patch 9.0.0640: cannot scroll by screen line if a line wraps
Bram Moolenaar <Bram@vim.org>
parents: 30417
diff changeset
6424 case PV_SMS: return (char_u *)&(curwin->w_p_sms);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6425 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6426 #ifdef FEAT_LINEBREAK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6427 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
5995
ef83b423ebf7 updated for version 7.4.338
Bram Moolenaar <bram@vim.org>
parents: 5991
diff changeset
6428 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
ef83b423ebf7 updated for version 7.4.338
Bram Moolenaar <bram@vim.org>
parents: 5991
diff changeset
6429 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6430 #endif
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents: 16764
diff changeset
6431 case PV_WCR: return (char_u *)&(curwin->w_p_wcr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6432 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2248
diff changeset
6433 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2248
diff changeset
6434 #ifdef FEAT_CONCEAL
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents: 11587
diff changeset
6435 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents: 11587
diff changeset
6436 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents: 11587
diff changeset
6437 #endif
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents: 11587
diff changeset
6438 #ifdef FEAT_TERMINAL
13742
a34b1323286c patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents: 13700
diff changeset
6439 case PV_TWK: return (char_u *)&(curwin->w_p_twk);
a34b1323286c patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents: 13700
diff changeset
6440 case PV_TWS: return (char_u *)&(curwin->w_p_tws);
a34b1323286c patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents: 13700
diff changeset
6441 case PV_TWSL: return (char_u *)&(curbuf->b_p_twsl);
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2248
diff changeset
6442 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6443
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6444 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6445 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6446 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6447 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6448 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6449 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6450 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6451 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6452 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6453 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
28353
8bc8071928ed patch 8.2.4702: C++ scope labels are hard-coded
Bram Moolenaar <Bram@vim.org>
parents: 28337
diff changeset
6454 case PV_CINSD: return (char_u *)&(curbuf->b_p_cinsd);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6455 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6456 case PV_COM: return (char_u *)&(curbuf->b_p_com);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6457 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6458 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6459 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6460 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
17809
59f8948b7590 patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
6461 #ifdef BACKSLASH_IN_FILENAME
17543
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17476
diff changeset
6462 case PV_CSL: return (char_u *)&(curbuf->b_p_csl);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6463 #endif
12
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
6464 #ifdef FEAT_COMPL_FUNC
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
6465 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
6466 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
12
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
6467 #endif
16447
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
6468 #ifdef FEAT_EVAL
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
6469 case PV_TFU: return (char_u *)&(curbuf->b_p_tfu);
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
6470 #endif
30966
685ee8453163 Add missing entry for the 'endoffile' option.
Bram Moolenaar <Bram@vim.org>
parents: 30853
diff changeset
6471 case PV_EOF: return (char_u *)&(curbuf->b_p_eof);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6472 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
6933
62ba356c2d4e patch 7.4.785
Bram Moolenaar <bram@vim.org>
parents: 6927
diff changeset
6473 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6474 case PV_ET: return (char_u *)&(curbuf->b_p_et);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6475 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6476 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6477 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6478 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 40
diff changeset
6479 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6480 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6481 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6482 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6483 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6484 #ifdef FEAT_FIND_ID
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6485 # ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6486 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6487 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6488 #endif
28942
6cdf55afaae9 patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents: 28919
diff changeset
6489 #if defined(FEAT_EVAL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6490 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6491 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6492 #endif
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 692
diff changeset
6493 #ifdef FEAT_EVAL
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 665
diff changeset
6494 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
9090f866cd57 updated for version 7.0197
vimboss
parents: 665
diff changeset
6495 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6496 #ifdef FEAT_CRYPT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6497 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6498 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6499 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
30853
40df8a6515f6 patch 9.0.0761: cannot use 'indentexpr' for Lisp indenting
Bram Moolenaar <Bram@vim.org>
parents: 30825
diff changeset
6500 case PV_LOP: return (char_u *)&(curbuf->b_p_lop);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6501 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6502 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6503 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6504 case PV_MOD: return (char_u *)&(curbuf->b_changed);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6505 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6506 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
12
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
6507 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6508 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6509 case PV_SI: return (char_u *)&(curbuf->b_p_si);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6510 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6511 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6512 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6513 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6514 #ifdef FEAT_SYN_HL
410
c60ba877860b updated for version 7.0107
vimboss
parents: 402
diff changeset
6515 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
744
07f7b4a7755c updated for version 7.0222
vimboss
parents: 731
diff changeset
6516 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
07f7b4a7755c updated for version 7.0222
vimboss
parents: 731
diff changeset
6517 #endif
07f7b4a7755c updated for version 7.0222
vimboss
parents: 731
diff changeset
6518 #ifdef FEAT_SPELL
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2248
diff changeset
6519 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2248
diff changeset
6520 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2248
diff changeset
6521 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
20802
ed00f0fbdaef patch 8.2.0953: spell checking doesn't work for CamelCased words
Bram Moolenaar <Bram@vim.org>
parents: 20603
diff changeset
6522 case PV_SPO: return (char_u *)&(curwin->w_s->b_p_spo);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6523 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6524 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6525 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6526 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6527 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2184
diff changeset
6528 #ifdef FEAT_PERSISTENT_UNDO
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2184
diff changeset
6529 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2184
diff changeset
6530 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6531 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6532 #ifdef FEAT_KEYMAP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6533 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6534 #endif
9852
4eea48b76d03 commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents: 9798
diff changeset
6535 #ifdef FEAT_SIGNS
4eea48b76d03 commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents: 9798
diff changeset
6536 case PV_SCL: return (char_u *)&(curwin->w_p_scl);
4eea48b76d03 commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents: 9798
diff changeset
6537 #endif
14175
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
6538 #ifdef FEAT_VARTABS
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
6539 case PV_VSTS: return (char_u *)&(curbuf->b_p_vsts);
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
6540 case PV_VTS: return (char_u *)&(curbuf->b_p_vts);
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
6541 #endif
26913
d4e61d61afd9 patch 8.2.3985: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26883
diff changeset
6542 default: iemsg(_(e_get_varp_error));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6543 }
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
6544 // always return a valid pointer to avoid a crash!
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6545 return (char_u *)&(curbuf->b_p_wm);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6546 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6547
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6548 /*
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6549 * Return a pointer to the variable for option at 'opt_idx'
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6550 */
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6551 char_u *
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6552 get_option_var(int opt_idx)
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6553 {
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6554 return options[opt_idx].var;
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6555 }
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6556
27018
268f6a3511df patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6557 #if defined(FEAT_EVAL) || defined(PROTO)
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6558 /*
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6559 * Return the full name of the option at 'opt_idx'
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6560 */
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6561 char_u *
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6562 get_option_fullname(int opt_idx)
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6563 {
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6564 return (char_u *)options[opt_idx].fullname;
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6565 }
27018
268f6a3511df patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6566 #endif
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6567
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
6568 /*
31996
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
6569 * Return the did_set callback function for the option at 'opt_idx'
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
6570 */
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
6571 opt_did_set_cb_T
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
6572 get_option_did_set_cb(int opt_idx)
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
6573 {
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
6574 return options[opt_idx].opt_did_set_cb;
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
6575 }
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
6576
ca6bc7c04163 patch 9.0.1330: handling new value of an option has a long "else if" chain
Bram Moolenaar <Bram@vim.org>
parents: 31962
diff changeset
6577 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6578 * Get the value of 'equalprg', either the buffer-local one or the global one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6579 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6580 char_u *
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
6581 get_equalprg(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6582 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6583 if (*curbuf->b_p_ep == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6584 return p_ep;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6585 return curbuf->b_p_ep;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6586 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6587
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6588 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6589 * Copy options from one window to another.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6590 * Used when splitting a window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6591 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6592 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
6593 win_copy_options(win_T *wp_from, win_T *wp_to)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6594 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6595 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6596 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
18156
c81370b3ede4 patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents: 18100
diff changeset
6597 after_copy_winopt(wp_to);
c81370b3ede4 patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents: 18100
diff changeset
6598 }
c81370b3ede4 patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents: 18100
diff changeset
6599
c81370b3ede4 patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents: 18100
diff changeset
6600 /*
c81370b3ede4 patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents: 18100
diff changeset
6601 * After copying window options: update variables depending on options.
c81370b3ede4 patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents: 18100
diff changeset
6602 */
c81370b3ede4 patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents: 18100
diff changeset
6603 void
27659
b5ebc885c25c patch 8.2.4355: unnecessary call to check_colorcolumn()
Bram Moolenaar <Bram@vim.org>
parents: 27509
diff changeset
6604 after_copy_winopt(win_T *wp)
18156
c81370b3ede4 patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents: 18100
diff changeset
6605 {
c81370b3ede4 patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents: 18100
diff changeset
6606 #ifdef FEAT_LINEBREAK
c81370b3ede4 patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents: 18100
diff changeset
6607 briopt_check(wp);
6162
e60327caf909 updated for version 7.4.417
Bram Moolenaar <bram@vim.org>
parents: 6130
diff changeset
6608 #endif
18068
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
6609 #ifdef FEAT_SYN_HL
18156
c81370b3ede4 patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents: 18100
diff changeset
6610 fill_culopt_flags(NULL, wp);
c81370b3ede4 patch 8.1.2073: when editing a buffer 'colorcolumn' may not work
Bram Moolenaar <Bram@vim.org>
parents: 18100
diff changeset
6611 check_colorcolumn(wp);
18068
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
6612 #endif
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
6613 set_listchars_option(wp, wp->w_p_lcs, TRUE);
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
6614 set_fillchars_option(wp, wp->w_p_fcs, TRUE);
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6615 }
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6616
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6617 static char_u *
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6618 copy_option_val(char_u *val)
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6619 {
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6620 if (val == empty_option)
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6621 return empty_option; // no need to allocate memory
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6622 return vim_strsave(val);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6623 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6624
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6625 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6626 * Copy the options from one winopt_T to another.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6627 * Doesn't free the old option values in "to", use clear_winopt() for that.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6628 * The 'scroll' option is not copied, because it depends on the window height.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6629 * The 'previewwindow' option is reset, there can be only one preview window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6630 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6631 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
6632 copy_winopt(winopt_T *from, winopt_T *to)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6633 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6634 #ifdef FEAT_ARABIC
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6635 to->wo_arab = from->wo_arab;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6636 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6637 to->wo_list = from->wo_list;
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6638 to->wo_lcs = copy_option_val(from->wo_lcs);
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6639 to->wo_fcs = copy_option_val(from->wo_fcs);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6640 to->wo_nu = from->wo_nu;
2178
c6f1aa1e9f32 Add 'relativenumber' patch from Markus Heidelberg.
Bram Moolenaar <bram@vim.org>
parents: 2144
diff changeset
6641 to->wo_rnu = from->wo_rnu;
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6642 to->wo_ve = copy_option_val(from->wo_ve);
25487
c26ff3203b43 patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents: 25419
diff changeset
6643 to->wo_ve_flags = from->wo_ve_flags;
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
6644 #ifdef FEAT_LINEBREAK
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
6645 to->wo_nuw = from->wo_nuw;
24d5189d3956 updated for version 7.0005
vimboss
parents: 12
diff changeset
6646 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6647 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6648 to->wo_rl = from->wo_rl;
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6649 to->wo_rlc = copy_option_val(from->wo_rlc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6650 #endif
18574
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6651 #ifdef FEAT_LINEBREAK
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6652 to->wo_sbr = copy_option_val(from->wo_sbr);
18574
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6653 #endif
40
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
6654 #ifdef FEAT_STL_OPT
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6655 to->wo_stl = copy_option_val(from->wo_stl);
40
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
6656 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6657 to->wo_wrap = from->wo_wrap;
5102
11d0c6df1d7b updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents: 5070
diff changeset
6658 #ifdef FEAT_DIFF
11d0c6df1d7b updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents: 5070
diff changeset
6659 to->wo_wrap_save = from->wo_wrap_save;
11d0c6df1d7b updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents: 5070
diff changeset
6660 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6661 #ifdef FEAT_LINEBREAK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6662 to->wo_lbr = from->wo_lbr;
5995
ef83b423ebf7 updated for version 7.4.338
Bram Moolenaar <bram@vim.org>
parents: 5991
diff changeset
6663 to->wo_bri = from->wo_bri;
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6664 to->wo_briopt = copy_option_val(from->wo_briopt);
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6665 #endif
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6666 to->wo_wcr = copy_option_val(from->wo_wcr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6667 to->wo_scb = from->wo_scb;
5102
11d0c6df1d7b updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents: 5070
diff changeset
6668 to->wo_scb_save = from->wo_scb_save;
30618
c2031ad5ed54 patch 9.0.0644: 'smoothscroll' is not copied to a new window on :split
Bram Moolenaar <Bram@vim.org>
parents: 30610
diff changeset
6669 to->wo_sms = from->wo_sms;
2651
b254cfdd7405 updated for version 7.3.071
Bram Moolenaar <bram@vim.org>
parents: 2599
diff changeset
6670 to->wo_crb = from->wo_crb;
5102
11d0c6df1d7b updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents: 5070
diff changeset
6671 to->wo_crb_save = from->wo_crb_save;
744
07f7b4a7755c updated for version 7.0222
vimboss
parents: 731
diff changeset
6672 #ifdef FEAT_SPELL
07f7b4a7755c updated for version 7.0222
vimboss
parents: 731
diff changeset
6673 to->wo_spell = from->wo_spell;
07f7b4a7755c updated for version 7.0222
vimboss
parents: 731
diff changeset
6674 #endif
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 190
diff changeset
6675 #ifdef FEAT_SYN_HL
744
07f7b4a7755c updated for version 7.0222
vimboss
parents: 731
diff changeset
6676 to->wo_cuc = from->wo_cuc;
07f7b4a7755c updated for version 7.0222
vimboss
parents: 731
diff changeset
6677 to->wo_cul = from->wo_cul;
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6678 to->wo_culopt = copy_option_val(from->wo_culopt);
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6679 to->wo_cc = copy_option_val(from->wo_cc);
221
7fd4b5df33be updated for version 7.0062
vimboss
parents: 190
diff changeset
6680 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6681 #ifdef FEAT_DIFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6682 to->wo_diff = from->wo_diff;
5102
11d0c6df1d7b updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents: 5070
diff changeset
6683 to->wo_diff_saved = from->wo_diff_saved;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6684 #endif
2378
85b7dc8da5eb Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents: 2362
diff changeset
6685 #ifdef FEAT_CONCEAL
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6686 to->wo_cocu = copy_option_val(from->wo_cocu);
2379
b67b0b5a93d3 Window split didn't copy the value of 'conceallevel'.
Bram Moolenaar <bram@vim.org>
parents: 2378
diff changeset
6687 to->wo_cole = from->wo_cole;
2378
85b7dc8da5eb Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents: 2362
diff changeset
6688 #endif
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents: 11587
diff changeset
6689 #ifdef FEAT_TERMINAL
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6690 to->wo_twk = copy_option_val(from->wo_twk);
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6691 to->wo_tws = copy_option_val(from->wo_tws);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents: 11587
diff changeset
6692 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6693 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6694 to->wo_fdc = from->wo_fdc;
5102
11d0c6df1d7b updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents: 5070
diff changeset
6695 to->wo_fdc_save = from->wo_fdc_save;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6696 to->wo_fen = from->wo_fen;
5102
11d0c6df1d7b updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents: 5070
diff changeset
6697 to->wo_fen_save = from->wo_fen_save;
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6698 to->wo_fdi = copy_option_val(from->wo_fdi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6699 to->wo_fml = from->wo_fml;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6700 to->wo_fdl = from->wo_fdl;
5102
11d0c6df1d7b updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents: 5070
diff changeset
6701 to->wo_fdl_save = from->wo_fdl_save;
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6702 to->wo_fdm = copy_option_val(from->wo_fdm);
5102
11d0c6df1d7b updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents: 5070
diff changeset
6703 to->wo_fdm_save = from->wo_diff_saved
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6704 ? vim_strsave(from->wo_fdm_save) : empty_option;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6705 to->wo_fdn = from->wo_fdn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6706 # ifdef FEAT_EVAL
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6707 to->wo_fde = copy_option_val(from->wo_fde);
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6708 to->wo_fdt = copy_option_val(from->wo_fdt);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6709 # endif
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6710 to->wo_fmr = copy_option_val(from->wo_fmr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6711 #endif
9852
4eea48b76d03 commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents: 9798
diff changeset
6712 #ifdef FEAT_SIGNS
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6713 to->wo_scl = copy_option_val(from->wo_scl);
9852
4eea48b76d03 commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents: 9798
diff changeset
6714 #endif
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6715
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6716 #ifdef FEAT_EVAL
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6717 // Copy the script context so that we know where the value was last set.
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6718 mch_memmove(to->wo_script_ctx, from->wo_script_ctx,
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6719 sizeof(to->wo_script_ctx));
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6720 #endif
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
6721 check_winopt(to); // don't want NULL pointers
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6722 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6723
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6724 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6725 * Check string options in a window for a NULL value.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6726 */
17789
0f7ae8010787 patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
6727 static void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
6728 check_win_options(win_T *win)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6729 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6730 check_winopt(&win->w_onebuf_opt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6731 check_winopt(&win->w_allbuf_opt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6732 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6733
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6734 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6735 * Check for NULL pointers in a winopt_T and replace them with empty_option.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6736 */
5997
fd7110d0c3bf updated for version 7.4.339
Bram Moolenaar <bram@vim.org>
parents: 5995
diff changeset
6737 static void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
6738 check_winopt(winopt_T *wop UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6739 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6740 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6741 check_string_option(&wop->wo_fdi);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6742 check_string_option(&wop->wo_fdm);
5102
11d0c6df1d7b updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents: 5070
diff changeset
6743 check_string_option(&wop->wo_fdm_save);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6744 # ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6745 check_string_option(&wop->wo_fde);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6746 check_string_option(&wop->wo_fdt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6747 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6748 check_string_option(&wop->wo_fmr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6749 #endif
9852
4eea48b76d03 commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents: 9798
diff changeset
6750 #ifdef FEAT_SIGNS
4eea48b76d03 commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents: 9798
diff changeset
6751 check_string_option(&wop->wo_scl);
4eea48b76d03 commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents: 9798
diff changeset
6752 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6753 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6754 check_string_option(&wop->wo_rlc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6755 #endif
18574
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6756 #ifdef FEAT_LINEBREAK
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6757 check_string_option(&wop->wo_sbr);
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6758 #endif
40
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
6759 #ifdef FEAT_STL_OPT
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
6760 check_string_option(&wop->wo_stl);
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
6761 #endif
2314
233eb4412f5d Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
6762 #ifdef FEAT_SYN_HL
18047
6650e3dff8d4 patch 8.1.2019: 'cursorline' always highlights the whole line
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
6763 check_string_option(&wop->wo_culopt);
2314
233eb4412f5d Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
6764 check_string_option(&wop->wo_cc);
233eb4412f5d Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
6765 #endif
2378
85b7dc8da5eb Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents: 2362
diff changeset
6766 #ifdef FEAT_CONCEAL
85b7dc8da5eb Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents: 2362
diff changeset
6767 check_string_option(&wop->wo_cocu);
85b7dc8da5eb Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents: 2362
diff changeset
6768 #endif
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents: 11587
diff changeset
6769 #ifdef FEAT_TERMINAL
13742
a34b1323286c patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents: 13700
diff changeset
6770 check_string_option(&wop->wo_twk);
a34b1323286c patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents: 13700
diff changeset
6771 check_string_option(&wop->wo_tws);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents: 11587
diff changeset
6772 #endif
5995
ef83b423ebf7 updated for version 7.4.338
Bram Moolenaar <bram@vim.org>
parents: 5991
diff changeset
6773 #ifdef FEAT_LINEBREAK
ef83b423ebf7 updated for version 7.4.338
Bram Moolenaar <bram@vim.org>
parents: 5991
diff changeset
6774 check_string_option(&wop->wo_briopt);
ef83b423ebf7 updated for version 7.4.338
Bram Moolenaar <bram@vim.org>
parents: 5991
diff changeset
6775 #endif
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents: 16764
diff changeset
6776 check_string_option(&wop->wo_wcr);
23952
44be09b25619 patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents: 23821
diff changeset
6777 check_string_option(&wop->wo_lcs);
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6778 check_string_option(&wop->wo_fcs);
25487
c26ff3203b43 patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents: 25419
diff changeset
6779 check_string_option(&wop->wo_ve);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6780 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6781
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6782 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6783 * Free the allocated memory inside a winopt_T.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6784 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6785 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
6786 clear_winopt(winopt_T *wop UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6787 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6788 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6789 clear_string_option(&wop->wo_fdi);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6790 clear_string_option(&wop->wo_fdm);
5102
11d0c6df1d7b updated for version 7.3.1294
Bram Moolenaar <bram@vim.org>
parents: 5070
diff changeset
6791 clear_string_option(&wop->wo_fdm_save);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6792 # ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6793 clear_string_option(&wop->wo_fde);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6794 clear_string_option(&wop->wo_fdt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6795 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6796 clear_string_option(&wop->wo_fmr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6797 #endif
9852
4eea48b76d03 commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents: 9798
diff changeset
6798 #ifdef FEAT_SIGNS
4eea48b76d03 commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents: 9798
diff changeset
6799 clear_string_option(&wop->wo_scl);
4eea48b76d03 commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents: 9798
diff changeset
6800 #endif
5995
ef83b423ebf7 updated for version 7.4.338
Bram Moolenaar <bram@vim.org>
parents: 5991
diff changeset
6801 #ifdef FEAT_LINEBREAK
ef83b423ebf7 updated for version 7.4.338
Bram Moolenaar <bram@vim.org>
parents: 5991
diff changeset
6802 clear_string_option(&wop->wo_briopt);
ef83b423ebf7 updated for version 7.4.338
Bram Moolenaar <bram@vim.org>
parents: 5991
diff changeset
6803 #endif
16778
eda4d65f232c patch 8.1.1391: no popup window support
Bram Moolenaar <Bram@vim.org>
parents: 16764
diff changeset
6804 clear_string_option(&wop->wo_wcr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6805 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6806 clear_string_option(&wop->wo_rlc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6807 #endif
18574
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6808 #ifdef FEAT_LINEBREAK
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6809 clear_string_option(&wop->wo_sbr);
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
6810 #endif
40
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
6811 #ifdef FEAT_STL_OPT
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
6812 clear_string_option(&wop->wo_stl);
f1d2a58883b9 updated for version 7.0024
vimboss
parents: 39
diff changeset
6813 #endif
2314
233eb4412f5d Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
6814 #ifdef FEAT_SYN_HL
18047
6650e3dff8d4 patch 8.1.2019: 'cursorline' always highlights the whole line
Bram Moolenaar <Bram@vim.org>
parents: 17940
diff changeset
6815 clear_string_option(&wop->wo_culopt);
2314
233eb4412f5d Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
6816 clear_string_option(&wop->wo_cc);
233eb4412f5d Added 'colorcolumn' option. Partly by Gregor Uhlenheuer.
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
6817 #endif
2378
85b7dc8da5eb Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents: 2362
diff changeset
6818 #ifdef FEAT_CONCEAL
85b7dc8da5eb Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents: 2362
diff changeset
6819 clear_string_option(&wop->wo_cocu);
85b7dc8da5eb Add the 'concealcursor' option to decide when the cursor line is to be
Bram Moolenaar <bram@vim.org>
parents: 2362
diff changeset
6820 #endif
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents: 11587
diff changeset
6821 #ifdef FEAT_TERMINAL
13742
a34b1323286c patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents: 13700
diff changeset
6822 clear_string_option(&wop->wo_twk);
a34b1323286c patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents: 13700
diff changeset
6823 clear_string_option(&wop->wo_tws);
11621
b8299e742f41 patch 8.0.0693: no terminal emulator support
Christian Brabandt <cb@256bit.org>
parents: 11587
diff changeset
6824 #endif
23952
44be09b25619 patch 8.2.2518: 'listchars' should be window-local
Bram Moolenaar <Bram@vim.org>
parents: 23821
diff changeset
6825 clear_string_option(&wop->wo_lcs);
29387
9dce192d1ac2 patch 9.0.0036: 'fillchars' cannot have window-local values
Bram Moolenaar <Bram@vim.org>
parents: 28942
diff changeset
6826 clear_string_option(&wop->wo_fcs);
25487
c26ff3203b43 patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents: 25419
diff changeset
6827 clear_string_option(&wop->wo_ve);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6828 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6829
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6830 #ifdef FEAT_EVAL
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6831 // Index into the options table for a buffer-local option enum.
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6832 static int buf_opt_idx[BV_COUNT];
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6833 # define COPY_OPT_SCTX(buf, bv) buf->b_p_script_ctx[bv] = options[buf_opt_idx[bv]].script_ctx
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6834
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6835 /*
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6836 * Initialize buf_opt_idx[] if not done already.
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6837 */
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6838 static void
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6839 init_buf_opt_idx(void)
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6840 {
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6841 static int did_init_buf_opt_idx = FALSE;
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6842 int i;
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6843
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6844 if (did_init_buf_opt_idx)
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6845 return;
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6846 did_init_buf_opt_idx = TRUE;
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6847 for (i = 0; !istermoption_idx(i); i++)
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6848 if (options[i].indir & PV_BUF)
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6849 buf_opt_idx[options[i].indir & PV_MASK] = i;
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6850 }
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6851 #else
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6852 # define COPY_OPT_SCTX(buf, bv)
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6853 #endif
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6854
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6855 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6856 * Copy global option values to local options for one buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6857 * Used when creating a new buffer and sometimes when entering a buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6858 * flags:
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6859 * BCO_ENTER We will enter the buffer "buf".
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6860 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6861 * appropriate.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6862 * BCO_NOHELP Don't copy the values to a help buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6863 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6864 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
6865 buf_copy_options(buf_T *buf, int flags)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6866 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6867 int should_copy = TRUE;
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
6868 char_u *save_p_isk = NULL; // init for GCC
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6869 int dont_do_help;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6870 int did_isk = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6871
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
6872 // Skip this when the option defaults have not been set yet. Happens when
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
6873 // main() allocates the first buffer.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6874 if (p_cpo != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6875 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6876 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6877 * Always copy when entering and 'cpo' contains 'S'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6878 * Don't copy when already initialized.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6879 * Don't copy when 'cpo' contains 's' and not entering.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6880 * 'S' BCO_ENTER initialized 's' should_copy
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6881 * yes yes X X TRUE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6882 * yes no yes X FALSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6883 * no X yes X FALSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6884 * X no no yes FALSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6885 * X no no no TRUE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6886 * no yes no X TRUE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6887 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6888 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6889 && (buf->b_p_initialized
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6890 || (!(flags & BCO_ENTER)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6891 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6892 should_copy = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6893
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6894 if (should_copy || (flags & BCO_ALWAYS))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6895 {
18384
63dd78ea6610 patch 8.1.2186: error for bad regexp even though regexp is not used
Bram Moolenaar <Bram@vim.org>
parents: 18380
diff changeset
6896 #ifdef FEAT_EVAL
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19405
diff changeset
6897 CLEAR_FIELD(buf->b_p_script_ctx);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6898 init_buf_opt_idx();
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6899 #endif
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6900 // Don't copy the options specific to a help buffer when
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6901 // BCO_NOHELP is given or the options were initialized already
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6902 // (jumping back to a help file with CTRL-T or CTRL-O)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6903 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6904 || buf->b_p_initialized;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6905 if (dont_do_help) // don't free b_p_isk
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6906 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6907 save_p_isk = buf->b_p_isk;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6908 buf->b_p_isk = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6909 }
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
6910 // Always free the allocated strings. If not already initialized,
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
6911 // reset 'readonly' and copy 'fileformat'.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6912 if (!buf->b_p_initialized)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6913 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6914 free_buf_options(buf, TRUE);
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
6915 buf->b_p_ro = FALSE; // don't copy readonly
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6916 buf->b_p_tx = p_tx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6917 buf->b_p_fenc = vim_strsave(p_fenc);
10268
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents: 10264
diff changeset
6918 switch (*p_ffs)
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents: 10264
diff changeset
6919 {
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents: 10264
diff changeset
6920 case 'm':
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents: 10264
diff changeset
6921 buf->b_p_ff = vim_strsave((char_u *)FF_MAC); break;
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents: 10264
diff changeset
6922 case 'd':
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents: 10264
diff changeset
6923 buf->b_p_ff = vim_strsave((char_u *)FF_DOS); break;
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents: 10264
diff changeset
6924 case 'u':
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents: 10264
diff changeset
6925 buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); break;
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents: 10264
diff changeset
6926 default:
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents: 10264
diff changeset
6927 buf->b_p_ff = vim_strsave(p_ff);
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents: 10264
diff changeset
6928 }
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents: 10264
diff changeset
6929 if (buf->b_p_ff != NULL)
c55a7232fb48 commit https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66
Christian Brabandt <cb@256bit.org>
parents: 10264
diff changeset
6930 buf->b_start_ffc = *buf->b_p_ff;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6931 buf->b_p_bh = empty_option;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6932 buf->b_p_bt = empty_option;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6933 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6934 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6935 free_buf_options(buf, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6936
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6937 buf->b_p_ai = p_ai;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6938 COPY_OPT_SCTX(buf, BV_AI);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6939 buf->b_p_ai_nopaste = p_ai_nopaste;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6940 buf->b_p_sw = p_sw;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6941 COPY_OPT_SCTX(buf, BV_SW);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6942 buf->b_p_tw = p_tw;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6943 COPY_OPT_SCTX(buf, BV_TW);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6944 buf->b_p_tw_nopaste = p_tw_nopaste;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6945 buf->b_p_tw_nobin = p_tw_nobin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6946 buf->b_p_wm = p_wm;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6947 COPY_OPT_SCTX(buf, BV_WM);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6948 buf->b_p_wm_nopaste = p_wm_nopaste;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6949 buf->b_p_wm_nobin = p_wm_nobin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6950 buf->b_p_bin = p_bin;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6951 COPY_OPT_SCTX(buf, BV_BIN);
402
5b1544b1b228 updated for version 7.0105
vimboss
parents: 389
diff changeset
6952 buf->b_p_bomb = p_bomb;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6953 COPY_OPT_SCTX(buf, BV_BOMB);
6954
a958ac497a81 patch 7.4.795
Bram Moolenaar <bram@vim.org>
parents: 6949
diff changeset
6954 buf->b_p_fixeol = p_fixeol;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6955 COPY_OPT_SCTX(buf, BV_FIXEOL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6956 buf->b_p_et = p_et;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6957 COPY_OPT_SCTX(buf, BV_ET);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6958 buf->b_p_et_nobin = p_et_nobin;
7113
83b3261352b3 commit https://github.com/vim/vim/commit/54f018cd5994c3ffcd0740526e56db6934edf1f2
Christian Brabandt <cb@256bit.org>
parents: 7058
diff changeset
6959 buf->b_p_et_nopaste = p_et_nopaste;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6960 buf->b_p_ml = p_ml;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6961 COPY_OPT_SCTX(buf, BV_ML);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6962 buf->b_p_ml_nobin = p_ml_nobin;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6963 buf->b_p_inf = p_inf;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6964 COPY_OPT_SCTX(buf, BV_INF);
22699
e82579016863 patch 8.2.1898: command modifier parsing always uses global cmdmod
Bram Moolenaar <Bram@vim.org>
parents: 22242
diff changeset
6965 if (cmdmod.cmod_flags & CMOD_NOSWAPFILE)
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6966 buf->b_p_swf = FALSE;
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6967 else
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6968 {
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6969 buf->b_p_swf = p_swf;
26550
919ee902079a patch 8.2.3804: script context not set when copying 'swf' and 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
6970 COPY_OPT_SCTX(buf, BV_SWF);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6971 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6972 buf->b_p_cpt = vim_strsave(p_cpt);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6973 COPY_OPT_SCTX(buf, BV_CPT);
17809
59f8948b7590 patch 8.1.1901: the +insert_expand feature is not always available
Bram Moolenaar <Bram@vim.org>
parents: 17791
diff changeset
6974 #ifdef BACKSLASH_IN_FILENAME
17543
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17476
diff changeset
6975 buf->b_p_csl = vim_strsave(p_csl);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6976 COPY_OPT_SCTX(buf, BV_CSL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6977 #endif
12
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
6978 #ifdef FEAT_COMPL_FUNC
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
6979 buf->b_p_cfu = vim_strsave(p_cfu);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6980 COPY_OPT_SCTX(buf, BV_CFU);
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26362
diff changeset
6981 set_buflocal_cfu_callback(buf);
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
6982 buf->b_p_ofu = vim_strsave(p_ofu);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6983 COPY_OPT_SCTX(buf, BV_OFU);
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26362
diff changeset
6984 set_buflocal_ofu_callback(buf);
12
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
6985 #endif
16447
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
6986 #ifdef FEAT_EVAL
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
6987 buf->b_p_tfu = vim_strsave(p_tfu);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6988 COPY_OPT_SCTX(buf, BV_TFU);
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26362
diff changeset
6989 set_buflocal_tfu_callback(buf);
16447
54ffc82f38a8 patch 8.1.1228: not possible to process tags with a function
Bram Moolenaar <Bram@vim.org>
parents: 16429
diff changeset
6990 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6991 buf->b_p_sts = p_sts;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6992 COPY_OPT_SCTX(buf, BV_STS);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6993 buf->b_p_sts_nopaste = p_sts_nopaste;
14175
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
6994 #ifdef FEAT_VARTABS
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
6995 buf->b_p_vsts = vim_strsave(p_vsts);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
6996 COPY_OPT_SCTX(buf, BV_VSTS);
14175
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
6997 if (p_vsts && p_vsts != empty_option)
25733
4b2616ffe32b patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents: 25487
diff changeset
6998 (void)tabstop_set(p_vsts, &buf->b_p_vsts_array);
14175
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
6999 else
27434
c1702fd7e716 patch 8.2.4245: ":retab 0" may cause illegal memory access
Bram Moolenaar <Bram@vim.org>
parents: 27426
diff changeset
7000 buf->b_p_vsts_array = NULL;
14175
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
7001 buf->b_p_vsts_nopaste = p_vsts_nopaste
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
7002 ? vim_strsave(p_vsts_nopaste) : NULL;
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
7003 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7004 buf->b_p_sn = p_sn;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7005 COPY_OPT_SCTX(buf, BV_SN);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7006 buf->b_p_com = vim_strsave(p_com);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7007 COPY_OPT_SCTX(buf, BV_COM);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7008 #ifdef FEAT_FOLDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7009 buf->b_p_cms = vim_strsave(p_cms);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7010 COPY_OPT_SCTX(buf, BV_CMS);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7011 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7012 buf->b_p_fo = vim_strsave(p_fo);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7013 COPY_OPT_SCTX(buf, BV_FO);
41
f529edb9bab3 updated for version 7.0025
vimboss
parents: 40
diff changeset
7014 buf->b_p_flp = vim_strsave(p_flp);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7015 COPY_OPT_SCTX(buf, BV_FLP);
18199
e2be5a6485f5 patch 8.1.2094: the fileio.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18156
diff changeset
7016 // NOTE: Valgrind may report a bogus memory leak for 'nrformats'
e2be5a6485f5 patch 8.1.2094: the fileio.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18156
diff changeset
7017 // when it is set to 8 bytes in defaults.vim.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7018 buf->b_p_nf = vim_strsave(p_nf);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7019 COPY_OPT_SCTX(buf, BV_NF);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7020 buf->b_p_mps = vim_strsave(p_mps);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7021 COPY_OPT_SCTX(buf, BV_MPS);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7022 buf->b_p_si = p_si;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7023 COPY_OPT_SCTX(buf, BV_SI);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7024 buf->b_p_ci = p_ci;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7025 COPY_OPT_SCTX(buf, BV_CI);
28942
6cdf55afaae9 patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents: 28919
diff changeset
7026
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7027 buf->b_p_cin = p_cin;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7028 COPY_OPT_SCTX(buf, BV_CIN);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7029 buf->b_p_cink = vim_strsave(p_cink);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7030 COPY_OPT_SCTX(buf, BV_CINK);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7031 buf->b_p_cino = vim_strsave(p_cino);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7032 COPY_OPT_SCTX(buf, BV_CINO);
28353
8bc8071928ed patch 8.2.4702: C++ scope labels are hard-coded
Bram Moolenaar <Bram@vim.org>
parents: 28337
diff changeset
7033 buf->b_p_cinsd = vim_strsave(p_cinsd);
8bc8071928ed patch 8.2.4702: C++ scope labels are hard-coded
Bram Moolenaar <Bram@vim.org>
parents: 28337
diff changeset
7034 COPY_OPT_SCTX(buf, BV_CINSD);
30853
40df8a6515f6 patch 9.0.0761: cannot use 'indentexpr' for Lisp indenting
Bram Moolenaar <Bram@vim.org>
parents: 30825
diff changeset
7035 buf->b_p_lop = vim_strsave(p_lop);
40df8a6515f6 patch 9.0.0761: cannot use 'indentexpr' for Lisp indenting
Bram Moolenaar <Bram@vim.org>
parents: 30825
diff changeset
7036 COPY_OPT_SCTX(buf, BV_LOP);
28942
6cdf55afaae9 patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents: 28919
diff changeset
7037
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7038 // Don't copy 'filetype', it must be detected
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7039 buf->b_p_ft = empty_option;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7040 buf->b_p_pi = p_pi;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7041 COPY_OPT_SCTX(buf, BV_PI);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7042 buf->b_p_cinw = vim_strsave(p_cinw);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7043 COPY_OPT_SCTX(buf, BV_CINW);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7044 buf->b_p_lisp = p_lisp;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7045 COPY_OPT_SCTX(buf, BV_LISP);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7046 #ifdef FEAT_SYN_HL
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7047 // Don't copy 'syntax', it must be set
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7048 buf->b_p_syn = empty_option;
410
c60ba877860b updated for version 7.0107
vimboss
parents: 402
diff changeset
7049 buf->b_p_smc = p_smc;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7050 COPY_OPT_SCTX(buf, BV_SMC);
7687
61354fabf8a2 commit https://github.com/vim/vim/commit/b8060fe862f684b591f9ac679eac5b2594d6c5a0
Christian Brabandt <cb@256bit.org>
parents: 7538
diff changeset
7051 buf->b_s.b_syn_isk = empty_option;
744
07f7b4a7755c updated for version 7.0222
vimboss
parents: 731
diff changeset
7052 #endif
07f7b4a7755c updated for version 7.0222
vimboss
parents: 731
diff changeset
7053 #ifdef FEAT_SPELL
2599
8aa94f8080bd updated for version 7.3.022
Bram Moolenaar <bram@vim.org>
parents: 2577
diff changeset
7054 buf->b_s.b_p_spc = vim_strsave(p_spc);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7055 COPY_OPT_SCTX(buf, BV_SPC);
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2248
diff changeset
7056 (void)compile_cap_prog(&buf->b_s);
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2248
diff changeset
7057 buf->b_s.b_p_spf = vim_strsave(p_spf);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7058 COPY_OPT_SCTX(buf, BV_SPF);
2250
1bac28a53fae Add the conceal patch from Vince Negri.
Bram Moolenaar <bram@vim.org>
parents: 2248
diff changeset
7059 buf->b_s.b_p_spl = vim_strsave(p_spl);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7060 COPY_OPT_SCTX(buf, BV_SPL);
20802
ed00f0fbdaef patch 8.2.0953: spell checking doesn't work for CamelCased words
Bram Moolenaar <Bram@vim.org>
parents: 20603
diff changeset
7061 buf->b_s.b_p_spo = vim_strsave(p_spo);
ed00f0fbdaef patch 8.2.0953: spell checking doesn't work for CamelCased words
Bram Moolenaar <Bram@vim.org>
parents: 20603
diff changeset
7062 COPY_OPT_SCTX(buf, BV_SPO);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7063 #endif
28942
6cdf55afaae9 patch 8.2.4993: smart/C/lisp indenting is optional
Bram Moolenaar <Bram@vim.org>
parents: 28919
diff changeset
7064 #if defined(FEAT_EVAL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7065 buf->b_p_inde = vim_strsave(p_inde);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7066 COPY_OPT_SCTX(buf, BV_INDE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7067 buf->b_p_indk = vim_strsave(p_indk);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7068 COPY_OPT_SCTX(buf, BV_INDK);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7069 #endif
10579
688b97124d23 patch 8.0.0179: cannot have a local value for 'formatprg'
Christian Brabandt <cb@256bit.org>
parents: 10456
diff changeset
7070 buf->b_p_fp = empty_option;
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 665
diff changeset
7071 #if defined(FEAT_EVAL)
9090f866cd57 updated for version 7.0197
vimboss
parents: 665
diff changeset
7072 buf->b_p_fex = vim_strsave(p_fex);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7073 COPY_OPT_SCTX(buf, BV_FEX);
667
9090f866cd57 updated for version 7.0197
vimboss
parents: 665
diff changeset
7074 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7075 #ifdef FEAT_CRYPT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7076 buf->b_p_key = vim_strsave(p_key);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7077 COPY_OPT_SCTX(buf, BV_KEY);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7078 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7079 buf->b_p_sua = vim_strsave(p_sua);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7080 COPY_OPT_SCTX(buf, BV_SUA);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7081 #ifdef FEAT_KEYMAP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7082 buf->b_p_keymap = vim_strsave(p_keymap);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7083 COPY_OPT_SCTX(buf, BV_KMAP);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7084 buf->b_kmap_state |= KEYMAP_INIT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7085 #endif
13742
a34b1323286c patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents: 13700
diff changeset
7086 #ifdef FEAT_TERMINAL
a34b1323286c patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents: 13700
diff changeset
7087 buf->b_p_twsl = p_twsl;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7088 COPY_OPT_SCTX(buf, BV_TWSL);
13742
a34b1323286c patch 8.0.1743: terminal window options are named inconsistently
Christian Brabandt <cb@256bit.org>
parents: 13700
diff changeset
7089 #endif
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7090 // This isn't really an option, but copying the langmap and IME
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7091 // state from the current buffer is better than resetting it.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7092 buf->b_p_iminsert = p_iminsert;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7093 COPY_OPT_SCTX(buf, BV_IMI);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7094 buf->b_p_imsearch = p_imsearch;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7095 COPY_OPT_SCTX(buf, BV_IMS);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7096
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7097 // options that are normally global but also have a local value
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7098 // are not copied, start using the global value
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7099 buf->b_p_ar = -1;
5446
d0595545e98a updated for version 7.4.073
Bram Moolenaar <bram@vim.org>
parents: 5438
diff changeset
7100 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
6243
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
7101 buf->b_p_bkc = empty_option;
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
7102 buf->b_bkc_flags = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7103 #ifdef FEAT_QUICKFIX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7104 buf->b_p_gp = empty_option;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7105 buf->b_p_mp = empty_option;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7106 buf->b_p_efm = empty_option;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7107 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7108 buf->b_p_ep = empty_option;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7109 buf->b_p_kp = empty_option;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7110 buf->b_p_path = empty_option;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7111 buf->b_p_tags = empty_option;
7266
6ba7182fb7bd commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents: 7218
diff changeset
7112 buf->b_p_tc = empty_option;
6ba7182fb7bd commit https://github.com/vim/vim/commit/0f6562e9036f889185dff49a75c7fc5ffb28b307
Christian Brabandt <cb@256bit.org>
parents: 7218
diff changeset
7113 buf->b_tc_flags = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7114 #ifdef FEAT_FIND_ID
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7115 buf->b_p_def = empty_option;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7116 buf->b_p_inc = empty_option;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7117 # ifdef FEAT_EVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7118 buf->b_p_inex = vim_strsave(p_inex);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7119 COPY_OPT_SCTX(buf, BV_INEX);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7120 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7121 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7122 buf->b_p_dict = empty_option;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7123 buf->b_p_tsr = empty_option;
25990
ac330e2fecc4 patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents: 25984
diff changeset
7124 #ifdef FEAT_COMPL_FUNC
ac330e2fecc4 patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents: 25984
diff changeset
7125 buf->b_p_tsrfu = empty_option;
ac330e2fecc4 patch 8.2.3528: 'thesaurus' and 'thesaurusfunc' do not have the same scope
Bram Moolenaar <Bram@vim.org>
parents: 25984
diff changeset
7126 #endif
12
bdeee1504ac1 updated for version 7.0004
vimboss
parents: 11
diff changeset
7127 buf->b_p_qe = vim_strsave(p_qe);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7128 COPY_OPT_SCTX(buf, BV_QE);
790
c8680debe1cc updated for version 7.0230
vimboss
parents: 786
diff changeset
7129 #if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
c8680debe1cc updated for version 7.0230
vimboss
parents: 786
diff changeset
7130 buf->b_p_bexpr = empty_option;
c8680debe1cc updated for version 7.0230
vimboss
parents: 786
diff changeset
7131 #endif
2360
d8e4b27cef80 Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents: 2348
diff changeset
7132 #if defined(FEAT_CRYPT)
d8e4b27cef80 Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents: 2348
diff changeset
7133 buf->b_p_cm = empty_option;
d8e4b27cef80 Change 'cryptmethod' from a number to a string option. Make it global-local.
Bram Moolenaar <bram@vim.org>
parents: 2348
diff changeset
7134 #endif
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2184
diff changeset
7135 #ifdef FEAT_PERSISTENT_UNDO
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2184
diff changeset
7136 buf->b_p_udf = p_udf;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7137 COPY_OPT_SCTX(buf, BV_UDF);
2214
f8222d1f9a73 Included patch for persistent undo. Lots of changes and added test.
Bram Moolenaar <bram@vim.org>
parents: 2184
diff changeset
7138 #endif
5712
06e5f65c34d8 updated for version 7.4.201
Bram Moolenaar <bram@vim.org>
parents: 5610
diff changeset
7139 buf->b_p_lw = empty_option;
11063
e71d3bdf3bc3 patch 8.0.0420: text garbled when the system encoding differs from 'encoding'
Christian Brabandt <cb@256bit.org>
parents: 10968
diff changeset
7140 buf->b_p_menc = empty_option;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7141
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
7142 // Don't copy the options set by ex_help(), use the saved values,
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
7143 // when going from a help buffer to a non-help buffer.
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
7144 // Don't touch these at all when BCO_NOHELP is used and going from
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
7145 // or to a help buffer.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7146 if (dont_do_help)
14175
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
7147 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7148 buf->b_p_isk = save_p_isk;
14175
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
7149 #ifdef FEAT_VARTABS
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
7150 if (p_vts && p_vts != empty_option && !buf->b_p_vts_array)
25733
4b2616ffe32b patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents: 25487
diff changeset
7151 (void)tabstop_set(p_vts, &buf->b_p_vts_array);
14175
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
7152 else
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
7153 buf->b_p_vts_array = NULL;
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
7154 #endif
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
7155 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7156 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7157 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7158 buf->b_p_isk = vim_strsave(p_isk);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7159 COPY_OPT_SCTX(buf, BV_ISK);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7160 did_isk = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7161 buf->b_p_ts = p_ts;
26550
919ee902079a patch 8.2.3804: script context not set when copying 'swf' and 'ts'
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
7162 COPY_OPT_SCTX(buf, BV_TS);
14175
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
7163 #ifdef FEAT_VARTABS
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
7164 buf->b_p_vts = vim_strsave(p_vts);
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7165 COPY_OPT_SCTX(buf, BV_VTS);
14175
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
7166 if (p_vts && p_vts != empty_option && !buf->b_p_vts_array)
25733
4b2616ffe32b patch 8.2.3402: invalid memory access when using :retab with large value
Bram Moolenaar <Bram@vim.org>
parents: 25487
diff changeset
7167 (void)tabstop_set(p_vts, &buf->b_p_vts_array);
14175
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
7168 else
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
7169 buf->b_p_vts_array = NULL;
2ad722003b36 patch 8.1.0105: all tab stops are the same
Christian Brabandt <cb@256bit.org>
parents: 14099
diff changeset
7170 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7171 buf->b_help = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7172 if (buf->b_p_bt[0] == 'h')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7173 clear_string_option(&buf->b_p_bt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7174 buf->b_p_ma = p_ma;
18380
212284f893d5 patch 8.1.2184: option context is not copied when splitting a window
Bram Moolenaar <Bram@vim.org>
parents: 18354
diff changeset
7175 COPY_OPT_SCTX(buf, BV_MA);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7176 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7177 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7178
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
7179 // When the options should be copied (ignoring BCO_ALWAYS), set the
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
7180 // flag that indicates that the options have been initialized.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7181 if (should_copy)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7182 buf->b_p_initialized = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7183 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7184
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7185 check_buf_options(buf); // make sure we don't have NULLs
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7186 if (did_isk)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7187 (void)buf_init_chartab(buf, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7188 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7189
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7190 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7191 * Reset the 'modifiable' option and its default value.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7192 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7193 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7194 reset_modifiable(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7195 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7196 int opt_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7197
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7198 curbuf->b_p_ma = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7199 p_ma = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7200 opt_idx = findoption((char_u *)"ma");
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
7201 if (opt_idx >= 0)
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
7202 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7203 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7204
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7205 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7206 * Set the global value for 'iminsert' to the local value.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7207 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7208 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7209 set_iminsert_global(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7210 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7211 p_iminsert = curbuf->b_p_iminsert;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7212 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7213
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7214 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7215 * Set the global value for 'imsearch' to the local value.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7216 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7217 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7218 set_imsearch_global(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7219 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7220 p_imsearch = curbuf->b_p_imsearch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7221 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7222
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7223 static int expand_option_idx = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7224 static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7225 static int expand_option_flags = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7226
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7227 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7228 set_context_in_set_cmd(
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7229 expand_T *xp,
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7230 char_u *arg,
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7231 int opt_flags) // OPT_GLOBAL and/or OPT_LOCAL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7232 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7233 int nextchar;
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7234 long_u flags = 0; // init for GCC
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7235 int opt_idx = 0; // init for GCC
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7236 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7237 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7238 int is_term_option = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7239 int key;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7240
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7241 expand_option_flags = opt_flags;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7242
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7243 xp->xp_context = EXPAND_SETTINGS;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7244 if (*arg == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7245 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7246 xp->xp_pattern = arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7247 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7248 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7249 p = arg + STRLEN(arg) - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7250 if (*p == ' ' && *(p - 1) != '\\')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7251 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7252 xp->xp_pattern = p + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7253 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7254 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7255 while (p > arg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7256 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7257 s = p;
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7258 // count number of backslashes before ' ' or ','
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7259 if (*p == ' ' || *p == ',')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7260 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7261 while (s > arg && *(s - 1) == '\\')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7262 --s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7263 }
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7264 // break at a space with an even number of backslashes
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7265 if (*p == ' ' && ((p - s) & 1) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7266 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7267 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7268 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7269 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7270 --p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7271 }
1911
afbe4a4c884c updated for version 7.2-208
vimboss
parents: 1904
diff changeset
7272 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7273 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7274 xp->xp_context = EXPAND_BOOL_SETTINGS;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7275 p += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7276 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7277 if (STRNCMP(p, "inv", 3) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7278 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7279 xp->xp_context = EXPAND_BOOL_SETTINGS;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7280 p += 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7281 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7282 xp->xp_pattern = arg = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7283 if (*arg == '<')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7284 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7285 while (*p != '>')
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7286 if (*p++ == NUL) // expand terminal option name
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7287 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7288 key = get_special_key_code(arg + 1);
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7289 if (key == 0) // unknown name
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7290 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7291 xp->xp_context = EXPAND_NOTHING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7292 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7293 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7294 nextchar = *++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7295 is_term_option = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7296 expand_option_name[2] = KEY2TERMCAP0(key);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7297 expand_option_name[3] = KEY2TERMCAP1(key);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7298 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7299 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7300 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7301 if (p[0] == 't' && p[1] == '_')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7302 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7303 p += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7304 if (*p != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7305 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7306 if (*p == NUL)
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7307 return; // expand option name
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7308 nextchar = *++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7309 is_term_option = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7310 expand_option_name[2] = p[-2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7311 expand_option_name[3] = p[-1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7312 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7313 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7314 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7315 // Allow * wildcard
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7316 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7317 p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7318 if (*p == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7319 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7320 nextchar = *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7321 *p = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7322 opt_idx = findoption(arg);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7323 *p = nextchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7324 if (opt_idx == -1 || options[opt_idx].var == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7325 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7326 xp->xp_context = EXPAND_NOTHING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7327 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7328 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7329 flags = options[opt_idx].flags;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7330 if (flags & P_BOOL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7331 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7332 xp->xp_context = EXPAND_NOTHING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7333 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7334 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7335 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7336 }
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7337 // handle "-=" and "+="
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7338 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7339 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7340 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7341 nextchar = '=';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7342 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7343 if ((nextchar != '=' && nextchar != ':')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7344 || xp->xp_context == EXPAND_BOOL_SETTINGS)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7345 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7346 xp->xp_context = EXPAND_UNSUCCESSFUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7347 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7348 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7349 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7350 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7351 xp->xp_context = EXPAND_OLD_SETTING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7352 if (is_term_option)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7353 expand_option_idx = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7354 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7355 expand_option_idx = opt_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7356 xp->xp_pattern = p + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7357 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7358 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7359 xp->xp_context = EXPAND_NOTHING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7360 if (is_term_option || (flags & P_NUM))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7361 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7362
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7363 xp->xp_pattern = p + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7364
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7365 if (flags & P_EXPAND)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7366 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7367 p = options[opt_idx].var;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7368 if (p == (char_u *)&p_bdir
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7369 || p == (char_u *)&p_dir
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7370 || p == (char_u *)&p_path
8182
95d59081580f commit https://github.com/vim/vim/commit/f6fee0e2d4341c0c2f5339c1268e5877fafd07cf
Christian Brabandt <cb@256bit.org>
parents: 8163
diff changeset
7371 || p == (char_u *)&p_pp
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7372 || p == (char_u *)&p_rtp
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7373 || p == (char_u *)&p_cdpath
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7374 #ifdef FEAT_SESSION
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7375 || p == (char_u *)&p_vdir
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7376 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7377 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7378 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7379 xp->xp_context = EXPAND_DIRECTORIES;
29853
31c598083364 patch 9.0.0265: no good reason why the "gf" command isn't in the tiny version
Bram Moolenaar <Bram@vim.org>
parents: 29765
diff changeset
7380 if (p == (char_u *)&p_path || p == (char_u *)&p_cdpath)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7381 xp->xp_backslash = XP_BS_THREE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7382 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7383 xp->xp_backslash = XP_BS_ONE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7384 }
23821
bfc1ae959d9d patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents: 23505
diff changeset
7385 else if (p == (char_u *)&p_ft)
bfc1ae959d9d patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents: 23505
diff changeset
7386 {
bfc1ae959d9d patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents: 23505
diff changeset
7387 xp->xp_context = EXPAND_FILETYPE;
bfc1ae959d9d patch 8.2.2452: no completion for the 'filetype' option
Bram Moolenaar <Bram@vim.org>
parents: 23505
diff changeset
7388 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7389 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7390 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7391 xp->xp_context = EXPAND_FILES;
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7392 // for 'tags' need three backslashes for a space
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7393 if (p == (char_u *)&p_tags)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7394 xp->xp_backslash = XP_BS_THREE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7395 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7396 xp->xp_backslash = XP_BS_ONE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7397 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7398 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7399
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7400 // For an option that is a list of file names, find the start of the
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7401 // last file name.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7402 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7403 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7404 // count number of backslashes before ' ' or ','
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7405 if (*p == ' ' || *p == ',')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7406 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7407 s = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7408 while (s > xp->xp_pattern && *(s - 1) == '\\')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7409 --s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7410 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7411 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7412 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7413 xp->xp_pattern = p + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7414 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7415 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7416 }
374
575dacb554d8 updated for version 7.0096
vimboss
parents: 359
diff changeset
7417
744
07f7b4a7755c updated for version 7.0222
vimboss
parents: 731
diff changeset
7418 #ifdef FEAT_SPELL
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7419 // for 'spellsuggest' start at "file:"
374
575dacb554d8 updated for version 7.0096
vimboss
parents: 359
diff changeset
7420 if (options[opt_idx].var == (char_u *)&p_sps
575dacb554d8 updated for version 7.0096
vimboss
parents: 359
diff changeset
7421 && STRNCMP(p, "file:", 5) == 0)
575dacb554d8 updated for version 7.0096
vimboss
parents: 359
diff changeset
7422 {
575dacb554d8 updated for version 7.0096
vimboss
parents: 359
diff changeset
7423 xp->xp_pattern = p + 5;
575dacb554d8 updated for version 7.0096
vimboss
parents: 359
diff changeset
7424 break;
575dacb554d8 updated for version 7.0096
vimboss
parents: 359
diff changeset
7425 }
575dacb554d8 updated for version 7.0096
vimboss
parents: 359
diff changeset
7426 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7427 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7428 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7429
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7430 /*
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7431 * Returns TRUE if 'str' either matches 'regmatch' or fuzzy matches 'pat'.
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7432 *
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7433 * If 'test_only' is TRUE and 'fuzzy' is FALSE and if 'str' matches the regular
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7434 * expression 'regmatch', then returns TRUE. Otherwise returns FALSE.
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7435 *
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7436 * If 'test_only' is FALSE and 'fuzzy' is FALSE and if 'str' matches the
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7437 * regular expression 'regmatch', then stores the match in matches[idx] and
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7438 * returns TRUE.
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7439 *
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7440 * If 'test_only' is TRUE and 'fuzzy' is TRUE and if 'str' fuzzy matches
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7441 * 'fuzzystr', then returns TRUE. Otherwise returns FALSE.
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7442 *
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7443 * If 'test_only' is FALSE and 'fuzzy' is TRUE and if 'str' fuzzy matches
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7444 * 'fuzzystr', then stores the match details in fuzmatch[idx] and returns TRUE.
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7445 */
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7446 static int
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7447 match_str(
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7448 char_u *str,
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7449 regmatch_T *regmatch,
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7450 char_u **matches,
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7451 int idx,
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7452 int test_only,
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7453 int fuzzy,
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7454 char_u *fuzzystr,
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7455 fuzmatch_str_T *fuzmatch)
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7456 {
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7457 if (!fuzzy)
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7458 {
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7459 if (vim_regexec(regmatch, str, (colnr_T)0))
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7460 {
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7461 if (!test_only)
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7462 matches[idx] = vim_strsave(str);
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7463 return TRUE;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7464 }
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7465 }
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7466 else
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7467 {
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7468 int score;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7469
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7470 score = fuzzy_match_str(str, fuzzystr);
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7471 if (score != 0)
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7472 {
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7473 if (!test_only)
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7474 {
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7475 fuzmatch[idx].idx = idx;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7476 fuzmatch[idx].str = vim_strsave(str);
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7477 fuzmatch[idx].score = score;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7478 }
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7479
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7480 return TRUE;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7481 }
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7482 }
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7483
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7484 return FALSE;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7485 }
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7486
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7487 int
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7488 ExpandSettings(
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7489 expand_T *xp,
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7490 regmatch_T *regmatch,
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7491 char_u *fuzzystr,
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7492 int *numMatches,
28786
fd5942a62312 patch 8.2.4917: fuzzy expansion of option names is not right
Bram Moolenaar <Bram@vim.org>
parents: 28773
diff changeset
7493 char_u ***matches,
28809
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28804
diff changeset
7494 int can_fuzzy)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7495 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7496 int num_normal = 0; // Nr of matching non-term-code settings
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7497 int num_term = 0; // Nr of matching terminal code settings
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7498 int opt_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7499 int match;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7500 int count = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7501 char_u *str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7502 int loop;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7503 int is_term_opt;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7504 char_u name_buf[MAX_KEY_NAME_LEN];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7505 static char *(names[]) = {"all", "termcap"};
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7506 int ic = regmatch->rm_ic; // remember the ignore-case flag
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7507 int fuzzy;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7508 fuzmatch_str_T *fuzmatch = NULL;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7509
28786
fd5942a62312 patch 8.2.4917: fuzzy expansion of option names is not right
Bram Moolenaar <Bram@vim.org>
parents: 28773
diff changeset
7510 fuzzy = can_fuzzy && cmdline_fuzzy_complete(fuzzystr);
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7511
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7512 // do this loop twice:
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7513 // loop == 0: count the number of matching options
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7514 // loop == 1: copy the matching options into allocated memory
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7515 for (loop = 0; loop <= 1; ++loop)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7516 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7517 regmatch->rm_ic = ic;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7518 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7519 {
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 24747
diff changeset
7520 for (match = 0; match < (int)ARRAY_LENGTH(names); ++match)
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7521 {
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7522 if (match_str((char_u *)names[match], regmatch, *matches,
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7523 count, (loop == 0), fuzzy, fuzzystr, fuzmatch))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7524 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7525 if (loop == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7526 num_normal++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7527 else
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7528 count++;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7529 }
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7530 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7531 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7532 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7533 opt_idx++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7534 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7535 if (options[opt_idx].var == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7536 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7537 if (xp->xp_context == EXPAND_BOOL_SETTINGS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7538 && !(options[opt_idx].flags & P_BOOL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7539 continue;
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
7540 is_term_opt = istermoption_idx(opt_idx);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7541 if (is_term_opt && num_normal > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7542 continue;
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7543
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7544 if (match_str(str, regmatch, *matches, count, (loop == 0),
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7545 fuzzy, fuzzystr, fuzmatch))
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7546 {
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7547 if (loop == 0)
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7548 {
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7549 if (is_term_opt)
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7550 num_term++;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7551 else
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7552 num_normal++;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7553 }
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7554 else
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7555 count++;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7556 }
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7557 else if (!fuzzy && options[opt_idx].shortname != NULL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7558 && vim_regexec(regmatch,
28809
d0241e74bfdb patch 8.2.4928: various white space and cosmetic mistakes
Bram Moolenaar <Bram@vim.org>
parents: 28804
diff changeset
7559 (char_u *)options[opt_idx].shortname, (colnr_T)0))
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7560 {
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7561 // Compare against the abbreviated option name (for regular
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7562 // expression match). Fuzzy matching (previous if) already
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7563 // matches against both the expanded and abbreviated names.
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7564 if (loop == 0)
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7565 {
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7566 if (is_term_opt)
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7567 num_term++;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7568 else
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7569 num_normal++;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7570 }
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7571 else
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7572 (*matches)[count++] = vim_strsave(str);
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7573 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7574 else if (is_term_opt)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7575 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7576 name_buf[0] = '<';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7577 name_buf[1] = 't';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7578 name_buf[2] = '_';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7579 name_buf[3] = str[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7580 name_buf[4] = str[3];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7581 name_buf[5] = '>';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7582 name_buf[6] = NUL;
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7583
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7584 if (match_str(name_buf, regmatch, *matches, count, (loop == 0),
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7585 fuzzy, fuzzystr, fuzmatch))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7586 {
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7587 if (loop == 0)
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7588 num_term++;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7589 else
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7590 count++;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7591 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7592 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7593 }
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7594
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
7595 // Check terminal key codes, these are not in the option table
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7596 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7597 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7598 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7599 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7600 if (!isprint(str[0]) || !isprint(str[1]))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7601 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7602
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7603 name_buf[0] = 't';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7604 name_buf[1] = '_';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7605 name_buf[2] = str[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7606 name_buf[3] = str[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7607 name_buf[4] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7608
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7609 if (match_str(name_buf, regmatch, *matches, count,
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7610 (loop == 0), fuzzy, fuzzystr, fuzmatch))
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7611 {
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7612 if (loop == 0)
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7613 num_term++;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7614 else
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7615 count++;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7616 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7617 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7618 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7619 name_buf[0] = '<';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7620 name_buf[1] = 't';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7621 name_buf[2] = '_';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7622 name_buf[3] = str[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7623 name_buf[4] = str[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7624 name_buf[5] = '>';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7625 name_buf[6] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7626
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7627 if (match_str(name_buf, regmatch, *matches, count,
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7628 (loop == 0), fuzzy, fuzzystr,
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7629 fuzmatch))
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7630 {
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7631 if (loop == 0)
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7632 num_term++;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7633 else
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7634 count++;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7635 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7636 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7637 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7638
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
7639 // Check special key names.
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7640 regmatch->rm_ic = TRUE; // ignore case here
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7641 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7642 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7643 name_buf[0] = '<';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7644 STRCPY(name_buf + 1, str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7645 STRCAT(name_buf, ">");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7646
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7647 if (match_str(name_buf, regmatch, *matches, count, (loop == 0),
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7648 fuzzy, fuzzystr, fuzmatch))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7649 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7650 if (loop == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7651 num_term++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7652 else
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7653 count++;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7654 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7655 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7656 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7657 if (loop == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7658 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7659 if (num_normal > 0)
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7660 *numMatches = num_normal;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7661 else if (num_term > 0)
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7662 *numMatches = num_term;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7663 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7664 return OK;
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7665 if (!fuzzy)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7666 {
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7667 *matches = ALLOC_MULT(char_u *, *numMatches);
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7668 if (*matches == NULL)
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7669 {
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7670 *matches = (char_u **)"";
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7671 return FAIL;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7672 }
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7673 }
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7674 else
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7675 {
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7676 fuzmatch = ALLOC_MULT(fuzmatch_str_T, *numMatches);
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7677 if (fuzmatch == NULL)
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7678 {
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7679 *matches = (char_u **)"";
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7680 return FAIL;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7681 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7682 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7683 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7684 }
27875
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7685
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7686 if (fuzzy &&
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7687 fuzzymatches_to_strmatches(fuzmatch, matches, count, FALSE) == FAIL)
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7688 return FAIL;
ae38d2e81fca patch 8.2.4463: completion only uses strict matching
Bram Moolenaar <Bram@vim.org>
parents: 27855
diff changeset
7689
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7690 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7691 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7692
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7693 int
31819
aec031683d61 patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents: 31766
diff changeset
7694 ExpandOldSetting(int *numMatches, char_u ***matches)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7695 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7696 char_u *var = NULL; // init for GCC
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7697 char_u *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7698
31819
aec031683d61 patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents: 31766
diff changeset
7699 *numMatches = 0;
aec031683d61 patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents: 31766
diff changeset
7700 *matches = ALLOC_ONE(char_u *);
aec031683d61 patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents: 31766
diff changeset
7701 if (*matches == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7702 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7703
32076
32acf287a9ae patch 9.0.1369: still some "else if" constructs for setting options
Bram Moolenaar <Bram@vim.org>
parents: 32043
diff changeset
7704 // For a terminal key code expand_option_idx is < 0.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7705 if (expand_option_idx < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7706 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7707 var = find_termcode(expand_option_name + 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7708 if (var == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7709 expand_option_idx = findoption(expand_option_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7710 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7711
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7712 if (expand_option_idx >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7713 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7714 // put string of option value in NameBuff
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7715 option_value2string(&options[expand_option_idx], expand_option_flags);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7716 var = NameBuff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7717 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7718 else if (var == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7719 var = (char_u *)"";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7720
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7721 // A backslash is required before some characters. This is the reverse of
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7722 // what happens in do_set().
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7723 buf = vim_strsave_escaped(var, escape_chars);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7724
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7725 if (buf == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7726 {
31819
aec031683d61 patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents: 31766
diff changeset
7727 VIM_CLEAR(*matches);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7728 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7729 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7730
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7731 #ifdef BACKSLASH_IN_FILENAME
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7732 // For MS-Windows et al. we don't double backslashes at the start and
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7733 // before a file name character.
11127
506f5d8b7d8b patch 8.0.0451: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 11121
diff changeset
7734 for (var = buf; *var != NUL; MB_PTR_ADV(var))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7735 if (var[0] == '\\' && var[1] == '\\'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7736 && expand_option_idx >= 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7737 && (options[expand_option_idx].flags & P_EXPAND)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7738 && vim_isfilec(var[2])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7739 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
1622
149d8b46404c updated for version 7.2a
vimboss
parents: 1601
diff changeset
7740 STRMOVE(var, var + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7741 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7742
31819
aec031683d61 patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents: 31766
diff changeset
7743 *matches[0] = buf;
aec031683d61 patch 9.0.1242: code for :runtime completion is not consistent
Bram Moolenaar <Bram@vim.org>
parents: 31766
diff changeset
7744 *numMatches = 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7745 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7746 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7747
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7748 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7749 * Get the value for the numeric or string option *opp in a nice format into
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7750 * NameBuff[]. Must not be called with a hidden option!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7751 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7752 static void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7753 option_value2string(
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7754 struct vimoption *opp,
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26400
diff changeset
7755 int scope) // OPT_GLOBAL and/or OPT_LOCAL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7756 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7757 char_u *varp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7758
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26400
diff changeset
7759 varp = get_varp_scope(opp, scope);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7760
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7761 if (opp->flags & P_NUM)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7762 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7763 long wc = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7764
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7765 if (wc_use_keyname(varp, &wc))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7766 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7767 else if (wc != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7768 STRCPY(NameBuff, transchar((int)wc));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7769 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7770 sprintf((char *)NameBuff, "%ld", *(long *)varp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7771 }
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7772 else // P_STRING
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7773 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7774 varp = *(char_u **)(varp);
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7775 if (varp == NULL) // just in case
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7776 NameBuff[0] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7777 #ifdef FEAT_CRYPT
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7778 // don't show the actual value of 'key', only that it's set
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 839
diff changeset
7779 else if (opp->var == (char_u *)&p_key && *varp)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7780 STRCPY(NameBuff, "*****");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7781 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7782 else if (opp->flags & P_EXPAND)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7783 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7784 // Translate 'pastetoggle' into special key names
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7785 else if ((char_u **)opp->var == &p_pt)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7786 str2specialbuf(p_pt, NameBuff, MAXPATHL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7787 else
419
f713fc55bf7b updated for version 7.0109
vimboss
parents: 410
diff changeset
7788 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7789 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7790 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7791
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7792 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7793 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7794 * printed as a keyname.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7795 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7796 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7797 static int
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7798 wc_use_keyname(char_u *varp, long *wcp)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7799 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7800 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7801 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7802 *wcp = *(long *)varp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7803 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7804 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7805 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7806 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7807 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7808
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7809 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7810 * Return TRUE if "x" is present in 'shortmess' option, or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7811 * 'shortmess' contains 'a' and "x" is present in SHM_A.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7812 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7813 int
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7814 shortmess(int x)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7815 {
3384
da670fb71d30 updated for version 7.3.458
Bram Moolenaar <bram@vim.org>
parents: 3359
diff changeset
7816 return p_shm != NULL &&
da670fb71d30 updated for version 7.3.458
Bram Moolenaar <bram@vim.org>
parents: 3359
diff changeset
7817 ( vim_strchr(p_shm, x) != NULL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7818 || (vim_strchr(p_shm, 'a') != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7819 && vim_strchr((char_u *)SHM_A, x) != NULL));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7820 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7821
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7822 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7823 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7824 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7825 * Reset 'compatible' and set the values for options that didn't get set yet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7826 * to the Vim defaults.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7827 * Don't do this if the 'compatible' option has been set or reset before.
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7828 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7829 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7830 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7831 vimrc_found(char_u *fname, char_u *envname)
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7832 {
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7833 int opt_idx;
826
1cdd2661f34c updated for version 7.0d01
vimboss
parents: 825
diff changeset
7834 int dofree = FALSE;
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7835 char_u *p;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7836
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7837 if (!option_was_set((char_u *)"cp"))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7838 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7839 p_cp = FALSE;
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
7840 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7841 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7842 set_option_default(opt_idx, OPT_FREE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7843 didset_options();
7040
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
7844 didset_options2();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7845 }
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7846
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7847 if (fname != NULL)
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7848 {
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7849 p = vim_getenv(envname, &dofree);
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7850 if (p == NULL)
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7851 {
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7852 // Set $MYVIMRC to the first vimrc file found.
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7853 p = FullName_save(fname, FALSE);
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7854 if (p != NULL)
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7855 {
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7856 vim_setenv(envname, p);
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7857 vim_free(p);
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7858 }
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7859 }
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7860 else if (dofree)
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7861 vim_free(p);
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 818
diff changeset
7862 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7863 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7864
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7865 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7866 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7867 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7868 void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7869 change_compatible(int on)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7870 {
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
7871 int opt_idx;
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
7872
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7873 if (p_cp != on)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7874 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7875 p_cp = on;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7876 compatible_set();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7877 }
838
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
7878 opt_idx = findoption((char_u *)"cp");
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
7879 if (opt_idx >= 0)
8e5830943bff updated for version 7.0e04
vimboss
parents: 836
diff changeset
7880 options[opt_idx].flags |= P_WAS_SET;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7881 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7882
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7883 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7884 * Return TRUE when option "name" has been set.
5245
8c6615a30951 updated for version 7.4a.047
Bram Moolenaar <bram@vim.org>
parents: 5157
diff changeset
7885 * Only works correctly for global options.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7886 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7887 int
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7888 option_was_set(char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7889 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7890 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7891
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7892 idx = findoption(name);
18808
7982f65d8f54 patch 8.1.2392: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18679
diff changeset
7893 if (idx < 0) // unknown option
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7894 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7895 if (options[idx].flags & P_WAS_SET)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7896 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7897 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7898 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7899
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7900 /*
3980
aab4b29520e7 updated for version 7.3.745
Bram Moolenaar <bram@vim.org>
parents: 3894
diff changeset
7901 * Reset the flag indicating option "name" was set.
aab4b29520e7 updated for version 7.3.745
Bram Moolenaar <bram@vim.org>
parents: 3894
diff changeset
7902 */
14748
00da090af0ab patch 8.1.0386: cannot test with non-default option value
Christian Brabandt <cb@256bit.org>
parents: 14702
diff changeset
7903 int
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7904 reset_option_was_set(char_u *name)
3980
aab4b29520e7 updated for version 7.3.745
Bram Moolenaar <bram@vim.org>
parents: 3894
diff changeset
7905 {
aab4b29520e7 updated for version 7.3.745
Bram Moolenaar <bram@vim.org>
parents: 3894
diff changeset
7906 int idx = findoption(name);
aab4b29520e7 updated for version 7.3.745
Bram Moolenaar <bram@vim.org>
parents: 3894
diff changeset
7907
31752
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
7908 if (idx < 0)
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
7909 return FAIL;
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
7910
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
7911 options[idx].flags &= ~P_WAS_SET;
3365a601e73b patch 9.0.1208: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31313
diff changeset
7912 return OK;
3980
aab4b29520e7 updated for version 7.3.745
Bram Moolenaar <bram@vim.org>
parents: 3894
diff changeset
7913 }
aab4b29520e7 updated for version 7.3.745
Bram Moolenaar <bram@vim.org>
parents: 3894
diff changeset
7914
aab4b29520e7 updated for version 7.3.745
Bram Moolenaar <bram@vim.org>
parents: 3894
diff changeset
7915 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7916 * compatible_set() - Called when 'compatible' has been set or unset.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7917 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7918 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7919 * flag) to a Vi compatible value.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7920 * When 'compatible' is unset: Set all options that have a different default
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7921 * for Vim (without the P_VI_DEF flag) to that default.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7922 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7923 static void
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7924 compatible_set(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7925 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7926 int opt_idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7927
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
7928 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7929 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7930 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7931 set_option_default(opt_idx, OPT_FREE, p_cp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7932 didset_options();
7040
17a3fa77e941 commit https://github.com/vim/vim/commit/e68c25c677167bb90ac5ec77038e340c730b6567
Christian Brabandt <cb@256bit.org>
parents: 7034
diff changeset
7933 didset_options2();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7934 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7935
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7936 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7937 * Check if backspacing over something is allowed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7938 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7939 int
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7940 can_bs(
20069
9a67d41708d2 patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
7941 int what) // BS_INDENT, BS_EOL, BS_START or BS_NOSTOP
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7942 {
14029
d9fc15c833d5 patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents: 14019
diff changeset
7943 #ifdef FEAT_JOB_CHANNEL
d9fc15c833d5 patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents: 14019
diff changeset
7944 if (what == BS_START && bt_prompt(curbuf))
d9fc15c833d5 patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents: 14019
diff changeset
7945 return FALSE;
d9fc15c833d5 patch 8.1.0032: BS in prompt buffer starts new line
Christian Brabandt <cb@256bit.org>
parents: 14019
diff changeset
7946 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7947 switch (*p_bs)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7948 {
20069
9a67d41708d2 patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
7949 case '3': return TRUE;
9a67d41708d2 patch 8.2.0590: no 'backspace' value allows ignoring the insertion point
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
7950 case '2': return (what != BS_NOSTOP);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7951 case '1': return (what != BS_START);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7952 case '0': return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7953 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7954 return vim_strchr(p_bs, what) != NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7955 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7956
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7957 /*
15713
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7958 * Return the effective 'scrolloff' value for the current window, using the
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7959 * global value when appropriate.
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7960 */
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7961 long
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7962 get_scrolloff_value(void)
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7963 {
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7964 return curwin->w_p_so < 0 ? p_so : curwin->w_p_so;
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7965 }
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7966
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7967 /*
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7968 * Return the effective 'sidescrolloff' value for the current window, using the
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7969 * global value when appropriate.
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7970 */
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7971 long
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7972 get_sidescrolloff_value(void)
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7973 {
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7974 return curwin->w_p_siso < 0 ? p_siso : curwin->w_p_siso;
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7975 }
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7976
ad8b2c109b22 patch 8.1.0864: cannot have a local value for 'scrolloff' and 'sidescrolloff'
Bram Moolenaar <Bram@vim.org>
parents: 15701
diff changeset
7977 /*
6243
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
7978 * Get the local or global value of 'backupcopy'.
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
7979 */
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
7980 unsigned int
7829
2a8d6b2dd925 commit https://github.com/vim/vim/commit/9b57814db13c29ecb08260b36923c0e1c8a373a9
Christian Brabandt <cb@256bit.org>
parents: 7805
diff changeset
7981 get_bkc_value(buf_T *buf)
6243
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
7982 {
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
7983 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
54194bd6ed60 updated for version 7.4.456
Bram Moolenaar <bram@vim.org>
parents: 6205
diff changeset
7984 }
9852
4eea48b76d03 commit https://github.com/vim/vim/commit/95ec9d6a6ab3117d60ff638670a803d43974ba51
Christian Brabandt <cb@256bit.org>
parents: 9798
diff changeset
7985
28405
473cfd79bcd8 patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents: 28357
diff changeset
7986 #if defined(FEAT_LINEBREAK) || defined(PROTO)
25380
ac88cd21ae88 patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
7987 /*
27128
164d59ddd48a patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
7988 * Get the local or global value of 'formatlistpat'.
164d59ddd48a patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
7989 */
164d59ddd48a patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
7990 char_u *
164d59ddd48a patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
7991 get_flp_value(buf_T *buf)
164d59ddd48a patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
7992 {
164d59ddd48a patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
7993 if (buf->b_p_flp == NULL || *buf->b_p_flp == NUL)
164d59ddd48a patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
7994 return p_flp;
164d59ddd48a patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
7995 return buf->b_p_flp;
164d59ddd48a patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
7996 }
28405
473cfd79bcd8 patch 8.2.4727: unused code
Bram Moolenaar <Bram@vim.org>
parents: 28357
diff changeset
7997 #endif
27128
164d59ddd48a patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
7998
164d59ddd48a patch 8.2.4093: cached breakindent values not initialized properly
Bram Moolenaar <Bram@vim.org>
parents: 27018
diff changeset
7999 /*
25380
ac88cd21ae88 patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
8000 * Get the local or global value of the 'virtualedit' flags.
ac88cd21ae88 patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
8001 */
ac88cd21ae88 patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
8002 unsigned int
ac88cd21ae88 patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
8003 get_ve_flags(void)
ac88cd21ae88 patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
8004 {
25487
c26ff3203b43 patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents: 25419
diff changeset
8005 return (curwin->w_ve_flags ? curwin->w_ve_flags : ve_flags)
c26ff3203b43 patch 8.2.3280: 'virtualedit' local to buffer is not the best solution
Bram Moolenaar <Bram@vim.org>
parents: 25419
diff changeset
8006 & ~(VE_NONE | VE_NONEU);
25380
ac88cd21ae88 patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
8007 }
ac88cd21ae88 patch 8.2.3227: 'virtualedit' can only be set globally
Bram Moolenaar <Bram@vim.org>
parents: 25320
diff changeset
8008
18574
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
8009 #if defined(FEAT_LINEBREAK) || defined(PROTO)
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
8010 /*
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
8011 * Get the local or global value of 'showbreak'.
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
8012 */
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
8013 char_u *
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
8014 get_showbreak_value(win_T *win)
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
8015 {
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
8016 if (win->w_p_sbr == NULL || *win->w_p_sbr == NUL)
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
8017 return p_sbr;
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
8018 if (STRCMP(win->w_p_sbr, "NONE") == 0)
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
8019 return empty_option;
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
8020 return win->w_p_sbr;
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
8021 }
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
8022 #endif
8b0114ffde2b patch 8.1.2281: 'showbreak' cannot be set for one window
Bram Moolenaar <Bram@vim.org>
parents: 18498
diff changeset
8023
9858
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8024 #if defined(FEAT_EVAL) || defined(PROTO)
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8025 /*
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8026 * Get window or buffer local options.
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8027 */
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8028 dict_T *
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8029 get_winbuf_options(int bufopt)
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8030 {
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8031 dict_T *d;
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8032 int opt_idx;
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8033
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8034 d = dict_alloc();
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8035 if (d == NULL)
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8036 return NULL;
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8037
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
8038 for (opt_idx = 0; !istermoption_idx(opt_idx); opt_idx++)
9858
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8039 {
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8040 struct vimoption *opt = &options[opt_idx];
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8041
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8042 if ((bufopt && (opt->indir & PV_BUF))
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8043 || (!bufopt && (opt->indir & PV_WIN)))
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8044 {
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8045 char_u *varp = get_varp(opt);
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8046
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8047 if (varp != NULL)
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8048 {
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8049 if (opt->flags & P_STRING)
14301
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14243
diff changeset
8050 dict_add_string(d, opt->fullname, *(char_u **)varp);
10205
22e97a250277 commit https://github.com/vim/vim/commit/789a5c0e3d27f09456678f0cfb6c1bd2d8ab4a35
Christian Brabandt <cb@256bit.org>
parents: 10070
diff changeset
8051 else if (opt->flags & P_NUM)
14301
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14243
diff changeset
8052 dict_add_number(d, opt->fullname, *(long *)varp);
9858
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8053 else
14301
3c80092eb211 patch 8.1.0166: using dict_add_nr_str() is clumsy
Christian Brabandt <cb@256bit.org>
parents: 14243
diff changeset
8054 dict_add_number(d, opt->fullname, *(int *)varp);
9858
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8055 }
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8056 }
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8057 }
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8058
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8059 return d;
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8060 }
3e96d9ed2ca1 commit https://github.com/vim/vim/commit/b5ae48e9ffd3b8eb6ca4057de11f1bddcde8ce6f
Christian Brabandt <cb@256bit.org>
parents: 9854
diff changeset
8061 #endif
18068
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8062
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
8063 #if defined(FEAT_SYN_HL) || defined(PROTO)
18068
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8064 /*
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8065 * This is called when 'culopt' is changed
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8066 */
18100
df5778d73320 patch 8.1.2045: the option.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 18068
diff changeset
8067 int
18068
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8068 fill_culopt_flags(char_u *val, win_T *wp)
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8069 {
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8070 char_u *p;
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8071 char_u culopt_flags_new = 0;
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8072
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8073 if (val == NULL)
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8074 p = wp->w_p_culopt;
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8075 else
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8076 p = val;
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8077 while (*p != NUL)
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8078 {
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8079 if (STRNCMP(p, "line", 4) == 0)
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8080 {
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8081 p += 4;
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8082 culopt_flags_new |= CULOPT_LINE;
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8083 }
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8084 else if (STRNCMP(p, "both", 4) == 0)
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8085 {
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8086 p += 4;
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8087 culopt_flags_new |= CULOPT_LINE | CULOPT_NBR;
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8088 }
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8089 else if (STRNCMP(p, "number", 6) == 0)
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8090 {
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8091 p += 6;
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8092 culopt_flags_new |= CULOPT_NBR;
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8093 }
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8094 else if (STRNCMP(p, "screenline", 10) == 0)
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8095 {
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8096 p += 10;
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8097 culopt_flags_new |= CULOPT_SCRLINE;
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8098 }
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8099
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8100 if (*p != ',' && *p != NUL)
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8101 return FAIL;
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8102 if (*p == ',')
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8103 ++p;
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8104 }
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8105
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8106 // Can't have both "line" and "screenline".
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8107 if ((culopt_flags_new & CULOPT_LINE) && (culopt_flags_new & CULOPT_SCRLINE))
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8108 return FAIL;
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8109 wp->w_p_culopt_flags = culopt_flags_new;
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8110
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8111 return OK;
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8112 }
1101eacc1444 patch 8.1.2029: cannot control 'cursorline' highlighting well
Bram Moolenaar <Bram@vim.org>
parents: 18054
diff changeset
8113 #endif
23272
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
8114
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
8115 /*
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
8116 * Get the value of 'magic' adjusted for Vim9 script.
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
8117 */
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
8118 int
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
8119 magic_isset(void)
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
8120 {
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
8121 switch (magic_overruled)
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
8122 {
23505
bb29b09902d5 patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
8123 case OPTION_MAGIC_ON: return TRUE;
bb29b09902d5 patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
8124 case OPTION_MAGIC_OFF: return FALSE;
bb29b09902d5 patch 8.2.2295: incsearch does not detect empty pattern properly
Bram Moolenaar <Bram@vim.org>
parents: 23467
diff changeset
8125 case OPTION_MAGIC_NOT_SET: break;
23272
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
8126 }
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
8127 #ifdef FEAT_EVAL
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
8128 if (in_vim9script())
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
8129 return TRUE;
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
8130 #endif
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
8131 return p_magic;
a84e7abb0c92 patch 8.2.2182: Vim9: value of 'magic' is still relevant
Bram Moolenaar <Bram@vim.org>
parents: 22699
diff changeset
8132 }
26175
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8133
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8134 /*
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8135 * Set the callback function value for an option that accepts a function name,
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8136 * lambda, et al. (e.g. 'operatorfunc', 'tagfunc', etc.)
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8137 * Returns OK if the option is successfully set to a function, otherwise
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8138 * returns FAIL.
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8139 */
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8140 int
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8141 option_set_callback_func(char_u *optval UNUSED, callback_T *optcb UNUSED)
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8142 {
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8143 #ifdef FEAT_EVAL
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8144 typval_T *tv;
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8145 callback_T cb;
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8146
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8147 if (optval == NULL || *optval == NUL)
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8148 {
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8149 free_callback(optcb);
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8150 return OK;
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8151 }
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8152
26362
dbe615b75f15 patch 8.2.3712: cannot use Vim9 lambda for 'tagfunc'
Bram Moolenaar <Bram@vim.org>
parents: 26336
diff changeset
8153 if (*optval == '{' || (in_vim9script() && *optval == '(')
26175
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8154 || (STRNCMP(optval, "function(", 9) == 0)
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8155 || (STRNCMP(optval, "funcref(", 8) == 0))
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8156 // Lambda expression or a funcref
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8157 tv = eval_expr(optval, NULL);
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8158 else
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8159 // treat everything else as a function name string
26721
9c9b8d95b05f patch 8.2.3889: duplicate code for translating script-local function name
Bram Moolenaar <Bram@vim.org>
parents: 26618
diff changeset
8160 tv = alloc_string_tv(vim_strsave(optval));
26175
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8161 if (tv == NULL)
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8162 return FAIL;
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8163
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8164 cb = get_callback(tv);
26452
65b4109a4297 patch 8.2.3756: might crash when callback is not valid
Bram Moolenaar <Bram@vim.org>
parents: 26441
diff changeset
8165 if (cb.cb_name == NULL || *cb.cb_name == NUL)
26175
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8166 {
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8167 free_tv(tv);
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8168 return FAIL;
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8169 }
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8170
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8171 free_callback(optcb);
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8172 set_callback(optcb, &cb);
31313
b6bef244837e patch 9.0.0990: callback name argument is changed by setqflist()
Bram Moolenaar <Bram@vim.org>
parents: 31259
diff changeset
8173 if (cb.cb_free_name)
b6bef244837e patch 9.0.0990: callback name argument is changed by setqflist()
Bram Moolenaar <Bram@vim.org>
parents: 31259
diff changeset
8174 vim_free(cb.cb_name);
26175
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8175 free_tv(tv);
27285
53edd190a607 patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents: 27142
diff changeset
8176
53edd190a607 patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents: 27142
diff changeset
8177 // when using Vim9 style "import.funcname" it needs to be expanded to
53edd190a607 patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents: 27142
diff changeset
8178 // "import#funcname".
53edd190a607 patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents: 27142
diff changeset
8179 expand_autload_callback(optcb);
53edd190a607 patch 8.2.4171: cannot invoke option function using autoload import
Bram Moolenaar <Bram@vim.org>
parents: 27142
diff changeset
8180
26175
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8181 return OK;
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8182 #else
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8183 return FAIL;
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8184 #endif
6b4f017d7005 patch 8.2.3619: cannot use a lambda for 'operatorfunc'
Bram Moolenaar <Bram@vim.org>
parents: 25990
diff changeset
8185 }