blob: 5b6dbe358c16e75c54281ad126e1ddcf8fe32ae0 [file] [log] [blame]
Bram Moolenaaredf3f972016-08-29 22:49:24 +02001/* vi:set ts=8 sts=4 sw=4 noet:
Bram Moolenaar071d4272004-06-13 20:20:40 +00002 *
3 * VIM - Vi IMproved by Bram Moolenaar
4 *
5 * Do ":help uganda" in Vim to read copying and usage conditions.
6 * Do ":help credits" in Vim to see a list of people who contributed.
7 * See README.txt for an overview of the Vim source code.
8 */
9
10/*
11 * Code to handle user-settable options. This is all pretty much table-
12 * driven. Checklist for adding a new option:
13 * - Put it in the options array below (copy an existing entry).
14 * - For a global option: Add a variable for it in option.h.
15 * - For a buffer or window local option:
16 * - Add a PV_XX entry to the enum below.
17 * - Add a variable to the window or buffer struct in structs.h.
18 * - For a window option, add some code to copy_winopt().
19 * - For a buffer option, add some code to buf_copy_options().
20 * - For a buffer string option, add code to check_buf_options().
21 * - If it's a numeric option, add any necessary bounds checks to do_set().
22 * - If it's a list of flags, add some code in do_set(), search for WW_ALL.
23 * - When adding an option with expansion (P_EXPAND), but with a different
24 * default for Vi and Vim (no P_VI_DEF), add some code at VIMEXP.
Bram Moolenaarcea912a2016-10-12 14:20:24 +020025 * - Add documentation! One line in doc/quickref.txt, full description in
Bram Moolenaar071d4272004-06-13 20:20:40 +000026 * options.txt, and any other related places.
27 * - Add an entry in runtime/optwin.vim.
28 * When making changes:
29 * - Adjust the help for the option in doc/option.txt.
30 * - When an entry has the P_VIM flag, or is lacking the P_VI_DEF flag, add a
31 * comment at the help for the 'compatible' option.
32 */
33
34#define IN_OPTION_C
35#include "vim.h"
36
37/*
38 * The options that are local to a window or buffer have "indir" set to one of
39 * these values. Special values:
40 * PV_NONE: global option.
Bram Moolenaara23ccb82006-02-27 00:08:02 +000041 * PV_WIN is added: window-local option
42 * PV_BUF is added: buffer-local option
Bram Moolenaar071d4272004-06-13 20:20:40 +000043 * PV_BOTH is added: global option which also has a local value.
44 */
45#define PV_BOTH 0x1000
Bram Moolenaara23ccb82006-02-27 00:08:02 +000046#define PV_WIN 0x2000
47#define PV_BUF 0x4000
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000048#define PV_MASK 0x0fff
Bram Moolenaara23ccb82006-02-27 00:08:02 +000049#define OPT_WIN(x) (idopt_T)(PV_WIN + (int)(x))
50#define OPT_BUF(x) (idopt_T)(PV_BUF + (int)(x))
Bram Moolenaar071d4272004-06-13 20:20:40 +000051#define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x))
52
Bram Moolenaara23ccb82006-02-27 00:08:02 +000053/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000054 * Definition of the PV_ values for buffer-local options.
55 * The BV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +000056 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +000057#define PV_AI OPT_BUF(BV_AI)
58#define PV_AR OPT_BOTH(OPT_BUF(BV_AR))
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020059#define PV_BKC OPT_BOTH(OPT_BUF(BV_BKC))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000060#ifdef FEAT_QUICKFIX
Bram Moolenaara23ccb82006-02-27 00:08:02 +000061# define PV_BH OPT_BUF(BV_BH)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000062# define PV_BT OPT_BUF(BV_BT)
63# define PV_EFM OPT_BOTH(OPT_BUF(BV_EFM))
64# define PV_GP OPT_BOTH(OPT_BUF(BV_GP))
65# define PV_MP OPT_BOTH(OPT_BUF(BV_MP))
Bram Moolenaara23ccb82006-02-27 00:08:02 +000066#endif
67#define PV_BIN OPT_BUF(BV_BIN)
68#define PV_BL OPT_BUF(BV_BL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000069#ifdef FEAT_MBYTE
70# define PV_BOMB OPT_BUF(BV_BOMB)
71#endif
72#define PV_CI OPT_BUF(BV_CI)
73#ifdef FEAT_CINDENT
74# define PV_CIN OPT_BUF(BV_CIN)
75# define PV_CINK OPT_BUF(BV_CINK)
76# define PV_CINO OPT_BUF(BV_CINO)
77#endif
78#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
79# define PV_CINW OPT_BUF(BV_CINW)
80#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020081#define PV_CM OPT_BOTH(OPT_BUF(BV_CM))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000082#ifdef FEAT_FOLDING
83# define PV_CMS OPT_BUF(BV_CMS)
84#endif
85#ifdef FEAT_COMMENTS
86# define PV_COM OPT_BUF(BV_COM)
87#endif
88#ifdef FEAT_INS_EXPAND
89# define PV_CPT OPT_BUF(BV_CPT)
90# define PV_DICT OPT_BOTH(OPT_BUF(BV_DICT))
91# define PV_TSR OPT_BOTH(OPT_BUF(BV_TSR))
92#endif
93#ifdef FEAT_COMPL_FUNC
94# define PV_CFU OPT_BUF(BV_CFU)
95#endif
96#ifdef FEAT_FIND_ID
97# define PV_DEF OPT_BOTH(OPT_BUF(BV_DEF))
98# define PV_INC OPT_BOTH(OPT_BUF(BV_INC))
99#endif
100#define PV_EOL OPT_BUF(BV_EOL)
Bram Moolenaar34d72d42015-07-17 14:18:08 +0200101#define PV_FIXEOL OPT_BUF(BV_FIXEOL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000102#define PV_EP OPT_BOTH(OPT_BUF(BV_EP))
103#define PV_ET OPT_BUF(BV_ET)
104#ifdef FEAT_MBYTE
105# define PV_FENC OPT_BUF(BV_FENC)
106#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000107#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
108# define PV_BEXPR OPT_BOTH(OPT_BUF(BV_BEXPR))
109#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000110#ifdef FEAT_EVAL
111# define PV_FEX OPT_BUF(BV_FEX)
112#endif
113#define PV_FF OPT_BUF(BV_FF)
114#define PV_FLP OPT_BUF(BV_FLP)
115#define PV_FO OPT_BUF(BV_FO)
116#ifdef FEAT_AUTOCMD
117# define PV_FT OPT_BUF(BV_FT)
118#endif
119#define PV_IMI OPT_BUF(BV_IMI)
120#define PV_IMS OPT_BUF(BV_IMS)
121#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
122# define PV_INDE OPT_BUF(BV_INDE)
123# define PV_INDK OPT_BUF(BV_INDK)
124#endif
125#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
126# define PV_INEX OPT_BUF(BV_INEX)
127#endif
128#define PV_INF OPT_BUF(BV_INF)
129#define PV_ISK OPT_BUF(BV_ISK)
130#ifdef FEAT_CRYPT
131# define PV_KEY OPT_BUF(BV_KEY)
132#endif
133#ifdef FEAT_KEYMAP
134# define PV_KMAP OPT_BUF(BV_KMAP)
135#endif
136#define PV_KP OPT_BOTH(OPT_BUF(BV_KP))
137#ifdef FEAT_LISP
138# define PV_LISP OPT_BUF(BV_LISP)
Bram Moolenaaraf6c1312014-03-12 18:55:58 +0100139# define PV_LW OPT_BOTH(OPT_BUF(BV_LW))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000140#endif
141#define PV_MA OPT_BUF(BV_MA)
142#define PV_ML OPT_BUF(BV_ML)
143#define PV_MOD OPT_BUF(BV_MOD)
144#define PV_MPS OPT_BUF(BV_MPS)
145#define PV_NF OPT_BUF(BV_NF)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000146#ifdef FEAT_COMPL_FUNC
147# define PV_OFU OPT_BUF(BV_OFU)
148#endif
149#define PV_PATH OPT_BOTH(OPT_BUF(BV_PATH))
150#define PV_PI OPT_BUF(BV_PI)
151#ifdef FEAT_TEXTOBJ
152# define PV_QE OPT_BUF(BV_QE)
153#endif
154#define PV_RO OPT_BUF(BV_RO)
155#ifdef FEAT_SMARTINDENT
156# define PV_SI OPT_BUF(BV_SI)
157#endif
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100158#define PV_SN OPT_BUF(BV_SN)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000159#ifdef FEAT_SYN_HL
160# define PV_SMC OPT_BUF(BV_SMC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000161# define PV_SYN OPT_BUF(BV_SYN)
162#endif
163#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000164# define PV_SPC OPT_BUF(BV_SPC)
165# define PV_SPF OPT_BUF(BV_SPF)
166# define PV_SPL OPT_BUF(BV_SPL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000167#endif
168#define PV_STS OPT_BUF(BV_STS)
169#ifdef FEAT_SEARCHPATH
170# define PV_SUA OPT_BUF(BV_SUA)
171#endif
172#define PV_SW OPT_BUF(BV_SW)
173#define PV_SWF OPT_BUF(BV_SWF)
174#define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS))
Bram Moolenaar0f6562e2015-11-24 18:48:14 +0100175#define PV_TC OPT_BOTH(OPT_BUF(BV_TC))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000176#define PV_TS OPT_BUF(BV_TS)
177#define PV_TW OPT_BUF(BV_TW)
178#define PV_TX OPT_BUF(BV_TX)
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200179#ifdef FEAT_PERSISTENT_UNDO
180# define PV_UDF OPT_BUF(BV_UDF)
181#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000182#define PV_WM OPT_BUF(BV_WM)
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000183
184/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000185 * Definition of the PV_ values for window-local options.
186 * The WV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000187 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000188#define PV_LIST OPT_WIN(WV_LIST)
189#ifdef FEAT_ARABIC
190# define PV_ARAB OPT_WIN(WV_ARAB)
191#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +0200192#ifdef FEAT_LINEBREAK
193# define PV_BRI OPT_WIN(WV_BRI)
194# define PV_BRIOPT OPT_WIN(WV_BRIOPT)
195#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000196#ifdef FEAT_DIFF
197# define PV_DIFF OPT_WIN(WV_DIFF)
198#endif
199#ifdef FEAT_FOLDING
200# define PV_FDC OPT_WIN(WV_FDC)
201# define PV_FEN OPT_WIN(WV_FEN)
202# define PV_FDI OPT_WIN(WV_FDI)
203# define PV_FDL OPT_WIN(WV_FDL)
204# define PV_FDM OPT_WIN(WV_FDM)
205# define PV_FML OPT_WIN(WV_FML)
206# define PV_FDN OPT_WIN(WV_FDN)
207# ifdef FEAT_EVAL
208# define PV_FDE OPT_WIN(WV_FDE)
209# define PV_FDT OPT_WIN(WV_FDT)
210# endif
211# define PV_FMR OPT_WIN(WV_FMR)
212#endif
213#ifdef FEAT_LINEBREAK
214# define PV_LBR OPT_WIN(WV_LBR)
215#endif
216#define PV_NU OPT_WIN(WV_NU)
Bram Moolenaar64486672010-05-16 15:46:46 +0200217#define PV_RNU OPT_WIN(WV_RNU)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000218#ifdef FEAT_LINEBREAK
219# define PV_NUW OPT_WIN(WV_NUW)
220#endif
221#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
222# define PV_PVW OPT_WIN(WV_PVW)
223#endif
224#ifdef FEAT_RIGHTLEFT
225# define PV_RL OPT_WIN(WV_RL)
226# define PV_RLC OPT_WIN(WV_RLC)
227#endif
228#ifdef FEAT_SCROLLBIND
229# define PV_SCBIND OPT_WIN(WV_SCBIND)
230#endif
231#define PV_SCROLL OPT_WIN(WV_SCROLL)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000232#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000233# define PV_SPELL OPT_WIN(WV_SPELL)
234#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000235#ifdef FEAT_SYN_HL
236# define PV_CUC OPT_WIN(WV_CUC)
237# define PV_CUL OPT_WIN(WV_CUL)
Bram Moolenaar1a384422010-07-14 19:53:30 +0200238# define PV_CC OPT_WIN(WV_CC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000239#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000240#ifdef FEAT_STL_OPT
241# define PV_STL OPT_BOTH(OPT_WIN(WV_STL))
242#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +0100243#define PV_UL OPT_BOTH(OPT_BUF(BV_UL))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000244#ifdef FEAT_WINDOWS
245# define PV_WFH OPT_WIN(WV_WFH)
Bram Moolenaar97b2ad32006-03-18 21:40:56 +0000246# define PV_WFW OPT_WIN(WV_WFW)
247#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000248#define PV_WRAP OPT_WIN(WV_WRAP)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200249#ifdef FEAT_CURSORBIND
250# define PV_CRBIND OPT_WIN(WV_CRBIND)
251#endif
252#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200253# define PV_COCU OPT_WIN(WV_COCU)
254# define PV_COLE OPT_WIN(WV_COLE)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200255#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +0200256#ifdef FEAT_SIGNS
257# define PV_SCL OPT_WIN(WV_SCL)
258#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000259
260/* WV_ and BV_ values get typecasted to this for the "indir" field */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000261typedef enum
262{
Bram Moolenaar7d96acd2008-06-09 15:07:54 +0000263 PV_NONE = 0,
264 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000265} idopt_T;
266
267/*
268 * Options local to a window have a value local to a buffer and global to all
269 * buffers. Indicate this by setting "var" to VAR_WIN.
270 */
271#define VAR_WIN ((char_u *)-1)
272
273/*
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000274 * These are the global values for options which are also local to a buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000275 * Only to be used in option.c!
276 */
277static int p_ai;
278static int p_bin;
279#ifdef FEAT_MBYTE
280static int p_bomb;
281#endif
282#if defined(FEAT_QUICKFIX)
283static char_u *p_bh;
284static char_u *p_bt;
285#endif
286static int p_bl;
287static int p_ci;
288#ifdef FEAT_CINDENT
289static int p_cin;
290static char_u *p_cink;
291static char_u *p_cino;
292#endif
293#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
294static char_u *p_cinw;
295#endif
296#ifdef FEAT_COMMENTS
297static char_u *p_com;
298#endif
299#ifdef FEAT_FOLDING
300static char_u *p_cms;
301#endif
302#ifdef FEAT_INS_EXPAND
303static char_u *p_cpt;
304#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000305#ifdef FEAT_COMPL_FUNC
306static char_u *p_cfu;
Bram Moolenaare344bea2005-09-01 20:46:49 +0000307static char_u *p_ofu;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000308#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000309static int p_eol;
Bram Moolenaar34d72d42015-07-17 14:18:08 +0200310static int p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000311static int p_et;
312#ifdef FEAT_MBYTE
313static char_u *p_fenc;
314#endif
315static char_u *p_ff;
316static char_u *p_fo;
Bram Moolenaar86b68352004-12-27 21:59:20 +0000317static char_u *p_flp;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000318#ifdef FEAT_AUTOCMD
319static char_u *p_ft;
320#endif
321static long p_iminsert;
322static long p_imsearch;
323#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
324static char_u *p_inex;
325#endif
326#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
327static char_u *p_inde;
328static char_u *p_indk;
329#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +0000330#if defined(FEAT_EVAL)
331static char_u *p_fex;
332#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000333static int p_inf;
334static char_u *p_isk;
335#ifdef FEAT_CRYPT
336static char_u *p_key;
337#endif
338#ifdef FEAT_LISP
339static int p_lisp;
340#endif
341static int p_ml;
342static int p_ma;
343static int p_mod;
344static char_u *p_mps;
345static char_u *p_nf;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000346static int p_pi;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000347#ifdef FEAT_TEXTOBJ
348static char_u *p_qe;
349#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000350static int p_ro;
351#ifdef FEAT_SMARTINDENT
352static int p_si;
353#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000354static int p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000355static long p_sts;
356#if defined(FEAT_SEARCHPATH)
357static char_u *p_sua;
358#endif
359static long p_sw;
360static int p_swf;
361#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +0000362static long p_smc;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000363static char_u *p_syn;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000364#endif
365#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000366static char_u *p_spc;
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000367static char_u *p_spf;
Bram Moolenaar217ad922005-03-20 22:37:15 +0000368static char_u *p_spl;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000369#endif
370static long p_ts;
371static long p_tw;
372static int p_tx;
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200373#ifdef FEAT_PERSISTENT_UNDO
374static int p_udf;
375#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000376static long p_wm;
377#ifdef FEAT_KEYMAP
378static char_u *p_keymap;
379#endif
380
381/* Saved values for when 'bin' is set. */
382static int p_et_nobin;
383static int p_ml_nobin;
384static long p_tw_nobin;
385static long p_wm_nobin;
386
387/* Saved values for when 'paste' is set */
Bram Moolenaar54f018c2015-09-15 17:30:40 +0200388static int p_ai_nopaste;
389static int p_et_nopaste;
390static long p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000391static long p_tw_nopaste;
392static long p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000393
394struct vimoption
395{
396 char *fullname; /* full option name */
397 char *shortname; /* permissible abbreviation */
398 long_u flags; /* see below */
399 char_u *var; /* global option: pointer to variable;
400 * window-local option: VAR_WIN;
401 * buffer-local option: global value */
402 idopt_T indir; /* global option: PV_NONE;
403 * local option: indirect option index */
404 char_u *def_val[2]; /* default values for variable (vi and vim) */
405#ifdef FEAT_EVAL
406 scid_T scriptID; /* script in which the option was last set */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000407# define SCRIPTID_INIT , 0
408#else
409# define SCRIPTID_INIT
Bram Moolenaar071d4272004-06-13 20:20:40 +0000410#endif
411};
412
413#define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */
414#define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */
415
416/*
417 * Flags
418 */
419#define P_BOOL 0x01 /* the option is boolean */
420#define P_NUM 0x02 /* the option is numeric */
421#define P_STRING 0x04 /* the option is a string */
422#define P_ALLOCED 0x08 /* the string option is in allocated memory,
Bram Moolenaar363cb672009-07-22 12:28:17 +0000423 must use free_string_option() when
424 assigning new value. Not set if default is
425 the same. */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000426#define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
427 never be used for local or hidden options! */
428#define P_NODEFAULT 0x40 /* don't set to default value */
429#define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must
430 use vim_free() when assigning new value */
431#define P_WAS_SET 0x100 /* option has been set/reset */
432#define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */
433#define P_VI_DEF 0x400 /* Use Vi default for Vim */
434#define P_VIM 0x800 /* Vim option, reset when 'cp' set */
435
436 /* when option changed, what to display: */
437#define P_RSTAT 0x1000 /* redraw status lines */
438#define P_RWIN 0x2000 /* redraw current window */
439#define P_RBUF 0x4000 /* redraw current buffer */
440#define P_RALL 0x6000 /* redraw all windows */
441#define P_RCLR 0x7000 /* clear and redraw all */
442
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200443#define P_COMMA 0x8000 /* comma separated list */
444#define P_ONECOMMA 0x18000L /* P_COMMA and cannot have two consecutive
445 * commas */
446#define P_NODUP 0x20000L /* don't allow duplicate strings */
447#define P_FLAGLIST 0x40000L /* list of single-char flags */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000448
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200449#define P_SECURE 0x80000L /* cannot change in modeline or secure mode */
450#define P_GETTEXT 0x100000L /* expand default value with _() */
451#define P_NOGLOB 0x200000L /* do not use local value for global vimrc */
452#define P_NFNAME 0x400000L /* only normal file name chars allowed */
453#define P_INSECURE 0x800000L /* option was set from a modeline */
454#define P_PRI_MKRC 0x1000000L /* priority for :mkvimrc (setting option has
Bram Moolenaar7554da42016-11-25 22:04:13 +0100455 side effects) */
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200456#define P_NO_ML 0x2000000L /* not allowed in modeline */
457#define P_CURSWANT 0x4000000L /* update curswant required; not needed when
Bram Moolenaar913077c2012-03-28 19:59:04 +0200458 * there is a redraw flag */
Bram Moolenaar7554da42016-11-25 22:04:13 +0100459#define P_NDNAME 0x8000000L /* only normal dir name chars allowed */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000460
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000461#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
462
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000463/* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used
464 * for the currency sign. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100465#if defined(MSWIN)
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000466# define ISP_LATIN1 (char_u *)"@,~-255"
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000467#else
468# define ISP_LATIN1 (char_u *)"@,161-255"
469#endif
470
Bram Moolenaar44a2f922016-03-19 22:11:51 +0100471/* Make the string as short as possible when compiling with few features. */
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000472#if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
Bram Moolenaar44a2f922016-03-19 22:11:51 +0100473 || defined(FEAT_WINDOWS) || defined(FEAT_CLIPBOARD) \
Bram Moolenaar860cae12010-06-05 23:22:07 +0200474 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) || defined(FEAT_CONCEAL)
Bram Moolenaar58b85342016-08-14 19:54:54 +0200475# define HIGHLIGHT_INIT "8:SpecialKey,~:EndOfBuffer,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000476#else
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100477# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000478#endif
479
Bram Moolenaar071d4272004-06-13 20:20:40 +0000480/*
481 * options[] is initialized here.
482 * The order of the options MUST be alphabetic for ":set all" and findoption().
483 * All option names MUST start with a lowercase letter (for findoption()).
484 * Exception: "t_" options are at the end.
485 * The options with a NULL variable are 'hidden': a set command for them is
486 * ignored and they are not printed.
487 */
Bram Moolenaare89ff042016-02-20 22:17:05 +0100488static struct vimoption options[] =
Bram Moolenaar071d4272004-06-13 20:20:40 +0000489{
Bram Moolenaar913077c2012-03-28 19:59:04 +0200490 {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000491#ifdef FEAT_RIGHTLEFT
492 (char_u *)&p_aleph, PV_NONE,
493#else
494 (char_u *)NULL, PV_NONE,
495#endif
496 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100497#if (defined(WIN3264)) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000498 (char_u *)128L,
499#else
500 (char_u *)224L,
501#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000502 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000503 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
504#if defined(FEAT_GUI) && defined(MACOS_X)
505 (char_u *)&p_antialias, PV_NONE,
506 {(char_u *)FALSE, (char_u *)FALSE}
507#else
508 (char_u *)NULL, PV_NONE,
509 {(char_u *)FALSE, (char_u *)FALSE}
510#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000511 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200512 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000513#ifdef FEAT_ARABIC
514 (char_u *)VAR_WIN, PV_ARAB,
515#else
516 (char_u *)NULL, PV_NONE,
517#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000518 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000519 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
520#ifdef FEAT_ARABIC
521 (char_u *)&p_arshape, PV_NONE,
522#else
523 (char_u *)NULL, PV_NONE,
524#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000525 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000526 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
527#ifdef FEAT_RIGHTLEFT
528 (char_u *)&p_ari, PV_NONE,
529#else
530 (char_u *)NULL, PV_NONE,
531#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000532 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000533 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
534#ifdef FEAT_FKMAP
535 (char_u *)&p_altkeymap, PV_NONE,
536#else
537 (char_u *)NULL, PV_NONE,
538#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000539 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000540 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
541#if defined(FEAT_MBYTE)
542 (char_u *)&p_ambw, PV_NONE,
543 {(char_u *)"single", (char_u *)0L}
544#else
545 (char_u *)NULL, PV_NONE,
546 {(char_u *)0L, (char_u *)0L}
547#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000548 SCRIPTID_INIT},
Bram Moolenaar8dff8182006-04-06 20:18:50 +0000549#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +0000550 {"autochdir", "acd", P_BOOL|P_VI_DEF,
551 (char_u *)&p_acd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000552 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000553#endif
554 {"autoindent", "ai", P_BOOL|P_VI_DEF,
555 (char_u *)&p_ai, PV_AI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000556 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000557 {"autoprint", "ap", P_BOOL|P_VI_DEF,
558 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000559 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000560 {"autoread", "ar", P_BOOL|P_VI_DEF,
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000561 (char_u *)&p_ar, PV_AR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000562 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000563 {"autowrite", "aw", P_BOOL|P_VI_DEF,
564 (char_u *)&p_aw, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000565 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000566 {"autowriteall","awa", P_BOOL|P_VI_DEF,
567 (char_u *)&p_awa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000568 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000569 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
570 (char_u *)&p_bg, PV_NONE,
571 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100572#if (defined(WIN3264)) && !defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000573 (char_u *)"dark",
574#else
575 (char_u *)"light",
576#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000577 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200578 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000579 (char_u *)&p_bs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000580 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000581 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
582 (char_u *)&p_bk, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000583 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200584 {"backupcopy", "bkc", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +0200585 (char_u *)&p_bkc, PV_BKC,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000586#ifdef UNIX
587 {(char_u *)"yes", (char_u *)"auto"}
588#else
589 {(char_u *)"auto", (char_u *)"auto"}
590#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000591 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200592 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
593 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000594 (char_u *)&p_bdir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000595 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000596 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000597 (char_u *)&p_bex, PV_NONE,
598 {
599#ifdef VMS
600 (char_u *)"_",
601#else
602 (char_u *)"~",
603#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000604 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200605 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000606#ifdef FEAT_WILDIGN
607 (char_u *)&p_bsk, PV_NONE,
608 {(char_u *)"", (char_u *)0L}
609#else
610 (char_u *)NULL, PV_NONE,
611 {(char_u *)0L, (char_u *)0L}
612#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000613 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000614#ifdef FEAT_BEVAL
615 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
616 (char_u *)&p_bdlay, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000617 {(char_u *)600L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000618 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
619 (char_u *)&p_beval, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000620 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000621# ifdef FEAT_EVAL
Bram Moolenaar39f05632006-03-19 22:15:26 +0000622 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000623 (char_u *)&p_bexpr, PV_BEXPR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000624 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000625# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000626#endif
627 {"beautify", "bf", P_BOOL|P_VI_DEF,
628 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000629 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar165bc692015-07-21 17:53:25 +0200630 {"belloff", "bo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
631 (char_u *)&p_bo, PV_NONE,
632 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000633 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
634 (char_u *)&p_bin, PV_BIN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000635 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000636 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000637 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000638 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000639 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
640#ifdef FEAT_MBYTE
641 (char_u *)&p_bomb, PV_BOMB,
642#else
643 (char_u *)NULL, PV_NONE,
644#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000645 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000646 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
647#ifdef FEAT_LINEBREAK
648 (char_u *)&p_breakat, PV_NONE,
649 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
650#else
651 (char_u *)NULL, PV_NONE,
652 {(char_u *)0L, (char_u *)0L}
653#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000654 SCRIPTID_INIT},
Bram Moolenaar597a4222014-06-25 14:39:50 +0200655 {"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
656#ifdef FEAT_LINEBREAK
657 (char_u *)VAR_WIN, PV_BRI,
658 {(char_u *)FALSE, (char_u *)0L}
659#else
660 (char_u *)NULL, PV_NONE,
661 {(char_u *)0L, (char_u *)0L}
662#endif
663 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200664 {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF
665 |P_ONECOMMA|P_NODUP,
Bram Moolenaar597a4222014-06-25 14:39:50 +0200666#ifdef FEAT_LINEBREAK
667 (char_u *)VAR_WIN, PV_BRIOPT,
668 {(char_u *)"", (char_u *)NULL}
669#else
670 (char_u *)NULL, PV_NONE,
671 {(char_u *)"", (char_u *)NULL}
672#endif
673 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000674 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
675#ifdef FEAT_BROWSE
676 (char_u *)&p_bsdir, PV_NONE,
677 {(char_u *)"last", (char_u *)0L}
678#else
679 (char_u *)NULL, PV_NONE,
680 {(char_u *)0L, (char_u *)0L}
681#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000682 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000683 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
684#if defined(FEAT_QUICKFIX)
685 (char_u *)&p_bh, PV_BH,
686 {(char_u *)"", (char_u *)0L}
687#else
688 (char_u *)NULL, PV_NONE,
689 {(char_u *)0L, (char_u *)0L}
690#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000691 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000692 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
693 (char_u *)&p_bl, PV_BL,
694 {(char_u *)1L, (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000695 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000696 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
697#if defined(FEAT_QUICKFIX)
698 (char_u *)&p_bt, PV_BT,
699 {(char_u *)"", (char_u *)0L}
700#else
701 (char_u *)NULL, PV_NONE,
702 {(char_u *)0L, (char_u *)0L}
703#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000704 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200705 {"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000706#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000707 (char_u *)&p_cmp, PV_NONE,
708 {(char_u *)"internal,keepascii", (char_u *)0L}
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000709#else
710 (char_u *)NULL, PV_NONE,
711 {(char_u *)0L, (char_u *)0L}
712#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000713 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000714 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
715#ifdef FEAT_SEARCHPATH
716 (char_u *)&p_cdpath, PV_NONE,
717 {(char_u *)",,", (char_u *)0L}
718#else
719 (char_u *)NULL, PV_NONE,
720 {(char_u *)0L, (char_u *)0L}
721#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000722 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000723 {"cedit", NULL, P_STRING,
724#ifdef FEAT_CMDWIN
725 (char_u *)&p_cedit, PV_NONE,
726 {(char_u *)"", (char_u *)CTRL_F_STR}
727#else
728 (char_u *)NULL, PV_NONE,
729 {(char_u *)0L, (char_u *)0L}
730#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000731 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000732 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
733#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
734 (char_u *)&p_ccv, PV_NONE,
735 {(char_u *)"", (char_u *)0L}
736#else
737 (char_u *)NULL, PV_NONE,
738 {(char_u *)0L, (char_u *)0L}
739#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000740 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000741 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
742#ifdef FEAT_CINDENT
743 (char_u *)&p_cin, PV_CIN,
744#else
745 (char_u *)NULL, PV_NONE,
746#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000747 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200748 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000749#ifdef FEAT_CINDENT
750 (char_u *)&p_cink, PV_CINK,
751 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
752#else
753 (char_u *)NULL, PV_NONE,
754 {(char_u *)0L, (char_u *)0L}
755#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000756 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200757 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000758#ifdef FEAT_CINDENT
759 (char_u *)&p_cino, PV_CINO,
760#else
761 (char_u *)NULL, PV_NONE,
762#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000763 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200764 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000765#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
766 (char_u *)&p_cinw, PV_CINW,
767 {(char_u *)"if,else,while,do,for,switch",
768 (char_u *)0L}
769#else
770 (char_u *)NULL, PV_NONE,
771 {(char_u *)0L, (char_u *)0L}
772#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000773 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200774 {"clipboard", "cb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000775#ifdef FEAT_CLIPBOARD
776 (char_u *)&p_cb, PV_NONE,
777# ifdef FEAT_XCLIPBOARD
778 {(char_u *)"autoselect,exclude:cons\\|linux",
779 (char_u *)0L}
780# else
781 {(char_u *)"", (char_u *)0L}
782# endif
783#else
784 (char_u *)NULL, PV_NONE,
785 {(char_u *)"", (char_u *)0L}
786#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000787 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000788 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
789 (char_u *)&p_ch, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000790 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000791 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
792#ifdef FEAT_CMDWIN
793 (char_u *)&p_cwh, PV_NONE,
794#else
795 (char_u *)NULL, PV_NONE,
796#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000797 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200798 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar1a384422010-07-14 19:53:30 +0200799#ifdef FEAT_SYN_HL
800 (char_u *)VAR_WIN, PV_CC,
801#else
802 (char_u *)NULL, PV_NONE,
803#endif
804 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000805 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
806 (char_u *)&Columns, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000807 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200808 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
809 |P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000810#ifdef FEAT_COMMENTS
811 (char_u *)&p_com, PV_COM,
812 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
813 (char_u *)0L}
814#else
815 (char_u *)NULL, PV_NONE,
816 {(char_u *)0L, (char_u *)0L}
817#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000818 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200819 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000820#ifdef FEAT_FOLDING
821 (char_u *)&p_cms, PV_CMS,
822 {(char_u *)"/*%s*/", (char_u *)0L}
823#else
824 (char_u *)NULL, PV_NONE,
825 {(char_u *)0L, (char_u *)0L}
826#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000827 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000828 /* P_PRI_MKRC isn't needed here, optval_default()
829 * always returns TRUE for 'compatible' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000830 {"compatible", "cp", P_BOOL|P_RALL,
831 (char_u *)&p_cp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000832 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200833 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000834#ifdef FEAT_INS_EXPAND
835 (char_u *)&p_cpt, PV_CPT,
836 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
837#else
838 (char_u *)NULL, PV_NONE,
839 {(char_u *)0L, (char_u *)0L}
840#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000841 SCRIPTID_INIT},
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200842 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200843#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200844 (char_u *)VAR_WIN, PV_COCU,
845 {(char_u *)"", (char_u *)NULL}
846#else
847 (char_u *)NULL, PV_NONE,
848 {(char_u *)NULL, (char_u *)0L}
849#endif
850 SCRIPTID_INIT},
851 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
852#ifdef FEAT_CONCEAL
853 (char_u *)VAR_WIN, PV_COLE,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200854#else
855 (char_u *)NULL, PV_NONE,
856#endif
857 {(char_u *)0L, (char_u *)0L}
858 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000859 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
860#ifdef FEAT_COMPL_FUNC
861 (char_u *)&p_cfu, PV_CFU,
862 {(char_u *)"", (char_u *)0L}
863#else
864 (char_u *)NULL, PV_NONE,
865 {(char_u *)0L, (char_u *)0L}
866#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000867 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200868 {"completeopt", "cot", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000869#ifdef FEAT_INS_EXPAND
870 (char_u *)&p_cot, PV_NONE,
Bram Moolenaarc270d802006-03-11 21:29:41 +0000871 {(char_u *)"menu,preview", (char_u *)0L}
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000872#else
873 (char_u *)NULL, PV_NONE,
874 {(char_u *)0L, (char_u *)0L}
875#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000876 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000877 {"confirm", "cf", P_BOOL|P_VI_DEF,
878#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
879 (char_u *)&p_confirm, PV_NONE,
880#else
881 (char_u *)NULL, PV_NONE,
882#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000883 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000884 {"conskey", "consk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000885 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000886 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000887 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
888 (char_u *)&p_ci, PV_CI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000889 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000890 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
891 (char_u *)&p_cpo, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000892 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
893 SCRIPTID_INIT},
Bram Moolenaar49771f42010-07-20 17:32:38 +0200894 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200895#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200896 (char_u *)&p_cm, PV_CM,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200897 {(char_u *)"zip", (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200898#else
899 (char_u *)NULL, PV_NONE,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200900 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200901#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +0200902 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000903 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
904#ifdef FEAT_CSCOPE
905 (char_u *)&p_cspc, PV_NONE,
906#else
907 (char_u *)NULL, PV_NONE,
908#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000909 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000910 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
911#ifdef FEAT_CSCOPE
912 (char_u *)&p_csprg, PV_NONE,
913 {(char_u *)"cscope", (char_u *)0L}
914#else
915 (char_u *)NULL, PV_NONE,
916 {(char_u *)0L, (char_u *)0L}
917#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000918 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200919 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000920#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
921 (char_u *)&p_csqf, PV_NONE,
922 {(char_u *)"", (char_u *)0L}
923#else
924 (char_u *)NULL, PV_NONE,
925 {(char_u *)0L, (char_u *)0L}
926#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000927 SCRIPTID_INIT},
Bram Moolenaarf7befa92011-06-12 22:13:40 +0200928 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM,
929#ifdef FEAT_CSCOPE
930 (char_u *)&p_csre, PV_NONE,
931#else
932 (char_u *)NULL, PV_NONE,
933#endif
934 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000935 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
936#ifdef FEAT_CSCOPE
937 (char_u *)&p_cst, PV_NONE,
938#else
939 (char_u *)NULL, PV_NONE,
940#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000941 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000942 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
943#ifdef FEAT_CSCOPE
944 (char_u *)&p_csto, PV_NONE,
945#else
946 (char_u *)NULL, PV_NONE,
947#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000948 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000949 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
950#ifdef FEAT_CSCOPE
951 (char_u *)&p_csverbose, PV_NONE,
952#else
953 (char_u *)NULL, PV_NONE,
954#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000955 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200956 {"cursorbind", "crb", P_BOOL|P_VI_DEF,
957#ifdef FEAT_CURSORBIND
958 (char_u *)VAR_WIN, PV_CRBIND,
959#else
960 (char_u *)NULL, PV_NONE,
961#endif
962 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000963 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
964#ifdef FEAT_SYN_HL
965 (char_u *)VAR_WIN, PV_CUC,
966#else
967 (char_u *)NULL, PV_NONE,
968#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000969 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000970 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWIN,
971#ifdef FEAT_SYN_HL
972 (char_u *)VAR_WIN, PV_CUL,
973#else
974 (char_u *)NULL, PV_NONE,
975#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000976 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000977 {"debug", NULL, P_STRING|P_VI_DEF,
978 (char_u *)&p_debug, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000979 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200980 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000981#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000982 (char_u *)&p_def, PV_DEF,
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000983 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000984#else
985 (char_u *)NULL, PV_NONE,
986 {(char_u *)NULL, (char_u *)0L}
987#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000988 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000989 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
990#ifdef FEAT_MBYTE
991 (char_u *)&p_deco, PV_NONE,
992#else
993 (char_u *)NULL, PV_NONE,
994#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000995 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7554da42016-11-25 22:04:13 +0100996 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000997#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000998 (char_u *)&p_dict, PV_DICT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000999#else
1000 (char_u *)NULL, PV_NONE,
1001#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001002 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001003 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
1004#ifdef FEAT_DIFF
1005 (char_u *)VAR_WIN, PV_DIFF,
1006#else
1007 (char_u *)NULL, PV_NONE,
1008#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001009 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001010 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001011#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1012 (char_u *)&p_dex, PV_NONE,
1013 {(char_u *)"", (char_u *)0L}
1014#else
1015 (char_u *)NULL, PV_NONE,
1016 {(char_u *)0L, (char_u *)0L}
1017#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001018 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001019 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_ONECOMMA
1020 |P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001021#ifdef FEAT_DIFF
1022 (char_u *)&p_dip, PV_NONE,
1023 {(char_u *)"filler", (char_u *)NULL}
1024#else
1025 (char_u *)NULL, PV_NONE,
1026 {(char_u *)"", (char_u *)NULL}
1027#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001028 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001029 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
1030#ifdef FEAT_DIGRAPHS
1031 (char_u *)&p_dg, PV_NONE,
1032#else
1033 (char_u *)NULL, PV_NONE,
1034#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001035 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001036 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
1037 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001038 (char_u *)&p_dir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001039 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001040 {"display", "dy", P_STRING|P_VI_DEF|P_ONECOMMA|P_RALL|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001041 (char_u *)&p_dy, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001042 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001043 {"eadirection", "ead", P_STRING|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01001044#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001045 (char_u *)&p_ead, PV_NONE,
1046 {(char_u *)"both", (char_u *)0L}
1047#else
1048 (char_u *)NULL, PV_NONE,
1049 {(char_u *)NULL, (char_u *)0L}
1050#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001051 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001052 {"edcompatible","ed", P_BOOL|P_VI_DEF,
1053 (char_u *)&p_ed, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001054 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3848e002016-03-19 18:42:29 +01001055 {"emoji", "emo", P_BOOL|P_VI_DEF|P_RCLR,
1056#if defined(FEAT_MBYTE)
1057 (char_u *)&p_emoji, PV_NONE,
1058 {(char_u *)TRUE, (char_u *)0L}
1059#else
1060 (char_u *)NULL, PV_NONE,
1061 {(char_u *)0L, (char_u *)0L}
1062#endif
1063 SCRIPTID_INIT},
Bram Moolenaar865242e2010-07-14 21:12:05 +02001064 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001065#ifdef FEAT_MBYTE
1066 (char_u *)&p_enc, PV_NONE,
1067 {(char_u *)ENC_DFLT, (char_u *)0L}
1068#else
1069 (char_u *)NULL, PV_NONE,
1070 {(char_u *)0L, (char_u *)0L}
1071#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001072 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001073 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1074 (char_u *)&p_eol, PV_EOL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001075 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001076 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1077 (char_u *)&p_ea, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001078 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001079 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001080 (char_u *)&p_ep, PV_EP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001081 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001082 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1083 (char_u *)&p_eb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001084 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001085 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1086#ifdef FEAT_QUICKFIX
1087 (char_u *)&p_ef, PV_NONE,
1088 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1089#else
1090 (char_u *)NULL, PV_NONE,
1091 {(char_u *)NULL, (char_u *)0L}
1092#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001093 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001094 {"errorformat", "efm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001095#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001096 (char_u *)&p_efm, PV_EFM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001097 {(char_u *)DFLT_EFM, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001098#else
1099 (char_u *)NULL, PV_NONE,
1100 {(char_u *)NULL, (char_u *)0L}
1101#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001102 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001103 {"esckeys", "ek", P_BOOL|P_VIM,
1104 (char_u *)&p_ek, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001105 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001106 {"eventignore", "ei", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001107#ifdef FEAT_AUTOCMD
1108 (char_u *)&p_ei, PV_NONE,
1109#else
1110 (char_u *)NULL, PV_NONE,
1111#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001112 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001113 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1114 (char_u *)&p_et, PV_ET,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001115 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001116 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1117 (char_u *)&p_exrc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001118 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001119 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF
1120 |P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001121#ifdef FEAT_MBYTE
1122 (char_u *)&p_fenc, PV_FENC,
1123 {(char_u *)"", (char_u *)0L}
1124#else
1125 (char_u *)NULL, PV_NONE,
1126 {(char_u *)0L, (char_u *)0L}
1127#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001128 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001129 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001130#ifdef FEAT_MBYTE
1131 (char_u *)&p_fencs, PV_NONE,
1132 {(char_u *)"ucs-bom", (char_u *)0L}
1133#else
1134 (char_u *)NULL, PV_NONE,
1135 {(char_u *)0L, (char_u *)0L}
1136#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001137 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001138 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC
1139 |P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001140 (char_u *)&p_ff, PV_FF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001141 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001142 {"fileformats", "ffs", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001143 (char_u *)&p_ffs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001144 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1145 SCRIPTID_INIT},
Bram Moolenaar71afbfe2013-03-19 16:49:16 +01001146 {"fileignorecase", "fic", P_BOOL|P_VI_DEF,
1147 (char_u *)&p_fic, PV_NONE,
1148 {
1149#ifdef CASE_INSENSITIVE_FILENAME
1150 (char_u *)TRUE,
1151#else
1152 (char_u *)FALSE,
1153#endif
1154 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001155 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001156#ifdef FEAT_AUTOCMD
1157 (char_u *)&p_ft, PV_FT,
1158 {(char_u *)"", (char_u *)0L}
1159#else
1160 (char_u *)NULL, PV_NONE,
1161 {(char_u *)0L, (char_u *)0L}
1162#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001163 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001164 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001165#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1166 (char_u *)&p_fcs, PV_NONE,
1167 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1168#else
1169 (char_u *)NULL, PV_NONE,
1170 {(char_u *)"", (char_u *)0L}
1171#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001172 SCRIPTID_INIT},
Bram Moolenaar34d72d42015-07-17 14:18:08 +02001173 {"fixendofline", "fixeol", P_BOOL|P_VI_DEF|P_RSTAT,
1174 (char_u *)&p_fixeol, PV_FIXEOL,
1175 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001176 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1177#ifdef FEAT_FKMAP
1178 (char_u *)&p_fkmap, PV_NONE,
1179#else
1180 (char_u *)NULL, PV_NONE,
1181#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001182 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001183 {"flash", "fl", P_BOOL|P_VI_DEF,
1184 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001185 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001186#ifdef FEAT_FOLDING
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001187 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001188 (char_u *)&p_fcl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001189 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001190 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1191 (char_u *)VAR_WIN, PV_FDC,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001192 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001193 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1194 (char_u *)VAR_WIN, PV_FEN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001195 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001196 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1197# ifdef FEAT_EVAL
1198 (char_u *)VAR_WIN, PV_FDE,
1199 {(char_u *)"0", (char_u *)NULL}
1200# else
1201 (char_u *)NULL, PV_NONE,
1202 {(char_u *)NULL, (char_u *)0L}
1203# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001204 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001205 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1206 (char_u *)VAR_WIN, PV_FDI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001207 {(char_u *)"#", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001208 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
1209 (char_u *)VAR_WIN, PV_FDL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001210 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001211 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001212 (char_u *)&p_fdls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001213 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001214 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001215 P_RWIN|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001216 (char_u *)VAR_WIN, PV_FMR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001217 {(char_u *)"{{{,}}}", (char_u *)NULL}
1218 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001219 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1220 (char_u *)VAR_WIN, PV_FDM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001221 {(char_u *)"manual", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001222 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1223 (char_u *)VAR_WIN, PV_FML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001224 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001225 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1226 (char_u *)VAR_WIN, PV_FDN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001227 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001228 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001229 (char_u *)&p_fdo, PV_NONE,
1230 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001231 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001232 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1233# ifdef FEAT_EVAL
1234 (char_u *)VAR_WIN, PV_FDT,
1235 {(char_u *)"foldtext()", (char_u *)NULL}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001236# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001237 (char_u *)NULL, PV_NONE,
1238 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001239# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001240 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001241#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001242 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001243#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001244 (char_u *)&p_fex, PV_FEX,
1245 {(char_u *)"", (char_u *)0L}
1246#else
1247 (char_u *)NULL, PV_NONE,
1248 {(char_u *)0L, (char_u *)0L}
1249#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001250 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001251 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1252 (char_u *)&p_fo, PV_FO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001253 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1254 SCRIPTID_INIT},
Bram Moolenaar86b68352004-12-27 21:59:20 +00001255 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1256 (char_u *)&p_flp, PV_FLP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001257 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1258 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001259 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1260 (char_u *)&p_fp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001261 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001262 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1263#ifdef HAVE_FSYNC
1264 (char_u *)&p_fs, PV_NONE,
1265 {(char_u *)TRUE, (char_u *)0L}
1266#else
1267 (char_u *)NULL, PV_NONE,
1268 {(char_u *)FALSE, (char_u *)0L}
1269#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001270 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001271 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1272 (char_u *)&p_gd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001273 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001274 {"graphic", "gr", P_BOOL|P_VI_DEF,
1275 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001276 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001277 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001278#ifdef FEAT_QUICKFIX
1279 (char_u *)&p_gefm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001280 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001281#else
1282 (char_u *)NULL, PV_NONE,
1283 {(char_u *)NULL, (char_u *)0L}
1284#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001285 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001286 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1287#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001288 (char_u *)&p_gp, PV_GP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001289 {
1290# ifdef WIN3264
1291 /* may be changed to "grep -n" in os_win32.c */
1292 (char_u *)"findstr /n",
1293# else
1294# ifdef UNIX
1295 /* Add an extra file name so that grep will always
1296 * insert a file name in the match line. */
1297 (char_u *)"grep -n $* /dev/null",
1298# else
1299# ifdef VMS
1300 (char_u *)"SEARCH/NUMBERS ",
1301# else
1302 (char_u *)"grep -n ",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001303# endif
1304# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001305# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001306 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001307#else
1308 (char_u *)NULL, PV_NONE,
1309 {(char_u *)NULL, (char_u *)0L}
1310#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001311 SCRIPTID_INIT},
Bram Moolenaar8a633e32016-04-21 21:10:14 +02001312 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001313#ifdef CURSOR_SHAPE
1314 (char_u *)&p_guicursor, PV_NONE,
1315 {
1316# ifdef FEAT_GUI
1317 (char_u *)"n-v-c:block-Cursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor,sm:block-Cursor-blinkwait175-blinkoff150-blinkon175",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001318# else /* Win32 console */
Bram Moolenaar071d4272004-06-13 20:20:40 +00001319 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1320# endif
1321 (char_u *)0L}
1322#else
1323 (char_u *)NULL, PV_NONE,
1324 {(char_u *)NULL, (char_u *)0L}
1325#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001326 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001327 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001328#ifdef FEAT_GUI
1329 (char_u *)&p_guifont, PV_NONE,
1330 {(char_u *)"", (char_u *)0L}
1331#else
1332 (char_u *)NULL, PV_NONE,
1333 {(char_u *)NULL, (char_u *)0L}
1334#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001335 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001336 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001337#if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1338 (char_u *)&p_guifontset, PV_NONE,
1339 {(char_u *)"", (char_u *)0L}
1340#else
1341 (char_u *)NULL, PV_NONE,
1342 {(char_u *)NULL, (char_u *)0L}
1343#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001344 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001345 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001346#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1347 (char_u *)&p_guifontwide, PV_NONE,
1348 {(char_u *)"", (char_u *)0L}
1349#else
1350 (char_u *)NULL, PV_NONE,
1351 {(char_u *)NULL, (char_u *)0L}
1352#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001353 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001354 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001355#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001356 (char_u *)&p_ghr, PV_NONE,
1357#else
1358 (char_u *)NULL, PV_NONE,
1359#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001360 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001361 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001362#if defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001363 (char_u *)&p_go, PV_NONE,
1364# if defined(UNIX) && !defined(MACOS)
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001365 {(char_u *)"aegimrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001366# else
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001367 {(char_u *)"egmrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001368# endif
1369#else
1370 (char_u *)NULL, PV_NONE,
1371 {(char_u *)NULL, (char_u *)0L}
1372#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001373 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001374 {"guipty", NULL, P_BOOL|P_VI_DEF,
1375#if defined(FEAT_GUI)
1376 (char_u *)&p_guipty, PV_NONE,
1377#else
1378 (char_u *)NULL, PV_NONE,
1379#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001380 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar18144c82006-04-12 21:52:12 +00001381 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00001382#if defined(FEAT_GUI_TABLINE)
1383 (char_u *)&p_gtl, PV_NONE,
1384 {(char_u *)"", (char_u *)0L}
1385#else
1386 (char_u *)NULL, PV_NONE,
1387 {(char_u *)NULL, (char_u *)0L}
1388#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001389 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001390 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar57657d82006-04-21 22:12:41 +00001391#if defined(FEAT_GUI_TABLINE)
1392 (char_u *)&p_gtt, PV_NONE,
1393 {(char_u *)"", (char_u *)0L}
1394#else
1395 (char_u *)NULL, PV_NONE,
1396 {(char_u *)NULL, (char_u *)0L}
1397#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001398 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001399 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1400 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001401 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001402 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1403 (char_u *)&p_hf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001404 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1405 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001406 {"helpheight", "hh", P_NUM|P_VI_DEF,
1407#ifdef FEAT_WINDOWS
1408 (char_u *)&p_hh, PV_NONE,
1409#else
1410 (char_u *)NULL, PV_NONE,
1411#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001412 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001413 {"helplang", "hlg", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001414#ifdef FEAT_MULTI_LANG
1415 (char_u *)&p_hlg, PV_NONE,
1416 {(char_u *)"", (char_u *)0L}
1417#else
1418 (char_u *)NULL, PV_NONE,
1419 {(char_u *)0L, (char_u *)0L}
1420#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001421 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001422 {"hidden", "hid", P_BOOL|P_VI_DEF,
1423 (char_u *)&p_hid, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001424 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001425 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001426 (char_u *)&p_hl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001427 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1428 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001429 {"history", "hi", P_NUM|P_VIM,
1430 (char_u *)&p_hi, PV_NONE,
Bram Moolenaar78159bb2014-06-25 11:48:54 +02001431 {(char_u *)0L, (char_u *)50L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001432 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1433#ifdef FEAT_RIGHTLEFT
1434 (char_u *)&p_hkmap, PV_NONE,
1435#else
1436 (char_u *)NULL, PV_NONE,
1437#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001438 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001439 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1440#ifdef FEAT_RIGHTLEFT
1441 (char_u *)&p_hkmapp, PV_NONE,
1442#else
1443 (char_u *)NULL, PV_NONE,
1444#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001445 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001446 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1447 (char_u *)&p_hls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001448 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001449 {"icon", NULL, P_BOOL|P_VI_DEF,
1450#ifdef FEAT_TITLE
1451 (char_u *)&p_icon, PV_NONE,
1452#else
1453 (char_u *)NULL, PV_NONE,
1454#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001455 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001456 {"iconstring", NULL, P_STRING|P_VI_DEF,
1457#ifdef FEAT_TITLE
1458 (char_u *)&p_iconstring, PV_NONE,
1459#else
1460 (char_u *)NULL, PV_NONE,
1461#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001462 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001463 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1464 (char_u *)&p_ic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001465 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001466 {"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
1467# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1468 (char_u *)&p_imaf, PV_NONE,
1469 {(char_u *)"", (char_u *)NULL}
1470# else
1471 (char_u *)NULL, PV_NONE,
1472 {(char_u *)NULL, (char_u *)0L}
1473# endif
1474 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001475 {"imactivatekey","imak",P_STRING|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001476#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001477 (char_u *)&p_imak, PV_NONE,
1478#else
1479 (char_u *)NULL, PV_NONE,
1480#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001481 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001482 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1483#ifdef USE_IM_CONTROL
1484 (char_u *)&p_imcmdline, PV_NONE,
1485#else
1486 (char_u *)NULL, PV_NONE,
1487#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001488 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001489 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1490#ifdef USE_IM_CONTROL
1491 (char_u *)&p_imdisable, PV_NONE,
1492#else
1493 (char_u *)NULL, PV_NONE,
1494#endif
1495#ifdef __sgi
1496 {(char_u *)TRUE, (char_u *)0L}
1497#else
1498 {(char_u *)FALSE, (char_u *)0L}
1499#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001500 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001501 {"iminsert", "imi", P_NUM|P_VI_DEF,
1502 (char_u *)&p_iminsert, PV_IMI,
1503#ifdef B_IMODE_IM
1504 {(char_u *)B_IMODE_IM, (char_u *)0L}
1505#else
1506 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1507#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001508 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001509 {"imsearch", "ims", P_NUM|P_VI_DEF,
1510 (char_u *)&p_imsearch, PV_IMS,
1511#ifdef B_IMODE_IM
1512 {(char_u *)B_IMODE_IM, (char_u *)0L}
1513#else
1514 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1515#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001516 SCRIPTID_INIT},
Bram Moolenaar4a460702013-06-29 14:42:26 +02001517 {"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001518# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1519 (char_u *)&p_imsf, PV_NONE,
1520 {(char_u *)"", (char_u *)NULL}
1521# else
1522 (char_u *)NULL, PV_NONE,
1523 {(char_u *)NULL, (char_u *)0L}
1524# endif
1525 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001526 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1527#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001528 (char_u *)&p_inc, PV_INC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001529 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1530#else
1531 (char_u *)NULL, PV_NONE,
1532 {(char_u *)0L, (char_u *)0L}
1533#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001534 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001535 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1536#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1537 (char_u *)&p_inex, PV_INEX,
1538 {(char_u *)"", (char_u *)0L}
1539#else
1540 (char_u *)NULL, PV_NONE,
1541 {(char_u *)0L, (char_u *)0L}
1542#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001543 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001544 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1545 (char_u *)&p_is, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001546 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001547 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1548#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1549 (char_u *)&p_inde, PV_INDE,
1550 {(char_u *)"", (char_u *)0L}
1551#else
1552 (char_u *)NULL, PV_NONE,
1553 {(char_u *)0L, (char_u *)0L}
1554#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001555 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001556 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001557#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1558 (char_u *)&p_indk, PV_INDK,
1559 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1560#else
1561 (char_u *)NULL, PV_NONE,
1562 {(char_u *)0L, (char_u *)0L}
1563#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001564 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001565 {"infercase", "inf", P_BOOL|P_VI_DEF,
1566 (char_u *)&p_inf, PV_INF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001567 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001568 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1569 (char_u *)&p_im, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001570 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001571 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1572 (char_u *)&p_isf, PV_NONE,
1573 {
1574#ifdef BACKSLASH_IN_FILENAME
1575 /* Excluded are: & and ^ are special in cmd.exe
1576 * ( and ) are used in text separating fnames */
1577 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1578#else
1579# ifdef AMIGA
1580 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1581# else
1582# ifdef VMS
1583 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1584# else /* UNIX et al. */
1585# ifdef EBCDIC
1586 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1587# else
1588 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1589# endif
1590# endif
1591# endif
1592#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001593 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001594 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1595 (char_u *)&p_isi, PV_NONE,
1596 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001597#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001598 (char_u *)"@,48-57,_,128-167,224-235",
1599#else
1600# ifdef EBCDIC
1601 /* TODO: EBCDIC Check this! @ == isalpha()*/
1602 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1603 "112-120,128,140-142,156,158,172,"
1604 "174,186,191,203-207,219-225,235-239,"
1605 "251-254",
1606# else
1607 (char_u *)"@,48-57,_,192-255",
1608# endif
1609#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001610 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001611 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1612 (char_u *)&p_isk, PV_ISK,
1613 {
1614#ifdef EBCDIC
1615 (char_u *)"@,240-249,_",
1616 /* TODO: EBCDIC Check this! @ == isalpha()*/
1617 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1618 "112-120,128,140-142,156,158,172,"
1619 "174,186,191,203-207,219-225,235-239,"
1620 "251-254",
1621#else
1622 (char_u *)"@,48-57,_",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001623# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001624 (char_u *)"@,48-57,_,128-167,224-235"
1625# else
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001626 ISK_LATIN1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001627# endif
1628#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001629 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001630 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1631 (char_u *)&p_isp, PV_NONE,
1632 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001633#if defined(MSWIN) || (defined(MACOS) && !defined(MACOS_X)) \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001634 || defined(VMS)
1635 (char_u *)"@,~-255",
1636#else
1637# ifdef EBCDIC
1638 /* all chars above 63 are printable */
1639 (char_u *)"63-255",
1640# else
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00001641 ISP_LATIN1,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001642# endif
1643#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001644 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001645 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1646 (char_u *)&p_js, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001647 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001648 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1649#ifdef FEAT_CRYPT
1650 (char_u *)&p_key, PV_KEY,
1651 {(char_u *)"", (char_u *)0L}
1652#else
1653 (char_u *)NULL, PV_NONE,
1654 {(char_u *)0L, (char_u *)0L}
1655#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001656 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001657 {"keymap", "kmp", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001658#ifdef FEAT_KEYMAP
1659 (char_u *)&p_keymap, PV_KMAP,
1660 {(char_u *)"", (char_u *)0L}
1661#else
1662 (char_u *)NULL, PV_NONE,
1663 {(char_u *)"", (char_u *)0L}
1664#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001665 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001666 {"keymodel", "km", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001667 (char_u *)&p_km, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001668 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001669 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001670 (char_u *)&p_kp, PV_KP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001671 {
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +02001672#ifdef MSWIN
Bram Moolenaar071d4272004-06-13 20:20:40 +00001673 (char_u *)":help",
1674#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001675# ifdef VMS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001676 (char_u *)"help",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01001677# else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001678# ifdef USEMAN_S
1679 (char_u *)"man -s",
1680# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001681 (char_u *)"man",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001682# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001683# endif
1684#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001685 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001686 {"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001687#ifdef FEAT_LANGMAP
1688 (char_u *)&p_langmap, PV_NONE,
1689 {(char_u *)"", /* unmatched } */
1690#else
1691 (char_u *)NULL, PV_NONE,
1692 {(char_u *)NULL,
1693#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001694 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001695 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001696#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1697 (char_u *)&p_lm, PV_NONE,
1698#else
1699 (char_u *)NULL, PV_NONE,
1700#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001701 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar4391cf92014-11-05 17:44:52 +01001702 {"langnoremap", "lnr", P_BOOL|P_VI_DEF,
1703#ifdef FEAT_LANGMAP
1704 (char_u *)&p_lnr, PV_NONE,
1705#else
1706 (char_u *)NULL, PV_NONE,
1707#endif
1708 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar920694c2016-08-21 17:45:02 +02001709 {"langremap", "lrm", P_BOOL|P_VI_DEF,
1710#ifdef FEAT_LANGMAP
1711 (char_u *)&p_lrm, PV_NONE,
1712#else
1713 (char_u *)NULL, PV_NONE,
1714#endif
Bram Moolenaarda9ce2c2016-09-02 19:34:10 +02001715 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001716 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1717#ifdef FEAT_WINDOWS
1718 (char_u *)&p_ls, PV_NONE,
1719#else
1720 (char_u *)NULL, PV_NONE,
1721#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001722 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001723 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1724 (char_u *)&p_lz, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001725 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001726 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1727#ifdef FEAT_LINEBREAK
1728 (char_u *)VAR_WIN, PV_LBR,
1729#else
1730 (char_u *)NULL, PV_NONE,
1731#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001732 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001733 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1734 (char_u *)&Rows, PV_NONE,
1735 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001736#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001737 (char_u *)25L,
1738#else
1739 (char_u *)24L,
1740#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001741 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001742 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1743#ifdef FEAT_GUI
1744 (char_u *)&p_linespace, PV_NONE,
1745#else
1746 (char_u *)NULL, PV_NONE,
1747#endif
1748#ifdef FEAT_GUI_W32
1749 {(char_u *)1L, (char_u *)0L}
1750#else
1751 {(char_u *)0L, (char_u *)0L}
1752#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001753 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001754 {"lisp", NULL, P_BOOL|P_VI_DEF,
1755#ifdef FEAT_LISP
1756 (char_u *)&p_lisp, PV_LISP,
1757#else
1758 (char_u *)NULL, PV_NONE,
1759#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001760 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001761 {"lispwords", "lw", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001762#ifdef FEAT_LISP
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01001763 (char_u *)&p_lispwords, PV_LW,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001764 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1765#else
1766 (char_u *)NULL, PV_NONE,
1767 {(char_u *)"", (char_u *)0L}
1768#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001769 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001770 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1771 (char_u *)VAR_WIN, PV_LIST,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001772 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001773 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001774 (char_u *)&p_lcs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001775 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001776 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1777 (char_u *)&p_lpl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001778 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001779#if defined(DYNAMIC_LUA)
Bram Moolenaara6e42502016-04-20 16:19:52 +02001780 {"luadll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01001781 (char_u *)&p_luadll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001782 {(char_u *)DYNAMIC_LUA_DLL, (char_u *)0L}
1783 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01001784#endif
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001785#ifdef FEAT_GUI_MAC
1786 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
1787 (char_u *)&p_macatsui, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001788 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001789#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001790 {"magic", NULL, P_BOOL|P_VI_DEF,
1791 (char_u *)&p_magic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001792 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00001793 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001794#ifdef FEAT_QUICKFIX
1795 (char_u *)&p_mef, PV_NONE,
1796 {(char_u *)"", (char_u *)0L}
1797#else
1798 (char_u *)NULL, PV_NONE,
1799 {(char_u *)NULL, (char_u *)0L}
1800#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001801 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001802 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1803#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001804 (char_u *)&p_mp, PV_MP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001805# ifdef VMS
1806 {(char_u *)"MMS", (char_u *)0L}
1807# else
1808 {(char_u *)"make", (char_u *)0L}
1809# endif
1810#else
1811 (char_u *)NULL, PV_NONE,
1812 {(char_u *)NULL, (char_u *)0L}
1813#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001814 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001815 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001816 (char_u *)&p_mps, PV_MPS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001817 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1818 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001819 {"matchtime", "mat", P_NUM|P_VI_DEF,
1820 (char_u *)&p_mat, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001821 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001822 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001823#ifdef FEAT_MBYTE
1824 (char_u *)&p_mco, PV_NONE,
1825#else
1826 (char_u *)NULL, PV_NONE,
1827#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001828 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001829 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1830#ifdef FEAT_EVAL
1831 (char_u *)&p_mfd, PV_NONE,
1832#else
1833 (char_u *)NULL, PV_NONE,
1834#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001835 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001836 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1837 (char_u *)&p_mmd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001838 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001839 {"maxmem", "mm", P_NUM|P_VI_DEF,
1840 (char_u *)&p_mm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001841 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1842 SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00001843 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1844 (char_u *)&p_mmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001845 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001846 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1847 (char_u *)&p_mmt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001848 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1849 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001850 {"menuitems", "mis", P_NUM|P_VI_DEF,
1851#ifdef FEAT_MENU
1852 (char_u *)&p_mis, PV_NONE,
1853#else
1854 (char_u *)NULL, PV_NONE,
1855#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001856 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001857 {"mesg", NULL, P_BOOL|P_VI_DEF,
1858 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001859 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001860 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001861#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001862 (char_u *)&p_msm, PV_NONE,
1863 {(char_u *)"460000,2000,500", (char_u *)0L}
1864#else
1865 (char_u *)NULL, PV_NONE,
1866 {(char_u *)0L, (char_u *)0L}
1867#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001868 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001869 {"modeline", "ml", P_BOOL|P_VIM,
1870 (char_u *)&p_ml, PV_ML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001871 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001872 {"modelines", "mls", P_NUM|P_VI_DEF,
1873 (char_u *)&p_mls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001874 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001875 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1876 (char_u *)&p_ma, PV_MA,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001877 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001878 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1879 (char_u *)&p_mod, PV_MOD,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001880 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001881 {"more", NULL, P_BOOL|P_VIM,
1882 (char_u *)&p_more, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001883 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001884 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
1885 (char_u *)&p_mouse, PV_NONE,
1886 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001887#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001888 (char_u *)"a",
1889#else
1890 (char_u *)"",
1891#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001892 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001893 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
1894#ifdef FEAT_GUI
1895 (char_u *)&p_mousef, PV_NONE,
1896#else
1897 (char_u *)NULL, PV_NONE,
1898#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001899 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001900 {"mousehide", "mh", P_BOOL|P_VI_DEF,
1901#ifdef FEAT_GUI
1902 (char_u *)&p_mh, PV_NONE,
1903#else
1904 (char_u *)NULL, PV_NONE,
1905#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001906 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001907 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
1908 (char_u *)&p_mousem, PV_NONE,
1909 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001910#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001911 (char_u *)"popup",
1912#else
1913# if defined(MACOS)
1914 (char_u *)"popup_setpos",
1915# else
1916 (char_u *)"extend",
1917# endif
1918#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001919 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001920 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001921#ifdef FEAT_MOUSESHAPE
1922 (char_u *)&p_mouseshape, PV_NONE,
1923 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
1924#else
1925 (char_u *)NULL, PV_NONE,
1926 {(char_u *)NULL, (char_u *)0L}
1927#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001928 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001929 {"mousetime", "mouset", P_NUM|P_VI_DEF,
1930 (char_u *)&p_mouset, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001931 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001932 {"mzquantum", "mzq", P_NUM,
1933#ifdef FEAT_MZSCHEME
1934 (char_u *)&p_mzq, PV_NONE,
1935#else
1936 (char_u *)NULL, PV_NONE,
1937#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001938 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001939 {"novice", NULL, P_BOOL|P_VI_DEF,
1940 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001941 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001942 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001943 (char_u *)&p_nf, PV_NF,
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01001944 {(char_u *)"bin,octal,hex", (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001945 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001946 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
1947 (char_u *)VAR_WIN, PV_NU,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001948 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00001949 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
1950#ifdef FEAT_LINEBREAK
1951 (char_u *)VAR_WIN, PV_NUW,
1952#else
1953 (char_u *)NULL, PV_NONE,
1954#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001955 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
Bram Moolenaarf75a9632005-09-13 21:20:47 +00001956 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
Bram Moolenaare344bea2005-09-01 20:46:49 +00001957#ifdef FEAT_COMPL_FUNC
1958 (char_u *)&p_ofu, PV_OFU,
1959 {(char_u *)"", (char_u *)0L}
1960#else
1961 (char_u *)NULL, PV_NONE,
1962 {(char_u *)0L, (char_u *)0L}
1963#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001964 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001965 {"open", NULL, P_BOOL|P_VI_DEF,
1966 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001967 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar043545e2006-10-10 16:44:07 +00001968 {"opendevice", "odev", P_BOOL|P_VI_DEF,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001969#if defined(MSWIN)
Bram Moolenaar043545e2006-10-10 16:44:07 +00001970 (char_u *)&p_odev, PV_NONE,
1971#else
1972 (char_u *)NULL, PV_NONE,
1973#endif
1974 {(char_u *)FALSE, (char_u *)FALSE}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001975 SCRIPTID_INIT},
Bram Moolenaar2c7a29c2005-12-12 22:02:31 +00001976 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
1977 (char_u *)&p_opfunc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001978 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001979 {"optimize", "opt", P_BOOL|P_VI_DEF,
1980 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001981 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001982 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001983 (char_u *)NULL, PV_NONE,
Bram Moolenaarb07269a2011-05-19 13:41:14 +02001984 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +01001985 {"packpath", "pp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
1986 |P_SECURE,
1987 (char_u *)&p_pp, PV_NONE,
1988 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
1989 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001990 {"paragraphs", "para", P_STRING|P_VI_DEF,
1991 (char_u *)&p_para, PV_NONE,
Bram Moolenaar57e48462008-03-12 16:38:55 +00001992 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001993 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001994 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001995 (char_u *)&p_paste, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001996 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001997 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
1998 (char_u *)&p_pt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001999 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002000 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
2001#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
2002 (char_u *)&p_pex, PV_NONE,
2003 {(char_u *)"", (char_u *)0L}
2004#else
2005 (char_u *)NULL, PV_NONE,
2006 {(char_u *)0L, (char_u *)0L}
2007#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002008 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002009 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002010 (char_u *)&p_pm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002011 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002012 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002013 (char_u *)&p_path, PV_PATH,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002014 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002015#if defined(AMIGA) || defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002016 (char_u *)".,,",
2017#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002018 (char_u *)".,/usr/include,,",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002019#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002020 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002021#if defined(DYNAMIC_PERL)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002022 {"perldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01002023 (char_u *)&p_perldll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002024 {(char_u *)DYNAMIC_PERL_DLL, (char_u *)0L}
2025 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01002026#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002027 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
2028 (char_u *)&p_pi, PV_PI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002029 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002030 {"previewheight", "pvh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002031#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2032 (char_u *)&p_pvh, PV_NONE,
2033#else
2034 (char_u *)NULL, PV_NONE,
2035#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002036 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002037 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2038#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2039 (char_u *)VAR_WIN, PV_PVW,
2040#else
2041 (char_u *)NULL, PV_NONE,
2042#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002043 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002044 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002045#ifdef FEAT_PRINTER
2046 (char_u *)&p_pdev, PV_NONE,
2047 {(char_u *)"", (char_u *)0L}
2048#else
2049 (char_u *)NULL, PV_NONE,
2050 {(char_u *)NULL, (char_u *)0L}
2051#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002052 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002053 {"printencoding", "penc", P_STRING|P_VI_DEF,
2054#ifdef FEAT_POSTSCRIPT
2055 (char_u *)&p_penc, PV_NONE,
2056 {(char_u *)"", (char_u *)0L}
2057#else
2058 (char_u *)NULL, PV_NONE,
2059 {(char_u *)NULL, (char_u *)0L}
2060#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002061 SCRIPTID_INIT},
Bram Moolenaar031cb742016-11-24 21:46:19 +01002062 {"printexpr", "pexpr", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002063#ifdef FEAT_POSTSCRIPT
2064 (char_u *)&p_pexpr, PV_NONE,
2065 {(char_u *)"", (char_u *)0L}
2066#else
2067 (char_u *)NULL, PV_NONE,
2068 {(char_u *)NULL, (char_u *)0L}
2069#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002070 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002071 {"printfont", "pfn", P_STRING|P_VI_DEF,
2072#ifdef FEAT_PRINTER
2073 (char_u *)&p_pfn, PV_NONE,
2074 {
2075# ifdef MSWIN
2076 (char_u *)"Courier_New:h10",
2077# else
2078 (char_u *)"courier",
2079# endif
2080 (char_u *)0L}
2081#else
2082 (char_u *)NULL, PV_NONE,
2083 {(char_u *)NULL, (char_u *)0L}
2084#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002085 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002086 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
2087#ifdef FEAT_PRINTER
2088 (char_u *)&p_header, PV_NONE,
2089 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
2090#else
2091 (char_u *)NULL, PV_NONE,
2092 {(char_u *)NULL, (char_u *)0L}
2093#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002094 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002095 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
2096#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2097 (char_u *)&p_pmcs, PV_NONE,
2098 {(char_u *)"", (char_u *)0L}
2099#else
2100 (char_u *)NULL, PV_NONE,
2101 {(char_u *)NULL, (char_u *)0L}
2102#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002103 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002104 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2105#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2106 (char_u *)&p_pmfn, PV_NONE,
2107 {(char_u *)"", (char_u *)0L}
2108#else
2109 (char_u *)NULL, PV_NONE,
2110 {(char_u *)NULL, (char_u *)0L}
2111#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002112 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002113 {"printoptions", "popt", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002114#ifdef FEAT_PRINTER
2115 (char_u *)&p_popt, PV_NONE,
2116 {(char_u *)"", (char_u *)0L}
2117#else
2118 (char_u *)NULL, PV_NONE,
2119 {(char_u *)NULL, (char_u *)0L}
2120#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002121 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002122 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002123 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002124 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002125 {"pumheight", "ph", P_NUM|P_VI_DEF,
2126#ifdef FEAT_INS_EXPAND
2127 (char_u *)&p_ph, PV_NONE,
2128#else
2129 (char_u *)NULL, PV_NONE,
2130#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002131 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002132#if defined(DYNAMIC_PYTHON3)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002133 {"pythonthreedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01002134 (char_u *)&p_py3dll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002135 {(char_u *)DYNAMIC_PYTHON3_DLL, (char_u *)0L}
2136 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01002137#endif
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002138#if defined(DYNAMIC_PYTHON)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002139 {"pythondll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01002140 (char_u *)&p_pydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002141 {(char_u *)DYNAMIC_PYTHON_DLL, (char_u *)0L}
2142 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01002143#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002144 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2145#ifdef FEAT_TEXTOBJ
2146 (char_u *)&p_qe, PV_QE,
2147 {(char_u *)"\\", (char_u *)0L}
2148#else
2149 (char_u *)NULL, PV_NONE,
2150 {(char_u *)NULL, (char_u *)0L}
2151#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002152 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002153 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2154 (char_u *)&p_ro, PV_RO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002155 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002156 {"redraw", NULL, P_BOOL|P_VI_DEF,
2157 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002158 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002159 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2160#ifdef FEAT_RELTIME
2161 (char_u *)&p_rdt, PV_NONE,
2162#else
2163 (char_u *)NULL, PV_NONE,
2164#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002165 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02002166 {"regexpengine", "re", P_NUM|P_VI_DEF,
2167 (char_u *)&p_re, PV_NONE,
2168 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002169 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2170 (char_u *)VAR_WIN, PV_RNU,
2171 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002172 {"remap", NULL, P_BOOL|P_VI_DEF,
2173 (char_u *)&p_remap, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002174 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002175 {"renderoptions", "rop", P_STRING|P_ONECOMMA|P_RCLR|P_VI_DEF,
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02002176#ifdef FEAT_RENDER_OPTIONS
2177 (char_u *)&p_rop, PV_NONE,
2178 {(char_u *)"", (char_u *)0L}
2179#else
2180 (char_u *)NULL, PV_NONE,
2181 {(char_u *)NULL, (char_u *)0L}
2182#endif
2183 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002184 {"report", NULL, P_NUM|P_VI_DEF,
2185 (char_u *)&p_report, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002186 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002187 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2188#ifdef WIN3264
2189 (char_u *)&p_rs, PV_NONE,
2190#else
2191 (char_u *)NULL, PV_NONE,
2192#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002193 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002194 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2195#ifdef FEAT_RIGHTLEFT
2196 (char_u *)&p_ri, PV_NONE,
2197#else
2198 (char_u *)NULL, PV_NONE,
2199#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002200 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002201 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2202#ifdef FEAT_RIGHTLEFT
2203 (char_u *)VAR_WIN, PV_RL,
2204#else
2205 (char_u *)NULL, PV_NONE,
2206#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002207 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002208 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2209#ifdef FEAT_RIGHTLEFT
2210 (char_u *)VAR_WIN, PV_RLC,
2211 {(char_u *)"search", (char_u *)NULL}
2212#else
2213 (char_u *)NULL, PV_NONE,
2214 {(char_u *)NULL, (char_u *)0L}
2215#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002216 SCRIPTID_INIT},
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002217#if defined(DYNAMIC_RUBY)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002218 {"rubydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaard94464e2015-11-02 15:28:18 +01002219 (char_u *)&p_rubydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002220 {(char_u *)DYNAMIC_RUBY_DLL, (char_u *)0L}
2221 SCRIPTID_INIT},
Bram Moolenaard94464e2015-11-02 15:28:18 +01002222#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002223 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2224#ifdef FEAT_CMDL_INFO
2225 (char_u *)&p_ru, PV_NONE,
2226#else
2227 (char_u *)NULL, PV_NONE,
2228#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002229 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002230 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2231#ifdef FEAT_STL_OPT
2232 (char_u *)&p_ruf, PV_NONE,
2233#else
2234 (char_u *)NULL, PV_NONE,
2235#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002236 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002237 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2238 |P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002239 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002240 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2241 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002242 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2243 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002244 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002245 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2246#ifdef FEAT_SCROLLBIND
2247 (char_u *)VAR_WIN, PV_SCBIND,
2248#else
2249 (char_u *)NULL, PV_NONE,
2250#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002251 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002252 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2253 (char_u *)&p_sj, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002254 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002255 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2256 (char_u *)&p_so, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002257 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002258 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002259#ifdef FEAT_SCROLLBIND
2260 (char_u *)&p_sbo, PV_NONE,
2261 {(char_u *)"ver,jump", (char_u *)0L}
2262#else
2263 (char_u *)NULL, PV_NONE,
2264 {(char_u *)0L, (char_u *)0L}
2265#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002266 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002267 {"sections", "sect", P_STRING|P_VI_DEF,
2268 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002269 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2270 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002271 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2272 (char_u *)&p_secure, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002273 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002274 {"selection", "sel", P_STRING|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002275 (char_u *)&p_sel, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002276 {(char_u *)"inclusive", (char_u *)0L}
2277 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002278 {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002279 (char_u *)&p_slm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002280 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002281 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002282#ifdef FEAT_SESSION
2283 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002284 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002285 (char_u *)0L}
2286#else
2287 (char_u *)NULL, PV_NONE,
2288 {(char_u *)0L, (char_u *)0L}
2289#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002290 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002291 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2292 (char_u *)&p_sh, PV_NONE,
2293 {
2294#ifdef VMS
2295 (char_u *)"-",
2296#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002297# if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002298 (char_u *)"", /* set in set_init_1() */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002299# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002300 (char_u *)"sh",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002301# endif
2302#endif /* VMS */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002303 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002304 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2305 (char_u *)&p_shcf, PV_NONE,
2306 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002307#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002308 (char_u *)"/c",
2309#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002310 (char_u *)"-c",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002311#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002312 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002313 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2314#ifdef FEAT_QUICKFIX
2315 (char_u *)&p_sp, PV_NONE,
2316 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002317#if defined(UNIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002318 (char_u *)"| tee",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002319#else
2320 (char_u *)">",
2321#endif
2322 (char_u *)0L}
2323#else
2324 (char_u *)NULL, PV_NONE,
2325 {(char_u *)0L, (char_u *)0L}
2326#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002327 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002328 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2329 (char_u *)&p_shq, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002330 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002331 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2332 (char_u *)&p_srr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002333 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002334 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2335#ifdef BACKSLASH_IN_FILENAME
2336 (char_u *)&p_ssl, PV_NONE,
2337#else
2338 (char_u *)NULL, PV_NONE,
2339#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002340 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002341 {"shelltemp", "stmp", P_BOOL,
2342 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002343 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002344 {"shelltype", "st", P_NUM|P_VI_DEF,
2345#ifdef AMIGA
2346 (char_u *)&p_st, PV_NONE,
2347#else
2348 (char_u *)NULL, PV_NONE,
2349#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002350 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002351 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2352 (char_u *)&p_sxq, PV_NONE,
2353 {
Bram Moolenaara06ecab2016-07-16 14:47:36 +02002354#if defined(UNIX) && defined(USE_SYSTEM)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002355 (char_u *)"\"",
2356#else
2357 (char_u *)"",
2358#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002359 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002360 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
2361 (char_u *)&p_sxe, PV_NONE,
2362 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002363#if defined(WIN3264)
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002364 (char_u *)"\"&|<>()@^",
2365#else
2366 (char_u *)"",
2367#endif
2368 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002369 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2370 (char_u *)&p_sr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002371 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002372 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2373 (char_u *)&p_sw, PV_SW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002374 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002375 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2376 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002377 {(char_u *)"", (char_u *)"filnxtToO"}
2378 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002379 {"shortname", "sn", P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002380 (char_u *)&p_sn, PV_SN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002381 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002382 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2383#ifdef FEAT_LINEBREAK
2384 (char_u *)&p_sbr, PV_NONE,
2385#else
2386 (char_u *)NULL, PV_NONE,
2387#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002388 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002389 {"showcmd", "sc", P_BOOL|P_VIM,
2390#ifdef FEAT_CMDL_INFO
2391 (char_u *)&p_sc, PV_NONE,
2392#else
2393 (char_u *)NULL, PV_NONE,
2394#endif
2395 {(char_u *)FALSE,
2396#ifdef UNIX
2397 (char_u *)FALSE
2398#else
2399 (char_u *)TRUE
2400#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002401 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002402 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2403 (char_u *)&p_sft, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002404 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002405 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2406 (char_u *)&p_sm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002407 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002408 {"showmode", "smd", P_BOOL|P_VIM,
2409 (char_u *)&p_smd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002410 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002411 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2412#ifdef FEAT_WINDOWS
2413 (char_u *)&p_stal, PV_NONE,
2414#else
2415 (char_u *)NULL, PV_NONE,
2416#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002417 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002418 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2419 (char_u *)&p_ss, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002420 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002421 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2422 (char_u *)&p_siso, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002423 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002424 {"signcolumn", "scl", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2425#ifdef FEAT_SIGNS
2426 (char_u *)VAR_WIN, PV_SCL,
Bram Moolenaarb3384832016-08-12 18:51:58 +02002427 {(char_u *)"auto", (char_u *)0L}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002428#else
2429 (char_u *)NULL, PV_NONE,
2430 {(char_u *)NULL, (char_u *)0L}
2431#endif
Bram Moolenaarb3384832016-08-12 18:51:58 +02002432 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002433 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2434 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002435 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002436 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2437 (char_u *)&p_scs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002438 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002439 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2440#ifdef FEAT_SMARTINDENT
2441 (char_u *)&p_si, PV_SI,
2442#else
2443 (char_u *)NULL, PV_NONE,
2444#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002445 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002446 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2447 (char_u *)&p_sta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002448 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002449 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2450 (char_u *)&p_sts, PV_STS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002451 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002452 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2453 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002454 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002455 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002456#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002457 (char_u *)VAR_WIN, PV_SPELL,
2458#else
2459 (char_u *)NULL, PV_NONE,
2460#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002461 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002462 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002463#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002464 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002465 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002466#else
2467 (char_u *)NULL, PV_NONE,
2468 {(char_u *)0L, (char_u *)0L}
2469#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002470 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002471 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE
2472 |P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002473#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002474 (char_u *)&p_spf, PV_SPF,
2475 {(char_u *)"", (char_u *)0L}
2476#else
2477 (char_u *)NULL, PV_NONE,
2478 {(char_u *)0L, (char_u *)0L}
2479#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002480 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002481 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
2482 |P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002483#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002484 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002485 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002486#else
2487 (char_u *)NULL, PV_NONE,
2488 {(char_u *)0L, (char_u *)0L}
2489#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002490 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002491 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002492#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002493 (char_u *)&p_sps, PV_NONE,
2494 {(char_u *)"best", (char_u *)0L}
2495#else
2496 (char_u *)NULL, PV_NONE,
2497 {(char_u *)0L, (char_u *)0L}
2498#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002499 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002500 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2501#ifdef FEAT_WINDOWS
2502 (char_u *)&p_sb, PV_NONE,
2503#else
2504 (char_u *)NULL, PV_NONE,
2505#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002506 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002507 {"splitright", "spr", P_BOOL|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002508#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002509 (char_u *)&p_spr, PV_NONE,
2510#else
2511 (char_u *)NULL, PV_NONE,
2512#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002513 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002514 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2515 (char_u *)&p_sol, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002516 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002517 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2518#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002519 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002520#else
2521 (char_u *)NULL, PV_NONE,
2522#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002523 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002524 {"suffixes", "su", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002525 (char_u *)&p_su, PV_NONE,
2526 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002527 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002528 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002529#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002530 (char_u *)&p_sua, PV_SUA,
2531 {(char_u *)"", (char_u *)0L}
2532#else
2533 (char_u *)NULL, PV_NONE,
2534 {(char_u *)0L, (char_u *)0L}
2535#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002536 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002537 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2538 (char_u *)&p_swf, PV_SWF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002539 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002540 {"swapsync", "sws", P_STRING|P_VI_DEF,
2541 (char_u *)&p_sws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002542 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002543 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002544 (char_u *)&p_swb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002545 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002546 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2547#ifdef FEAT_SYN_HL
2548 (char_u *)&p_smc, PV_SMC,
2549 {(char_u *)3000L, (char_u *)0L}
2550#else
2551 (char_u *)NULL, PV_NONE,
2552 {(char_u *)0L, (char_u *)0L}
2553#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002554 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002555 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002556#ifdef FEAT_SYN_HL
2557 (char_u *)&p_syn, PV_SYN,
2558 {(char_u *)"", (char_u *)0L}
2559#else
2560 (char_u *)NULL, PV_NONE,
2561 {(char_u *)0L, (char_u *)0L}
2562#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002563 SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002564 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2565#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002566 (char_u *)&p_tal, PV_NONE,
2567#else
2568 (char_u *)NULL, PV_NONE,
2569#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002570 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002571 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2572#ifdef FEAT_WINDOWS
2573 (char_u *)&p_tpm, PV_NONE,
2574#else
2575 (char_u *)NULL, PV_NONE,
2576#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002577 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002578 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2579 (char_u *)&p_ts, PV_TS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002580 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002581 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2582 (char_u *)&p_tbs, PV_NONE,
2583#ifdef VMS /* binary searching doesn't appear to work on VMS */
2584 {(char_u *)0L, (char_u *)0L}
2585#else
2586 {(char_u *)TRUE, (char_u *)0L}
2587#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002588 SCRIPTID_INIT},
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01002589 {"tagcase", "tc", P_STRING|P_VIM,
2590 (char_u *)&p_tc, PV_TC,
2591 {(char_u *)"followic", (char_u *)"followic"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002592 {"taglength", "tl", P_NUM|P_VI_DEF,
2593 (char_u *)&p_tl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002594 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002595 {"tagrelative", "tr", P_BOOL|P_VIM,
2596 (char_u *)&p_tr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002597 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002598 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002599 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002600 {
2601#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2602 (char_u *)"./tags,./TAGS,tags,TAGS",
2603#else
2604 (char_u *)"./tags,tags",
2605#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002606 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002607 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2608 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002609 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002610#if defined(DYNAMIC_TCL)
Bram Moolenaara6e42502016-04-20 16:19:52 +02002611 {"tcldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002612 (char_u *)&p_tcldll, PV_NONE,
2613 {(char_u *)DYNAMIC_TCL_DLL, (char_u *)0L}
2614 SCRIPTID_INIT},
2615#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002616 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2617 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002618 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002619 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2620#ifdef FEAT_ARABIC
2621 (char_u *)&p_tbidi, PV_NONE,
2622#else
2623 (char_u *)NULL, PV_NONE,
2624#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002625 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002626 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2627#ifdef FEAT_MBYTE
2628 (char_u *)&p_tenc, PV_NONE,
2629 {(char_u *)"", (char_u *)0L}
2630#else
2631 (char_u *)NULL, PV_NONE,
2632 {(char_u *)0L, (char_u *)0L}
2633#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002634 SCRIPTID_INIT},
Bram Moolenaar61be73b2016-04-29 22:59:22 +02002635 {"termguicolors", "tgc", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
2636#ifdef FEAT_TERMGUICOLORS
2637 (char_u *)&p_tgc, PV_NONE,
2638 {(char_u *)FALSE, (char_u *)FALSE}
2639#else
2640 (char_u*)NULL, PV_NONE,
2641 {(char_u *)FALSE, (char_u *)FALSE}
2642#endif
2643 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002644 {"terse", NULL, P_BOOL|P_VI_DEF,
2645 (char_u *)&p_terse, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002646 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002647 {"textauto", "ta", P_BOOL|P_VIM,
2648 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002649 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2650 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002651 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2652 (char_u *)&p_tx, PV_TX,
2653 {
2654#ifdef USE_CRNL
2655 (char_u *)TRUE,
2656#else
2657 (char_u *)FALSE,
2658#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002659 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +02002660 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002661 (char_u *)&p_tw, PV_TW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002662 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002663 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002664#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002665 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002666#else
2667 (char_u *)NULL, PV_NONE,
2668#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002669 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002670 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2671 (char_u *)&p_to, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002672 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002673 {"timeout", "to", P_BOOL|P_VI_DEF,
2674 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002675 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002676 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2677 (char_u *)&p_tm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002678 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002679 {"title", NULL, P_BOOL|P_VI_DEF,
2680#ifdef FEAT_TITLE
2681 (char_u *)&p_title, PV_NONE,
2682#else
2683 (char_u *)NULL, PV_NONE,
2684#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002685 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002686 {"titlelen", NULL, P_NUM|P_VI_DEF,
2687#ifdef FEAT_TITLE
2688 (char_u *)&p_titlelen, PV_NONE,
2689#else
2690 (char_u *)NULL, PV_NONE,
2691#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002692 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002693 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002694#ifdef FEAT_TITLE
2695 (char_u *)&p_titleold, PV_NONE,
2696 {(char_u *)N_("Thanks for flying Vim"),
2697 (char_u *)0L}
2698#else
2699 (char_u *)NULL, PV_NONE,
2700 {(char_u *)0L, (char_u *)0L}
2701#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002702 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002703 {"titlestring", NULL, P_STRING|P_VI_DEF,
2704#ifdef FEAT_TITLE
2705 (char_u *)&p_titlestring, PV_NONE,
2706#else
2707 (char_u *)NULL, PV_NONE,
2708#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002709 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002710#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002711 {"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002712 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002713 {(char_u *)"icons,tooltips", (char_u *)0L}
2714 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002715#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002716#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002717 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
2718 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002719 {(char_u *)"small", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002720#endif
2721 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2722 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002723 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002724 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2725 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002726 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002727 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2728 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002729 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002730 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2731 (char_u *)&p_tf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002732 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002733 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2734#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2735 (char_u *)&p_ttym, PV_NONE,
2736#else
2737 (char_u *)NULL, PV_NONE,
2738#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002739 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002740 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2741 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002742 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002743 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2744 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002745 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002746 {"undodir", "udir", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP|P_SECURE
2747 |P_VI_DEF,
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002748#ifdef FEAT_PERSISTENT_UNDO
2749 (char_u *)&p_udir, PV_NONE,
2750 {(char_u *)".", (char_u *)0L}
2751#else
2752 (char_u *)NULL, PV_NONE,
2753 {(char_u *)0L, (char_u *)0L}
2754#endif
2755 SCRIPTID_INIT},
2756 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2757#ifdef FEAT_PERSISTENT_UNDO
2758 (char_u *)&p_udf, PV_UDF,
2759#else
2760 (char_u *)NULL, PV_NONE,
2761#endif
2762 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002763 {"undolevels", "ul", P_NUM|P_VI_DEF,
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01002764 (char_u *)&p_ul, PV_UL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002765 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002766#if defined(UNIX) || defined(WIN3264) || defined(VMS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002767 (char_u *)1000L,
2768#else
2769 (char_u *)100L,
2770#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002771 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar59f931e2010-07-24 20:27:03 +02002772 {"undoreload", "ur", P_NUM|P_VI_DEF,
2773 (char_u *)&p_ur, PV_NONE,
2774 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002775 {"updatecount", "uc", P_NUM|P_VI_DEF,
2776 (char_u *)&p_uc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002777 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002778 {"updatetime", "ut", P_NUM|P_VI_DEF,
2779 (char_u *)&p_ut, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002780 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002781 {"verbose", "vbs", P_NUM|P_VI_DEF,
2782 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002783 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002784 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2785 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002786 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002787 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2788#ifdef FEAT_SESSION
2789 (char_u *)&p_vdir, PV_NONE,
2790 {(char_u *)DFLT_VDIR, (char_u *)0L}
2791#else
2792 (char_u *)NULL, PV_NONE,
2793 {(char_u *)0L, (char_u *)0L}
2794#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002795 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002796 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002797#ifdef FEAT_SESSION
2798 (char_u *)&p_vop, PV_NONE,
2799 {(char_u *)"folds,options,cursor", (char_u *)0L}
2800#else
2801 (char_u *)NULL, PV_NONE,
2802 {(char_u *)0L, (char_u *)0L}
2803#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002804 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002805 {"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002806#ifdef FEAT_VIMINFO
2807 (char_u *)&p_viminfo, PV_NONE,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002808#if defined(MSWIN)
Bram Moolenaard812df62008-11-09 12:46:09 +00002809 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002810#else
2811# ifdef AMIGA
2812 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002813 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002814# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002815 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002816# endif
2817#endif
2818#else
2819 (char_u *)NULL, PV_NONE,
2820 {(char_u *)0L, (char_u *)0L}
2821#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002822 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002823 {"virtualedit", "ve", P_STRING|P_ONECOMMA|P_NODUP|P_VI_DEF
2824 |P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002825#ifdef FEAT_VIRTUALEDIT
2826 (char_u *)&p_ve, PV_NONE,
2827 {(char_u *)"", (char_u *)""}
2828#else
2829 (char_u *)NULL, PV_NONE,
2830 {(char_u *)0L, (char_u *)0L}
2831#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002832 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002833 {"visualbell", "vb", P_BOOL|P_VI_DEF,
2834 (char_u *)&p_vb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002835 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002836 {"w300", NULL, P_NUM|P_VI_DEF,
2837 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002838 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002839 {"w1200", NULL, P_NUM|P_VI_DEF,
2840 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002841 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002842 {"w9600", NULL, P_NUM|P_VI_DEF,
2843 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002844 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002845 {"warn", NULL, P_BOOL|P_VI_DEF,
2846 (char_u *)&p_warn, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002847 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002848 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
2849 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002850 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002851 {"whichwrap", "ww", P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002852 (char_u *)&p_ww, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002853 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002854 {"wildchar", "wc", P_NUM|P_VIM,
2855 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002856 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
2857 SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002858 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002859 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002860 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002861 {"wildignore", "wig", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002862#ifdef FEAT_WILDIGN
2863 (char_u *)&p_wig, PV_NONE,
2864#else
2865 (char_u *)NULL, PV_NONE,
2866#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002867 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002868 {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
2869 (char_u *)&p_wic, PV_NONE,
2870 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002871 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
2872#ifdef FEAT_WILDMENU
2873 (char_u *)&p_wmnu, PV_NONE,
2874#else
2875 (char_u *)NULL, PV_NONE,
2876#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002877 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002878 {"wildmode", "wim", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002879 (char_u *)&p_wim, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002880 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00002881 {"wildoptions", "wop", P_STRING|P_VI_DEF,
2882#ifdef FEAT_CMDL_COMPL
2883 (char_u *)&p_wop, PV_NONE,
2884 {(char_u *)"", (char_u *)0L}
2885#else
2886 (char_u *)NULL, PV_NONE,
2887 {(char_u *)NULL, (char_u *)0L}
2888#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002889 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002890 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
2891#ifdef FEAT_WAK
2892 (char_u *)&p_wak, PV_NONE,
2893 {(char_u *)"menu", (char_u *)0L}
2894#else
2895 (char_u *)NULL, PV_NONE,
2896 {(char_u *)NULL, (char_u *)0L}
2897#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002898 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002899 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00002900 (char_u *)&p_window, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002901 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002902 {"winheight", "wh", P_NUM|P_VI_DEF,
2903#ifdef FEAT_WINDOWS
2904 (char_u *)&p_wh, PV_NONE,
2905#else
2906 (char_u *)NULL, PV_NONE,
2907#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002908 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002909 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002910#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002911 (char_u *)VAR_WIN, PV_WFH,
2912#else
2913 (char_u *)NULL, PV_NONE,
2914#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002915 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002916 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002917#ifdef FEAT_WINDOWS
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002918 (char_u *)VAR_WIN, PV_WFW,
2919#else
2920 (char_u *)NULL, PV_NONE,
2921#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002922 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002923 {"winminheight", "wmh", P_NUM|P_VI_DEF,
2924#ifdef FEAT_WINDOWS
2925 (char_u *)&p_wmh, PV_NONE,
2926#else
2927 (char_u *)NULL, PV_NONE,
2928#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002929 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002930 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002931#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002932 (char_u *)&p_wmw, PV_NONE,
2933#else
2934 (char_u *)NULL, PV_NONE,
2935#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002936 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002937 {"winwidth", "wiw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002938#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002939 (char_u *)&p_wiw, PV_NONE,
2940#else
2941 (char_u *)NULL, PV_NONE,
2942#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002943 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002944 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
2945 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002946 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002947 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
2948 (char_u *)&p_wm, PV_WM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002949 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002950 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
2951 (char_u *)&p_ws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002952 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002953 {"write", NULL, P_BOOL|P_VI_DEF,
2954 (char_u *)&p_write, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002955 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002956 {"writeany", "wa", P_BOOL|P_VI_DEF,
2957 (char_u *)&p_wa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002958 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002959 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
2960 (char_u *)&p_wb, PV_NONE,
2961 {
2962#ifdef FEAT_WRITEBACKUP
2963 (char_u *)TRUE,
2964#else
2965 (char_u *)FALSE,
2966#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002967 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002968 {"writedelay", "wd", P_NUM|P_VI_DEF,
2969 (char_u *)&p_wd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002970 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002971
2972/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002973#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00002974 (char_u *)&vvv, PV_NONE, \
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002975 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002976
2977 p_term("t_AB", T_CAB)
2978 p_term("t_AF", T_CAF)
2979 p_term("t_AL", T_CAL)
2980 p_term("t_al", T_AL)
2981 p_term("t_bc", T_BC)
2982 p_term("t_cd", T_CD)
2983 p_term("t_ce", T_CE)
2984 p_term("t_cl", T_CL)
2985 p_term("t_cm", T_CM)
Bram Moolenaar450ca432015-11-10 13:30:39 +01002986 p_term("t_Ce", T_UCE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002987 p_term("t_Co", T_CCO)
2988 p_term("t_CS", T_CCS)
Bram Moolenaar450ca432015-11-10 13:30:39 +01002989 p_term("t_Cs", T_UCS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002990 p_term("t_cs", T_CS)
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002991#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002992 p_term("t_CV", T_CSV)
2993#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002994 p_term("t_da", T_DA)
2995 p_term("t_db", T_DB)
2996 p_term("t_DL", T_CDL)
2997 p_term("t_dl", T_DL)
Bram Moolenaare5401222015-06-25 19:16:56 +02002998 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002999 p_term("t_fs", T_FS)
3000 p_term("t_IE", T_CIE)
3001 p_term("t_IS", T_CIS)
3002 p_term("t_ke", T_KE)
3003 p_term("t_ks", T_KS)
3004 p_term("t_le", T_LE)
3005 p_term("t_mb", T_MB)
3006 p_term("t_md", T_MD)
3007 p_term("t_me", T_ME)
3008 p_term("t_mr", T_MR)
3009 p_term("t_ms", T_MS)
3010 p_term("t_nd", T_ND)
3011 p_term("t_op", T_OP)
Bram Moolenaare5401222015-06-25 19:16:56 +02003012 p_term("t_RB", T_RBG)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003013 p_term("t_RI", T_CRI)
3014 p_term("t_RV", T_CRV)
3015 p_term("t_Sb", T_CSB)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003016 p_term("t_se", T_SE)
Bram Moolenaare5401222015-06-25 19:16:56 +02003017 p_term("t_Sf", T_CSF)
3018 p_term("t_SI", T_CSI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003019 p_term("t_so", T_SO)
Bram Moolenaare5401222015-06-25 19:16:56 +02003020 p_term("t_SR", T_CSR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003021 p_term("t_sr", T_SR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003022 p_term("t_te", T_TE)
3023 p_term("t_ti", T_TI)
Bram Moolenaare5401222015-06-25 19:16:56 +02003024 p_term("t_ts", T_TS)
3025 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003026 p_term("t_ue", T_UE)
3027 p_term("t_us", T_US)
Bram Moolenaare5401222015-06-25 19:16:56 +02003028 p_term("t_ut", T_UT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003029 p_term("t_vb", T_VB)
3030 p_term("t_ve", T_VE)
3031 p_term("t_vi", T_VI)
3032 p_term("t_vs", T_VS)
3033 p_term("t_WP", T_CWP)
3034 p_term("t_WS", T_CWS)
Bram Moolenaar494838a2015-02-10 19:20:37 +01003035 p_term("t_xn", T_XN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003036 p_term("t_xs", T_XS)
3037 p_term("t_ZH", T_CZH)
3038 p_term("t_ZR", T_CZR)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02003039 p_term("t_8f", T_8F)
3040 p_term("t_8b", T_8B)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003041
3042/* terminal key codes are not in here */
3043
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003044 /* end marker */
3045 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00003046};
3047
3048#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
3049
3050#ifdef FEAT_MBYTE
3051static char *(p_ambw_values[]) = {"single", "double", NULL};
3052#endif
3053static char *(p_bg_values[]) = {"light", "dark", NULL};
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01003054static char *(p_nf_values[]) = {"bin", "octal", "hex", "alpha", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003055static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003056#ifdef FEAT_CRYPT
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02003057static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2", NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003058#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003059#ifdef FEAT_CMDL_COMPL
3060static char *(p_wop_values[]) = {"tagfile", NULL};
3061#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003062#ifdef FEAT_WAK
3063static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
3064#endif
3065static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003066static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
3067static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003068static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003069#ifdef FEAT_BROWSE
3070static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
3071#endif
3072#ifdef FEAT_SCROLLBIND
3073static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
3074#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00003075static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003076#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003077static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
3078#endif
3079#if defined(FEAT_QUICKFIX)
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003080# ifdef FEAT_AUTOCMD
3081static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
3082# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003083static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003084# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003085static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
3086#endif
3087static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
3088#ifdef FEAT_FOLDING
3089static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003090# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00003091 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003092# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003093 NULL};
3094static char *(p_fcl_values[]) = {"all", NULL};
3095#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003096#ifdef FEAT_INS_EXPAND
Bram Moolenaarb6be1e22015-07-10 18:18:40 +02003097static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003098#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02003099#ifdef FEAT_SIGNS
3100static char *(p_scl_values[]) = {"yes", "no", "auto", NULL};
3101#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003102
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003103static void set_option_default(int, int opt_flags, int compatible);
3104static void set_options_default(int opt_flags);
3105static char_u *term_bg_default(void);
3106static void did_set_option(int opt_idx, int opt_flags, int new_value);
3107static char_u *illegal_char(char_u *, int);
3108static int string_to_key(char_u *arg);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003109#ifdef FEAT_CMDWIN
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003110static char_u *check_cedit(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003111#endif
3112#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003113static void did_set_title(int icon);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003114#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003115static char_u *option_expand(int opt_idx, char_u *val);
3116static void didset_options(void);
3117static void didset_options2(void);
3118static void check_string_option(char_u **pp);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003119#if defined(FEAT_EVAL) || defined(PROTO)
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003120static long_u *insecure_flag(int opt_idx, int opt_flags);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003121#else
3122# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3123#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003124static void set_string_option_global(int opt_idx, char_u **varp);
3125static char_u *set_string_option(int opt_idx, char_u *value, int opt_flags);
3126static char_u *did_set_string_option(int opt_idx, char_u **varp, int new_value_alloced, char_u *oldval, char_u *errbuf, int opt_flags);
3127static char_u *set_chars_option(char_u **varp);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003128#ifdef FEAT_SYN_HL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003129static int int_cmp(const void *a, const void *b);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003130#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003131#ifdef FEAT_CLIPBOARD
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003132static char_u *check_clipboard_option(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003133#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003134#ifdef FEAT_SPELL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003135static char_u *did_set_spell_option(int is_spellfile);
3136static char_u *compile_cap_prog(synblock_T *synblock);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003137#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003138#ifdef FEAT_EVAL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003139static void set_option_scriptID_idx(int opt_idx, int opt_flags, int id);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003140#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003141static char_u *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags);
3142static char_u *set_num_option(int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags);
3143static void check_redraw(long_u flags);
3144static int findoption(char_u *);
3145static int find_key_option(char_u *);
3146static void showoptions(int all, int opt_flags);
3147static int optval_default(struct vimoption *, char_u *varp);
3148static void showoneopt(struct vimoption *, int opt_flags);
3149static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int expand);
3150static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep);
3151static int put_setbool(FILE *fd, char *cmd, char *name, int value);
3152static int istermoption(struct vimoption *);
3153static char_u *get_varp_scope(struct vimoption *p, int opt_flags);
3154static char_u *get_varp(struct vimoption *);
3155static void option_value2string(struct vimoption *, int opt_flags);
3156static void check_winopt(winopt_T *wop);
3157static int wc_use_keyname(char_u *varp, long *wcp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003158#ifdef FEAT_LANGMAP
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003159static void langmap_init(void);
3160static void langmap_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003161#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003162static void paste_option_changed(void);
3163static void compatible_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003164#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003165static void fill_breakat_flags(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003166#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003167static int opt_strings_flags(char_u *val, char **values, unsigned *flagp, int list);
3168static int check_opt_strings(char_u *val, char **values, int);
3169static int check_opt_wim(void);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003170#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003171static int briopt_check(win_T *wp);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003172#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003173
3174/*
3175 * Initialize the options, first part.
3176 *
3177 * Called only once from main(), just after creating the first buffer.
3178 */
3179 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003180set_init_1(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003181{
3182 char_u *p;
3183 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003184 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003185
3186#ifdef FEAT_LANGMAP
3187 langmap_init();
3188#endif
3189
3190 /* Be Vi compatible by default */
3191 p_cp = TRUE;
3192
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003193 /* Use POSIX compatibility when $VIM_POSIX is set. */
3194 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003195 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003196 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003197 set_string_default("shm", (char_u *)"A");
3198 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003199
Bram Moolenaar071d4272004-06-13 20:20:40 +00003200 /*
3201 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003202 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003203 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003204 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003205#if defined(MSWIN)
Bram Moolenaar7c626922005-02-07 22:01:03 +00003206 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003207# ifdef WIN3264
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003208 || ((p = (char_u *)default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003209# endif
3210#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003211 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003212 set_string_default("sh", p);
3213
3214#ifdef FEAT_WILDIGN
3215 /*
3216 * Set the default for 'backupskip' to include environment variables for
3217 * temp files.
3218 */
3219 {
3220# ifdef UNIX
3221 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3222# else
3223 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3224# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003225 int len;
3226 garray_T ga;
3227 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003228
3229 ga_init2(&ga, 1, 100);
3230 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3231 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003232 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003233# ifdef UNIX
3234 if (*names[n] == NUL)
3235 p = (char_u *)"/tmp";
3236 else
3237# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003238 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003239 if (p != NULL && *p != NUL)
3240 {
3241 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003242 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003243 if (ga_grow(&ga, len) == OK)
3244 {
3245 if (ga.ga_len > 0)
3246 STRCAT(ga.ga_data, ",");
3247 STRCAT(ga.ga_data, p);
3248 add_pathsep(ga.ga_data);
3249 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003250 ga.ga_len += len;
3251 }
3252 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003253 if (mustfree)
3254 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003255 }
3256 if (ga.ga_data != NULL)
3257 {
3258 set_string_default("bsk", ga.ga_data);
3259 vim_free(ga.ga_data);
3260 }
3261 }
3262#endif
3263
3264 /*
3265 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3266 */
3267 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003268 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003269 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003270#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3271 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3272#endif
3273 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003274#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003275 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003276 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003277#else
3278# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003279 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003280 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003281# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003282 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003283# endif
3284#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003285 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003286 opt_idx = findoption((char_u *)"maxmem");
3287 if (opt_idx >= 0)
3288 {
3289#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
Bram Moolenaar35be4532015-12-11 22:38:36 +01003290 if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n
3291 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L)
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003292#endif
3293 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3294 }
3295 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003296 }
3297
Bram Moolenaar071d4272004-06-13 20:20:40 +00003298#ifdef FEAT_SEARCHPATH
3299 {
3300 char_u *cdpath;
3301 char_u *buf;
3302 int i;
3303 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003304 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003305
3306 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003307 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003308 if (cdpath != NULL)
3309 {
3310 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3311 if (buf != NULL)
3312 {
3313 buf[0] = ','; /* start with ",", current dir first */
3314 j = 1;
3315 for (i = 0; cdpath[i] != NUL; ++i)
3316 {
3317 if (vim_ispathlistsep(cdpath[i]))
3318 buf[j++] = ',';
3319 else
3320 {
3321 if (cdpath[i] == ' ' || cdpath[i] == ',')
3322 buf[j++] = '\\';
3323 buf[j++] = cdpath[i];
3324 }
3325 }
3326 buf[j] = NUL;
3327 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003328 if (opt_idx >= 0)
3329 {
3330 options[opt_idx].def_val[VI_DEFAULT] = buf;
3331 options[opt_idx].flags |= P_DEF_ALLOCED;
3332 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003333 else
3334 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003335 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003336 if (mustfree)
3337 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003338 }
3339 }
3340#endif
3341
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003342#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003343 /* Set print encoding on platforms that don't default to latin1 */
3344 set_string_default("penc",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003345# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003346 (char_u *)"cp1252"
3347# else
3348# ifdef VMS
3349 (char_u *)"dec-mcs"
3350# else
3351# ifdef EBCDIC
3352 (char_u *)"ebcdic-uk"
3353# else
3354# ifdef MAC
3355 (char_u *)"mac-roman"
3356# else /* HPUX */
3357 (char_u *)"hp-roman8"
3358# endif
3359# endif
3360# endif
3361# endif
3362 );
3363#endif
3364
3365#ifdef FEAT_POSTSCRIPT
3366 /* 'printexpr' must be allocated to be able to evaluate it. */
3367 set_string_default("pexpr",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003368# if defined(MSWIN)
Bram Moolenaared203462004-06-16 11:19:22 +00003369 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003370# else
3371# ifdef VMS
3372 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3373
3374# else
3375 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3376# endif
3377# endif
3378 );
3379#endif
3380
3381 /*
3382 * Set all the options (except the terminal options) to their default
3383 * value. Also set the global value for local options.
3384 */
3385 set_options_default(0);
3386
3387#ifdef FEAT_GUI
3388 if (found_reverse_arg)
3389 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3390#endif
3391
3392 curbuf->b_p_initialized = TRUE;
3393 curbuf->b_p_ar = -1; /* no local 'autoread' value */
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01003394 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003395 check_buf_options(curbuf);
3396 check_win_options(curwin);
3397 check_options();
3398
3399 /* Must be before option_expand(), because that one needs vim_isIDc() */
3400 didset_options();
3401
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003402#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003403 /* Use the current chartab for the generic chartab. This is not in
3404 * didset_options() because it only depends on 'encoding'. */
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003405 init_spell_chartab();
3406#endif
3407
Bram Moolenaar071d4272004-06-13 20:20:40 +00003408 /*
3409 * Expand environment variables and things like "~" for the defaults.
3410 * If option_expand() returns non-NULL the variable is expanded. This can
3411 * only happen for non-indirect options.
3412 * Also set the default to the expanded value, so ":set" does not list
3413 * them.
3414 * Don't set the P_ALLOCED flag, because we don't want to free the
3415 * default.
3416 */
3417 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3418 {
3419 if ((options[opt_idx].flags & P_GETTEXT)
3420 && options[opt_idx].var != NULL)
3421 p = (char_u *)_(*(char **)options[opt_idx].var);
3422 else
3423 p = option_expand(opt_idx, NULL);
3424 if (p != NULL && (p = vim_strsave(p)) != NULL)
3425 {
3426 *(char_u **)options[opt_idx].var = p;
3427 /* VIMEXP
3428 * Defaults for all expanded options are currently the same for Vi
3429 * and Vim. When this changes, add some code here! Also need to
3430 * split P_DEF_ALLOCED in two.
3431 */
3432 if (options[opt_idx].flags & P_DEF_ALLOCED)
3433 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3434 options[opt_idx].def_val[VI_DEFAULT] = p;
3435 options[opt_idx].flags |= P_DEF_ALLOCED;
3436 }
3437 }
3438
Bram Moolenaar071d4272004-06-13 20:20:40 +00003439 save_file_ff(curbuf); /* Buffer is unchanged */
3440
Bram Moolenaar071d4272004-06-13 20:20:40 +00003441#if defined(FEAT_ARABIC)
3442 /* Detect use of mlterm.
3443 * Mlterm is a terminal emulator akin to xterm that has some special
3444 * abilities (bidi namely).
3445 * NOTE: mlterm's author is being asked to 'set' a variable
3446 * instead of an environment variable due to inheritance.
3447 */
3448 if (mch_getenv((char_u *)"MLTERM") != NULL)
3449 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3450#endif
3451
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003452 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003453
3454#ifdef FEAT_MBYTE
3455# if defined(WIN3264) && defined(FEAT_GETTEXT)
3456 /*
3457 * If $LANG isn't set, try to get a good value for it. This makes the
3458 * right language be used automatically. Don't do this for English.
3459 */
3460 if (mch_getenv((char_u *)"LANG") == NULL)
3461 {
3462 char buf[20];
3463
3464 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3465 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3466 * only the first two. */
3467 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3468 (LPTSTR)buf, 20);
3469 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3470 {
3471 /* There are a few exceptions (probably more) */
3472 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3473 STRCPY(buf, "zh_TW");
3474 else if (STRNICMP(buf, "chs", 3) == 0
3475 || STRNICMP(buf, "zhc", 3) == 0)
3476 STRCPY(buf, "zh_CN");
3477 else if (STRNICMP(buf, "jp", 2) == 0)
3478 STRCPY(buf, "ja");
3479 else
3480 buf[2] = NUL; /* truncate to two-letter code */
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003481 vim_setenv((char_u *)"LANG", (char_u *)buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003482 }
3483 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003484# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003485# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003486 /* Moved to os_mac_conv.c to avoid dependency problems. */
3487 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003488# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003489# endif
3490
3491 /* enc_locale() will try to find the encoding of the current locale. */
3492 p = enc_locale();
3493 if (p != NULL)
3494 {
3495 char_u *save_enc;
3496
3497 /* Try setting 'encoding' and check if the value is valid.
3498 * If not, go back to the default "latin1". */
3499 save_enc = p_enc;
3500 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003501 if (STRCMP(p_enc, "gb18030") == 0)
3502 {
3503 /* We don't support "gb18030", but "cp936" is a good substitute
3504 * for practical purposes, thus use that. It's not an alias to
3505 * still support conversion between gb18030 and utf-8. */
3506 p_enc = vim_strsave((char_u *)"cp936");
3507 vim_free(p);
3508 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003509 if (mb_init() == NULL)
3510 {
3511 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003512 if (opt_idx >= 0)
3513 {
3514 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3515 options[opt_idx].flags |= P_DEF_ALLOCED;
3516 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003517
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003518#if defined(MSWIN) || defined(MACOS) || defined(VMS)
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003519 if (STRCMP(p_enc, "latin1") == 0
3520# ifdef FEAT_MBYTE
3521 || enc_utf8
3522# endif
3523 )
3524 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003525 /* Adjust the default for 'isprint' and 'iskeyword' to match
3526 * latin1. Also set the defaults for when 'nocompatible' is
3527 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003528 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003529 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003530 set_string_option_direct((char_u *)"isk", -1,
3531 ISK_LATIN1, OPT_FREE, SID_NONE);
3532 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003533 if (opt_idx >= 0)
3534 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003535 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003536 if (opt_idx >= 0)
3537 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003538 (void)init_chartab();
3539 }
3540#endif
3541
Bram Moolenaar071d4272004-06-13 20:20:40 +00003542# if defined(WIN3264) && !defined(FEAT_GUI)
3543 /* Win32 console: When GetACP() returns a different value from
3544 * GetConsoleCP() set 'termencoding'. */
3545 if (GetACP() != GetConsoleCP())
3546 {
3547 char buf[50];
3548
3549 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3550 p_tenc = vim_strsave((char_u *)buf);
3551 if (p_tenc != NULL)
3552 {
3553 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003554 if (opt_idx >= 0)
3555 {
3556 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3557 options[opt_idx].flags |= P_DEF_ALLOCED;
3558 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003559 convert_setup(&input_conv, p_tenc, p_enc);
3560 convert_setup(&output_conv, p_enc, p_tenc);
3561 }
3562 else
3563 p_tenc = empty_option;
3564 }
3565# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003566# if defined(WIN3264) && defined(FEAT_MBYTE)
3567 /* $HOME may have characters in active code page. */
3568 init_homedir();
3569# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003570 }
3571 else
3572 {
3573 vim_free(p_enc);
3574 p_enc = save_enc;
3575 }
3576 }
3577#endif
3578
3579#ifdef FEAT_MULTI_LANG
3580 /* Set the default for 'helplang'. */
3581 set_helplang_default(get_mess_lang());
3582#endif
3583}
3584
3585/*
3586 * Set an option to its default value.
3587 * This does not take care of side effects!
3588 */
3589 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003590set_option_default(
3591 int opt_idx,
3592 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3593 int compatible) /* use Vi default value */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003594{
3595 char_u *varp; /* pointer to variable for current option */
3596 int dvi; /* index in def_val[] */
3597 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003598 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003599 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3600
3601 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3602 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003603 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003604 {
3605 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3606 if (flags & P_STRING)
3607 {
3608 /* Use set_string_option_direct() for local options to handle
3609 * freeing and allocating the value. */
3610 if (options[opt_idx].indir != PV_NONE)
3611 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003612 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003613 else
3614 {
3615 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3616 free_string_option(*(char_u **)(varp));
3617 *(char_u **)varp = options[opt_idx].def_val[dvi];
3618 options[opt_idx].flags &= ~P_ALLOCED;
3619 }
3620 }
3621 else if (flags & P_NUM)
3622 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003623 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003624 win_comp_scroll(curwin);
3625 else
3626 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003627 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003628 /* May also set global value for local option. */
3629 if (both)
3630 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3631 *(long *)varp;
3632 }
3633 }
3634 else /* P_BOOL */
3635 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003636 /* the cast to long is required for Manx C, long_i is needed for
3637 * MSVC */
3638 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003639#ifdef UNIX
3640 /* 'modeline' defaults to off for root */
3641 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3642 *(int *)varp = FALSE;
3643#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003644 /* May also set global value for local option. */
3645 if (both)
3646 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3647 *(int *)varp;
3648 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003649
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003650 /* The default value is not insecure. */
3651 flagsp = insecure_flag(opt_idx, opt_flags);
3652 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003653 }
3654
3655#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003656 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003657#endif
3658}
3659
3660/*
3661 * Set all options (except terminal options) to their default value.
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003662 * When "opt_flags" is non-zero skip 'encoding'.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003663 */
3664 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003665set_options_default(
3666 int opt_flags) /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003667{
3668 int i;
3669#ifdef FEAT_WINDOWS
3670 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003671 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003672#endif
3673
3674 for (i = 0; !istermoption(&options[i]); i++)
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003675 if (!(options[i].flags & P_NODEFAULT)
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003676#if defined(FEAT_MBYTE) || defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003677 && (opt_flags == 0
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003678 || (TRUE
3679# if defined(FEAT_MBYTE)
3680 && options[i].var != (char_u *)&p_enc
3681# endif
3682# if defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003683 && options[i].var != (char_u *)&p_cm
Bram Moolenaar80606872015-08-25 21:27:35 +02003684 && options[i].var != (char_u *)&p_key
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003685# endif
3686 ))
Bram Moolenaar80606872015-08-25 21:27:35 +02003687#endif
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003688 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003689 set_option_default(i, opt_flags, p_cp);
3690
3691#ifdef FEAT_WINDOWS
3692 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003693 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003694 win_comp_scroll(wp);
3695#else
3696 win_comp_scroll(curwin);
3697#endif
Bram Moolenaar5a4eceb2014-09-09 17:33:07 +02003698#ifdef FEAT_CINDENT
3699 parse_cino(curbuf);
3700#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003701}
3702
3703/*
3704 * Set the Vi-default value of a string option.
3705 * Used for 'sh', 'backupskip' and 'term'.
3706 */
3707 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003708set_string_default(char *name, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003709{
3710 char_u *p;
3711 int opt_idx;
3712
3713 p = vim_strsave(val);
3714 if (p != NULL) /* we don't want a NULL */
3715 {
3716 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003717 if (opt_idx >= 0)
3718 {
3719 if (options[opt_idx].flags & P_DEF_ALLOCED)
3720 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3721 options[opt_idx].def_val[VI_DEFAULT] = p;
3722 options[opt_idx].flags |= P_DEF_ALLOCED;
3723 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003724 }
3725}
3726
3727/*
3728 * Set the Vi-default value of a number option.
3729 * Used for 'lines' and 'columns'.
3730 */
3731 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003732set_number_default(char *name, long val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003733{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003734 int opt_idx;
3735
3736 opt_idx = findoption((char_u *)name);
3737 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003738 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003739}
3740
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003741#if defined(EXITFREE) || defined(PROTO)
3742/*
3743 * Free all options.
3744 */
3745 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003746free_all_options(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003747{
3748 int i;
3749
3750 for (i = 0; !istermoption(&options[i]); i++)
3751 {
3752 if (options[i].indir == PV_NONE)
3753 {
3754 /* global option: free value and default value. */
3755 if (options[i].flags & P_ALLOCED && options[i].var != NULL)
3756 free_string_option(*(char_u **)options[i].var);
3757 if (options[i].flags & P_DEF_ALLOCED)
3758 free_string_option(options[i].def_val[VI_DEFAULT]);
3759 }
3760 else if (options[i].var != VAR_WIN
3761 && (options[i].flags & P_STRING))
3762 /* buffer-local option: free global value */
3763 free_string_option(*(char_u **)options[i].var);
3764 }
3765}
3766#endif
3767
3768
Bram Moolenaar071d4272004-06-13 20:20:40 +00003769/*
3770 * Initialize the options, part two: After getting Rows and Columns and
3771 * setting 'term'.
3772 */
3773 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003774set_init_2(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003775{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003776 int idx;
3777
Bram Moolenaar071d4272004-06-13 20:20:40 +00003778 /*
3779 * 'scroll' defaults to half the window height. Note that this default is
3780 * wrong when the window height changes.
3781 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003782 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003783 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003784 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003785 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003786 comp_col();
3787
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003788 /*
3789 * 'window' is only for backwards compatibility with Vi.
3790 * Default is Rows - 1.
3791 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003792 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003793 p_window = Rows - 1;
3794 set_number_default("window", Rows - 1);
3795
Bram Moolenaarf740b292006-02-16 22:11:02 +00003796 /* For DOS console the default is always black. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003797#if !((defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003798 /*
3799 * If 'background' wasn't set by the user, try guessing the value,
3800 * depending on the terminal name. Only need to check for terminals
3801 * with a dark background, that can handle color.
3802 */
3803 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003804 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3805 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003806 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003807 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003808 /* don't mark it as set, when starting the GUI it may be
3809 * changed again */
3810 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003811 }
3812#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003813
3814#ifdef CURSOR_SHAPE
3815 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3816#endif
3817#ifdef FEAT_MOUSESHAPE
3818 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3819#endif
3820#ifdef FEAT_PRINTER
3821 (void)parse_printoptions(); /* parse 'printoptions' default value */
3822#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003823}
3824
3825/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00003826 * Return "dark" or "light" depending on the kind of terminal.
3827 * This is just guessing! Recognized are:
3828 * "linux" Linux console
3829 * "screen.linux" Linux console with screen
3830 * "cygwin" Cygwin shell
3831 * "putty" Putty program
3832 * We also check the COLORFGBG environment variable, which is set by
3833 * rxvt and derivatives. This variable contains either two or three
3834 * values separated by semicolons; we want the last value in either
3835 * case. If this value is 0-6 or 8, our background is dark.
3836 */
3837 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01003838term_bg_default(void)
Bram Moolenaarf740b292006-02-16 22:11:02 +00003839{
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003840#if defined(WIN3264)
Bram Moolenaarf740b292006-02-16 22:11:02 +00003841 /* DOS console nearly always black */
3842 return (char_u *)"dark";
3843#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00003844 char_u *p;
3845
Bram Moolenaarf740b292006-02-16 22:11:02 +00003846 if (STRCMP(T_NAME, "linux") == 0
3847 || STRCMP(T_NAME, "screen.linux") == 0
3848 || STRCMP(T_NAME, "cygwin") == 0
3849 || STRCMP(T_NAME, "putty") == 0
3850 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
3851 && (p = vim_strrchr(p, ';')) != NULL
3852 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
3853 && p[2] == NUL))
3854 return (char_u *)"dark";
3855 return (char_u *)"light";
3856#endif
3857}
3858
3859/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00003860 * Initialize the options, part three: After reading the .vimrc
3861 */
3862 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003863set_init_3(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003864{
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003865#if defined(UNIX) || defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003866/*
3867 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
3868 * This is done after other initializations, where 'shell' might have been
3869 * set, but only if they have not been set before.
3870 */
3871 char_u *p;
3872 int idx_srr;
3873 int do_srr;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003874# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00003875 int idx_sp;
3876 int do_sp;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003877# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003878
3879 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003880 if (idx_srr < 0)
3881 do_srr = FALSE;
3882 else
3883 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003884# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00003885 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003886 if (idx_sp < 0)
3887 do_sp = FALSE;
3888 else
3889 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003890# endif
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003891 p = get_isolated_shell_name();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003892 if (p != NULL)
3893 {
3894 /*
3895 * Default for p_sp is "| tee", for p_srr is ">".
3896 * For known shells it is changed here to include stderr.
3897 */
3898 if ( fnamecmp(p, "csh") == 0
3899 || fnamecmp(p, "tcsh") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003900# if defined(WIN3264) /* also check with .exe extension */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003901 || fnamecmp(p, "csh.exe") == 0
3902 || fnamecmp(p, "tcsh.exe") == 0
3903# endif
3904 )
3905 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003906# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003907 if (do_sp)
3908 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003909# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003910 p_sp = (char_u *)">&";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003911# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003912 p_sp = (char_u *)"|& tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003913# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003914 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3915 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003916# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003917 if (do_srr)
3918 {
3919 p_srr = (char_u *)">&";
3920 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3921 }
3922 }
3923 else
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003924 /* Always use bourne shell style redirection if we reach this */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003925 if ( fnamecmp(p, "sh") == 0
3926 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003927 || fnamecmp(p, "mksh") == 0
3928 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003929 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003930 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003931 || fnamecmp(p, "bash") == 0
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003932 || fnamecmp(p, "fish") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003933# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003934 || fnamecmp(p, "cmd") == 0
3935 || fnamecmp(p, "sh.exe") == 0
3936 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003937 || fnamecmp(p, "mksh.exe") == 0
3938 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003939 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003940 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003941 || fnamecmp(p, "bash.exe") == 0
3942 || fnamecmp(p, "cmd.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003943# endif
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003944 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003945 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003946# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003947 if (do_sp)
3948 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003949# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003950 p_sp = (char_u *)">%s 2>&1";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003951# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003952 p_sp = (char_u *)"2>&1| tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003953# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003954 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3955 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003956# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003957 if (do_srr)
3958 {
3959 p_srr = (char_u *)">%s 2>&1";
3960 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3961 }
3962 }
3963 vim_free(p);
3964 }
3965#endif
3966
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003967#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003968 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01003969 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
3970 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003971 * This is done after other initializations, where 'shell' might have been
3972 * set, but only if they have not been set before. Default for p_shcf is
3973 * "/c", for p_shq is "". For "sh" like shells it is changed here to
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003974 * "-c" and "\"". And for Win32 we need to set p_sxq instead.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003975 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00003976 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003977 {
3978 int idx3;
3979
3980 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003981 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003982 {
3983 p_shcf = (char_u *)"-c";
3984 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3985 }
3986
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003987# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003988 /* Somehow Win32 requires the quotes around the redirection too */
3989 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003990 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003991 {
3992 p_sxq = (char_u *)"\"";
3993 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3994 }
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003995# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003996 idx3 = findoption((char_u *)"shq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003997 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003998 {
3999 p_shq = (char_u *)"\"";
4000 options[idx3].def_val[VI_DEFAULT] = p_shq;
4001 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004002# endif
4003 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01004004 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
4005 {
4006 int idx3;
4007
4008 /*
4009 * cmd.exe on Windows will strip the first and last double quote given
4010 * on the command line, e.g. most of the time things like:
4011 * cmd /c "my path/to/echo" "my args to echo"
4012 * become:
4013 * my path/to/echo" "my args to echo
4014 * when executed.
4015 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01004016 * To avoid this, set shellxquote to surround the command in
4017 * parenthesis. This appears to make most commands work, without
4018 * breaking commands that worked previously, such as
4019 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01004020 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01004021 idx3 = findoption((char_u *)"sxq");
4022 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4023 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004024 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004025 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4026 }
4027
Bram Moolenaara64ba222012-02-12 23:23:31 +01004028 idx3 = findoption((char_u *)"shcf");
4029 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4030 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004031 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004032 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4033 }
4034 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004035#endif
4036
Bram Moolenaar364fa5c2016-03-20 17:53:25 +01004037 if (bufempty())
4038 {
4039 int idx_ffs = findoption((char_u *)"ffs");
4040
4041 /* Apply the first entry of 'fileformats' to the initial buffer. */
4042 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET))
4043 set_fileformat(default_fileformat(), OPT_LOCAL);
4044 }
4045
Bram Moolenaar071d4272004-06-13 20:20:40 +00004046#ifdef FEAT_TITLE
4047 set_title_defaults();
4048#endif
4049}
4050
4051#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4052/*
4053 * When 'helplang' is still at its default value, set it to "lang".
4054 * Only the first two characters of "lang" are used.
4055 */
4056 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004057set_helplang_default(char_u *lang)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004058{
4059 int idx;
4060
4061 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4062 return;
4063 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004064 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004065 {
4066 if (options[idx].flags & P_ALLOCED)
4067 free_string_option(p_hlg);
4068 p_hlg = vim_strsave(lang);
4069 if (p_hlg == NULL)
4070 p_hlg = empty_option;
4071 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004072 {
4073 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4074 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4075 {
4076 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4077 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4078 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004079 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004080 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004081 options[idx].flags |= P_ALLOCED;
4082 }
4083}
4084#endif
4085
4086#ifdef FEAT_GUI
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01004087static char_u *gui_bg_default(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004088
4089 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01004090gui_bg_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004091{
4092 if (gui_get_lightness(gui.back_pixel) < 127)
4093 return (char_u *)"dark";
4094 return (char_u *)"light";
4095}
4096
4097/*
4098 * Option initializations that can only be done after opening the GUI window.
4099 */
4100 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004101init_gui_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004102{
4103 /* Set the 'background' option according to the lightness of the
4104 * background color, unless the user has set it already. */
4105 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4106 {
4107 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4108 highlight_changed();
4109 }
4110}
4111#endif
4112
4113#ifdef FEAT_TITLE
4114/*
4115 * 'title' and 'icon' only default to true if they have not been set or reset
4116 * in .vimrc and we can read the old value.
4117 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4118 * they can be reset. This reduces startup time when using X on a remote
4119 * machine.
4120 */
4121 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004122set_title_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004123{
4124 int idx1;
4125 long val;
4126
4127 /*
4128 * If GUI is (going to be) used, we can always set the window title and
4129 * icon name. Saves a bit of time, because the X11 display server does
4130 * not need to be contacted.
4131 */
4132 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004133 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004134 {
4135#ifdef FEAT_GUI
4136 if (gui.starting || gui.in_use)
4137 val = TRUE;
4138 else
4139#endif
4140 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004141 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004142 p_title = val;
4143 }
4144 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004145 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004146 {
4147#ifdef FEAT_GUI
4148 if (gui.starting || gui.in_use)
4149 val = TRUE;
4150 else
4151#endif
4152 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004153 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004154 p_icon = val;
4155 }
4156}
4157#endif
4158
4159/*
4160 * Parse 'arg' for option settings.
4161 *
4162 * 'arg' may be IObuff, but only when no errors can be present and option
4163 * does not need to be expanded with option_expand().
4164 * "opt_flags":
4165 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004166 * OPT_GLOBAL for ":setglobal"
4167 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004168 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004169 * OPT_WINONLY to only set window-local options
4170 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004171 *
4172 * returns FAIL if an error is detected, OK otherwise
4173 */
4174 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01004175do_set(
4176 char_u *arg, /* option string (may be written to!) */
4177 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004178{
4179 int opt_idx;
4180 char_u *errmsg;
4181 char_u errbuf[80];
4182 char_u *startarg;
4183 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4184 int nextchar; /* next non-white char after option name */
4185 int afterchar; /* character just after option name */
4186 int len;
4187 int i;
Bram Moolenaar22fcfad2016-07-01 18:17:26 +02004188 varnumber_T value;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004189 int key;
4190 long_u flags; /* flags for current option */
4191 char_u *varp = NULL; /* pointer to variable for current option */
4192 int did_show = FALSE; /* already showed one value */
4193 int adding; /* "opt+=arg" */
4194 int prepending; /* "opt^=arg" */
4195 int removing; /* "opt-=arg" */
4196 int cp_val = 0;
4197 char_u key_name[2];
4198
4199 if (*arg == NUL)
4200 {
4201 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004202 did_show = TRUE;
4203 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004204 }
4205
4206 while (*arg != NUL) /* loop to process all options */
4207 {
4208 errmsg = NULL;
4209 startarg = arg; /* remember for error message */
4210
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004211 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4212 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004213 {
4214 /*
4215 * ":set all" show all options.
4216 * ":set all&" set all options to their default value.
4217 */
4218 arg += 3;
4219 if (*arg == '&')
4220 {
4221 ++arg;
4222 /* Only for :set command set global value of local options. */
4223 set_options_default(OPT_FREE | opt_flags);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02004224 didset_options();
4225 didset_options2();
Bram Moolenaarb341dda2015-08-25 12:56:31 +02004226 redraw_all_later(CLEAR);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004227 }
4228 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004229 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004230 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004231 did_show = TRUE;
4232 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004233 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004234 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004235 {
4236 showoptions(2, opt_flags);
4237 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004238 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004239 arg += 7;
4240 }
4241 else
4242 {
4243 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004244 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004245 {
4246 prefix = 0;
4247 arg += 2;
4248 }
4249 else if (STRNCMP(arg, "inv", 3) == 0)
4250 {
4251 prefix = 2;
4252 arg += 3;
4253 }
4254
4255 /* find end of name */
4256 key = 0;
4257 if (*arg == '<')
4258 {
4259 nextchar = 0;
4260 opt_idx = -1;
4261 /* look out for <t_>;> */
4262 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4263 len = 5;
4264 else
4265 {
4266 len = 1;
4267 while (arg[len] != NUL && arg[len] != '>')
4268 ++len;
4269 }
4270 if (arg[len] != '>')
4271 {
4272 errmsg = e_invarg;
4273 goto skip;
4274 }
4275 arg[len] = NUL; /* put NUL after name */
4276 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4277 opt_idx = findoption(arg + 1);
4278 arg[len++] = '>'; /* restore '>' */
4279 if (opt_idx == -1)
4280 key = find_key_option(arg + 1);
4281 }
4282 else
4283 {
4284 len = 0;
4285 /*
4286 * The two characters after "t_" may not be alphanumeric.
4287 */
4288 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4289 len = 4;
4290 else
4291 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4292 ++len;
4293 nextchar = arg[len];
4294 arg[len] = NUL; /* put NUL after name */
4295 opt_idx = findoption(arg);
4296 arg[len] = nextchar; /* restore nextchar */
4297 if (opt_idx == -1)
4298 key = find_key_option(arg);
4299 }
4300
4301 /* remember character after option name */
4302 afterchar = arg[len];
4303
4304 /* skip white space, allow ":set ai ?" */
4305 while (vim_iswhite(arg[len]))
4306 ++len;
4307
4308 adding = FALSE;
4309 prepending = FALSE;
4310 removing = FALSE;
4311 if (arg[len] != NUL && arg[len + 1] == '=')
4312 {
4313 if (arg[len] == '+')
4314 {
4315 adding = TRUE; /* "+=" */
4316 ++len;
4317 }
4318 else if (arg[len] == '^')
4319 {
4320 prepending = TRUE; /* "^=" */
4321 ++len;
4322 }
4323 else if (arg[len] == '-')
4324 {
4325 removing = TRUE; /* "-=" */
4326 ++len;
4327 }
4328 }
4329 nextchar = arg[len];
4330
4331 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4332 {
4333 errmsg = (char_u *)N_("E518: Unknown option");
4334 goto skip;
4335 }
4336
4337 if (opt_idx >= 0)
4338 {
4339 if (options[opt_idx].var == NULL) /* hidden option: skip */
4340 {
4341 /* Only give an error message when requesting the value of
4342 * a hidden option, ignore setting it. */
4343 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4344 && (!(options[opt_idx].flags & P_BOOL)
4345 || nextchar == '?'))
4346 errmsg = (char_u *)N_("E519: Option not supported");
4347 goto skip;
4348 }
4349
4350 flags = options[opt_idx].flags;
4351 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4352 }
4353 else
4354 {
4355 flags = P_STRING;
4356 if (key < 0)
4357 {
4358 key_name[0] = KEY2TERMCAP0(key);
4359 key_name[1] = KEY2TERMCAP1(key);
4360 }
4361 else
4362 {
4363 key_name[0] = KS_KEY;
4364 key_name[1] = (key & 0xff);
4365 }
4366 }
4367
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004368 /* Skip all options that are not window-local (used when showing
4369 * an already loaded buffer in a window). */
4370 if ((opt_flags & OPT_WINONLY)
4371 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4372 goto skip;
4373
Bram Moolenaara3227e22006-03-08 21:32:40 +00004374 /* Skip all options that are window-local (used for :vimgrep). */
4375 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4376 && options[opt_idx].var == VAR_WIN)
4377 goto skip;
4378
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004379 /* Disallow changing some options from modelines. */
4380 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004381 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004382 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004383 {
4384 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4385 goto skip;
4386 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004387#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004388 /* In diff mode some options are overruled. This avoids that
4389 * 'foldmethod' becomes "marker" instead of "diff" and that
4390 * "wrap" gets set. */
4391 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004392 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004393 && (options[opt_idx].indir == PV_FDM
4394 || options[opt_idx].indir == PV_WRAP))
4395 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004396#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004397 }
4398
4399#ifdef HAVE_SANDBOX
4400 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004401 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004402 {
4403 errmsg = (char_u *)_(e_sandbox);
4404 goto skip;
4405 }
4406#endif
4407
4408 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4409 {
4410 arg += len;
4411 cp_val = p_cp;
4412 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4413 {
4414 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4415 {
4416 cp_val = FALSE;
4417 arg += 3;
4418 }
4419 else /* "opt&vi": set to Vi default */
4420 {
4421 cp_val = TRUE;
4422 arg += 2;
4423 }
4424 }
4425 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
4426 && arg[1] != NUL && !vim_iswhite(arg[1]))
4427 {
4428 errmsg = e_trailing;
4429 goto skip;
4430 }
4431 }
4432
4433 /*
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004434 * allow '=' and ':' for hystorical reasons (MSDOS command.com
4435 * allows only one '=' character per "set" command line. grrr. (jw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004436 */
4437 if (nextchar == '?'
4438 || (prefix == 1
4439 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4440 && !(flags & P_BOOL)))
4441 {
4442 /*
4443 * print value
4444 */
4445 if (did_show)
4446 msg_putchar('\n'); /* cursor below last one */
4447 else
4448 {
4449 gotocmdline(TRUE); /* cursor at status line */
4450 did_show = TRUE; /* remember that we did a line */
4451 }
4452 if (opt_idx >= 0)
4453 {
4454 showoneopt(&options[opt_idx], opt_flags);
4455#ifdef FEAT_EVAL
4456 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004457 {
4458 /* Mention where the option was last set. */
4459 if (varp == options[opt_idx].var)
4460 last_set_msg(options[opt_idx].scriptID);
4461 else if ((int)options[opt_idx].indir & PV_WIN)
4462 last_set_msg(curwin->w_p_scriptID[
4463 (int)options[opt_idx].indir & PV_MASK]);
4464 else if ((int)options[opt_idx].indir & PV_BUF)
4465 last_set_msg(curbuf->b_p_scriptID[
4466 (int)options[opt_idx].indir & PV_MASK]);
4467 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004468#endif
4469 }
4470 else
4471 {
4472 char_u *p;
4473
4474 p = find_termcode(key_name);
4475 if (p == NULL)
4476 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004477 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004478 goto skip;
4479 }
4480 else
4481 (void)show_one_termcode(key_name, p, TRUE);
4482 }
4483 if (nextchar != '?'
4484 && nextchar != NUL && !vim_iswhite(afterchar))
4485 errmsg = e_trailing;
4486 }
4487 else
4488 {
4489 if (flags & P_BOOL) /* boolean */
4490 {
4491 if (nextchar == '=' || nextchar == ':')
4492 {
4493 errmsg = e_invarg;
4494 goto skip;
4495 }
4496
4497 /*
4498 * ":set opt!": invert
4499 * ":set opt&": reset to default value
4500 * ":set opt<": reset to global value
4501 */
4502 if (nextchar == '!')
4503 value = *(int *)(varp) ^ 1;
4504 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004505 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004506 ((flags & P_VI_DEF) || cp_val)
4507 ? VI_DEFAULT : VIM_DEFAULT];
4508 else if (nextchar == '<')
4509 {
4510 /* For 'autoread' -1 means to use global value. */
4511 if ((int *)varp == &curbuf->b_p_ar
4512 && opt_flags == OPT_LOCAL)
4513 value = -1;
4514 else
4515 value = *(int *)get_varp_scope(&(options[opt_idx]),
4516 OPT_GLOBAL);
4517 }
4518 else
4519 {
4520 /*
4521 * ":set invopt": invert
4522 * ":set opt" or ":set noopt": set or reset
4523 */
4524 if (nextchar != NUL && !vim_iswhite(afterchar))
4525 {
4526 errmsg = e_trailing;
4527 goto skip;
4528 }
4529 if (prefix == 2) /* inv */
4530 value = *(int *)(varp) ^ 1;
4531 else
4532 value = prefix;
4533 }
4534
4535 errmsg = set_bool_option(opt_idx, varp, (int)value,
4536 opt_flags);
4537 }
4538 else /* numeric or string */
4539 {
4540 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4541 || prefix != 1)
4542 {
4543 errmsg = e_invarg;
4544 goto skip;
4545 }
4546
4547 if (flags & P_NUM) /* numeric */
4548 {
4549 /*
4550 * Different ways to set a number option:
4551 * & set to default value
4552 * < set to global value
4553 * <xx> accept special key codes for 'wildchar'
4554 * c accept any non-digit for 'wildchar'
4555 * [-]0-9 set number
4556 * other error
4557 */
4558 ++arg;
4559 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004560 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004561 ((flags & P_VI_DEF) || cp_val)
4562 ? VI_DEFAULT : VIM_DEFAULT];
4563 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004564 {
4565 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4566 * use the global value. */
4567 if ((long *)varp == &curbuf->b_p_ul
4568 && opt_flags == OPT_LOCAL)
4569 value = NO_LOCAL_UNDOLEVEL;
4570 else
4571 value = *(long *)get_varp_scope(
4572 &(options[opt_idx]), OPT_GLOBAL);
4573 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004574 else if (((long *)varp == &p_wc
4575 || (long *)varp == &p_wcm)
4576 && (*arg == '<'
4577 || *arg == '^'
4578 || ((!arg[1] || vim_iswhite(arg[1]))
4579 && !VIM_ISDIGIT(*arg))))
4580 {
4581 value = string_to_key(arg);
4582 if (value == 0 && (long *)varp != &p_wcm)
4583 {
4584 errmsg = e_invarg;
4585 goto skip;
4586 }
4587 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004588 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4589 {
Bram Moolenaar18400e62015-01-27 15:58:40 +01004590 /* Allow negative (for 'undolevels'), octal and
4591 * hex numbers. */
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01004592 vim_str2nr(arg, NULL, &i, STR2NR_ALL,
4593 &value, NULL, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004594 if (arg[i] != NUL && !vim_iswhite(arg[i]))
4595 {
4596 errmsg = e_invarg;
4597 goto skip;
4598 }
4599 }
4600 else
4601 {
4602 errmsg = (char_u *)N_("E521: Number required after =");
4603 goto skip;
4604 }
4605
4606 if (adding)
4607 value = *(long *)varp + value;
4608 if (prepending)
4609 value = *(long *)varp * value;
4610 if (removing)
4611 value = *(long *)varp - value;
4612 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004613 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004614 }
4615 else if (opt_idx >= 0) /* string */
4616 {
4617 char_u *save_arg = NULL;
4618 char_u *s = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004619 char_u *oldval = NULL; /* previous value if *varp */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004620 char_u *newval;
Bram Moolenaar53744302015-07-17 17:38:22 +02004621 char_u *origval = NULL;
4622#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4623 char_u *saved_origval = NULL;
4624#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004625 unsigned newlen;
4626 int comma;
4627 int bs;
4628 int new_value_alloced; /* new string option
4629 was allocated */
4630
4631 /* When using ":set opt=val" for a global option
4632 * with a local value the local value will be
4633 * reset, use the global value here. */
4634 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004635 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004636 varp = options[opt_idx].var;
4637
4638 /* The old value is kept until we are sure that the
4639 * new value is valid. */
4640 oldval = *(char_u **)varp;
4641 if (nextchar == '&') /* set to default val */
4642 {
4643 newval = options[opt_idx].def_val[
4644 ((flags & P_VI_DEF) || cp_val)
4645 ? VI_DEFAULT : VIM_DEFAULT];
4646 if ((char_u **)varp == &p_bg)
4647 {
4648 /* guess the value of 'background' */
4649#ifdef FEAT_GUI
4650 if (gui.in_use)
4651 newval = gui_bg_default();
4652 else
4653#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004654 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004655 }
4656
4657 /* expand environment variables and ~ (since the
4658 * default value was already expanded, only
4659 * required when an environment variable was set
4660 * later */
4661 if (newval == NULL)
4662 newval = empty_option;
4663 else
4664 {
4665 s = option_expand(opt_idx, newval);
4666 if (s == NULL)
4667 s = newval;
4668 newval = vim_strsave(s);
4669 }
4670 new_value_alloced = TRUE;
4671 }
4672 else if (nextchar == '<') /* set to global val */
4673 {
4674 newval = vim_strsave(*(char_u **)get_varp_scope(
4675 &(options[opt_idx]), OPT_GLOBAL));
4676 new_value_alloced = TRUE;
4677 }
4678 else
4679 {
4680 ++arg; /* jump to after the '=' or ':' */
4681
4682 /*
4683 * Set 'keywordprg' to ":help" if an empty
4684 * value was passed to :set by the user.
4685 * Misuse errbuf[] for the resulting string.
4686 */
4687 if (varp == (char_u *)&p_kp
4688 && (*arg == NUL || *arg == ' '))
4689 {
4690 STRCPY(errbuf, ":help");
4691 save_arg = arg;
4692 arg = errbuf;
4693 }
4694 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004695 * Convert 'backspace' number to string, for
4696 * adding, prepending and removing string.
4697 */
4698 else if (varp == (char_u *)&p_bs
4699 && VIM_ISDIGIT(**(char_u **)varp))
4700 {
4701 i = getdigits((char_u **)varp);
4702 switch (i)
4703 {
4704 case 0:
4705 *(char_u **)varp = empty_option;
4706 break;
4707 case 1:
4708 *(char_u **)varp = vim_strsave(
4709 (char_u *)"indent,eol");
4710 break;
4711 case 2:
4712 *(char_u **)varp = vim_strsave(
4713 (char_u *)"indent,eol,start");
4714 break;
4715 }
4716 vim_free(oldval);
4717 oldval = *(char_u **)varp;
4718 }
4719 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004720 * Convert 'whichwrap' number to string, for
4721 * backwards compatibility with Vim 3.0.
4722 * Misuse errbuf[] for the resulting string.
4723 */
4724 else if (varp == (char_u *)&p_ww
4725 && VIM_ISDIGIT(*arg))
4726 {
4727 *errbuf = NUL;
4728 i = getdigits(&arg);
4729 if (i & 1)
4730 STRCAT(errbuf, "b,");
4731 if (i & 2)
4732 STRCAT(errbuf, "s,");
4733 if (i & 4)
4734 STRCAT(errbuf, "h,l,");
4735 if (i & 8)
4736 STRCAT(errbuf, "<,>,");
4737 if (i & 16)
4738 STRCAT(errbuf, "[,],");
4739 if (*errbuf != NUL) /* remove trailing , */
4740 errbuf[STRLEN(errbuf) - 1] = NUL;
4741 save_arg = arg;
4742 arg = errbuf;
4743 }
4744 /*
4745 * Remove '>' before 'dir' and 'bdir', for
4746 * backwards compatibility with version 3.0
4747 */
4748 else if ( *arg == '>'
4749 && (varp == (char_u *)&p_dir
4750 || varp == (char_u *)&p_bdir))
4751 {
4752 ++arg;
4753 }
4754
4755 /* When setting the local value of a global
4756 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004757 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004758 && (opt_flags & OPT_LOCAL))
4759 origval = *(char_u **)get_varp(
4760 &options[opt_idx]);
4761 else
4762 origval = oldval;
4763
4764 /*
4765 * Copy the new string into allocated memory.
4766 * Can't use set_string_option_direct(), because
4767 * we need to remove the backslashes.
4768 */
4769 /* get a bit too much */
4770 newlen = (unsigned)STRLEN(arg) + 1;
4771 if (adding || prepending || removing)
4772 newlen += (unsigned)STRLEN(origval) + 1;
4773 newval = alloc(newlen);
4774 if (newval == NULL) /* out of mem, don't change */
4775 break;
4776 s = newval;
4777
4778 /*
4779 * Copy the string, skip over escaped chars.
4780 * For MS-DOS and WIN32 backslashes before normal
4781 * file name characters are not removed, and keep
4782 * backslash at start, for "\\machine\path", but
4783 * do remove it for "\\\\machine\\path".
4784 * The reverse is found in ExpandOldSetting().
4785 */
4786 while (*arg && !vim_iswhite(*arg))
4787 {
4788 if (*arg == '\\' && arg[1] != NUL
4789#ifdef BACKSLASH_IN_FILENAME
4790 && !((flags & P_EXPAND)
4791 && vim_isfilec(arg[1])
4792 && (arg[1] != '\\'
4793 || (s == newval
4794 && arg[2] != '\\')))
4795#endif
4796 )
4797 ++arg; /* remove backslash */
4798#ifdef FEAT_MBYTE
4799 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00004800 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004801 {
4802 /* copy multibyte char */
4803 mch_memmove(s, arg, (size_t)i);
4804 arg += i;
4805 s += i;
4806 }
4807 else
4808#endif
4809 *s++ = *arg++;
4810 }
4811 *s = NUL;
4812
4813 /*
4814 * Expand environment variables and ~.
4815 * Don't do it when adding without inserting a
4816 * comma.
4817 */
4818 if (!(adding || prepending || removing)
4819 || (flags & P_COMMA))
4820 {
4821 s = option_expand(opt_idx, newval);
4822 if (s != NULL)
4823 {
4824 vim_free(newval);
4825 newlen = (unsigned)STRLEN(s) + 1;
4826 if (adding || prepending || removing)
4827 newlen += (unsigned)STRLEN(origval) + 1;
4828 newval = alloc(newlen);
4829 if (newval == NULL)
4830 break;
4831 STRCPY(newval, s);
4832 }
4833 }
4834
4835 /* locate newval[] in origval[] when removing it
4836 * and when adding to avoid duplicates */
4837 i = 0; /* init for GCC */
4838 if (removing || (flags & P_NODUP))
4839 {
4840 i = (int)STRLEN(newval);
4841 bs = 0;
4842 for (s = origval; *s; ++s)
4843 {
4844 if ((!(flags & P_COMMA)
4845 || s == origval
4846 || (s[-1] == ',' && !(bs & 1)))
4847 && STRNCMP(s, newval, i) == 0
4848 && (!(flags & P_COMMA)
4849 || s[i] == ','
4850 || s[i] == NUL))
4851 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004852 /* Count backslashes. Only a comma with an
Bram Moolenaar8f79acd2016-01-01 14:48:20 +01004853 * even number of backslashes or a single
4854 * backslash preceded by a comma before it
4855 * is recognized as a separator */
4856 if ((s > origval + 1
4857 && s[-1] == '\\'
4858 && s[-2] != ',')
4859 || (s == origval + 1
4860 && s[-1] == '\\'))
4861
Bram Moolenaar071d4272004-06-13 20:20:40 +00004862 ++bs;
4863 else
4864 bs = 0;
4865 }
4866
4867 /* do not add if already there */
4868 if ((adding || prepending) && *s)
4869 {
4870 prepending = FALSE;
4871 adding = FALSE;
4872 STRCPY(newval, origval);
4873 }
4874 }
4875
4876 /* concatenate the two strings; add a ',' if
4877 * needed */
4878 if (adding || prepending)
4879 {
4880 comma = ((flags & P_COMMA) && *origval != NUL
4881 && *newval != NUL);
4882 if (adding)
4883 {
4884 i = (int)STRLEN(origval);
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004885 /* strip a trailing comma, would get 2 */
Bram Moolenaar17467472015-11-10 17:50:24 +01004886 if (comma && i > 1
4887 && (flags & P_ONECOMMA) == P_ONECOMMA
4888 && origval[i - 1] == ','
4889 && origval[i - 2] != '\\')
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004890 i--;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004891 mch_memmove(newval + i + comma, newval,
4892 STRLEN(newval) + 1);
4893 mch_memmove(newval, origval, (size_t)i);
4894 }
4895 else
4896 {
4897 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004898 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004899 }
4900 if (comma)
4901 newval[i] = ',';
4902 }
4903
4904 /* Remove newval[] from origval[]. (Note: "i" has
4905 * been set above and is used here). */
4906 if (removing)
4907 {
4908 STRCPY(newval, origval);
4909 if (*s)
4910 {
4911 /* may need to remove a comma */
4912 if (flags & P_COMMA)
4913 {
4914 if (s == origval)
4915 {
4916 /* include comma after string */
4917 if (s[i] == ',')
4918 ++i;
4919 }
4920 else
4921 {
4922 /* include comma before string */
4923 --s;
4924 ++i;
4925 }
4926 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004927 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004928 }
4929 }
4930
4931 if (flags & P_FLAGLIST)
4932 {
4933 /* Remove flags that appear twice. */
4934 for (s = newval; *s; ++s)
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02004935 {
4936 /* if options have P_FLAGLIST and
4937 * P_ONECOMMA such as 'whichwrap' */
4938 if (flags & P_ONECOMMA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004939 {
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02004940 if (*s != ',' && *(s + 1) == ','
4941 && vim_strchr(s + 2, *s) != NULL)
4942 {
4943 /* Remove the duplicated value and
4944 * the next comma. */
4945 STRMOVE(s, s + 2);
4946 s -= 2;
4947 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004948 }
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02004949 else
4950 {
4951 if ((!(flags & P_COMMA) || *s != ',')
4952 && vim_strchr(s + 1, *s) != NULL)
4953 {
4954 STRMOVE(s, s + 1);
4955 --s;
4956 }
4957 }
4958 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004959 }
4960
4961 if (save_arg != NULL) /* number for 'whichwrap' */
4962 arg = save_arg;
4963 new_value_alloced = TRUE;
4964 }
4965
4966 /* Set the new value. */
4967 *(char_u **)(varp) = newval;
4968
Bram Moolenaar53744302015-07-17 17:38:22 +02004969#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02004970 if (!starting
4971# ifdef FEAT_CRYPT
4972 && options[opt_idx].indir != PV_KEY
4973# endif
Bram Moolenaar53744302015-07-17 17:38:22 +02004974 && origval != NULL)
4975 /* origval may be freed by
4976 * did_set_string_option(), make a copy. */
4977 saved_origval = vim_strsave(origval);
4978#endif
4979
Bram Moolenaar071d4272004-06-13 20:20:40 +00004980 /* Handle side effects, and set the global value for
4981 * ":set" on local options. */
4982 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
4983 new_value_alloced, oldval, errbuf, opt_flags);
4984
4985 /* If error detected, print the error message. */
4986 if (errmsg != NULL)
Bram Moolenaara9884962015-12-13 15:08:56 +01004987 {
4988#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4989 vim_free(saved_origval);
4990#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004991 goto skip;
Bram Moolenaara9884962015-12-13 15:08:56 +01004992 }
Bram Moolenaar53744302015-07-17 17:38:22 +02004993#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4994 if (saved_origval != NULL)
4995 {
4996 char_u buf_type[7];
4997
4998 sprintf((char *)buf_type, "%s",
4999 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02005000 set_vim_var_string(VV_OPTION_NEW,
5001 *(char_u **)varp, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02005002 set_vim_var_string(VV_OPTION_OLD, saved_origval, -1);
5003 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
5004 apply_autocmds(EVENT_OPTIONSET,
5005 (char_u *)options[opt_idx].fullname,
5006 NULL, FALSE, NULL);
5007 reset_v_option_vars();
5008 vim_free(saved_origval);
5009 }
5010#endif
5011
Bram Moolenaar071d4272004-06-13 20:20:40 +00005012 }
5013 else /* key code option */
5014 {
5015 char_u *p;
5016
5017 if (nextchar == '&')
5018 {
5019 if (add_termcap_entry(key_name, TRUE) == FAIL)
5020 errmsg = (char_u *)N_("E522: Not found in termcap");
5021 }
5022 else
5023 {
5024 ++arg; /* jump to after the '=' or ':' */
5025 for (p = arg; *p && !vim_iswhite(*p); ++p)
5026 if (*p == '\\' && p[1] != NUL)
5027 ++p;
5028 nextchar = *p;
5029 *p = NUL;
5030 add_termcode(key_name, arg, FALSE);
5031 *p = nextchar;
5032 }
5033 if (full_screen)
5034 ttest(FALSE);
5035 redraw_all_later(CLEAR);
5036 }
5037 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005038
Bram Moolenaar071d4272004-06-13 20:20:40 +00005039 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005040 did_set_option(opt_idx, opt_flags,
5041 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005042 }
5043
5044skip:
5045 /*
5046 * Advance to next argument.
5047 * - skip until a blank found, taking care of backslashes
5048 * - skip blanks
5049 * - skip one "=val" argument (for hidden options ":set gfn =xx")
5050 */
5051 for (i = 0; i < 2 ; ++i)
5052 {
5053 while (*arg != NUL && !vim_iswhite(*arg))
5054 if (*arg++ == '\\' && *arg != NUL)
5055 ++arg;
5056 arg = skipwhite(arg);
5057 if (*arg != '=')
5058 break;
5059 }
5060 }
5061
5062 if (errmsg != NULL)
5063 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005064 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005065 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005066 if (i + (arg - startarg) < IOSIZE)
5067 {
5068 /* append the argument with the error */
5069 STRCAT(IObuff, ": ");
5070 mch_memmove(IObuff + i, startarg, (arg - startarg));
5071 IObuff[i + (arg - startarg)] = NUL;
5072 }
5073 /* make sure all characters are printable */
5074 trans_characters(IObuff, IOSIZE);
5075
5076 ++no_wait_return; /* wait_return done later */
5077 emsg(IObuff); /* show error highlighted */
5078 --no_wait_return;
5079
5080 return FAIL;
5081 }
5082
5083 arg = skipwhite(arg);
5084 }
5085
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005086theend:
5087 if (silent_mode && did_show)
5088 {
5089 /* After displaying option values in silent mode. */
5090 silent_mode = FALSE;
5091 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5092 msg_putchar('\n');
5093 cursor_on(); /* msg_start() switches it off */
5094 out_flush();
5095 silent_mode = TRUE;
5096 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5097 }
5098
Bram Moolenaar071d4272004-06-13 20:20:40 +00005099 return OK;
5100}
5101
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005102/*
5103 * Call this when an option has been given a new value through a user command.
5104 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5105 */
5106 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005107did_set_option(
5108 int opt_idx,
5109 int opt_flags, /* possibly with OPT_MODELINE */
5110 int new_value) /* value was replaced completely */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005111{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005112 long_u *p;
5113
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005114 options[opt_idx].flags |= P_WAS_SET;
5115
5116 /* When an option is set in the sandbox, from a modeline or in secure mode
5117 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005118 * flag. */
5119 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005120 if (secure
5121#ifdef HAVE_SANDBOX
5122 || sandbox != 0
5123#endif
5124 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005125 *p = *p | P_INSECURE;
5126 else if (new_value)
5127 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005128}
5129
Bram Moolenaar071d4272004-06-13 20:20:40 +00005130 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005131illegal_char(char_u *errbuf, int c)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005132{
5133 if (errbuf == NULL)
5134 return (char_u *)"";
5135 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005136 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005137 return errbuf;
5138}
5139
5140/*
5141 * Convert a key name or string into a key value.
5142 * Used for 'wildchar' and 'cedit' options.
5143 */
5144 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005145string_to_key(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005146{
5147 if (*arg == '<')
5148 return find_key_option(arg + 1);
5149 if (*arg == '^')
5150 return Ctrl_chr(arg[1]);
5151 return *arg;
5152}
5153
5154#ifdef FEAT_CMDWIN
5155/*
5156 * Check value of 'cedit' and set cedit_key.
5157 * Returns NULL if value is OK, error message otherwise.
5158 */
5159 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005160check_cedit(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005161{
5162 int n;
5163
5164 if (*p_cedit == NUL)
5165 cedit_key = -1;
5166 else
5167 {
5168 n = string_to_key(p_cedit);
5169 if (vim_isprintc(n))
5170 return e_invarg;
5171 cedit_key = n;
5172 }
5173 return NULL;
5174}
5175#endif
5176
5177#ifdef FEAT_TITLE
5178/*
5179 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5180 * maketitle() to create and display it.
5181 * When switching the title or icon off, call mch_restore_title() to get
5182 * the old value back.
5183 */
5184 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005185did_set_title(
5186 int icon) /* Did set icon instead of title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005187{
5188 if (starting != NO_SCREEN
5189#ifdef FEAT_GUI
5190 && !gui.starting
5191#endif
5192 )
5193 {
5194 maketitle();
5195 if (icon)
5196 {
5197 if (!p_icon)
5198 mch_restore_title(2);
5199 }
5200 else
5201 {
5202 if (!p_title)
5203 mch_restore_title(1);
5204 }
5205 }
5206}
5207#endif
5208
5209/*
5210 * set_options_bin - called when 'bin' changes value.
5211 */
5212 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005213set_options_bin(
5214 int oldval,
5215 int newval,
5216 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005217{
5218 /*
5219 * The option values that are changed when 'bin' changes are
5220 * copied when 'bin is set and restored when 'bin' is reset.
5221 */
5222 if (newval)
5223 {
5224 if (!oldval) /* switched on */
5225 {
5226 if (!(opt_flags & OPT_GLOBAL))
5227 {
5228 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5229 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5230 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5231 curbuf->b_p_et_nobin = curbuf->b_p_et;
5232 }
5233 if (!(opt_flags & OPT_LOCAL))
5234 {
5235 p_tw_nobin = p_tw;
5236 p_wm_nobin = p_wm;
5237 p_ml_nobin = p_ml;
5238 p_et_nobin = p_et;
5239 }
5240 }
5241
5242 if (!(opt_flags & OPT_GLOBAL))
5243 {
5244 curbuf->b_p_tw = 0; /* no automatic line wrap */
5245 curbuf->b_p_wm = 0; /* no automatic line wrap */
5246 curbuf->b_p_ml = 0; /* no modelines */
5247 curbuf->b_p_et = 0; /* no expandtab */
5248 }
5249 if (!(opt_flags & OPT_LOCAL))
5250 {
5251 p_tw = 0;
5252 p_wm = 0;
5253 p_ml = FALSE;
5254 p_et = FALSE;
5255 p_bin = TRUE; /* needed when called for the "-b" argument */
5256 }
5257 }
5258 else if (oldval) /* switched off */
5259 {
5260 if (!(opt_flags & OPT_GLOBAL))
5261 {
5262 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5263 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5264 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5265 curbuf->b_p_et = curbuf->b_p_et_nobin;
5266 }
5267 if (!(opt_flags & OPT_LOCAL))
5268 {
5269 p_tw = p_tw_nobin;
5270 p_wm = p_wm_nobin;
5271 p_ml = p_ml_nobin;
5272 p_et = p_et_nobin;
5273 }
5274 }
5275}
5276
5277#ifdef FEAT_VIMINFO
5278/*
5279 * Find the parameter represented by the given character (eg ', :, ", or /),
5280 * and return its associated value in the 'viminfo' string.
5281 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005282 * If the parameter is not specified in the string or there is no following
5283 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005284 */
5285 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005286get_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005287{
5288 char_u *p;
5289
5290 p = find_viminfo_parameter(type);
5291 if (p != NULL && VIM_ISDIGIT(*p))
5292 return atoi((char *)p);
5293 return -1;
5294}
5295
5296/*
5297 * Find the parameter represented by the given character (eg ''', ':', '"', or
5298 * '/') in the 'viminfo' option and return a pointer to the string after it.
5299 * Return NULL if the parameter is not specified in the string.
5300 */
5301 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005302find_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005303{
5304 char_u *p;
5305
5306 for (p = p_viminfo; *p; ++p)
5307 {
5308 if (*p == type)
5309 return p + 1;
5310 if (*p == 'n') /* 'n' is always the last one */
5311 break;
5312 p = vim_strchr(p, ','); /* skip until next ',' */
5313 if (p == NULL) /* hit the end without finding parameter */
5314 break;
5315 }
5316 return NULL;
5317}
5318#endif
5319
5320/*
5321 * Expand environment variables for some string options.
5322 * These string options cannot be indirect!
5323 * If "val" is NULL expand the current value of the option.
5324 * Return pointer to NameBuff, or NULL when not expanded.
5325 */
5326 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005327option_expand(int opt_idx, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005328{
5329 /* if option doesn't need expansion nothing to do */
5330 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5331 return NULL;
5332
5333 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5334 * expand_env() would truncate the string. */
5335 if (val != NULL && STRLEN(val) > MAXPATHL)
5336 return NULL;
5337
5338 if (val == NULL)
5339 val = *(char_u **)options[opt_idx].var;
5340
5341 /*
5342 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5343 * Escape spaces when expanding 'tags', they are used to separate file
5344 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005345 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005346 */
5347 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005348 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005349#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005350 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5351#endif
5352 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005353 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5354 return NULL;
5355
5356 return NameBuff;
5357}
5358
5359/*
5360 * After setting various option values: recompute variables that depend on
5361 * option values.
5362 */
5363 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005364didset_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005365{
5366 /* initialize the table for 'iskeyword' et.al. */
5367 (void)init_chartab();
5368
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005369#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005370 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005371#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005372 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
Bram Moolenaar165bc692015-07-21 17:53:25 +02005373 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005374#ifdef FEAT_SESSION
5375 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5376 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5377#endif
5378#ifdef FEAT_FOLDING
5379 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5380#endif
5381 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005382 (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005383#ifdef FEAT_VIRTUALEDIT
5384 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5385#endif
5386#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5387 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5388#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005389#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005390 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005391 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005392 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005393 (void)did_set_spell_option(TRUE);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005394#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005395#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5396 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5397#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005398#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005399 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5400#endif
5401#ifdef FEAT_CMDWIN
5402 /* set cedit_key */
5403 (void)check_cedit();
5404#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005405#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005406 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005407#endif
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005408#ifdef FEAT_LINEBREAK
5409 /* initialize the table for 'breakat'. */
5410 fill_breakat_flags();
5411#endif
5412
5413}
5414
5415/*
5416 * More side effects of setting options.
5417 */
5418 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005419didset_options2(void)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005420{
5421 /* Initialize the highlight_attr[] table. */
5422 (void)highlight_changed();
5423
5424 /* Parse default for 'wildmode' */
5425 check_opt_wim();
5426
5427 (void)set_chars_option(&p_lcs);
5428#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5429 /* Parse default for 'fillchars'. */
5430 (void)set_chars_option(&p_fcs);
5431#endif
5432
5433#ifdef FEAT_CLIPBOARD
5434 /* Parse default for 'clipboard' */
5435 (void)check_clipboard_option();
5436#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005437}
5438
5439/*
5440 * Check for string options that are NULL (normally only termcap options).
5441 */
5442 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005443check_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005444{
5445 int opt_idx;
5446
5447 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5448 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5449 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5450}
5451
5452/*
5453 * Check string options in a buffer for NULL value.
5454 */
5455 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005456check_buf_options(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005457{
5458#if defined(FEAT_QUICKFIX)
5459 check_string_option(&buf->b_p_bh);
5460 check_string_option(&buf->b_p_bt);
5461#endif
5462#ifdef FEAT_MBYTE
5463 check_string_option(&buf->b_p_fenc);
5464#endif
5465 check_string_option(&buf->b_p_ff);
5466#ifdef FEAT_FIND_ID
5467 check_string_option(&buf->b_p_def);
5468 check_string_option(&buf->b_p_inc);
5469# ifdef FEAT_EVAL
5470 check_string_option(&buf->b_p_inex);
5471# endif
5472#endif
5473#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5474 check_string_option(&buf->b_p_inde);
5475 check_string_option(&buf->b_p_indk);
5476#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005477#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5478 check_string_option(&buf->b_p_bexpr);
5479#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005480#if defined(FEAT_CRYPT)
5481 check_string_option(&buf->b_p_cm);
5482#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005483#if defined(FEAT_EVAL)
5484 check_string_option(&buf->b_p_fex);
5485#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005486#ifdef FEAT_CRYPT
5487 check_string_option(&buf->b_p_key);
5488#endif
5489 check_string_option(&buf->b_p_kp);
5490 check_string_option(&buf->b_p_mps);
5491 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005492 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005493 check_string_option(&buf->b_p_isk);
5494#ifdef FEAT_COMMENTS
5495 check_string_option(&buf->b_p_com);
5496#endif
5497#ifdef FEAT_FOLDING
5498 check_string_option(&buf->b_p_cms);
5499#endif
5500 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005501#ifdef FEAT_TEXTOBJ
5502 check_string_option(&buf->b_p_qe);
5503#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005504#ifdef FEAT_SYN_HL
5505 check_string_option(&buf->b_p_syn);
Bram Moolenaarb8060fe2016-01-19 22:29:28 +01005506 check_string_option(&buf->b_s.b_syn_isk);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005507#endif
5508#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005509 check_string_option(&buf->b_s.b_p_spc);
5510 check_string_option(&buf->b_s.b_p_spf);
5511 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005512#endif
5513#ifdef FEAT_SEARCHPATH
5514 check_string_option(&buf->b_p_sua);
5515#endif
5516#ifdef FEAT_CINDENT
5517 check_string_option(&buf->b_p_cink);
5518 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005519 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005520#endif
5521#ifdef FEAT_AUTOCMD
5522 check_string_option(&buf->b_p_ft);
5523#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005524#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5525 check_string_option(&buf->b_p_cinw);
5526#endif
5527#ifdef FEAT_INS_EXPAND
5528 check_string_option(&buf->b_p_cpt);
5529#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005530#ifdef FEAT_COMPL_FUNC
5531 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005532 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005533#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005534#ifdef FEAT_KEYMAP
5535 check_string_option(&buf->b_p_keymap);
5536#endif
5537#ifdef FEAT_QUICKFIX
5538 check_string_option(&buf->b_p_gp);
5539 check_string_option(&buf->b_p_mp);
5540 check_string_option(&buf->b_p_efm);
5541#endif
5542 check_string_option(&buf->b_p_ep);
5543 check_string_option(&buf->b_p_path);
5544 check_string_option(&buf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005545 check_string_option(&buf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005546#ifdef FEAT_INS_EXPAND
5547 check_string_option(&buf->b_p_dict);
5548 check_string_option(&buf->b_p_tsr);
5549#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005550#ifdef FEAT_LISP
5551 check_string_option(&buf->b_p_lw);
5552#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005553 check_string_option(&buf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005554}
5555
5556/*
5557 * Free the string allocated for an option.
5558 * Checks for the string being empty_option. This may happen if we're out of
5559 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5560 * check_options().
5561 * Does NOT check for P_ALLOCED flag!
5562 */
5563 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005564free_string_option(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005565{
5566 if (p != empty_option)
5567 vim_free(p);
5568}
5569
5570 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005571clear_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005572{
5573 if (*pp != empty_option)
5574 vim_free(*pp);
5575 *pp = empty_option;
5576}
5577
5578 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005579check_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005580{
5581 if (*pp == NULL)
5582 *pp = empty_option;
5583}
5584
5585/*
5586 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5587 */
5588 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005589set_term_option_alloced(char_u **p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005590{
5591 int opt_idx;
5592
5593 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5594 if (options[opt_idx].var == (char_u *)p)
5595 {
5596 options[opt_idx].flags |= P_ALLOCED;
5597 return;
5598 }
5599 return; /* cannot happen: didn't find it! */
5600}
5601
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005602#if defined(FEAT_EVAL) || defined(PROTO)
5603/*
5604 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5605 * Return FALSE when it wasn't.
5606 * Return -1 for an unknown option.
5607 */
5608 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005609was_set_insecurely(char_u *opt, int opt_flags)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005610{
5611 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005612 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005613
5614 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005615 {
5616 flagp = insecure_flag(idx, opt_flags);
5617 return (*flagp & P_INSECURE) != 0;
5618 }
Bram Moolenaar95f09602016-11-10 20:01:45 +01005619 internal_error("was_set_insecurely()");
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005620 return -1;
5621}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005622
5623/*
5624 * Get a pointer to the flags used for the P_INSECURE flag of option
5625 * "opt_idx". For some local options a local flags field is used.
5626 */
5627 static long_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005628insecure_flag(int opt_idx, int opt_flags)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005629{
5630 if (opt_flags & OPT_LOCAL)
5631 switch ((int)options[opt_idx].indir)
5632 {
5633#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005634 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005635#endif
5636#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005637# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005638 case PV_FDE: return &curwin->w_p_fde_flags;
5639 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005640# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005641# ifdef FEAT_BEVAL
5642 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5643# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005644# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005645 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005646# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005647 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005648# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005649 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005650# endif
5651#endif
5652 }
5653
5654 /* Nothing special, return global flags field. */
5655 return &options[opt_idx].flags;
5656}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005657#endif
5658
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005659#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01005660static void redraw_titles(void);
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005661
5662/*
5663 * Redraw the window title and/or tab page text later.
5664 */
Bram Moolenaar9b578142016-01-30 19:39:49 +01005665static void redraw_titles(void)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005666{
5667 need_maketitle = TRUE;
5668# ifdef FEAT_WINDOWS
5669 redraw_tabline = TRUE;
5670# endif
5671}
5672#endif
5673
Bram Moolenaar071d4272004-06-13 20:20:40 +00005674/*
5675 * Set a string option to a new value (without checking the effect).
5676 * The string is copied into allocated memory.
5677 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005678 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005679 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005680 */
5681 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005682set_string_option_direct(
5683 char_u *name,
5684 int opt_idx,
5685 char_u *val,
5686 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
5687 int set_sid UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005688{
5689 char_u *s;
5690 char_u **varp;
5691 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005692 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005693
Bram Moolenaar89d40322006-08-29 15:30:07 +00005694 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005695 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005696 idx = findoption(name);
5697 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005698 {
5699 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar95f09602016-11-10 20:01:45 +01005700 IEMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005701 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005702 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005703 }
5704
Bram Moolenaar89d40322006-08-29 15:30:07 +00005705 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005706 return;
5707
5708 s = vim_strsave(val);
5709 if (s != NULL)
5710 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005711 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005712 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005713 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005714 free_string_option(*varp);
5715 *varp = s;
5716
5717 /* For buffer/window local option may also set the global value. */
5718 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005719 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005720
Bram Moolenaar89d40322006-08-29 15:30:07 +00005721 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005722
5723 /* When setting both values of a global option with a local value,
5724 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005725 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005726 {
5727 free_string_option(*varp);
5728 *varp = empty_option;
5729 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005730# ifdef FEAT_EVAL
5731 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005732 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005733 set_sid == 0 ? current_SID : set_sid);
5734# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005735 }
5736}
5737
5738/*
5739 * Set global value for string option when it's a local option.
5740 */
5741 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005742set_string_option_global(
5743 int opt_idx, /* option index */
5744 char_u **varp) /* pointer to option variable */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005745{
5746 char_u **p, *s;
5747
5748 /* the global value is always allocated */
5749 if (options[opt_idx].var == VAR_WIN)
5750 p = (char_u **)GLOBAL_WO(varp);
5751 else
5752 p = (char_u **)options[opt_idx].var;
5753 if (options[opt_idx].indir != PV_NONE
5754 && p != varp
5755 && (s = vim_strsave(*varp)) != NULL)
5756 {
5757 free_string_option(*p);
5758 *p = s;
5759 }
5760}
5761
5762/*
5763 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005764 *
5765 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005766 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005767 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005768set_string_option(
5769 int opt_idx,
5770 char_u *value,
5771 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005772{
5773 char_u *s;
5774 char_u **varp;
5775 char_u *oldval;
Bram Moolenaar53744302015-07-17 17:38:22 +02005776#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5777 char_u *saved_oldval = NULL;
5778#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005779 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005780
5781 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005782 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005783
5784 s = vim_strsave(value);
5785 if (s != NULL)
5786 {
5787 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5788 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005789 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005790 ? OPT_GLOBAL : OPT_LOCAL)
5791 : opt_flags);
5792 oldval = *varp;
5793 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02005794
5795#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005796 if (!starting
5797# ifdef FEAT_CRYPT
5798 && options[opt_idx].indir != PV_KEY
5799# endif
5800 )
Bram Moolenaar53744302015-07-17 17:38:22 +02005801 saved_oldval = vim_strsave(oldval);
5802#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005803 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5804 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005805 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02005806
5807 /* call autocomamnd after handling side effects */
5808#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5809 if (saved_oldval != NULL)
5810 {
5811 char_u buf_type[7];
5812 sprintf((char *)buf_type, "%s",
5813 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02005814 set_vim_var_string(VV_OPTION_NEW, *varp, -1);
5815 set_vim_var_string(VV_OPTION_OLD, saved_oldval, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02005816 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
5817 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
5818 reset_v_option_vars();
5819 vim_free(saved_oldval);
5820 }
5821#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005822 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005823 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005824}
5825
Bram Moolenaar40d3f132016-11-05 20:13:35 +01005826#if defined(FEAT_KEYMAP) || defined(FEAT_AUTOCMD) || defined(FEAT_SYN_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005827/*
Bram Moolenaard0b51382016-11-04 15:23:45 +01005828 * Return TRUE if "val" is a valid 'filetype' name.
5829 * Also used for 'syntax' and 'keymap'.
5830 */
5831 static int
5832valid_filetype(char_u *val)
5833{
5834 char_u *s;
5835
5836 for (s = val; *s != NUL; ++s)
5837 if (!ASCII_ISALNUM(*s) && vim_strchr((char_u *)".-_", *s) == NULL)
5838 return FALSE;
5839 return TRUE;
5840}
Bram Moolenaar40d3f132016-11-05 20:13:35 +01005841#endif
Bram Moolenaard0b51382016-11-04 15:23:45 +01005842
5843/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00005844 * Handle string options that need some action to perform when changed.
5845 * Returns NULL for success, or an error message for an error.
5846 */
5847 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005848did_set_string_option(
5849 int opt_idx, /* index in options[] table */
5850 char_u **varp, /* pointer to the option variable */
5851 int new_value_alloced, /* new value was allocated */
5852 char_u *oldval, /* previous value of the option */
5853 char_u *errbuf, /* buffer for errors, or NULL */
5854 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005855{
5856 char_u *errmsg = NULL;
5857 char_u *s, *p;
5858 int did_chartab = FALSE;
5859 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005860 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00005861#ifdef FEAT_GUI
5862 /* set when changing an option that only requires a redraw in the GUI */
5863 int redraw_gui_only = FALSE;
5864#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005865
5866 /* Get the global option to compare with, otherwise we would have to check
5867 * two values for all local options. */
5868 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
5869
5870 /* Disallow changing some options from secure mode */
5871 if ((secure
5872#ifdef HAVE_SANDBOX
5873 || sandbox != 0
5874#endif
5875 ) && (options[opt_idx].flags & P_SECURE))
5876 {
5877 errmsg = e_secure;
5878 }
5879
Bram Moolenaar7554da42016-11-25 22:04:13 +01005880 /* Check for a "normal" directory or file name in some options. Disallow a
5881 * path separator (slash and/or backslash), wildcards and characters that
5882 * are often illegal in a file name. */
5883 else if (((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar319afe32016-11-24 18:30:59 +01005884 && vim_strpbrk(*varp, (char_u *)"/\\*?[|;&<>\r\n") != NULL)
Bram Moolenaar7554da42016-11-25 22:04:13 +01005885 || ((options[opt_idx].flags & P_NDNAME)
5886 && vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL))
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005887 {
5888 errmsg = e_invarg;
5889 }
5890
Bram Moolenaar071d4272004-06-13 20:20:40 +00005891 /* 'term' */
5892 else if (varp == &T_NAME)
5893 {
5894 if (T_NAME[0] == NUL)
5895 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
5896#ifdef FEAT_GUI
5897 if (gui.in_use)
5898 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
5899 else if (term_is_gui(T_NAME))
5900 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
5901#endif
5902 else if (set_termname(T_NAME) == FAIL)
5903 errmsg = (char_u *)N_("E522: Not found in termcap");
5904 else
5905 /* Screen colors may have changed. */
5906 redraw_later_clear();
5907 }
5908
5909 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005910 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005911 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005912 char_u *bkc = p_bkc;
5913 unsigned int *flags = &bkc_flags;
5914
5915 if (opt_flags & OPT_LOCAL)
5916 {
5917 bkc = curbuf->b_p_bkc;
5918 flags = &curbuf->b_bkc_flags;
5919 }
5920
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005921 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
5922 /* make the local value empty: use the global value */
5923 *flags = 0;
5924 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00005925 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005926 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
5927 errmsg = e_invarg;
5928 if ((((int)*flags & BKC_AUTO) != 0)
5929 + (((int)*flags & BKC_YES) != 0)
5930 + (((int)*flags & BKC_NO) != 0) != 1)
5931 {
5932 /* Must have exactly one of "auto", "yes" and "no". */
5933 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
5934 errmsg = e_invarg;
5935 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005936 }
5937 }
5938
5939 /* 'backupext' and 'patchmode' */
5940 else if (varp == &p_bex || varp == &p_pm)
5941 {
5942 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
5943 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
5944 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
5945 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02005946#ifdef FEAT_LINEBREAK
5947 /* 'breakindentopt' */
5948 else if (varp == &curwin->w_p_briopt)
5949 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005950 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02005951 errmsg = e_invarg;
5952 }
5953#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005954
5955 /*
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01005956 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[]
Bram Moolenaar071d4272004-06-13 20:20:40 +00005957 * If the new option is invalid, use old value. 'lisp' option: refill
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01005958 * g_chartab[] for '-' char
Bram Moolenaar071d4272004-06-13 20:20:40 +00005959 */
5960 else if ( varp == &p_isi
5961 || varp == &(curbuf->b_p_isk)
5962 || varp == &p_isp
5963 || varp == &p_isf)
5964 {
5965 if (init_chartab() == FAIL)
5966 {
5967 did_chartab = TRUE; /* need to restore it below */
5968 errmsg = e_invarg; /* error in value */
5969 }
5970 }
5971
5972 /* 'helpfile' */
5973 else if (varp == &p_hf)
5974 {
5975 /* May compute new values for $VIM and $VIMRUNTIME */
5976 if (didset_vim)
5977 {
5978 vim_setenv((char_u *)"VIM", (char_u *)"");
5979 didset_vim = FALSE;
5980 }
5981 if (didset_vimruntime)
5982 {
5983 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
5984 didset_vimruntime = FALSE;
5985 }
5986 }
5987
Bram Moolenaar1a384422010-07-14 19:53:30 +02005988#ifdef FEAT_SYN_HL
5989 /* 'colorcolumn' */
5990 else if (varp == &curwin->w_p_cc)
5991 errmsg = check_colorcolumn(curwin);
5992#endif
5993
Bram Moolenaar071d4272004-06-13 20:20:40 +00005994#ifdef FEAT_MULTI_LANG
5995 /* 'helplang' */
5996 else if (varp == &p_hlg)
5997 {
5998 /* Check for "", "ab", "ab,cd", etc. */
5999 for (s = p_hlg; *s != NUL; s += 3)
6000 {
6001 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
6002 {
6003 errmsg = e_invarg;
6004 break;
6005 }
6006 if (s[2] == NUL)
6007 break;
6008 }
6009 }
6010#endif
6011
6012 /* 'highlight' */
6013 else if (varp == &p_hl)
6014 {
6015 if (highlight_changed() == FAIL)
6016 errmsg = e_invarg; /* invalid flags */
6017 }
6018
6019 /* 'nrformats' */
6020 else if (gvarp == &p_nf)
6021 {
6022 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
6023 errmsg = e_invarg;
6024 }
6025
6026#ifdef FEAT_SESSION
6027 /* 'sessionoptions' */
6028 else if (varp == &p_ssop)
6029 {
6030 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
6031 errmsg = e_invarg;
6032 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
6033 {
6034 /* Don't allow both "sesdir" and "curdir". */
6035 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
6036 errmsg = e_invarg;
6037 }
6038 }
6039 /* 'viewoptions' */
6040 else if (varp == &p_vop)
6041 {
6042 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
6043 errmsg = e_invarg;
6044 }
6045#endif
6046
6047 /* 'scrollopt' */
6048#ifdef FEAT_SCROLLBIND
6049 else if (varp == &p_sbo)
6050 {
6051 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
6052 errmsg = e_invarg;
6053 }
6054#endif
6055
6056 /* 'ambiwidth' */
6057#ifdef FEAT_MBYTE
Bram Moolenaar3848e002016-03-19 18:42:29 +01006058 else if (varp == &p_ambw || varp == &p_emoji)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006059 {
6060 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
6061 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02006062 else if (set_chars_option(&p_lcs) != NULL)
6063 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
6064# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6065 else if (set_chars_option(&p_fcs) != NULL)
6066 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
6067# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006068 }
6069#endif
6070
6071 /* 'background' */
6072 else if (varp == &p_bg)
6073 {
6074 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
6075 {
6076#ifdef FEAT_EVAL
6077 int dark = (*p_bg == 'd');
6078#endif
6079
6080 init_highlight(FALSE, FALSE);
6081
6082#ifdef FEAT_EVAL
6083 if (dark != (*p_bg == 'd')
6084 && get_var_value((char_u *)"g:colors_name") != NULL)
6085 {
6086 /* The color scheme must have set 'background' back to another
6087 * value, that's not what we want here. Disable the color
6088 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00006089 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006090 free_string_option(p_bg);
6091 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
6092 check_string_option(&p_bg);
6093 init_highlight(FALSE, FALSE);
6094 }
6095#endif
6096 }
6097 else
6098 errmsg = e_invarg;
6099 }
6100
6101 /* 'wildmode' */
6102 else if (varp == &p_wim)
6103 {
6104 if (check_opt_wim() == FAIL)
6105 errmsg = e_invarg;
6106 }
6107
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006108#ifdef FEAT_CMDL_COMPL
6109 /* 'wildoptions' */
6110 else if (varp == &p_wop)
6111 {
6112 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6113 errmsg = e_invarg;
6114 }
6115#endif
6116
Bram Moolenaar071d4272004-06-13 20:20:40 +00006117#ifdef FEAT_WAK
6118 /* 'winaltkeys' */
6119 else if (varp == &p_wak)
6120 {
6121 if (*p_wak == NUL
6122 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6123 errmsg = e_invarg;
6124# ifdef FEAT_MENU
6125# ifdef FEAT_GUI_MOTIF
6126 else if (gui.in_use)
6127 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6128# else
6129# ifdef FEAT_GUI_GTK
6130 else if (gui.in_use)
6131 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6132# endif
6133# endif
6134# endif
6135 }
6136#endif
6137
6138#ifdef FEAT_AUTOCMD
6139 /* 'eventignore' */
6140 else if (varp == &p_ei)
6141 {
6142 if (check_ei() == FAIL)
6143 errmsg = e_invarg;
6144 }
6145#endif
6146
6147#ifdef FEAT_MBYTE
6148 /* 'encoding' and 'fileencoding' */
6149 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc)
6150 {
6151 if (gvarp == &p_fenc)
6152 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006153 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006154 errmsg = e_modifiable;
6155 else if (vim_strchr(*varp, ',') != NULL)
6156 /* No comma allowed in 'fileencoding'; catches confusing it
6157 * with 'fileencodings'. */
6158 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006159 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006160 {
6161# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006162 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006163 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006164# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006165 /* Add 'fileencoding' to the swap file. */
6166 ml_setflags(curbuf);
6167 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006168 }
6169 if (errmsg == NULL)
6170 {
6171 /* canonize the value, so that STRCMP() can be used on it */
6172 p = enc_canonize(*varp);
6173 if (p != NULL)
6174 {
6175 vim_free(*varp);
6176 *varp = p;
6177 }
6178 if (varp == &p_enc)
6179 {
6180 errmsg = mb_init();
6181# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006182 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006183# endif
6184 }
6185 }
6186
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006187# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006188 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6189 {
6190 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6191 if (STRCMP(p_tenc, "utf-8") != 0)
6192 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6193 }
6194# endif
6195
6196 if (errmsg == NULL)
6197 {
6198# ifdef FEAT_KEYMAP
6199 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6200 * (with another encoding). */
6201 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6202 (void)keymap_init();
6203# endif
6204
6205 /* When 'termencoding' is not empty and 'encoding' changes or when
6206 * 'termencoding' changes, need to setup for keyboard input and
6207 * display output conversion. */
6208 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6209 {
6210 convert_setup(&input_conv, p_tenc, p_enc);
6211 convert_setup(&output_conv, p_enc, p_tenc);
6212 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006213
6214# if defined(WIN3264) && defined(FEAT_MBYTE)
6215 /* $HOME may have characters in active code page. */
6216 if (varp == &p_enc)
6217 init_homedir();
6218# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006219 }
6220 }
6221#endif
6222
6223#if defined(FEAT_POSTSCRIPT)
6224 else if (varp == &p_penc)
6225 {
6226 /* Canonize printencoding if VIM standard one */
6227 p = enc_canonize(p_penc);
6228 if (p != NULL)
6229 {
6230 vim_free(p_penc);
6231 p_penc = p;
6232 }
6233 else
6234 {
6235 /* Ensure lower case and '-' for '_' */
6236 for (s = p_penc; *s != NUL; s++)
6237 {
6238 if (*s == '_')
6239 *s = '-';
6240 else
6241 *s = TOLOWER_ASC(*s);
6242 }
6243 }
6244 }
6245#endif
6246
Bram Moolenaar9372a112005-12-06 19:59:18 +00006247#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006248 else if (varp == &p_imak)
6249 {
6250 if (gui.in_use && !im_xim_isvalid_imactivate())
6251 errmsg = e_invarg;
6252 }
6253#endif
6254
6255#ifdef FEAT_KEYMAP
6256 else if (varp == &curbuf->b_p_keymap)
6257 {
Bram Moolenaard0b51382016-11-04 15:23:45 +01006258 if (!valid_filetype(*varp))
6259 errmsg = e_invarg;
6260 else
6261 /* load or unload key mapping tables */
6262 errmsg = keymap_init();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006263
Bram Moolenaarfab06232009-03-04 03:13:35 +00006264 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006265 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006266 if (*curbuf->b_p_keymap != NUL)
6267 {
6268 /* Installed a new keymap, switch on using it. */
6269 curbuf->b_p_iminsert = B_IMODE_LMAP;
6270 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6271 curbuf->b_p_imsearch = B_IMODE_LMAP;
6272 }
6273 else
6274 {
6275 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6276 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6277 curbuf->b_p_iminsert = B_IMODE_NONE;
6278 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6279 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6280 }
6281 if ((opt_flags & OPT_LOCAL) == 0)
6282 {
6283 set_iminsert_global();
6284 set_imsearch_global();
6285 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006286# ifdef FEAT_WINDOWS
6287 status_redraw_curbuf();
6288# endif
6289 }
6290 }
6291#endif
6292
6293 /* 'fileformat' */
6294 else if (gvarp == &p_ff)
6295 {
6296 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6297 errmsg = e_modifiable;
6298 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6299 errmsg = e_invarg;
6300 else
6301 {
6302 /* may also change 'textmode' */
6303 if (get_fileformat(curbuf) == EOL_DOS)
6304 curbuf->b_p_tx = TRUE;
6305 else
6306 curbuf->b_p_tx = FALSE;
6307#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006308 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006309#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006310 /* update flag in swap file */
6311 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006312 /* Redraw needed when switching to/from "mac": a CR in the text
6313 * will be displayed differently. */
6314 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6315 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006316 }
6317 }
6318
6319 /* 'fileformats' */
6320 else if (varp == &p_ffs)
6321 {
6322 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6323 errmsg = e_invarg;
6324 else
6325 {
6326 /* also change 'textauto' */
6327 if (*p_ffs == NUL)
6328 p_ta = FALSE;
6329 else
6330 p_ta = TRUE;
6331 }
6332 }
6333
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006334#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006335 /* 'cryptkey' */
6336 else if (gvarp == &p_key)
6337 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006338# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006339 /* Make sure the ":set" command doesn't show the new value in the
6340 * history. */
6341 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006342# endif
6343 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6344 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006345 ml_set_crypt_key(curbuf, oldval,
6346 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006347 }
6348
6349 else if (gvarp == &p_cm)
6350 {
6351 if (opt_flags & OPT_LOCAL)
6352 p = curbuf->b_p_cm;
6353 else
6354 p = p_cm;
6355 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6356 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006357 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006358 errmsg = e_invarg;
6359 else
6360 {
6361 /* When setting the global value to empty, make it "zip". */
6362 if (*p_cm == NUL)
6363 {
6364 if (new_value_alloced)
6365 free_string_option(p_cm);
6366 p_cm = vim_strsave((char_u *)"zip");
6367 new_value_alloced = TRUE;
6368 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006369 /* When using ":set cm=name" the local value is going to be empty.
6370 * Do that here, otherwise the crypt functions will still use the
6371 * local value. */
6372 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6373 {
6374 free_string_option(curbuf->b_p_cm);
6375 curbuf->b_p_cm = empty_option;
6376 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006377
6378 /* Need to update the swapfile when the effective method changed.
6379 * Set "s" to the effective old value, "p" to the effective new
6380 * method and compare. */
6381 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6382 s = p_cm; /* was previously using the global value */
6383 else
6384 s = oldval;
6385 if (*curbuf->b_p_cm == NUL)
6386 p = p_cm; /* is now using the global value */
6387 else
6388 p = curbuf->b_p_cm;
6389 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006390 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006391
6392 /* If the global value changes need to update the swapfile for all
6393 * buffers using that value. */
6394 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6395 {
6396 buf_T *buf;
6397
Bram Moolenaar29323592016-07-24 22:04:11 +02006398 FOR_ALL_BUFFERS(buf)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006399 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006400 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006401 }
6402 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006403 }
6404#endif
6405
6406 /* 'matchpairs' */
6407 else if (gvarp == &p_mps)
6408 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006409#ifdef FEAT_MBYTE
6410 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006411 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006412 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006413 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006414 int x2 = -1;
6415 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006416
6417 if (*p != NUL)
6418 p += mb_ptr2len(p);
6419 if (*p != NUL)
6420 x2 = *p++;
6421 if (*p != NUL)
6422 {
6423 x3 = mb_ptr2char(p);
6424 p += mb_ptr2len(p);
6425 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006426 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006427 {
6428 errmsg = e_invarg;
6429 break;
6430 }
6431 if (*p == NUL)
6432 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006433 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006434 }
6435 else
6436#endif
6437 {
6438 /* Check for "x:y,x:y" */
6439 for (p = *varp; *p != NUL; p += 4)
6440 {
6441 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6442 {
6443 errmsg = e_invarg;
6444 break;
6445 }
6446 if (p[3] == NUL)
6447 break;
6448 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006449 }
6450 }
6451
6452#ifdef FEAT_COMMENTS
6453 /* 'comments' */
6454 else if (gvarp == &p_com)
6455 {
6456 for (s = *varp; *s; )
6457 {
6458 while (*s && *s != ':')
6459 {
6460 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6461 && !VIM_ISDIGIT(*s) && *s != '-')
6462 {
6463 errmsg = illegal_char(errbuf, *s);
6464 break;
6465 }
6466 ++s;
6467 }
6468 if (*s++ == NUL)
6469 errmsg = (char_u *)N_("E524: Missing colon");
6470 else if (*s == ',' || *s == NUL)
6471 errmsg = (char_u *)N_("E525: Zero length string");
6472 if (errmsg != NULL)
6473 break;
6474 while (*s && *s != ',')
6475 {
6476 if (*s == '\\' && s[1] != NUL)
6477 ++s;
6478 ++s;
6479 }
6480 s = skip_to_option_part(s);
6481 }
6482 }
6483#endif
6484
6485 /* 'listchars' */
6486 else if (varp == &p_lcs)
6487 {
6488 errmsg = set_chars_option(varp);
6489 }
6490
6491#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6492 /* 'fillchars' */
6493 else if (varp == &p_fcs)
6494 {
6495 errmsg = set_chars_option(varp);
6496 }
6497#endif
6498
6499#ifdef FEAT_CMDWIN
6500 /* 'cedit' */
6501 else if (varp == &p_cedit)
6502 {
6503 errmsg = check_cedit();
6504 }
6505#endif
6506
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006507 /* 'verbosefile' */
6508 else if (varp == &p_vfile)
6509 {
6510 verbose_stop();
6511 if (*p_vfile != NUL && verbose_open() == FAIL)
6512 errmsg = e_invarg;
6513 }
6514
Bram Moolenaar071d4272004-06-13 20:20:40 +00006515#ifdef FEAT_VIMINFO
6516 /* 'viminfo' */
6517 else if (varp == &p_viminfo)
6518 {
6519 for (s = p_viminfo; *s;)
6520 {
6521 /* Check it's a valid character */
6522 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6523 {
6524 errmsg = illegal_char(errbuf, *s);
6525 break;
6526 }
6527 if (*s == 'n') /* name is always last one */
6528 {
6529 break;
6530 }
6531 else if (*s == 'r') /* skip until next ',' */
6532 {
6533 while (*++s && *s != ',')
6534 ;
6535 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006536 else if (*s == '%')
6537 {
6538 /* optional number */
6539 while (vim_isdigit(*++s))
6540 ;
6541 }
6542 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006543 ++s; /* no extra chars */
6544 else /* must have a number */
6545 {
6546 while (vim_isdigit(*++s))
6547 ;
6548
6549 if (!VIM_ISDIGIT(*(s - 1)))
6550 {
6551 if (errbuf != NULL)
6552 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006553 sprintf((char *)errbuf,
6554 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006555 transchar_byte(*(s - 1)));
6556 errmsg = errbuf;
6557 }
6558 else
6559 errmsg = (char_u *)"";
6560 break;
6561 }
6562 }
6563 if (*s == ',')
6564 ++s;
6565 else if (*s)
6566 {
6567 if (errbuf != NULL)
6568 errmsg = (char_u *)N_("E527: Missing comma");
6569 else
6570 errmsg = (char_u *)"";
6571 break;
6572 }
6573 }
6574 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6575 errmsg = (char_u *)N_("E528: Must specify a ' value");
6576 }
6577#endif /* FEAT_VIMINFO */
6578
6579 /* terminal options */
6580 else if (istermoption(&options[opt_idx]) && full_screen)
6581 {
6582 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6583 if (varp == &T_CCO)
6584 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006585 int colors = atoi((char *)T_CCO);
6586
6587 /* Only reinitialize colors if t_Co value has really changed to
6588 * avoid expensive reload of colorscheme if t_Co is set to the
6589 * same value multiple times. */
6590 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006591 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006592 t_colors = colors;
6593 if (t_colors <= 1)
6594 {
6595 if (new_value_alloced)
6596 vim_free(T_CCO);
6597 T_CCO = empty_option;
6598 }
6599 /* We now have a different color setup, initialize it again. */
6600 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006601 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006602 }
6603 ttest(FALSE);
6604 if (varp == &T_ME)
6605 {
6606 out_str(T_ME);
6607 redraw_later(CLEAR);
Bram Moolenaar48e330a2016-02-23 14:53:34 +01006608#if defined(WIN3264) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006609 /* Since t_me has been set, this probably means that the user
6610 * wants to use this as default colors. Need to reset default
6611 * background/foreground colors. */
6612 mch_set_normal_colors();
6613#endif
6614 }
6615 }
6616
6617#ifdef FEAT_LINEBREAK
6618 /* 'showbreak' */
6619 else if (varp == &p_sbr)
6620 {
6621 for (s = p_sbr; *s; )
6622 {
6623 if (ptr2cells(s) != 1)
6624 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006625 mb_ptr_adv(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006626 }
6627 }
6628#endif
6629
6630#ifdef FEAT_GUI
6631 /* 'guifont' */
6632 else if (varp == &p_guifont)
6633 {
6634 if (gui.in_use)
6635 {
6636 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006637# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006638 /*
6639 * Put up a font dialog and let the user select a new value.
6640 * If this is cancelled go back to the old value but don't
6641 * give an error message.
6642 */
6643 if (STRCMP(p, "*") == 0)
6644 {
6645 p = gui_mch_font_dialog(oldval);
6646
6647 if (new_value_alloced)
6648 free_string_option(p_guifont);
6649
6650 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6651 new_value_alloced = TRUE;
6652 }
6653# endif
6654 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6655 {
6656# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6657 if (STRCMP(p_guifont, "*") == 0)
6658 {
6659 /* Dialog was cancelled: Keep the old value without giving
6660 * an error message. */
6661 if (new_value_alloced)
6662 free_string_option(p_guifont);
6663 p_guifont = vim_strsave(oldval);
6664 new_value_alloced = TRUE;
6665 }
6666 else
6667# endif
6668 errmsg = (char_u *)N_("E596: Invalid font(s)");
6669 }
6670 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006671 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006672 }
6673# ifdef FEAT_XFONTSET
6674 else if (varp == &p_guifontset)
6675 {
6676 if (STRCMP(p_guifontset, "*") == 0)
6677 errmsg = (char_u *)N_("E597: can't select fontset");
6678 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6679 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006680 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006681 }
6682# endif
6683# ifdef FEAT_MBYTE
6684 else if (varp == &p_guifontwide)
6685 {
6686 if (STRCMP(p_guifontwide, "*") == 0)
6687 errmsg = (char_u *)N_("E533: can't select wide font");
6688 else if (gui_get_wide_font() == FAIL)
6689 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006690 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006691 }
6692# endif
6693#endif
6694
6695#ifdef CURSOR_SHAPE
6696 /* 'guicursor' */
6697 else if (varp == &p_guicursor)
6698 errmsg = parse_shape_opt(SHAPE_CURSOR);
6699#endif
6700
6701#ifdef FEAT_MOUSESHAPE
6702 /* 'mouseshape' */
6703 else if (varp == &p_mouseshape)
6704 {
6705 errmsg = parse_shape_opt(SHAPE_MOUSE);
6706 update_mouseshape(-1);
6707 }
6708#endif
6709
6710#ifdef FEAT_PRINTER
6711 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006712 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006713# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006714 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006715 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006716# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006717#endif
6718
6719#ifdef FEAT_LANGMAP
6720 /* 'langmap' */
6721 else if (varp == &p_langmap)
6722 langmap_set();
6723#endif
6724
6725#ifdef FEAT_LINEBREAK
6726 /* 'breakat' */
6727 else if (varp == &p_breakat)
6728 fill_breakat_flags();
6729#endif
6730
6731#ifdef FEAT_TITLE
6732 /* 'titlestring' and 'iconstring' */
6733 else if (varp == &p_titlestring || varp == &p_iconstring)
6734 {
6735# ifdef FEAT_STL_OPT
6736 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6737
6738 /* NULL => statusline syntax */
6739 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6740 stl_syntax |= flagval;
6741 else
6742 stl_syntax &= ~flagval;
6743# endif
6744 did_set_title(varp == &p_iconstring);
6745
6746 }
6747#endif
6748
6749#ifdef FEAT_GUI
6750 /* 'guioptions' */
6751 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006752 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006753 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006754 redraw_gui_only = TRUE;
6755 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006756#endif
6757
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006758#if defined(FEAT_GUI_TABLINE)
6759 /* 'guitablabel' */
6760 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006761 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006762 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006763 redraw_gui_only = TRUE;
6764 }
6765 /* 'guitabtooltip' */
6766 else if (varp == &p_gtt)
6767 {
6768 redraw_gui_only = TRUE;
6769 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006770#endif
6771
Bram Moolenaar071d4272004-06-13 20:20:40 +00006772#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6773 /* 'ttymouse' */
6774 else if (varp == &p_ttym)
6775 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006776 /* Switch the mouse off before changing the escape sequences used for
6777 * that. */
6778 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006779 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6780 errmsg = e_invarg;
6781 else
6782 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006783 if (termcap_active)
6784 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006785 }
6786#endif
6787
Bram Moolenaar071d4272004-06-13 20:20:40 +00006788 /* 'selection' */
6789 else if (varp == &p_sel)
6790 {
6791 if (*p_sel == NUL
6792 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6793 errmsg = e_invarg;
6794 }
6795
6796 /* 'selectmode' */
6797 else if (varp == &p_slm)
6798 {
6799 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6800 errmsg = e_invarg;
6801 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006802
6803#ifdef FEAT_BROWSE
6804 /* 'browsedir' */
6805 else if (varp == &p_bsdir)
6806 {
6807 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
6808 && !mch_isdir(p_bsdir))
6809 errmsg = e_invarg;
6810 }
6811#endif
6812
Bram Moolenaar071d4272004-06-13 20:20:40 +00006813 /* 'keymodel' */
6814 else if (varp == &p_km)
6815 {
6816 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
6817 errmsg = e_invarg;
6818 else
6819 {
6820 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
6821 km_startsel = (vim_strchr(p_km, 'a') != NULL);
6822 }
6823 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006824
6825 /* 'mousemodel' */
6826 else if (varp == &p_mousem)
6827 {
6828 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
6829 errmsg = e_invarg;
6830#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
6831 else if (*p_mousem != *oldval)
6832 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
6833 * to create or delete the popup menus. */
6834 gui_motif_update_mousemodel(root_menu);
6835#endif
6836 }
6837
6838 /* 'switchbuf' */
6839 else if (varp == &p_swb)
6840 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00006841 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006842 errmsg = e_invarg;
6843 }
6844
6845 /* 'debug' */
6846 else if (varp == &p_debug)
6847 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00006848 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006849 errmsg = e_invarg;
6850 }
6851
6852 /* 'display' */
6853 else if (varp == &p_dy)
6854 {
6855 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
6856 errmsg = e_invarg;
6857 else
6858 (void)init_chartab();
6859
6860 }
6861
Bram Moolenaar44a2f922016-03-19 22:11:51 +01006862#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00006863 /* 'eadirection' */
6864 else if (varp == &p_ead)
6865 {
6866 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
6867 errmsg = e_invarg;
6868 }
6869#endif
6870
6871#ifdef FEAT_CLIPBOARD
6872 /* 'clipboard' */
6873 else if (varp == &p_cb)
6874 errmsg = check_clipboard_option();
6875#endif
6876
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00006877#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006878 /* When 'spelllang' or 'spellfile' is set and there is a window for this
6879 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006880 else if (varp == &(curwin->w_s->b_p_spl)
6881 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00006882 {
Bram Moolenaare68c25c2015-08-25 15:39:55 +02006883 errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf));
Bram Moolenaar217ad922005-03-20 22:37:15 +00006884 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006885 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006886 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006887 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006888 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006889 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006890 /* 'spellsuggest' */
6891 else if (varp == &p_sps)
6892 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00006893 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006894 errmsg = e_invarg;
6895 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00006896 /* 'mkspellmem' */
6897 else if (varp == &p_msm)
6898 {
6899 if (spell_check_msm() != OK)
6900 errmsg = e_invarg;
6901 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006902#endif
6903
Bram Moolenaar071d4272004-06-13 20:20:40 +00006904#ifdef FEAT_QUICKFIX
6905 /* When 'bufhidden' is set, check for valid value. */
6906 else if (gvarp == &p_bh)
6907 {
6908 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
6909 errmsg = e_invarg;
6910 }
6911
6912 /* When 'buftype' is set, check for valid value. */
6913 else if (gvarp == &p_bt)
6914 {
6915 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
6916 errmsg = e_invarg;
6917 else
6918 {
6919# ifdef FEAT_WINDOWS
6920 if (curwin->w_status_height)
6921 {
6922 curwin->w_redr_status = TRUE;
6923 redraw_later(VALID);
6924 }
6925# endif
6926 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar5075aad2010-01-27 15:58:13 +01006927# ifdef FEAT_TITLE
6928 redraw_titles();
6929# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006930 }
6931 }
6932#endif
6933
6934#ifdef FEAT_STL_OPT
6935 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006936 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006937 {
6938 int wid;
6939
6940 if (varp == &p_ruf) /* reset ru_wid first */
6941 ru_wid = 0;
6942 s = *varp;
6943 if (varp == &p_ruf && *s == '%')
6944 {
6945 /* set ru_wid if 'ruf' starts with "%99(" */
6946 if (*++s == '-') /* ignore a '-' */
6947 s++;
6948 wid = getdigits(&s);
6949 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
6950 ru_wid = wid;
6951 else
6952 errmsg = check_stl_option(p_ruf);
6953 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00006954 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00006955 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006956 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006957 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006958 comp_col();
6959 }
6960#endif
6961
6962#ifdef FEAT_INS_EXPAND
6963 /* check if it is a valid value for 'complete' -- Acevedo */
6964 else if (gvarp == &p_cpt)
6965 {
6966 for (s = *varp; *s;)
6967 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02006968 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006969 s++;
6970 if (!*s)
6971 break;
6972 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
6973 {
6974 errmsg = illegal_char(errbuf, *s);
6975 break;
6976 }
6977 if (*++s != NUL && *s != ',' && *s != ' ')
6978 {
6979 if (s[-1] == 'k' || s[-1] == 's')
6980 {
6981 /* skip optional filename after 'k' and 's' */
6982 while (*s && *s != ',' && *s != ' ')
6983 {
6984 if (*s == '\\')
6985 ++s;
6986 ++s;
6987 }
6988 }
6989 else
6990 {
6991 if (errbuf != NULL)
6992 {
6993 sprintf((char *)errbuf,
6994 _("E535: Illegal character after <%c>"),
6995 *--s);
6996 errmsg = errbuf;
6997 }
6998 else
6999 errmsg = (char_u *)"";
7000 break;
7001 }
7002 }
7003 }
7004 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007005
7006 /* 'completeopt' */
7007 else if (varp == &p_cot)
7008 {
7009 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
7010 errmsg = e_invarg;
Bram Moolenaarc0200422016-04-20 12:02:02 +02007011 else
7012 completeopt_was_set();
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007013 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007014#endif /* FEAT_INS_EXPAND */
7015
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02007016#ifdef FEAT_SIGNS
7017 /* 'signcolumn' */
7018 else if (varp == &curwin->w_p_scl)
7019 {
7020 if (check_opt_strings(*varp, p_scl_values, FALSE) != OK)
7021 errmsg = e_invarg;
7022 }
7023#endif
7024
Bram Moolenaar071d4272004-06-13 20:20:40 +00007025
7026#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007027 /* 'toolbar' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007028 else if (varp == &p_toolbar)
7029 {
7030 if (opt_strings_flags(p_toolbar, p_toolbar_values,
7031 &toolbar_flags, TRUE) != OK)
7032 errmsg = e_invarg;
7033 else
7034 {
7035 out_flush();
7036 gui_mch_show_toolbar((toolbar_flags &
7037 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7038 }
7039 }
7040#endif
7041
Bram Moolenaar182c5be2010-06-25 05:37:59 +02007042#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007043 /* 'toolbariconsize': GTK+ 2 only */
7044 else if (varp == &p_tbis)
7045 {
7046 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
7047 errmsg = e_invarg;
7048 else
7049 {
7050 out_flush();
7051 gui_mch_show_toolbar((toolbar_flags &
7052 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7053 }
7054 }
7055#endif
7056
7057 /* 'pastetoggle': translate key codes like in a mapping */
7058 else if (varp == &p_pt)
7059 {
7060 if (*p_pt)
7061 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00007062 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007063 if (p != NULL)
7064 {
7065 if (new_value_alloced)
7066 free_string_option(p_pt);
7067 p_pt = p;
7068 new_value_alloced = TRUE;
7069 }
7070 }
7071 }
7072
7073 /* 'backspace' */
7074 else if (varp == &p_bs)
7075 {
7076 if (VIM_ISDIGIT(*p_bs))
7077 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01007078 if (*p_bs > '2' || p_bs[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007079 errmsg = e_invarg;
7080 }
7081 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
7082 errmsg = e_invarg;
7083 }
Bram Moolenaar165bc692015-07-21 17:53:25 +02007084 else if (varp == &p_bo)
7085 {
7086 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK)
7087 errmsg = e_invarg;
7088 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007089
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01007090 /* 'tagcase' */
7091 else if (gvarp == &p_tc)
7092 {
7093 unsigned int *flags;
7094
7095 if (opt_flags & OPT_LOCAL)
7096 {
7097 p = curbuf->b_p_tc;
7098 flags = &curbuf->b_tc_flags;
7099 }
7100 else
7101 {
7102 p = p_tc;
7103 flags = &tc_flags;
7104 }
7105
7106 if ((opt_flags & OPT_LOCAL) && *p == NUL)
7107 /* make the local value empty: use the global value */
7108 *flags = 0;
7109 else if (*p == NUL
7110 || opt_strings_flags(p, p_tc_values, flags, FALSE) != OK)
7111 errmsg = e_invarg;
7112 }
7113
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007114#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007115 /* 'casemap' */
7116 else if (varp == &p_cmp)
7117 {
7118 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
7119 errmsg = e_invarg;
7120 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007121#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007122
7123#ifdef FEAT_DIFF
7124 /* 'diffopt' */
7125 else if (varp == &p_dip)
7126 {
7127 if (diffopt_changed() == FAIL)
7128 errmsg = e_invarg;
7129 }
7130#endif
7131
7132#ifdef FEAT_FOLDING
7133 /* 'foldmethod' */
7134 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7135 {
7136 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7137 || *curwin->w_p_fdm == NUL)
7138 errmsg = e_invarg;
7139 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007140 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007141 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007142 if (foldmethodIsDiff(curwin))
7143 newFoldLevel();
7144 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007145 }
7146# ifdef FEAT_EVAL
7147 /* 'foldexpr' */
7148 else if (varp == &curwin->w_p_fde)
7149 {
7150 if (foldmethodIsExpr(curwin))
7151 foldUpdateAll(curwin);
7152 }
7153# endif
7154 /* 'foldmarker' */
7155 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7156 {
7157 p = vim_strchr(*varp, ',');
7158 if (p == NULL)
7159 errmsg = (char_u *)N_("E536: comma required");
7160 else if (p == *varp || p[1] == NUL)
7161 errmsg = e_invarg;
7162 else if (foldmethodIsMarker(curwin))
7163 foldUpdateAll(curwin);
7164 }
7165 /* 'commentstring' */
7166 else if (gvarp == &p_cms)
7167 {
7168 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7169 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7170 }
7171 /* 'foldopen' */
7172 else if (varp == &p_fdo)
7173 {
7174 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7175 errmsg = e_invarg;
7176 }
7177 /* 'foldclose' */
7178 else if (varp == &p_fcl)
7179 {
7180 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7181 errmsg = e_invarg;
7182 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007183 /* 'foldignore' */
7184 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7185 {
7186 if (foldmethodIsIndent(curwin))
7187 foldUpdateAll(curwin);
7188 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007189#endif
7190
7191#ifdef FEAT_VIRTUALEDIT
7192 /* 'virtualedit' */
7193 else if (varp == &p_ve)
7194 {
7195 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7196 errmsg = e_invarg;
7197 else if (STRCMP(p_ve, oldval) != 0)
7198 {
7199 /* Recompute cursor position in case the new 've' setting
7200 * changes something. */
7201 validate_virtcol();
7202 coladvance(curwin->w_virtcol);
7203 }
7204 }
7205#endif
7206
7207#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7208 else if (varp == &p_csqf)
7209 {
7210 if (p_csqf != NULL)
7211 {
7212 p = p_csqf;
7213 while (*p != NUL)
7214 {
7215 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7216 || p[1] == NUL
7217 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7218 || (p[2] != NUL && p[2] != ','))
7219 {
7220 errmsg = e_invarg;
7221 break;
7222 }
7223 else if (p[2] == NUL)
7224 break;
7225 else
7226 p += 3;
7227 }
7228 }
7229 }
7230#endif
7231
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007232#ifdef FEAT_CINDENT
7233 /* 'cinoptions' */
7234 else if (gvarp == &p_cino)
7235 {
7236 /* TODO: recognize errors */
7237 parse_cino(curbuf);
7238 }
7239#endif
7240
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007241#if defined(FEAT_RENDER_OPTIONS)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007242 /* 'renderoptions' */
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007243 else if (varp == &p_rop && gui.in_use)
7244 {
7245 if (!gui_mch_set_rendering_options(p_rop))
7246 errmsg = e_invarg;
7247 }
7248#endif
7249
Bram Moolenaard0b51382016-11-04 15:23:45 +01007250#ifdef FEAT_AUTOCMD
7251 else if (gvarp == &p_ft)
7252 {
7253 if (!valid_filetype(*varp))
7254 errmsg = e_invarg;
7255 }
7256#endif
7257
7258#ifdef FEAT_SYN_HL
7259 else if (gvarp == &p_syn)
7260 {
7261 if (!valid_filetype(*varp))
7262 errmsg = e_invarg;
7263 }
7264#endif
7265
Bram Moolenaar071d4272004-06-13 20:20:40 +00007266 /* Options that are a list of flags. */
7267 else
7268 {
7269 p = NULL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007270 if (varp == &p_ww) /* 'whichwrap' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007271 p = (char_u *)WW_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007272 if (varp == &p_shm) /* 'shortmess' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007273 p = (char_u *)SHM_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007274 else if (varp == &(p_cpo)) /* 'cpoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007275 p = (char_u *)CPO_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007276 else if (varp == &(curbuf->b_p_fo)) /* 'formatoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007277 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007278#ifdef FEAT_CONCEAL
Bram Moolenaar031cb742016-11-24 21:46:19 +01007279 else if (varp == &curwin->w_p_cocu) /* 'concealcursor' */
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007280 p = (char_u *)COCU_ALL;
7281#endif
Bram Moolenaar031cb742016-11-24 21:46:19 +01007282 else if (varp == &p_mouse) /* 'mouse' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007283 {
7284#ifdef FEAT_MOUSE
7285 p = (char_u *)MOUSE_ALL;
7286#else
7287 if (*p_mouse != NUL)
7288 errmsg = (char_u *)N_("E538: No mouse support");
7289#endif
7290 }
7291#if defined(FEAT_GUI)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007292 else if (varp == &p_go) /* 'guioptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007293 p = (char_u *)GO_ALL;
7294#endif
7295 if (p != NULL)
7296 {
7297 for (s = *varp; *s; ++s)
7298 if (vim_strchr(p, *s) == NULL)
7299 {
7300 errmsg = illegal_char(errbuf, *s);
7301 break;
7302 }
7303 }
7304 }
7305
7306 /*
7307 * If error detected, restore the previous value.
7308 */
7309 if (errmsg != NULL)
7310 {
7311 if (new_value_alloced)
7312 free_string_option(*varp);
7313 *varp = oldval;
7314 /*
7315 * When resetting some values, need to act on it.
7316 */
7317 if (did_chartab)
7318 (void)init_chartab();
7319 if (varp == &p_hl)
7320 (void)highlight_changed();
7321 }
7322 else
7323 {
7324#ifdef FEAT_EVAL
7325 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007326 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007327#endif
7328 /*
7329 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007330 * Use "free_oldval", because recursiveness may change the flags under
7331 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007332 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007333 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007334 free_string_option(oldval);
7335 if (new_value_alloced)
7336 options[opt_idx].flags |= P_ALLOCED;
7337 else
7338 options[opt_idx].flags &= ~P_ALLOCED;
7339
7340 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007341 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007342 {
7343 /* global option with local value set to use global value; free
7344 * the local value and make it empty */
7345 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7346 free_string_option(*(char_u **)p);
7347 *(char_u **)p = empty_option;
7348 }
7349
7350 /* May set global value for local option. */
7351 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7352 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007353
7354#ifdef FEAT_AUTOCMD
7355 /*
7356 * Trigger the autocommand only after setting the flags.
7357 */
7358# ifdef FEAT_SYN_HL
7359 /* When 'syntax' is set, load the syntax of that name */
7360 if (varp == &(curbuf->b_p_syn))
7361 {
7362 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7363 curbuf->b_fname, TRUE, curbuf);
7364 }
7365# endif
7366 else if (varp == &(curbuf->b_p_ft))
7367 {
7368 /* 'filetype' is set, trigger the FileType autocommand */
7369 did_filetype = TRUE;
7370 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
7371 curbuf->b_fname, TRUE, curbuf);
7372 }
7373#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007374#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007375 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007376 {
7377 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007378 char_u *q = curwin->w_s->b_p_spl;
7379
7380 /* Skip the first name if it is "cjk". */
7381 if (STRNCMP(q, "cjk,", 4) == 0)
7382 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007383
7384 /*
7385 * Source the spell/LANG.vim in 'runtimepath'.
7386 * They could set 'spellcapcheck' depending on the language.
7387 * Use the first name in 'spelllang' up to '_region' or
7388 * '.encoding'.
7389 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007390 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007391 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7392 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007393 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar7f8989d2016-03-12 22:11:39 +01007394 source_runtime(fname, DIP_ALL);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007395 }
7396#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007397 }
7398
7399#ifdef FEAT_MOUSE
7400 if (varp == &p_mouse)
7401 {
7402# ifdef FEAT_MOUSE_TTY
7403 if (*p_mouse == NUL)
7404 mch_setmouse(FALSE); /* switch mouse off */
7405 else
7406# endif
7407 setmouse(); /* in case 'mouse' changed */
7408 }
7409#endif
7410
Bram Moolenaar913077c2012-03-28 19:59:04 +02007411 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007412 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007413 curwin->w_set_curswant = TRUE;
7414
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007415#ifdef FEAT_GUI
7416 /* check redraw when it's not a GUI option or the GUI is active. */
7417 if (!redraw_gui_only || gui.in_use)
7418#endif
7419 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007420
7421 return errmsg;
7422}
7423
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007424#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007425/*
7426 * Simple int comparison function for use with qsort()
7427 */
7428 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01007429int_cmp(const void *a, const void *b)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007430{
7431 return *(const int *)a - *(const int *)b;
7432}
7433
7434/*
7435 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7436 * Returns error message, NULL if it's OK.
7437 */
7438 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007439check_colorcolumn(win_T *wp)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007440{
7441 char_u *s;
7442 int col;
7443 int count = 0;
7444 int color_cols[256];
7445 int i;
7446 int j = 0;
7447
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007448 if (wp->w_buffer == NULL)
7449 return NULL; /* buffer was closed */
7450
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007451 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007452 {
7453 if (*s == '-' || *s == '+')
7454 {
7455 /* -N and +N: add to 'textwidth' */
7456 col = (*s == '-') ? -1 : 1;
7457 ++s;
7458 if (!VIM_ISDIGIT(*s))
7459 return e_invarg;
7460 col = col * getdigits(&s);
7461 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007462 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007463 col += wp->w_buffer->b_p_tw;
7464 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007465 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007466 }
7467 else if (VIM_ISDIGIT(*s))
7468 col = getdigits(&s);
7469 else
7470 return e_invarg;
7471 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007472skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007473 if (*s == NUL)
7474 break;
7475 if (*s != ',')
7476 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007477 if (*++s == NUL)
7478 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007479 }
7480
7481 vim_free(wp->w_p_cc_cols);
7482 if (count == 0)
7483 wp->w_p_cc_cols = NULL;
7484 else
7485 {
7486 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7487 if (wp->w_p_cc_cols != NULL)
7488 {
7489 /* sort the columns for faster usage on screen redraw inside
7490 * win_line() */
7491 qsort(color_cols, count, sizeof(int), int_cmp);
7492
7493 for (i = 0; i < count; ++i)
7494 /* skip duplicates */
7495 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7496 wp->w_p_cc_cols[j++] = color_cols[i];
7497 wp->w_p_cc_cols[j] = -1; /* end marker */
7498 }
7499 }
7500
7501 return NULL; /* no error */
7502}
7503#endif
7504
Bram Moolenaar071d4272004-06-13 20:20:40 +00007505/*
7506 * Handle setting 'listchars' or 'fillchars'.
7507 * Returns error message, NULL if it's OK.
7508 */
7509 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007510set_chars_option(char_u **varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007511{
7512 int round, i, len, entries;
7513 char_u *p, *s;
7514 int c1, c2 = 0;
7515 struct charstab
7516 {
7517 int *cp;
7518 char *name;
7519 };
7520#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7521 static struct charstab filltab[] =
7522 {
7523 {&fill_stl, "stl"},
7524 {&fill_stlnc, "stlnc"},
7525 {&fill_vert, "vert"},
7526 {&fill_fold, "fold"},
7527 {&fill_diff, "diff"},
7528 };
7529#endif
7530 static struct charstab lcstab[] =
7531 {
7532 {&lcs_eol, "eol"},
7533 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007534 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007535 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007536 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007537 {&lcs_tab2, "tab"},
7538 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007539#ifdef FEAT_CONCEAL
7540 {&lcs_conceal, "conceal"},
7541#else
7542 {NULL, "conceal"},
7543#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007544 };
7545 struct charstab *tab;
7546
7547#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7548 if (varp == &p_lcs)
7549#endif
7550 {
7551 tab = lcstab;
7552 entries = sizeof(lcstab) / sizeof(struct charstab);
7553 }
7554#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7555 else
7556 {
7557 tab = filltab;
7558 entries = sizeof(filltab) / sizeof(struct charstab);
7559 }
7560#endif
7561
7562 /* first round: check for valid value, second round: assign values */
7563 for (round = 0; round <= 1; ++round)
7564 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007565 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007566 {
7567 /* After checking that the value is valid: set defaults: space for
7568 * 'fillchars', NUL for 'listchars' */
7569 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007570 if (tab[i].cp != NULL)
7571 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007572 if (varp == &p_lcs)
7573 lcs_tab1 = NUL;
7574#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7575 else
7576 fill_diff = '-';
7577#endif
7578 }
7579 p = *varp;
7580 while (*p)
7581 {
7582 for (i = 0; i < entries; ++i)
7583 {
7584 len = (int)STRLEN(tab[i].name);
7585 if (STRNCMP(p, tab[i].name, len) == 0
7586 && p[len] == ':'
7587 && p[len + 1] != NUL)
7588 {
7589 s = p + len + 1;
7590#ifdef FEAT_MBYTE
7591 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007592 if (mb_char2cells(c1) > 1)
7593 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007594#else
7595 c1 = *s++;
7596#endif
7597 if (tab[i].cp == &lcs_tab2)
7598 {
7599 if (*s == NUL)
7600 continue;
7601#ifdef FEAT_MBYTE
7602 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007603 if (mb_char2cells(c2) > 1)
7604 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007605#else
7606 c2 = *s++;
7607#endif
7608 }
7609 if (*s == ',' || *s == NUL)
7610 {
7611 if (round)
7612 {
7613 if (tab[i].cp == &lcs_tab2)
7614 {
7615 lcs_tab1 = c1;
7616 lcs_tab2 = c2;
7617 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007618 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007619 *(tab[i].cp) = c1;
7620
7621 }
7622 p = s;
7623 break;
7624 }
7625 }
7626 }
7627
7628 if (i == entries)
7629 return e_invarg;
7630 if (*p == ',')
7631 ++p;
7632 }
7633 }
7634
7635 return NULL; /* no error */
7636}
7637
7638#ifdef FEAT_STL_OPT
7639/*
7640 * Check validity of options with the 'statusline' format.
7641 * Return error message or NULL.
7642 */
7643 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007644check_stl_option(char_u *s)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007645{
7646 int itemcnt = 0;
7647 int groupdepth = 0;
7648 static char_u errbuf[80];
7649
7650 while (*s && itemcnt < STL_MAX_ITEM)
7651 {
7652 /* Check for valid keys after % sequences */
7653 while (*s && *s != '%')
7654 s++;
7655 if (!*s)
7656 break;
7657 s++;
7658 if (*s != '%' && *s != ')')
7659 ++itemcnt;
7660 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7661 {
7662 s++;
7663 continue;
7664 }
7665 if (*s == ')')
7666 {
7667 s++;
7668 if (--groupdepth < 0)
7669 break;
7670 continue;
7671 }
7672 if (*s == '-')
7673 s++;
7674 while (VIM_ISDIGIT(*s))
7675 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007676 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007677 continue;
7678 if (*s == '.')
7679 {
7680 s++;
7681 while (*s && VIM_ISDIGIT(*s))
7682 s++;
7683 }
7684 if (*s == '(')
7685 {
7686 groupdepth++;
7687 continue;
7688 }
7689 if (vim_strchr(STL_ALL, *s) == NULL)
7690 {
7691 return illegal_char(errbuf, *s);
7692 }
7693 if (*s == '{')
7694 {
7695 s++;
7696 while (*s != '}' && *s)
7697 s++;
7698 if (*s != '}')
7699 return (char_u *)N_("E540: Unclosed expression sequence");
7700 }
7701 }
7702 if (itemcnt >= STL_MAX_ITEM)
7703 return (char_u *)N_("E541: too many items");
7704 if (groupdepth != 0)
7705 return (char_u *)N_("E542: unbalanced groups");
7706 return NULL;
7707}
7708#endif
7709
7710#ifdef FEAT_CLIPBOARD
7711/*
7712 * Extract the items in the 'clipboard' option and set global values.
7713 */
7714 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007715check_clipboard_option(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007716{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007717 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007718 int new_autoselect_star = FALSE;
7719 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007720 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007721 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007722 regprog_T *new_exclude_prog = NULL;
7723 char_u *errmsg = NULL;
7724 char_u *p;
7725
7726 for (p = p_cb; *p != NUL; )
7727 {
7728 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7729 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007730 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007731 p += 7;
7732 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007733 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007734 && (p[11] == ',' || p[11] == NUL))
7735 {
7736 new_unnamed |= CLIP_UNNAMED_PLUS;
7737 p += 11;
7738 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007739 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007740 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007741 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007742 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007743 p += 10;
7744 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007745 else if (STRNCMP(p, "autoselectplus", 14) == 0
7746 && (p[14] == ',' || p[14] == NUL))
7747 {
7748 new_autoselect_plus = TRUE;
7749 p += 14;
7750 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007751 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007752 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007753 {
7754 new_autoselectml = TRUE;
7755 p += 12;
7756 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007757 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7758 {
7759 new_html = TRUE;
7760 p += 4;
7761 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007762 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7763 {
7764 p += 8;
7765 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7766 if (new_exclude_prog == NULL)
7767 errmsg = e_invarg;
7768 break;
7769 }
7770 else
7771 {
7772 errmsg = e_invarg;
7773 break;
7774 }
7775 if (*p == ',')
7776 ++p;
7777 }
7778 if (errmsg == NULL)
7779 {
7780 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007781 clip_autoselect_star = new_autoselect_star;
7782 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007783 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007784 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02007785 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007786 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02007787#ifdef FEAT_GUI_GTK
7788 if (gui.in_use)
7789 {
7790 gui_gtk_set_selection_targets();
7791 gui_gtk_set_dnd_targets();
7792 }
7793#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007794 }
7795 else
Bram Moolenaar473de612013-06-08 18:19:48 +02007796 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007797
7798 return errmsg;
7799}
7800#endif
7801
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007802#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007803 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007804did_set_spell_option(int is_spellfile)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007805{
7806 char_u *errmsg = NULL;
7807 win_T *wp;
7808 int l;
7809
7810 if (is_spellfile)
7811 {
7812 l = (int)STRLEN(curwin->w_s->b_p_spf);
7813 if (l > 0 && (l < 4
7814 || STRCMP(curwin->w_s->b_p_spf + l - 4, ".add") != 0))
7815 errmsg = e_invarg;
7816 }
7817
7818 if (errmsg == NULL)
7819 {
7820 FOR_ALL_WINDOWS(wp)
7821 if (wp->w_buffer == curbuf && wp->w_p_spell)
7822 {
7823 errmsg = did_set_spelllang(wp);
7824# ifdef FEAT_WINDOWS
7825 break;
7826# endif
7827 }
7828 }
7829 return errmsg;
7830}
7831
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007832/*
7833 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
7834 * Return error message when failed, NULL when OK.
7835 */
7836 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007837compile_cap_prog(synblock_T *synblock)
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007838{
Bram Moolenaar860cae12010-06-05 23:22:07 +02007839 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007840 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007841
Bram Moolenaar860cae12010-06-05 23:22:07 +02007842 if (*synblock->b_p_spc == NUL)
7843 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007844 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007845 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007846 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007847 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007848 if (re != NULL)
7849 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007850 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02007851 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02007852 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007853 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007854 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007855 return e_invarg;
7856 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007857 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007858 }
7859
Bram Moolenaar473de612013-06-08 18:19:48 +02007860 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007861 return NULL;
7862}
7863#endif
7864
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007865#if defined(FEAT_EVAL) || defined(PROTO)
7866/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007867 * Set the scriptID for an option, taking care of setting the buffer- or
7868 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007869 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007870 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01007871set_option_scriptID_idx(int opt_idx, int opt_flags, int id)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007872{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007873 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
7874 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007875
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007876 /* Remember where the option was set. For local options need to do that
7877 * in the buffer or window structure. */
7878 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007879 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007880 if (both || (opt_flags & OPT_LOCAL))
7881 {
7882 if (indir & PV_BUF)
7883 curbuf->b_p_scriptID[indir & PV_MASK] = id;
7884 else if (indir & PV_WIN)
7885 curwin->w_p_scriptID[indir & PV_MASK] = id;
7886 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007887}
7888#endif
7889
Bram Moolenaar071d4272004-06-13 20:20:40 +00007890/*
7891 * Set the value of a boolean option, and take care of side effects.
7892 * Returns NULL for success, or an error message for an error.
7893 */
7894 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007895set_bool_option(
7896 int opt_idx, /* index in options[] table */
7897 char_u *varp, /* pointer to the option variable */
7898 int value, /* new value */
7899 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007900{
7901 int old_value = *(int *)varp;
7902
Bram Moolenaar071d4272004-06-13 20:20:40 +00007903 /* Disallow changing some options from secure mode */
7904 if ((secure
7905#ifdef HAVE_SANDBOX
7906 || sandbox != 0
7907#endif
7908 ) && (options[opt_idx].flags & P_SECURE))
7909 return e_secure;
7910
7911 *(int *)varp = value; /* set the new value */
7912#ifdef FEAT_EVAL
7913 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007914 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007915#endif
7916
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00007917#ifdef FEAT_GUI
7918 need_mouse_correct = TRUE;
7919#endif
7920
Bram Moolenaar071d4272004-06-13 20:20:40 +00007921 /* May set global value for local option. */
7922 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
7923 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
7924
7925 /*
7926 * Handle side effects of changing a bool option.
7927 */
7928
7929 /* 'compatible' */
7930 if ((int *)varp == &p_cp)
7931 {
7932 compatible_set();
7933 }
7934
Bram Moolenaar920694c2016-08-21 17:45:02 +02007935#ifdef FEAT_LANGMAP
7936 if ((int *)varp == &p_lrm)
7937 /* 'langremap' -> !'langnoremap' */
7938 p_lnr = !p_lrm;
7939 else if ((int *)varp == &p_lnr)
7940 /* 'langnoremap' -> !'langremap' */
7941 p_lrm = !p_lnr;
7942#endif
7943
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007944#ifdef FEAT_PERSISTENT_UNDO
7945 /* 'undofile' */
7946 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
7947 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007948 /* Only take action when the option was set. When reset we do not
7949 * delete the undo file, the option may be set again without making
7950 * any changes in between. */
7951 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007952 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007953 char_u hash[UNDO_HASH_SIZE];
7954 buf_T *save_curbuf = curbuf;
7955
Bram Moolenaar29323592016-07-24 22:04:11 +02007956 FOR_ALL_BUFFERS(curbuf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007957 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007958 /* When 'undofile' is set globally: for every buffer, otherwise
7959 * only for the current buffer: Try to read in the undofile,
7960 * if one exists, the buffer wasn't changed and the buffer was
7961 * loaded */
7962 if ((curbuf == save_curbuf
7963 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
7964 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
7965 {
7966 u_compute_hash(hash);
7967 u_read_undo(NULL, hash, curbuf->b_fname);
7968 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007969 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007970 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007971 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007972 }
7973#endif
7974
Bram Moolenaar071d4272004-06-13 20:20:40 +00007975 else if ((int *)varp == &curbuf->b_p_ro)
7976 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007977 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007978 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
7979 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007980
7981 /* when 'readonly' is set may give W10 again */
7982 if (curbuf->b_p_ro)
7983 curbuf->b_did_warn = FALSE;
7984
Bram Moolenaar071d4272004-06-13 20:20:40 +00007985#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007986 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007987#endif
7988 }
7989
Bram Moolenaar9c449722010-07-20 18:44:27 +02007990#ifdef FEAT_GUI
7991 else if ((int *)varp == &p_mh)
7992 {
7993 if (!p_mh)
7994 gui_mch_mousehide(FALSE);
7995 }
7996#endif
7997
Bram Moolenaara539df02010-08-01 14:35:05 +02007998#ifdef FEAT_TITLE
7999 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008000 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008001 {
8002 redraw_titles();
8003 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008004 /* when 'endofline' is changed, redraw the window title */
8005 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008006 {
8007 redraw_titles();
8008 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02008009 /* when 'fixeol' is changed, redraw the window title */
8010 else if ((int *)varp == &curbuf->b_p_fixeol)
8011 {
8012 redraw_titles();
8013 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008014# ifdef FEAT_MBYTE
8015 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00008016 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008017 {
8018 redraw_titles();
8019 }
8020# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008021#endif
8022
8023 /* when 'bin' is set also set some other options */
8024 else if ((int *)varp == &curbuf->b_p_bin)
8025 {
8026 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
8027#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008028 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008029#endif
8030 }
8031
8032#ifdef FEAT_AUTOCMD
8033 /* when 'buflisted' changes, trigger autocommands */
8034 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
8035 {
8036 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
8037 NULL, NULL, TRUE, curbuf);
8038 }
8039#endif
8040
8041 /* when 'swf' is set, create swapfile, when reset remove swapfile */
8042 else if ((int *)varp == &curbuf->b_p_swf)
8043 {
8044 if (curbuf->b_p_swf && p_uc)
8045 ml_open_file(curbuf); /* create the swap file */
8046 else
Bram Moolenaard55de222007-05-06 13:38:48 +00008047 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
8048 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008049 mf_close_file(curbuf, TRUE); /* remove the swap file */
8050 }
8051
8052 /* when 'terse' is set change 'shortmess' */
8053 else if ((int *)varp == &p_terse)
8054 {
8055 char_u *p;
8056
8057 p = vim_strchr(p_shm, SHM_SEARCH);
8058
8059 /* insert 's' in p_shm */
8060 if (p_terse && p == NULL)
8061 {
8062 STRCPY(IObuff, p_shm);
8063 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008064 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008065 }
8066 /* remove 's' from p_shm */
8067 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00008068 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008069 }
8070
8071 /* when 'paste' is set or reset also change other options */
8072 else if ((int *)varp == &p_paste)
8073 {
8074 paste_option_changed();
8075 }
8076
8077 /* when 'insertmode' is set from an autocommand need to do work here */
8078 else if ((int *)varp == &p_im)
8079 {
8080 if (p_im)
8081 {
8082 if ((State & INSERT) == 0)
8083 need_start_insertmode = TRUE;
8084 stop_insert_mode = FALSE;
8085 }
Bram Moolenaar00672e12016-06-26 18:38:13 +02008086 /* only reset if it was set previously */
8087 else if (old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008088 {
8089 need_start_insertmode = FALSE;
8090 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00008091 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008092 clear_cmdline = TRUE; /* remove "(insert)" */
8093 restart_edit = 0;
8094 }
8095 }
8096
8097 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
8098 else if ((int *)varp == &p_ic && p_hls)
8099 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008100 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008101 }
8102
8103#ifdef FEAT_SEARCH_EXTRA
8104 /* when 'hlsearch' is set or reset: reset no_hlsearch */
8105 else if ((int *)varp == &p_hls)
8106 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01008107 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008108 }
8109#endif
8110
8111#ifdef FEAT_SCROLLBIND
8112 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
8113 * at the end of normal_cmd() */
8114 else if ((int *)varp == &curwin->w_p_scb)
8115 {
8116 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008117 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00008118 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008119 curwin->w_scbind_pos = curwin->w_topline;
8120 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008121 }
8122#endif
8123
8124#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
8125 /* There can be only one window with 'previewwindow' set. */
8126 else if ((int *)varp == &curwin->w_p_pvw)
8127 {
8128 if (curwin->w_p_pvw)
8129 {
8130 win_T *win;
8131
Bram Moolenaar29323592016-07-24 22:04:11 +02008132 FOR_ALL_WINDOWS(win)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008133 if (win->w_p_pvw && win != curwin)
8134 {
8135 curwin->w_p_pvw = FALSE;
8136 return (char_u *)N_("E590: A preview window already exists");
8137 }
8138 }
8139 }
8140#endif
8141
8142 /* when 'textmode' is set or reset also change 'fileformat' */
8143 else if ((int *)varp == &curbuf->b_p_tx)
8144 {
8145 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
8146 }
8147
8148 /* when 'textauto' is set or reset also change 'fileformats' */
8149 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008150 set_string_option_direct((char_u *)"ffs", -1,
8151 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008152 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008153
8154 /*
8155 * When 'lisp' option changes include/exclude '-' in
8156 * keyword characters.
8157 */
8158#ifdef FEAT_LISP
8159 else if (varp == (char_u *)&(curbuf->b_p_lisp))
8160 {
8161 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
8162 }
8163#endif
8164
8165#ifdef FEAT_TITLE
8166 /* when 'title' changed, may need to change the title; same for 'icon' */
8167 else if ((int *)varp == &p_title)
8168 {
8169 did_set_title(FALSE);
8170 }
8171
8172 else if ((int *)varp == &p_icon)
8173 {
8174 did_set_title(TRUE);
8175 }
8176#endif
8177
8178 else if ((int *)varp == &curbuf->b_changed)
8179 {
8180 if (!value)
8181 save_file_ff(curbuf); /* Buffer is unchanged */
8182#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008183 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008184#endif
8185#ifdef FEAT_AUTOCMD
8186 modified_was_set = value;
8187#endif
8188 }
8189
8190#ifdef BACKSLASH_IN_FILENAME
8191 else if ((int *)varp == &p_ssl)
8192 {
8193 if (p_ssl)
8194 {
8195 psepc = '/';
8196 psepcN = '\\';
8197 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008198 }
8199 else
8200 {
8201 psepc = '\\';
8202 psepcN = '/';
8203 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008204 }
8205
8206 /* need to adjust the file name arguments and buffer names. */
8207 buflist_slash_adjust();
8208 alist_slash_adjust();
8209# ifdef FEAT_EVAL
8210 scriptnames_slash_adjust();
8211# endif
8212 }
8213#endif
8214
8215 /* If 'wrap' is set, set w_leftcol to zero. */
8216 else if ((int *)varp == &curwin->w_p_wrap)
8217 {
8218 if (curwin->w_p_wrap)
8219 curwin->w_leftcol = 0;
8220 }
8221
8222#ifdef FEAT_WINDOWS
8223 else if ((int *)varp == &p_ea)
8224 {
8225 if (p_ea && !old_value)
8226 win_equal(curwin, FALSE, 0);
8227 }
8228#endif
8229
8230 else if ((int *)varp == &p_wiv)
8231 {
8232 /*
8233 * When 'weirdinvert' changed, set/reset 't_xs'.
8234 * Then set 'weirdinvert' according to value of 't_xs'.
8235 */
8236 if (p_wiv && !old_value)
8237 T_XS = (char_u *)"y";
8238 else if (!p_wiv && old_value)
8239 T_XS = empty_option;
8240 p_wiv = (*T_XS != NUL);
8241 }
8242
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00008243#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00008244 else if ((int *)varp == &p_beval)
8245 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008246 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008247 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008248 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008249 gui_mch_disable_beval_area(balloonEval);
8250 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008251#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008252
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008253#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008254 else if ((int *)varp == &p_acd)
8255 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008256 /* Change directories when the 'acd' option is set now. */
8257 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008258 }
8259#endif
8260
8261#ifdef FEAT_DIFF
8262 /* 'diff' */
8263 else if ((int *)varp == &curwin->w_p_diff)
8264 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008265 /* May add or remove the buffer from the list of diff buffers. */
8266 diff_buf_adjust(curwin);
8267# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008268 if (foldmethodIsDiff(curwin))
8269 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008270# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008271 }
8272#endif
8273
8274#ifdef USE_IM_CONTROL
8275 /* 'imdisable' */
8276 else if ((int *)varp == &p_imdisable)
8277 {
8278 /* Only de-activate it here, it will be enabled when changing mode. */
8279 if (p_imdisable)
8280 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008281 else if (State & INSERT)
8282 /* When the option is set from an autocommand, it may need to take
8283 * effect right away. */
8284 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008285 }
8286#endif
8287
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008288#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008289 /* 'spell' */
8290 else if ((int *)varp == &curwin->w_p_spell)
8291 {
8292 if (curwin->w_p_spell)
8293 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008294 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008295 if (errmsg != NULL)
8296 EMSG(_(errmsg));
8297 }
8298 }
8299#endif
8300
Bram Moolenaar071d4272004-06-13 20:20:40 +00008301#ifdef FEAT_FKMAP
8302 else if ((int *)varp == &p_altkeymap)
8303 {
8304 if (old_value != p_altkeymap)
8305 {
8306 if (!p_altkeymap)
8307 {
8308 p_hkmap = p_fkmap;
8309 p_fkmap = 0;
8310 }
8311 else
8312 {
8313 p_fkmap = p_hkmap;
8314 p_hkmap = 0;
8315 }
8316 (void)init_chartab();
8317 }
8318 }
8319
8320 /*
8321 * In case some second language keymapping options have changed, check
8322 * and correct the setting in a consistent way.
8323 */
8324
8325 /*
8326 * If hkmap or fkmap are set, reset Arabic keymapping.
8327 */
8328 if ((p_hkmap || p_fkmap) && p_altkeymap)
8329 {
8330 p_altkeymap = p_fkmap;
8331# ifdef FEAT_ARABIC
8332 curwin->w_p_arab = FALSE;
8333# endif
8334 (void)init_chartab();
8335 }
8336
8337 /*
8338 * If hkmap set, reset Farsi keymapping.
8339 */
8340 if (p_hkmap && p_altkeymap)
8341 {
8342 p_altkeymap = 0;
8343 p_fkmap = 0;
8344# ifdef FEAT_ARABIC
8345 curwin->w_p_arab = FALSE;
8346# endif
8347 (void)init_chartab();
8348 }
8349
8350 /*
8351 * If fkmap set, reset Hebrew keymapping.
8352 */
8353 if (p_fkmap && !p_altkeymap)
8354 {
8355 p_altkeymap = 1;
8356 p_hkmap = 0;
8357# ifdef FEAT_ARABIC
8358 curwin->w_p_arab = FALSE;
8359# endif
8360 (void)init_chartab();
8361 }
8362#endif
8363
8364#ifdef FEAT_ARABIC
8365 if ((int *)varp == &curwin->w_p_arab)
8366 {
8367 if (curwin->w_p_arab)
8368 {
8369 /*
8370 * 'arabic' is set, handle various sub-settings.
8371 */
8372 if (!p_tbidi)
8373 {
8374 /* set rightleft mode */
8375 if (!curwin->w_p_rl)
8376 {
8377 curwin->w_p_rl = TRUE;
8378 changed_window_setting();
8379 }
8380
8381 /* Enable Arabic shaping (major part of what Arabic requires) */
8382 if (!p_arshape)
8383 {
8384 p_arshape = TRUE;
8385 redraw_later_clear();
8386 }
8387 }
8388
8389 /* Arabic requires a utf-8 encoding, inform the user if its not
8390 * set. */
8391 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008392 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008393 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8394
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008395 msg_source(hl_attr(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008396 MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
8397#ifdef FEAT_EVAL
8398 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8399#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008400 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008401
8402# ifdef FEAT_MBYTE
8403 /* set 'delcombine' */
8404 p_deco = TRUE;
8405# endif
8406
8407# ifdef FEAT_KEYMAP
8408 /* Force-set the necessary keymap for arabic */
8409 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8410 OPT_LOCAL);
8411# endif
8412# ifdef FEAT_FKMAP
8413 p_altkeymap = 0;
8414 p_hkmap = 0;
8415 p_fkmap = 0;
8416 (void)init_chartab();
8417# endif
8418 }
8419 else
8420 {
8421 /*
8422 * 'arabic' is reset, handle various sub-settings.
8423 */
8424 if (!p_tbidi)
8425 {
8426 /* reset rightleft mode */
8427 if (curwin->w_p_rl)
8428 {
8429 curwin->w_p_rl = FALSE;
8430 changed_window_setting();
8431 }
8432
8433 /* 'arabicshape' isn't reset, it is a global option and
8434 * another window may still need it "on". */
8435 }
8436
8437 /* 'delcombine' isn't reset, it is a global option and another
8438 * window may still want it "on". */
8439
8440# ifdef FEAT_KEYMAP
8441 /* Revert to the default keymap */
8442 curbuf->b_p_iminsert = B_IMODE_NONE;
8443 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8444# endif
8445 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008446 }
8447
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008448#endif
8449
Bram Moolenaar61be73b2016-04-29 22:59:22 +02008450#ifdef FEAT_TERMGUICOLORS
8451 /* 'termguicolors' */
8452 else if ((int *)varp == &p_tgc)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02008453 {
8454# ifdef FEAT_GUI
8455 if (!gui.in_use && !gui.starting)
8456# endif
8457 highlight_gui_started();
8458 }
8459#endif
8460
Bram Moolenaar071d4272004-06-13 20:20:40 +00008461 /*
8462 * End of handling side effects for bool options.
8463 */
8464
Bram Moolenaar53744302015-07-17 17:38:22 +02008465 /* after handling side effects, call autocommand */
8466
Bram Moolenaar071d4272004-06-13 20:20:40 +00008467 options[opt_idx].flags |= P_WAS_SET;
8468
Bram Moolenaar53744302015-07-17 17:38:22 +02008469#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8470 if (!starting)
8471 {
8472 char_u buf_old[2], buf_new[2], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008473 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8474 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8475 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008476 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8477 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8478 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8479 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8480 reset_v_option_vars();
8481 }
8482#endif
8483
Bram Moolenaar071d4272004-06-13 20:20:40 +00008484 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008485 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008486 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008487 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008488 check_redraw(options[opt_idx].flags);
8489
8490 return NULL;
8491}
8492
8493/*
8494 * Set the value of a number option, and take care of side effects.
8495 * Returns NULL for success, or an error message for an error.
8496 */
8497 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008498set_num_option(
8499 int opt_idx, /* index in options[] table */
8500 char_u *varp, /* pointer to the option variable */
8501 long value, /* new value */
8502 char_u *errbuf, /* buffer for error messages */
8503 size_t errbuflen, /* length of "errbuf" */
8504 int opt_flags) /* OPT_LOCAL, OPT_GLOBAL and
Bram Moolenaar071d4272004-06-13 20:20:40 +00008505 OPT_MODELINE */
8506{
8507 char_u *errmsg = NULL;
8508 long old_value = *(long *)varp;
8509 long old_Rows = Rows; /* remember old Rows */
8510 long old_Columns = Columns; /* remember old Columns */
8511 long *pp = (long *)varp;
8512
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008513 /* Disallow changing some options from secure mode. */
8514 if ((secure
8515#ifdef HAVE_SANDBOX
8516 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008517#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008518 ) && (options[opt_idx].flags & P_SECURE))
8519 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008520
8521 *pp = value;
8522#ifdef FEAT_EVAL
8523 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008524 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008525#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008526#ifdef FEAT_GUI
8527 need_mouse_correct = TRUE;
8528#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008529
Bram Moolenaar14f24742012-08-08 18:01:05 +02008530 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008531 {
8532 errmsg = e_positive;
8533 curbuf->b_p_sw = curbuf->b_p_ts;
8534 }
8535
8536 /*
8537 * Number options that need some action when changed
8538 */
8539#ifdef FEAT_WINDOWS
8540 if (pp == &p_wh || pp == &p_hh)
8541 {
8542 if (p_wh < 1)
8543 {
8544 errmsg = e_positive;
8545 p_wh = 1;
8546 }
8547 if (p_wmh > p_wh)
8548 {
8549 errmsg = e_winheight;
8550 p_wh = p_wmh;
8551 }
8552 if (p_hh < 0)
8553 {
8554 errmsg = e_positive;
8555 p_hh = 0;
8556 }
8557
8558 /* Change window height NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008559 if (!ONE_WINDOW)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008560 {
8561 if (pp == &p_wh && curwin->w_height < p_wh)
8562 win_setheight((int)p_wh);
8563 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8564 win_setheight((int)p_hh);
8565 }
8566 }
8567
8568 /* 'winminheight' */
8569 else if (pp == &p_wmh)
8570 {
8571 if (p_wmh < 0)
8572 {
8573 errmsg = e_positive;
8574 p_wmh = 0;
8575 }
8576 if (p_wmh > p_wh)
8577 {
8578 errmsg = e_winheight;
8579 p_wmh = p_wh;
8580 }
8581 win_setminheight();
8582 }
8583
Bram Moolenaar44a2f922016-03-19 22:11:51 +01008584# ifdef FEAT_WINDOWS
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008585 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008586 {
8587 if (p_wiw < 1)
8588 {
8589 errmsg = e_positive;
8590 p_wiw = 1;
8591 }
8592 if (p_wmw > p_wiw)
8593 {
8594 errmsg = e_winwidth;
8595 p_wiw = p_wmw;
8596 }
8597
8598 /* Change window width NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008599 if (!ONE_WINDOW && curwin->w_width < p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008600 win_setwidth((int)p_wiw);
8601 }
8602
8603 /* 'winminwidth' */
8604 else if (pp == &p_wmw)
8605 {
8606 if (p_wmw < 0)
8607 {
8608 errmsg = e_positive;
8609 p_wmw = 0;
8610 }
8611 if (p_wmw > p_wiw)
8612 {
8613 errmsg = e_winwidth;
8614 p_wmw = p_wiw;
8615 }
8616 win_setminheight();
8617 }
8618# endif
8619
8620#endif
8621
8622#ifdef FEAT_WINDOWS
8623 /* (re)set last window status line */
8624 else if (pp == &p_ls)
8625 {
8626 last_status(FALSE);
8627 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008628
8629 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008630 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008631 {
8632 shell_new_rows(); /* recompute window positions and heights */
8633 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008634#endif
8635
8636#ifdef FEAT_GUI
8637 else if (pp == &p_linespace)
8638 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008639 /* Recompute gui.char_height and resize the Vim window to keep the
8640 * same number of lines. */
8641 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008642 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008643 }
8644#endif
8645
8646#ifdef FEAT_FOLDING
8647 /* 'foldlevel' */
8648 else if (pp == &curwin->w_p_fdl)
8649 {
8650 if (curwin->w_p_fdl < 0)
8651 curwin->w_p_fdl = 0;
8652 newFoldLevel();
8653 }
8654
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008655 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008656 else if (pp == &curwin->w_p_fml)
8657 {
8658 foldUpdateAll(curwin);
8659 }
8660
8661 /* 'foldnestmax' */
8662 else if (pp == &curwin->w_p_fdn)
8663 {
8664 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8665 foldUpdateAll(curwin);
8666 }
8667
8668 /* 'foldcolumn' */
8669 else if (pp == &curwin->w_p_fdc)
8670 {
8671 if (curwin->w_p_fdc < 0)
8672 {
8673 errmsg = e_positive;
8674 curwin->w_p_fdc = 0;
8675 }
8676 else if (curwin->w_p_fdc > 12)
8677 {
8678 errmsg = e_invarg;
8679 curwin->w_p_fdc = 12;
8680 }
8681 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008682#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008683
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008684#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008685 /* 'shiftwidth' or 'tabstop' */
8686 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8687 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008688# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008689 if (foldmethodIsIndent(curwin))
8690 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008691# endif
8692# ifdef FEAT_CINDENT
8693 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8694 * parse 'cinoptions'. */
8695 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8696 parse_cino(curbuf);
8697# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008698 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008699#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008700
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008701#ifdef FEAT_MBYTE
8702 /* 'maxcombine' */
8703 else if (pp == &p_mco)
8704 {
8705 if (p_mco > MAX_MCO)
8706 p_mco = MAX_MCO;
8707 else if (p_mco < 0)
8708 p_mco = 0;
8709 screenclear(); /* will re-allocate the screen */
8710 }
8711#endif
8712
Bram Moolenaar071d4272004-06-13 20:20:40 +00008713 else if (pp == &curbuf->b_p_iminsert)
8714 {
8715 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8716 {
8717 errmsg = e_invarg;
8718 curbuf->b_p_iminsert = B_IMODE_NONE;
8719 }
8720 p_iminsert = curbuf->b_p_iminsert;
8721 if (termcap_active) /* don't do this in the alternate screen */
8722 showmode();
8723#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8724 /* Show/unshow value of 'keymap' in status lines. */
8725 status_redraw_curbuf();
8726#endif
8727 }
8728
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008729 else if (pp == &p_window)
8730 {
8731 if (p_window < 1)
8732 p_window = 1;
8733 else if (p_window >= Rows)
8734 p_window = Rows - 1;
8735 }
8736
Bram Moolenaar071d4272004-06-13 20:20:40 +00008737 else if (pp == &curbuf->b_p_imsearch)
8738 {
8739 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8740 {
8741 errmsg = e_invarg;
8742 curbuf->b_p_imsearch = B_IMODE_NONE;
8743 }
8744 p_imsearch = curbuf->b_p_imsearch;
8745 }
8746
8747#ifdef FEAT_TITLE
8748 /* if 'titlelen' has changed, redraw the title */
8749 else if (pp == &p_titlelen)
8750 {
8751 if (p_titlelen < 0)
8752 {
8753 errmsg = e_positive;
8754 p_titlelen = 85;
8755 }
8756 if (starting != NO_SCREEN && old_value != p_titlelen)
8757 need_maketitle = TRUE;
8758 }
8759#endif
8760
8761 /* if p_ch changed value, change the command line height */
8762 else if (pp == &p_ch)
8763 {
8764 if (p_ch < 1)
8765 {
8766 errmsg = e_positive;
8767 p_ch = 1;
8768 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008769 if (p_ch > Rows - min_rows() + 1)
8770 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008771
8772 /* Only compute the new window layout when startup has been
8773 * completed. Otherwise the frame sizes may be wrong. */
8774 if (p_ch != old_value && full_screen
8775#ifdef FEAT_GUI
8776 && !gui.starting
8777#endif
8778 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008779 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008780 }
8781
8782 /* when 'updatecount' changes from zero to non-zero, open swap files */
8783 else if (pp == &p_uc)
8784 {
8785 if (p_uc < 0)
8786 {
8787 errmsg = e_positive;
8788 p_uc = 100;
8789 }
8790 if (p_uc && !old_value)
8791 ml_open_files();
8792 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008793#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008794 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008795 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008796 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008797 {
8798 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008799 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008800 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008801 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008802 {
8803 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008804 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008805 }
8806 }
8807#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008808#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008809 else if (pp == &p_mzq)
8810 mzvim_reset_timer();
8811#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008812
8813 /* sync undo before 'undolevels' changes */
8814 else if (pp == &p_ul)
8815 {
8816 /* use the old value, otherwise u_sync() may not work properly */
8817 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00008818 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008819 p_ul = value;
8820 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01008821 else if (pp == &curbuf->b_p_ul)
8822 {
8823 /* use the old value, otherwise u_sync() may not work properly */
8824 curbuf->b_p_ul = old_value;
8825 u_sync(TRUE);
8826 curbuf->b_p_ul = value;
8827 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008828
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008829#ifdef FEAT_LINEBREAK
8830 /* 'numberwidth' must be positive */
8831 else if (pp == &curwin->w_p_nuw)
8832 {
8833 if (curwin->w_p_nuw < 1)
8834 {
8835 errmsg = e_positive;
8836 curwin->w_p_nuw = 1;
8837 }
8838 if (curwin->w_p_nuw > 10)
8839 {
8840 errmsg = e_invarg;
8841 curwin->w_p_nuw = 10;
8842 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02008843 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008844 }
8845#endif
8846
Bram Moolenaar1a384422010-07-14 19:53:30 +02008847 else if (pp == &curbuf->b_p_tw)
8848 {
8849 if (curbuf->b_p_tw < 0)
8850 {
8851 errmsg = e_positive;
8852 curbuf->b_p_tw = 0;
8853 }
8854#ifdef FEAT_SYN_HL
8855# ifdef FEAT_WINDOWS
8856 {
8857 win_T *wp;
8858 tabpage_T *tp;
8859
8860 FOR_ALL_TAB_WINDOWS(tp, wp)
8861 check_colorcolumn(wp);
8862 }
8863# else
8864 check_colorcolumn(curwin);
8865# endif
8866#endif
8867 }
8868
Bram Moolenaar071d4272004-06-13 20:20:40 +00008869 /*
8870 * Check the bounds for numeric options here
8871 */
8872 if (Rows < min_rows() && full_screen)
8873 {
8874 if (errbuf != NULL)
8875 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008876 vim_snprintf((char *)errbuf, errbuflen,
8877 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00008878 errmsg = errbuf;
8879 }
8880 Rows = min_rows();
8881 }
8882 if (Columns < MIN_COLUMNS && full_screen)
8883 {
8884 if (errbuf != NULL)
8885 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008886 vim_snprintf((char *)errbuf, errbuflen,
8887 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008888 errmsg = errbuf;
8889 }
8890 Columns = MIN_COLUMNS;
8891 }
Bram Moolenaare057d402013-06-30 17:51:51 +02008892 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008893
Bram Moolenaar071d4272004-06-13 20:20:40 +00008894 /*
8895 * If the screen (shell) height has been changed, assume it is the
8896 * physical screenheight.
8897 */
8898 if (old_Rows != Rows || old_Columns != Columns)
8899 {
8900 /* Changing the screen size is not allowed while updating the screen. */
8901 if (updating_screen)
8902 *pp = old_value;
8903 else if (full_screen
8904#ifdef FEAT_GUI
8905 && !gui.starting
8906#endif
8907 )
8908 set_shellsize((int)Columns, (int)Rows, TRUE);
8909 else
8910 {
8911 /* Postpone the resizing; check the size and cmdline position for
8912 * messages. */
8913 check_shellsize();
8914 if (cmdline_row > Rows - p_ch && Rows > p_ch)
8915 cmdline_row = Rows - p_ch;
8916 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00008917 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008918 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008919 }
8920
Bram Moolenaar071d4272004-06-13 20:20:40 +00008921 if (curbuf->b_p_ts <= 0)
8922 {
8923 errmsg = e_positive;
8924 curbuf->b_p_ts = 8;
8925 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008926 if (p_tm < 0)
8927 {
8928 errmsg = e_positive;
8929 p_tm = 0;
8930 }
8931 if ((curwin->w_p_scr <= 0
8932 || (curwin->w_p_scr > curwin->w_height
8933 && curwin->w_height > 0))
8934 && full_screen)
8935 {
8936 if (pp == &(curwin->w_p_scr))
8937 {
8938 if (curwin->w_p_scr != 0)
8939 errmsg = e_scroll;
8940 win_comp_scroll(curwin);
8941 }
8942 /* If 'scroll' became invalid because of a side effect silently adjust
8943 * it. */
8944 else if (curwin->w_p_scr <= 0)
8945 curwin->w_p_scr = 1;
8946 else /* curwin->w_p_scr > curwin->w_height */
8947 curwin->w_p_scr = curwin->w_height;
8948 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00008949 if (p_hi < 0)
8950 {
8951 errmsg = e_positive;
8952 p_hi = 0;
8953 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02008954 else if (p_hi > 10000)
8955 {
8956 errmsg = e_invarg;
8957 p_hi = 10000;
8958 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02008959 if (p_re < 0 || p_re > 2)
8960 {
8961 errmsg = e_invarg;
8962 p_re = 0;
8963 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008964 if (p_report < 0)
8965 {
8966 errmsg = e_positive;
8967 p_report = 1;
8968 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00008969 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008970 {
8971 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
8972 p_sj = Rows / 2;
8973 else
8974 {
8975 errmsg = e_scroll;
8976 p_sj = 1;
8977 }
8978 }
8979 if (p_so < 0 && full_screen)
8980 {
8981 errmsg = e_scroll;
8982 p_so = 0;
8983 }
8984 if (p_siso < 0 && full_screen)
8985 {
8986 errmsg = e_positive;
8987 p_siso = 0;
8988 }
8989#ifdef FEAT_CMDWIN
8990 if (p_cwh < 1)
8991 {
8992 errmsg = e_positive;
8993 p_cwh = 1;
8994 }
8995#endif
8996 if (p_ut < 0)
8997 {
8998 errmsg = e_positive;
8999 p_ut = 2000;
9000 }
9001 if (p_ss < 0)
9002 {
9003 errmsg = e_positive;
9004 p_ss = 0;
9005 }
9006
9007 /* May set global value for local option. */
9008 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
9009 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
9010
9011 options[opt_idx].flags |= P_WAS_SET;
9012
Bram Moolenaar53744302015-07-17 17:38:22 +02009013#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
9014 if (!starting && errmsg == NULL)
9015 {
9016 char_u buf_old[11], buf_new[11], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02009017 vim_snprintf((char *)buf_old, 10, "%ld", old_value);
9018 vim_snprintf((char *)buf_new, 10, "%ld", value);
9019 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02009020 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
9021 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
9022 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
9023 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
9024 reset_v_option_vars();
9025 }
9026#endif
9027
Bram Moolenaar071d4272004-06-13 20:20:40 +00009028 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02009029 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01009030 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02009031 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009032 check_redraw(options[opt_idx].flags);
9033
9034 return errmsg;
9035}
9036
9037/*
9038 * Called after an option changed: check if something needs to be redrawn.
9039 */
9040 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009041check_redraw(long_u flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009042{
9043 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009044 int doclear = (flags & P_RCLR) == P_RCLR;
9045 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009046
9047#ifdef FEAT_WINDOWS
9048 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
9049 status_redraw_all();
9050#endif
9051
9052 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
9053 changed_window_setting();
9054 if (flags & P_RBUF)
9055 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009056 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009057 redraw_all_later(CLEAR);
9058 else if (all)
9059 redraw_all_later(NOT_VALID);
9060}
9061
9062/*
9063 * Find index for option 'arg'.
9064 * Return -1 if not found.
9065 */
9066 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009067findoption(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009068{
9069 int opt_idx;
9070 char *s, *p;
9071 static short quick_tab[27] = {0, 0}; /* quick access table */
9072 int is_term_opt;
9073
9074 /*
9075 * For first call: Initialize the quick-access table.
9076 * It contains the index for the first option that starts with a certain
9077 * letter. There are 26 letters, plus the first "t_" option.
9078 */
9079 if (quick_tab[1] == 0)
9080 {
9081 p = options[0].fullname;
9082 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9083 {
9084 if (s[0] != p[0])
9085 {
9086 if (s[0] == 't' && s[1] == '_')
9087 quick_tab[26] = opt_idx;
9088 else
9089 quick_tab[CharOrdLow(s[0])] = opt_idx;
9090 }
9091 p = s;
9092 }
9093 }
9094
9095 /*
9096 * Check for name starting with an illegal character.
9097 */
9098#ifdef EBCDIC
9099 if (!islower(arg[0]))
9100#else
9101 if (arg[0] < 'a' || arg[0] > 'z')
9102#endif
9103 return -1;
9104
9105 is_term_opt = (arg[0] == 't' && arg[1] == '_');
9106 if (is_term_opt)
9107 opt_idx = quick_tab[26];
9108 else
9109 opt_idx = quick_tab[CharOrdLow(arg[0])];
9110 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9111 {
9112 if (STRCMP(arg, s) == 0) /* match full name */
9113 break;
9114 }
9115 if (s == NULL && !is_term_opt)
9116 {
9117 opt_idx = quick_tab[CharOrdLow(arg[0])];
9118 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
9119 {
9120 s = options[opt_idx].shortname;
9121 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
9122 break;
9123 s = NULL;
9124 }
9125 }
9126 if (s == NULL)
9127 opt_idx = -1;
9128 return opt_idx;
9129}
9130
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009131#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009132/*
9133 * Get the value for an option.
9134 *
9135 * Returns:
9136 * Number or Toggle option: 1, *numval gets value.
9137 * String option: 0, *stringval gets allocated string.
9138 * Hidden Number or Toggle option: -1.
9139 * hidden String option: -2.
9140 * unknown option: -3.
9141 */
9142 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009143get_option_value(
9144 char_u *name,
9145 long *numval,
9146 char_u **stringval, /* NULL when only checking existence */
9147 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009148{
9149 int opt_idx;
9150 char_u *varp;
9151
9152 opt_idx = findoption(name);
9153 if (opt_idx < 0) /* unknown option */
9154 return -3;
9155
9156 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
9157
9158 if (options[opt_idx].flags & P_STRING)
9159 {
9160 if (varp == NULL) /* hidden option */
9161 return -2;
9162 if (stringval != NULL)
9163 {
9164#ifdef FEAT_CRYPT
9165 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00009166 if ((char_u **)varp == &curbuf->b_p_key
9167 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009168 *stringval = vim_strsave((char_u *)"*****");
9169 else
9170#endif
9171 *stringval = vim_strsave(*(char_u **)(varp));
9172 }
9173 return 0;
9174 }
9175
9176 if (varp == NULL) /* hidden option */
9177 return -1;
9178 if (options[opt_idx].flags & P_NUM)
9179 *numval = *(long *)varp;
9180 else
9181 {
9182 /* Special case: 'modified' is b_changed, but we also want to consider
9183 * it set when 'ff' or 'fenc' changed. */
9184 if ((int *)varp == &curbuf->b_changed)
9185 *numval = curbufIsChanged();
9186 else
Bram Moolenaar2acfbed2016-07-01 23:14:02 +02009187 *numval = (long) *(int *)varp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009188 }
9189 return 1;
9190}
9191#endif
9192
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009193#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009194/*
9195 * Returns the option attributes and its value. Unlike the above function it
9196 * will return either global value or local value of the option depending on
9197 * what was requested, but it will never return global value if it was
9198 * requested to return local one and vice versa. Neither it will return
9199 * buffer-local value if it was requested to return window-local one.
9200 *
9201 * Pretends that option is absent if it is not present in the requested scope
9202 * (i.e. has no global, window-local or buffer-local value depending on
9203 * opt_type). Uses
9204 *
9205 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009206 * 0 hidden or unknown option, also option that does not have requested
9207 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009208 * see SOPT_* in vim.h for other flags
9209 *
9210 * Possible opt_type values: see SREQ_* in vim.h
9211 */
9212 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009213get_option_value_strict(
9214 char_u *name,
9215 long *numval,
9216 char_u **stringval, /* NULL when only obtaining attributes */
9217 int opt_type,
9218 void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009219{
9220 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009221 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009222 struct vimoption *p;
9223 int r = 0;
9224
9225 opt_idx = findoption(name);
9226 if (opt_idx < 0)
9227 return 0;
9228
9229 p = &(options[opt_idx]);
9230
9231 /* Hidden option */
9232 if (p->var == NULL)
9233 return 0;
9234
9235 if (p->flags & P_BOOL)
9236 r |= SOPT_BOOL;
9237 else if (p->flags & P_NUM)
9238 r |= SOPT_NUM;
9239 else if (p->flags & P_STRING)
9240 r |= SOPT_STRING;
9241
9242 if (p->indir == PV_NONE)
9243 {
9244 if (opt_type == SREQ_GLOBAL)
9245 r |= SOPT_GLOBAL;
9246 else
9247 return 0; /* Did not request global-only option */
9248 }
9249 else
9250 {
9251 if (p->indir & PV_BOTH)
9252 r |= SOPT_GLOBAL;
9253 else if (opt_type == SREQ_GLOBAL)
9254 return 0; /* Requested global option */
9255
9256 if (p->indir & PV_WIN)
9257 {
9258 if (opt_type == SREQ_BUF)
9259 return 0; /* Did not request window-local option */
9260 else
9261 r |= SOPT_WIN;
9262 }
9263 else if (p->indir & PV_BUF)
9264 {
9265 if (opt_type == SREQ_WIN)
9266 return 0; /* Did not request buffer-local option */
9267 else
9268 r |= SOPT_BUF;
9269 }
9270 }
9271
9272 if (stringval == NULL)
9273 return r;
9274
9275 if (opt_type == SREQ_GLOBAL)
9276 varp = p->var;
9277 else
9278 {
9279 if (opt_type == SREQ_BUF)
9280 {
9281 /* Special case: 'modified' is b_changed, but we also want to
9282 * consider it set when 'ff' or 'fenc' changed. */
9283 if (p->indir == PV_MOD)
9284 {
9285 *numval = bufIsChanged((buf_T *) from);
9286 varp = NULL;
9287 }
9288#ifdef FEAT_CRYPT
9289 else if (p->indir == PV_KEY)
9290 {
9291 /* never return the value of the crypt key */
9292 *stringval = NULL;
9293 varp = NULL;
9294 }
9295#endif
9296 else
9297 {
9298 aco_save_T aco;
9299 aucmd_prepbuf(&aco, (buf_T *) from);
9300 varp = get_varp(p);
9301 aucmd_restbuf(&aco);
9302 }
9303 }
9304 else if (opt_type == SREQ_WIN)
9305 {
9306 win_T *save_curwin;
9307 save_curwin = curwin;
9308 curwin = (win_T *) from;
9309 curbuf = curwin->w_buffer;
9310 varp = get_varp(p);
9311 curwin = save_curwin;
9312 curbuf = curwin->w_buffer;
9313 }
9314 if (varp == p->var)
9315 return (r | SOPT_UNSET);
9316 }
9317
9318 if (varp != NULL)
9319 {
9320 if (p->flags & P_STRING)
9321 *stringval = vim_strsave(*(char_u **)(varp));
9322 else if (p->flags & P_NUM)
9323 *numval = *(long *) varp;
9324 else
9325 *numval = *(int *)varp;
9326 }
9327
9328 return r;
9329}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009330
9331/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009332 * Iterate over options. First argument is a pointer to a pointer to a
9333 * structure inside options[] array, second is option type like in the above
9334 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009335 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009336 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009337 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009338 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009339 * first argument to NULL.
9340 *
9341 * Returns full option name for current option on each call.
9342 */
9343 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009344option_iter_next(void **option, int opt_type)
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009345{
9346 struct vimoption *ret = NULL;
9347 do
9348 {
9349 if (*option == NULL)
9350 *option = (void *) options;
9351 else if (((struct vimoption *) (*option))->fullname == NULL)
9352 {
9353 *option = NULL;
9354 return NULL;
9355 }
9356 else
9357 *option = (void *) (((struct vimoption *) (*option)) + 1);
9358
9359 ret = ((struct vimoption *) (*option));
9360
9361 /* Hidden option */
9362 if (ret->var == NULL)
9363 {
9364 ret = NULL;
9365 continue;
9366 }
9367
9368 switch (opt_type)
9369 {
9370 case SREQ_GLOBAL:
9371 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9372 ret = NULL;
9373 break;
9374 case SREQ_BUF:
9375 if (!(ret->indir & PV_BUF))
9376 ret = NULL;
9377 break;
9378 case SREQ_WIN:
9379 if (!(ret->indir & PV_WIN))
9380 ret = NULL;
9381 break;
9382 default:
Bram Moolenaar95f09602016-11-10 20:01:45 +01009383 internal_error("option_iter_next()");
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009384 return NULL;
9385 }
9386 }
9387 while (ret == NULL);
9388
9389 return (char_u *)ret->fullname;
9390}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009391#endif
9392
Bram Moolenaar071d4272004-06-13 20:20:40 +00009393/*
9394 * Set the value of option "name".
9395 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009396 *
9397 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009398 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009399 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009400set_option_value(
9401 char_u *name,
9402 long number,
9403 char_u *string,
9404 int opt_flags) /* OPT_LOCAL or 0 (both) */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009405{
9406 int opt_idx;
9407 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009408 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009409
9410 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009411 if (opt_idx < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009412 EMSG2(_("E355: Unknown option: %s"), name);
9413 else
9414 {
9415 flags = options[opt_idx].flags;
9416#ifdef HAVE_SANDBOX
9417 /* Disallow changing some options in the sandbox */
9418 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009419 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009420 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009421 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009422 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009423#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009424 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009425 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009426 else
9427 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009428 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009429 if (varp != NULL) /* hidden option is not changed */
9430 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009431 if (number == 0 && string != NULL)
9432 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009433 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009434
9435 /* Either we are given a string or we are setting option
9436 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009437 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009438 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009439 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009440 {
9441 /* There's another character after zeros or the string
9442 * is empty. In both cases, we are trying to set a
9443 * num option using a string. */
9444 EMSG3(_("E521: Number required: &%s = '%s'"),
9445 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009446 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009447
9448 }
9449 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009450 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009451 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009452 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009453 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009454 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009455 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009456 }
9457 }
9458 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009459 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009460}
9461
9462/*
9463 * Get the terminal code for a terminal option.
9464 * Returns NULL when not found.
9465 */
9466 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009467get_term_code(char_u *tname)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009468{
9469 int opt_idx;
9470 char_u *varp;
9471
9472 if (tname[0] != 't' || tname[1] != '_' ||
9473 tname[2] == NUL || tname[3] == NUL)
9474 return NULL;
9475 if ((opt_idx = findoption(tname)) >= 0)
9476 {
9477 varp = get_varp(&(options[opt_idx]));
9478 if (varp != NULL)
9479 varp = *(char_u **)(varp);
9480 return varp;
9481 }
9482 return find_termcode(tname + 2);
9483}
9484
9485 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009486get_highlight_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009487{
9488 int i;
9489
9490 i = findoption((char_u *)"hl");
9491 if (i >= 0)
9492 return options[i].def_val[VI_DEFAULT];
9493 return (char_u *)NULL;
9494}
9495
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009496#if defined(FEAT_MBYTE) || defined(PROTO)
9497 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009498get_encoding_default(void)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009499{
9500 int i;
9501
9502 i = findoption((char_u *)"enc");
9503 if (i >= 0)
9504 return options[i].def_val[VI_DEFAULT];
9505 return (char_u *)NULL;
9506}
9507#endif
9508
Bram Moolenaar071d4272004-06-13 20:20:40 +00009509/*
9510 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9511 */
9512 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009513find_key_option(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009514{
9515 int key;
9516 int modifiers;
9517
9518 /*
9519 * Don't use get_special_key_code() for t_xx, we don't want it to call
9520 * add_termcap_entry().
9521 */
9522 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9523 key = TERMCAP2KEY(arg[2], arg[3]);
9524 else
9525 {
9526 --arg; /* put arg at the '<' */
9527 modifiers = 0;
Bram Moolenaar35a4cfa2016-08-14 16:07:48 +02009528 key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009529 if (modifiers) /* can't handle modifiers here */
9530 key = 0;
9531 }
9532 return key;
9533}
9534
9535/*
9536 * if 'all' == 0: show changed options
9537 * if 'all' == 1: show all normal options
9538 * if 'all' == 2: show all terminal options
9539 */
9540 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009541showoptions(
9542 int all,
9543 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009544{
9545 struct vimoption *p;
9546 int col;
9547 int isterm;
9548 char_u *varp;
9549 struct vimoption **items;
9550 int item_count;
9551 int run;
9552 int row, rows;
9553 int cols;
9554 int i;
9555 int len;
9556
9557#define INC 20
9558#define GAP 3
9559
9560 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9561 PARAM_COUNT));
9562 if (items == NULL)
9563 return;
9564
9565 /* Highlight title */
9566 if (all == 2)
9567 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9568 else if (opt_flags & OPT_GLOBAL)
9569 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9570 else if (opt_flags & OPT_LOCAL)
9571 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9572 else
9573 MSG_PUTS_TITLE(_("\n--- Options ---"));
9574
9575 /*
9576 * do the loop two times:
9577 * 1. display the short items
9578 * 2. display the long items (only strings and numbers)
9579 */
9580 for (run = 1; run <= 2 && !got_int; ++run)
9581 {
9582 /*
9583 * collect the items in items[]
9584 */
9585 item_count = 0;
9586 for (p = &options[0]; p->fullname != NULL; p++)
9587 {
9588 varp = NULL;
9589 isterm = istermoption(p);
9590 if (opt_flags != 0)
9591 {
9592 if (p->indir != PV_NONE && !isterm)
9593 varp = get_varp_scope(p, opt_flags);
9594 }
9595 else
9596 varp = get_varp(p);
9597 if (varp != NULL
9598 && ((all == 2 && isterm)
9599 || (all == 1 && !isterm)
9600 || (all == 0 && !optval_default(p, varp))))
9601 {
9602 if (p->flags & P_BOOL)
9603 len = 1; /* a toggle option fits always */
9604 else
9605 {
9606 option_value2string(p, opt_flags);
9607 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9608 }
9609 if ((len <= INC - GAP && run == 1) ||
9610 (len > INC - GAP && run == 2))
9611 items[item_count++] = p;
9612 }
9613 }
9614
9615 /*
9616 * display the items
9617 */
9618 if (run == 1)
9619 {
9620 cols = (Columns + GAP - 3) / INC;
9621 if (cols == 0)
9622 cols = 1;
9623 rows = (item_count + cols - 1) / cols;
9624 }
9625 else /* run == 2 */
9626 rows = item_count;
9627 for (row = 0; row < rows && !got_int; ++row)
9628 {
9629 msg_putchar('\n'); /* go to next line */
9630 if (got_int) /* 'q' typed in more */
9631 break;
9632 col = 0;
9633 for (i = row; i < item_count; i += rows)
9634 {
9635 msg_col = col; /* make columns */
9636 showoneopt(items[i], opt_flags);
9637 col += INC;
9638 }
9639 out_flush();
9640 ui_breakcheck();
9641 }
9642 }
9643 vim_free(items);
9644}
9645
9646/*
9647 * Return TRUE if option "p" has its default value.
9648 */
9649 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009650optval_default(struct vimoption *p, char_u *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009651{
9652 int dvi;
9653
9654 if (varp == NULL)
9655 return TRUE; /* hidden option is always at default */
9656 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9657 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009658 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009659 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009660 /* the cast to long is required for Manx C, long_i is
9661 * needed for MSVC */
9662 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009663 /* P_STRING */
9664 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9665}
9666
9667/*
9668 * showoneopt: show the value of one option
9669 * must not be called with a hidden option!
9670 */
9671 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009672showoneopt(
9673 struct vimoption *p,
9674 int opt_flags) /* OPT_LOCAL or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009675{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009676 char_u *varp;
9677 int save_silent = silent_mode;
9678
9679 silent_mode = FALSE;
9680 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009681
9682 varp = get_varp_scope(p, opt_flags);
9683
9684 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9685 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9686 ? !curbufIsChanged() : !*(int *)varp))
9687 MSG_PUTS("no");
9688 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9689 MSG_PUTS("--");
9690 else
9691 MSG_PUTS(" ");
9692 MSG_PUTS(p->fullname);
9693 if (!(p->flags & P_BOOL))
9694 {
9695 msg_putchar('=');
9696 /* put value string in NameBuff */
9697 option_value2string(p, opt_flags);
9698 msg_outtrans(NameBuff);
9699 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009700
9701 silent_mode = save_silent;
9702 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009703}
9704
9705/*
9706 * Write modified options as ":set" commands to a file.
9707 *
9708 * There are three values for "opt_flags":
9709 * OPT_GLOBAL: Write global option values and fresh values of
9710 * buffer-local options (used for start of a session
9711 * file).
9712 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
9713 * curwin (used for a vimrc file).
9714 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
9715 * and local values for window-local options of
9716 * curwin. Local values are also written when at the
9717 * default value, because a modeline or autocommand
9718 * may have set them when doing ":edit file" and the
9719 * user has set them back at the default or fresh
9720 * value.
9721 * When "local_only" is TRUE, don't write fresh
9722 * values, only local values (for ":mkview").
9723 * (fresh value = value used for a new buffer or window for a local option).
9724 *
9725 * Return FAIL on error, OK otherwise.
9726 */
9727 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009728makeset(FILE *fd, int opt_flags, int local_only)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009729{
9730 struct vimoption *p;
9731 char_u *varp; /* currently used value */
9732 char_u *varp_fresh; /* local value */
9733 char_u *varp_local = NULL; /* fresh value */
9734 char *cmd;
9735 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009736 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009737
9738 /*
9739 * The options that don't have a default (terminal name, columns, lines)
9740 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009741 * Do the loop over "options[]" twice: once for options with the
9742 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009743 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009744 for (pri = 1; pri >= 0; --pri)
9745 {
9746 for (p = &options[0]; !istermoption(p); p++)
9747 if (!(p->flags & P_NO_MKRC)
9748 && !istermoption(p)
9749 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009750 {
9751 /* skip global option when only doing locals */
9752 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
9753 continue;
9754
9755 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
9756 * file, they are always buffer-specific. */
9757 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
9758 continue;
9759
9760 /* Global values are only written when not at the default value. */
9761 varp = get_varp_scope(p, opt_flags);
9762 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
9763 continue;
9764
9765 round = 2;
9766 if (p->indir != PV_NONE)
9767 {
9768 if (p->var == VAR_WIN)
9769 {
9770 /* skip window-local option when only doing globals */
9771 if (!(opt_flags & OPT_LOCAL))
9772 continue;
9773 /* When fresh value of window-local option is not at the
9774 * default, need to write it too. */
9775 if (!(opt_flags & OPT_GLOBAL) && !local_only)
9776 {
9777 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
9778 if (!optval_default(p, varp_fresh))
9779 {
9780 round = 1;
9781 varp_local = varp;
9782 varp = varp_fresh;
9783 }
9784 }
9785 }
9786 }
9787
9788 /* Round 1: fresh value for window-local options.
9789 * Round 2: other values */
9790 for ( ; round <= 2; varp = varp_local, ++round)
9791 {
9792 if (round == 1 || (opt_flags & OPT_GLOBAL))
9793 cmd = "set";
9794 else
9795 cmd = "setlocal";
9796
9797 if (p->flags & P_BOOL)
9798 {
9799 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
9800 return FAIL;
9801 }
9802 else if (p->flags & P_NUM)
9803 {
9804 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
9805 return FAIL;
9806 }
9807 else /* P_STRING */
9808 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009809#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9810 int do_endif = FALSE;
9811
Bram Moolenaar071d4272004-06-13 20:20:40 +00009812 /* Don't set 'syntax' and 'filetype' again if the value is
9813 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009814 if (
9815# if defined(FEAT_SYN_HL)
9816 p->indir == PV_SYN
9817# if defined(FEAT_AUTOCMD)
9818 ||
9819# endif
9820# endif
9821# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009822 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009823# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009824 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00009825 {
9826 if (fprintf(fd, "if &%s != '%s'", p->fullname,
9827 *(char_u **)(varp)) < 0
9828 || put_eol(fd) < 0)
9829 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009830 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009831 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009832#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009833 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
9834 (p->flags & P_EXPAND) != 0) == FAIL)
9835 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009836#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9837 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009838 {
9839 if (put_line(fd, "endif") == FAIL)
9840 return FAIL;
9841 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009842#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009843 }
9844 }
9845 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009846 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009847 return OK;
9848}
9849
9850#if defined(FEAT_FOLDING) || defined(PROTO)
9851/*
9852 * Generate set commands for the local fold options only. Used when
9853 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
9854 */
9855 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009856makefoldset(FILE *fd)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009857{
9858 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
9859# ifdef FEAT_EVAL
9860 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
9861 == FAIL
9862# endif
9863 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
9864 == FAIL
9865 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
9866 == FAIL
9867 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
9868 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
9869 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
9870 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
9871 )
9872 return FAIL;
9873
9874 return OK;
9875}
9876#endif
9877
9878 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009879put_setstring(
9880 FILE *fd,
9881 char *cmd,
9882 char *name,
9883 char_u **valuep,
9884 int expand)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009885{
9886 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009887 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009888
9889 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9890 return FAIL;
9891 if (*valuep != NULL)
9892 {
9893 /* Output 'pastetoggle' as key names. For other
9894 * options some characters have to be escaped with
9895 * CTRL-V or backslash */
9896 if (valuep == &p_pt)
9897 {
9898 s = *valuep;
9899 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +00009900 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009901 return FAIL;
9902 }
9903 else if (expand)
9904 {
Bram Moolenaarf8441472011-04-28 17:24:58 +02009905 buf = alloc(MAXPATHL);
9906 if (buf == NULL)
9907 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009908 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
9909 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +02009910 {
9911 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009912 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009913 }
9914 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009915 }
9916 else if (put_escstr(fd, *valuep, 2) == FAIL)
9917 return FAIL;
9918 }
9919 if (put_eol(fd) < 0)
9920 return FAIL;
9921 return OK;
9922}
9923
9924 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009925put_setnum(
9926 FILE *fd,
9927 char *cmd,
9928 char *name,
9929 long *valuep)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009930{
9931 long wc;
9932
9933 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9934 return FAIL;
9935 if (wc_use_keyname((char_u *)valuep, &wc))
9936 {
9937 /* print 'wildchar' and 'wildcharm' as a key name */
9938 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
9939 return FAIL;
9940 }
9941 else if (fprintf(fd, "%ld", *valuep) < 0)
9942 return FAIL;
9943 if (put_eol(fd) < 0)
9944 return FAIL;
9945 return OK;
9946}
9947
9948 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009949put_setbool(
9950 FILE *fd,
9951 char *cmd,
9952 char *name,
9953 int value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009954{
Bram Moolenaar893de922007-10-02 18:40:57 +00009955 if (value < 0) /* global/local option using global value */
9956 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009957 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
9958 || put_eol(fd) < 0)
9959 return FAIL;
9960 return OK;
9961}
9962
9963/*
9964 * Clear all the terminal options.
9965 * If the option has been allocated, free the memory.
9966 * Terminal options are never hidden or indirect.
9967 */
9968 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009969clear_termoptions(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009970{
Bram Moolenaar071d4272004-06-13 20:20:40 +00009971 /*
9972 * Reset a few things before clearing the old options. This may cause
9973 * outputting a few things that the terminal doesn't understand, but the
9974 * screen will be cleared later, so this is OK.
9975 */
9976#ifdef FEAT_MOUSE_TTY
9977 mch_setmouse(FALSE); /* switch mouse off */
9978#endif
9979#ifdef FEAT_TITLE
9980 mch_restore_title(3); /* restore window titles */
9981#endif
9982#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
9983 /* When starting the GUI close the display opened for the clipboard.
9984 * After restoring the title, because that will need the display. */
9985 if (gui.starting)
9986 clear_xterm_clip();
9987#endif
Bram Moolenaarcea912a2016-10-12 14:20:24 +02009988 stoptermcap(); /* stop termcap mode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009989
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00009990 free_termoptions();
9991}
9992
9993 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009994free_termoptions(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00009995{
9996 struct vimoption *p;
9997
Bram Moolenaar071d4272004-06-13 20:20:40 +00009998 for (p = &options[0]; p->fullname != NULL; p++)
9999 if (istermoption(p))
10000 {
10001 if (p->flags & P_ALLOCED)
10002 free_string_option(*(char_u **)(p->var));
10003 if (p->flags & P_DEF_ALLOCED)
10004 free_string_option(p->def_val[VI_DEFAULT]);
10005 *(char_u **)(p->var) = empty_option;
10006 p->def_val[VI_DEFAULT] = empty_option;
10007 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
10008 }
10009 clear_termcodes();
10010}
10011
10012/*
Bram Moolenaar363cb672009-07-22 12:28:17 +000010013 * Free the string for one term option, if it was allocated.
10014 * Set the string to empty_option and clear allocated flag.
10015 * "var" points to the option value.
10016 */
10017 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010018free_one_termoption(char_u *var)
Bram Moolenaar363cb672009-07-22 12:28:17 +000010019{
10020 struct vimoption *p;
10021
10022 for (p = &options[0]; p->fullname != NULL; p++)
10023 if (p->var == var)
10024 {
10025 if (p->flags & P_ALLOCED)
10026 free_string_option(*(char_u **)(p->var));
10027 *(char_u **)(p->var) = empty_option;
10028 p->flags &= ~P_ALLOCED;
10029 break;
10030 }
10031}
10032
10033/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010034 * Set the terminal option defaults to the current value.
10035 * Used after setting the terminal name.
10036 */
10037 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010038set_term_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010039{
10040 struct vimoption *p;
10041
10042 for (p = &options[0]; p->fullname != NULL; p++)
10043 {
10044 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
10045 {
10046 if (p->flags & P_DEF_ALLOCED)
10047 {
10048 free_string_option(p->def_val[VI_DEFAULT]);
10049 p->flags &= ~P_DEF_ALLOCED;
10050 }
10051 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
10052 if (p->flags & P_ALLOCED)
10053 {
10054 p->flags |= P_DEF_ALLOCED;
10055 p->flags &= ~P_ALLOCED; /* don't free the value now */
10056 }
10057 }
10058 }
10059}
10060
10061/*
10062 * return TRUE if 'p' starts with 't_'
10063 */
10064 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010065istermoption(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010066{
10067 return (p->fullname[0] == 't' && p->fullname[1] == '_');
10068}
10069
10070/*
10071 * Compute columns for ruler and shown command. 'sc_col' is also used to
10072 * decide what the maximum length of a message on the status line can be.
10073 * If there is a status line for the last window, 'sc_col' is independent
10074 * of 'ru_col'.
10075 */
10076
10077#define COL_RULER 17 /* columns needed by standard ruler */
10078
10079 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010080comp_col(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010081{
10082#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
Bram Moolenaar459ca562016-11-10 18:16:33 +010010083 int last_has_status = (p_ls == 2 || (p_ls == 1 && !ONE_WINDOW));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010084
10085 sc_col = 0;
10086 ru_col = 0;
10087 if (p_ru)
10088 {
10089#ifdef FEAT_STL_OPT
10090 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
10091#else
10092 ru_col = COL_RULER + 1;
10093#endif
10094 /* no last status line, adjust sc_col */
10095 if (!last_has_status)
10096 sc_col = ru_col;
10097 }
10098 if (p_sc)
10099 {
10100 sc_col += SHOWCMD_COLS;
10101 if (!p_ru || last_has_status) /* no need for separating space */
10102 ++sc_col;
10103 }
10104 sc_col = Columns - sc_col;
10105 ru_col = Columns - ru_col;
10106 if (sc_col <= 0) /* screen too narrow, will become a mess */
10107 sc_col = 1;
10108 if (ru_col <= 0)
10109 ru_col = 1;
10110#else
10111 sc_col = Columns;
10112 ru_col = Columns;
10113#endif
10114}
10115
10116/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010117 * Unset local option value, similar to ":set opt<".
10118 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010119 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010120unset_global_local_option(char_u *name, void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010121{
10122 struct vimoption *p;
10123 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010124 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010125
10126 opt_idx = findoption(name);
Bram Moolenaarbd8539a2015-08-11 18:53:03 +020010127 if (opt_idx < 0)
10128 return;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010129 p = &(options[opt_idx]);
10130
10131 switch ((int)p->indir)
10132 {
10133 /* global option with local value: use local value if it's been set */
10134 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010135 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010136 break;
10137 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010138 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010139 break;
10140 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010141 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010142 break;
10143 case PV_AR:
10144 buf->b_p_ar = -1;
10145 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010146 case PV_BKC:
10147 clear_string_option(&buf->b_p_bkc);
10148 buf->b_bkc_flags = 0;
10149 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010150 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010151 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010152 break;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010153 case PV_TC:
10154 clear_string_option(&buf->b_p_tc);
10155 buf->b_tc_flags = 0;
10156 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010157#ifdef FEAT_FIND_ID
10158 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010159 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010160 break;
10161 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010162 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010163 break;
10164#endif
10165#ifdef FEAT_INS_EXPAND
10166 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010167 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010168 break;
10169 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010170 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010171 break;
10172#endif
10173#ifdef FEAT_QUICKFIX
10174 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010175 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010176 break;
10177 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010178 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010179 break;
10180 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010181 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010182 break;
10183#endif
10184#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10185 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010186 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010187 break;
10188#endif
10189#if defined(FEAT_CRYPT)
10190 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010191 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010192 break;
10193#endif
10194#ifdef FEAT_STL_OPT
10195 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010196 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010197 break;
10198#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010199 case PV_UL:
10200 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10201 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010202#ifdef FEAT_LISP
10203 case PV_LW:
10204 clear_string_option(&buf->b_p_lw);
10205 break;
10206#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010207 }
10208}
10209
10210/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010211 * Get pointer to option variable, depending on local or global scope.
10212 */
10213 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010214get_varp_scope(struct vimoption *p, int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010215{
10216 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10217 {
10218 if (p->var == VAR_WIN)
10219 return (char_u *)GLOBAL_WO(get_varp(p));
10220 return p->var;
10221 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010222 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010223 {
10224 switch ((int)p->indir)
10225 {
10226#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010227 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10228 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10229 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010230#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010231 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10232 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10233 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010234 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010235 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010236 case PV_TC: return (char_u *)&(curbuf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010237#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010238 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10239 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010240#endif
10241#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010242 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10243 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010244#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010245#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10246 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10247#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010248#if defined(FEAT_CRYPT)
10249 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10250#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010251#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010252 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010253#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010254 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010255#ifdef FEAT_LISP
10256 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10257#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010258 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010259 }
10260 return NULL; /* "cannot happen" */
10261 }
10262 return get_varp(p);
10263}
10264
10265/*
10266 * Get pointer to option variable.
10267 */
10268 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010269get_varp(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010270{
10271 /* hidden option, always return NULL */
10272 if (p->var == NULL)
10273 return NULL;
10274
10275 switch ((int)p->indir)
10276 {
10277 case PV_NONE: return p->var;
10278
10279 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010280 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010281 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010282 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010283 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010284 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010285 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010286 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010287 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010288 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010289 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010290 case PV_TC: return *curbuf->b_p_tc != NUL
10291 ? (char_u *)&(curbuf->b_p_tc) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010292 case PV_BKC: return *curbuf->b_p_bkc != NUL
10293 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010294#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010295 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010296 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010297 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010298 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10299#endif
10300#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010301 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010302 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010303 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010304 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10305#endif
10306#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010307 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010308 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010309 case PV_GP: return *curbuf->b_p_gp != NUL
10310 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10311 case PV_MP: return *curbuf->b_p_mp != NUL
10312 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010313#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010314#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10315 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10316 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10317#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010318#if defined(FEAT_CRYPT)
10319 case PV_CM: return *curbuf->b_p_cm != NUL
10320 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10321#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010322#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010323 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010324 ? (char_u *)&(curwin->w_p_stl) : p->var;
10325#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010326 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10327 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010328#ifdef FEAT_LISP
10329 case PV_LW: return *curbuf->b_p_lw != NUL
10330 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10331#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010332
10333#ifdef FEAT_ARABIC
10334 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10335#endif
10336 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010337#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010338 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10339#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010340#ifdef FEAT_SYN_HL
10341 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10342 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010343 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010344#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010345#ifdef FEAT_DIFF
10346 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10347#endif
10348#ifdef FEAT_FOLDING
10349 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10350 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10351 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10352 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10353 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10354 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10355 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10356# ifdef FEAT_EVAL
10357 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10358 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10359# endif
10360 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10361#endif
10362 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010363 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010364#ifdef FEAT_LINEBREAK
10365 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10366#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010367#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010368 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010369 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10370#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010371#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10372 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10373#endif
10374#ifdef FEAT_RIGHTLEFT
10375 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10376 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10377#endif
10378 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10379 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10380#ifdef FEAT_LINEBREAK
10381 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010382 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10383 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010384#endif
10385#ifdef FEAT_SCROLLBIND
10386 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10387#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010388#ifdef FEAT_CURSORBIND
10389 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10390#endif
10391#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010392 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10393 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010394#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010395
10396 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10397 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10398#ifdef FEAT_MBYTE
10399 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10400#endif
10401#if defined(FEAT_QUICKFIX)
10402 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10403 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
10404#endif
10405 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10406 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10407#ifdef FEAT_CINDENT
10408 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10409 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10410 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10411#endif
10412#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10413 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10414#endif
10415#ifdef FEAT_COMMENTS
10416 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10417#endif
10418#ifdef FEAT_FOLDING
10419 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10420#endif
10421#ifdef FEAT_INS_EXPAND
10422 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10423#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010424#ifdef FEAT_COMPL_FUNC
10425 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010426 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010427#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010428 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010429 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010430 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10431#ifdef FEAT_MBYTE
10432 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10433#endif
10434 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10435#ifdef FEAT_AUTOCMD
10436 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10437#endif
10438 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010439 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010440 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10441 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10442 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10443 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10444#ifdef FEAT_FIND_ID
10445# ifdef FEAT_EVAL
10446 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10447# endif
10448#endif
10449#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10450 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10451 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10452#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010453#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010454 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10455#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010456#ifdef FEAT_CRYPT
10457 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10458#endif
10459#ifdef FEAT_LISP
10460 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10461#endif
10462 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10463 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10464 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10465 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10466 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010467 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010468#ifdef FEAT_TEXTOBJ
10469 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10470#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010471 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10472#ifdef FEAT_SMARTINDENT
10473 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10474#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010475 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010476 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10477#ifdef FEAT_SEARCHPATH
10478 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10479#endif
10480 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10481#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010482 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010483 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10484#endif
10485#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010486 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10487 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10488 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010489#endif
10490 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10491 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10492 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10493 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010494#ifdef FEAT_PERSISTENT_UNDO
10495 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10496#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010497 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10498#ifdef FEAT_KEYMAP
10499 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10500#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010501#ifdef FEAT_SIGNS
10502 case PV_SCL: return (char_u *)&(curwin->w_p_scl);
10503#endif
Bram Moolenaar95f09602016-11-10 20:01:45 +010010504 default: IEMSG(_("E356: get_varp ERROR"));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010505 }
10506 /* always return a valid pointer to avoid a crash! */
10507 return (char_u *)&(curbuf->b_p_wm);
10508}
10509
10510/*
10511 * Get the value of 'equalprg', either the buffer-local one or the global one.
10512 */
10513 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010514get_equalprg(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010515{
10516 if (*curbuf->b_p_ep == NUL)
10517 return p_ep;
10518 return curbuf->b_p_ep;
10519}
10520
10521#if defined(FEAT_WINDOWS) || defined(PROTO)
10522/*
10523 * Copy options from one window to another.
10524 * Used when splitting a window.
10525 */
10526 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010527win_copy_options(win_T *wp_from, win_T *wp_to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010528{
10529 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10530 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10531# ifdef FEAT_RIGHTLEFT
10532# ifdef FEAT_FKMAP
10533 /* Is this right? */
10534 wp_to->w_farsi = wp_from->w_farsi;
10535# endif
10536# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020010537#if defined(FEAT_LINEBREAK)
10538 briopt_check(wp_to);
10539#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010540}
10541#endif
10542
10543/*
10544 * Copy the options from one winopt_T to another.
10545 * Doesn't free the old option values in "to", use clear_winopt() for that.
10546 * The 'scroll' option is not copied, because it depends on the window height.
10547 * The 'previewwindow' option is reset, there can be only one preview window.
10548 */
10549 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010550copy_winopt(winopt_T *from, winopt_T *to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010551{
10552#ifdef FEAT_ARABIC
10553 to->wo_arab = from->wo_arab;
10554#endif
10555 to->wo_list = from->wo_list;
10556 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010557 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010558#ifdef FEAT_LINEBREAK
10559 to->wo_nuw = from->wo_nuw;
10560#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010561#ifdef FEAT_RIGHTLEFT
10562 to->wo_rl = from->wo_rl;
10563 to->wo_rlc = vim_strsave(from->wo_rlc);
10564#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010565#ifdef FEAT_STL_OPT
10566 to->wo_stl = vim_strsave(from->wo_stl);
10567#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010568 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010569#ifdef FEAT_DIFF
10570 to->wo_wrap_save = from->wo_wrap_save;
10571#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010572#ifdef FEAT_LINEBREAK
10573 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020010574 to->wo_bri = from->wo_bri;
10575 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010576#endif
10577#ifdef FEAT_SCROLLBIND
10578 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010579 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010580#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010581#ifdef FEAT_CURSORBIND
10582 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010583 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010584#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010585#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010586 to->wo_spell = from->wo_spell;
10587#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010588#ifdef FEAT_SYN_HL
10589 to->wo_cuc = from->wo_cuc;
10590 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010591 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010592#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010593#ifdef FEAT_DIFF
10594 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010595 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010596#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010597#ifdef FEAT_CONCEAL
10598 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010599 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010600#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010601#ifdef FEAT_FOLDING
10602 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010603 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010604 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010605 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010606 to->wo_fdi = vim_strsave(from->wo_fdi);
10607 to->wo_fml = from->wo_fml;
10608 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010609 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010610 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010611 to->wo_fdm_save = from->wo_diff_saved
10612 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010613 to->wo_fdn = from->wo_fdn;
10614# ifdef FEAT_EVAL
10615 to->wo_fde = vim_strsave(from->wo_fde);
10616 to->wo_fdt = vim_strsave(from->wo_fdt);
10617# endif
10618 to->wo_fmr = vim_strsave(from->wo_fmr);
10619#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010620#ifdef FEAT_SIGNS
10621 to->wo_scl = vim_strsave(from->wo_scl);
10622#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010623 check_winopt(to); /* don't want NULL pointers */
10624}
10625
10626/*
10627 * Check string options in a window for a NULL value.
10628 */
10629 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010630check_win_options(win_T *win)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010631{
10632 check_winopt(&win->w_onebuf_opt);
10633 check_winopt(&win->w_allbuf_opt);
10634}
10635
10636/*
10637 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10638 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020010639 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010640check_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010641{
10642#ifdef FEAT_FOLDING
10643 check_string_option(&wop->wo_fdi);
10644 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010645 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010646# ifdef FEAT_EVAL
10647 check_string_option(&wop->wo_fde);
10648 check_string_option(&wop->wo_fdt);
10649# endif
10650 check_string_option(&wop->wo_fmr);
10651#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010652#ifdef FEAT_SIGNS
10653 check_string_option(&wop->wo_scl);
10654#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010655#ifdef FEAT_RIGHTLEFT
10656 check_string_option(&wop->wo_rlc);
10657#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010658#ifdef FEAT_STL_OPT
10659 check_string_option(&wop->wo_stl);
10660#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010661#ifdef FEAT_SYN_HL
10662 check_string_option(&wop->wo_cc);
10663#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010664#ifdef FEAT_CONCEAL
10665 check_string_option(&wop->wo_cocu);
10666#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010667#ifdef FEAT_LINEBREAK
10668 check_string_option(&wop->wo_briopt);
10669#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010670}
10671
10672/*
10673 * Free the allocated memory inside a winopt_T.
10674 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010675 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010676clear_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010677{
10678#ifdef FEAT_FOLDING
10679 clear_string_option(&wop->wo_fdi);
10680 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010681 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010682# ifdef FEAT_EVAL
10683 clear_string_option(&wop->wo_fde);
10684 clear_string_option(&wop->wo_fdt);
10685# endif
10686 clear_string_option(&wop->wo_fmr);
10687#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010688#ifdef FEAT_SIGNS
10689 clear_string_option(&wop->wo_scl);
10690#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010691#ifdef FEAT_LINEBREAK
10692 clear_string_option(&wop->wo_briopt);
10693#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010694#ifdef FEAT_RIGHTLEFT
10695 clear_string_option(&wop->wo_rlc);
10696#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010697#ifdef FEAT_STL_OPT
10698 clear_string_option(&wop->wo_stl);
10699#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010700#ifdef FEAT_SYN_HL
10701 clear_string_option(&wop->wo_cc);
10702#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010703#ifdef FEAT_CONCEAL
10704 clear_string_option(&wop->wo_cocu);
10705#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010706}
10707
10708/*
10709 * Copy global option values to local options for one buffer.
10710 * Used when creating a new buffer and sometimes when entering a buffer.
10711 * flags:
10712 * BCO_ENTER We will enter the buf buffer.
10713 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
10714 * appropriate.
10715 * BCO_NOHELP Don't copy the values to a help buffer.
10716 */
10717 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010718buf_copy_options(buf_T *buf, int flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010719{
10720 int should_copy = TRUE;
10721 char_u *save_p_isk = NULL; /* init for GCC */
10722 int dont_do_help;
10723 int did_isk = FALSE;
10724
10725 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010726 * Skip this when the option defaults have not been set yet. Happens when
10727 * main() allocates the first buffer.
10728 */
10729 if (p_cpo != NULL)
10730 {
10731 /*
10732 * Always copy when entering and 'cpo' contains 'S'.
10733 * Don't copy when already initialized.
10734 * Don't copy when 'cpo' contains 's' and not entering.
10735 * 'S' BCO_ENTER initialized 's' should_copy
10736 * yes yes X X TRUE
10737 * yes no yes X FALSE
10738 * no X yes X FALSE
10739 * X no no yes FALSE
10740 * X no no no TRUE
10741 * no yes no X TRUE
10742 */
10743 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
10744 && (buf->b_p_initialized
10745 || (!(flags & BCO_ENTER)
10746 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
10747 should_copy = FALSE;
10748
10749 if (should_copy || (flags & BCO_ALWAYS))
10750 {
10751 /* Don't copy the options specific to a help buffer when
10752 * BCO_NOHELP is given or the options were initialized already
10753 * (jumping back to a help file with CTRL-T or CTRL-O) */
10754 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
10755 || buf->b_p_initialized;
10756 if (dont_do_help) /* don't free b_p_isk */
10757 {
10758 save_p_isk = buf->b_p_isk;
10759 buf->b_p_isk = NULL;
10760 }
10761 /*
10762 * Always free the allocated strings.
10763 * If not already initialized, set 'readonly' and copy 'fileformat'.
10764 */
10765 if (!buf->b_p_initialized)
10766 {
10767 free_buf_options(buf, TRUE);
10768 buf->b_p_ro = FALSE; /* don't copy readonly */
10769 buf->b_p_tx = p_tx;
10770#ifdef FEAT_MBYTE
10771 buf->b_p_fenc = vim_strsave(p_fenc);
10772#endif
Bram Moolenaare8ef3a02016-10-12 17:45:29 +020010773 switch (*p_ffs)
10774 {
10775 case 'm':
10776 buf->b_p_ff = vim_strsave((char_u *)FF_MAC); break;
10777 case 'd':
10778 buf->b_p_ff = vim_strsave((char_u *)FF_DOS); break;
10779 case 'u':
10780 buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); break;
10781 default:
10782 buf->b_p_ff = vim_strsave(p_ff);
10783 }
10784 if (buf->b_p_ff != NULL)
10785 buf->b_start_ffc = *buf->b_p_ff;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010786#if defined(FEAT_QUICKFIX)
10787 buf->b_p_bh = empty_option;
10788 buf->b_p_bt = empty_option;
10789#endif
10790 }
10791 else
10792 free_buf_options(buf, FALSE);
10793
10794 buf->b_p_ai = p_ai;
10795 buf->b_p_ai_nopaste = p_ai_nopaste;
10796 buf->b_p_sw = p_sw;
10797 buf->b_p_tw = p_tw;
10798 buf->b_p_tw_nopaste = p_tw_nopaste;
10799 buf->b_p_tw_nobin = p_tw_nobin;
10800 buf->b_p_wm = p_wm;
10801 buf->b_p_wm_nopaste = p_wm_nopaste;
10802 buf->b_p_wm_nobin = p_wm_nobin;
10803 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000010804#ifdef FEAT_MBYTE
10805 buf->b_p_bomb = p_bomb;
10806#endif
Bram Moolenaarb388be02015-07-22 22:19:38 +020010807 buf->b_p_fixeol = p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010808 buf->b_p_et = p_et;
10809 buf->b_p_et_nobin = p_et_nobin;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020010810 buf->b_p_et_nopaste = p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010811 buf->b_p_ml = p_ml;
10812 buf->b_p_ml_nobin = p_ml_nobin;
10813 buf->b_p_inf = p_inf;
10814 buf->b_p_swf = p_swf;
10815#ifdef FEAT_INS_EXPAND
10816 buf->b_p_cpt = vim_strsave(p_cpt);
10817#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010818#ifdef FEAT_COMPL_FUNC
10819 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010820 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010821#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010822 buf->b_p_sts = p_sts;
10823 buf->b_p_sts_nopaste = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010824 buf->b_p_sn = p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010825#ifdef FEAT_COMMENTS
10826 buf->b_p_com = vim_strsave(p_com);
10827#endif
10828#ifdef FEAT_FOLDING
10829 buf->b_p_cms = vim_strsave(p_cms);
10830#endif
10831 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010832 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010833 buf->b_p_nf = vim_strsave(p_nf);
10834 buf->b_p_mps = vim_strsave(p_mps);
10835#ifdef FEAT_SMARTINDENT
10836 buf->b_p_si = p_si;
10837#endif
10838 buf->b_p_ci = p_ci;
10839#ifdef FEAT_CINDENT
10840 buf->b_p_cin = p_cin;
10841 buf->b_p_cink = vim_strsave(p_cink);
10842 buf->b_p_cino = vim_strsave(p_cino);
10843#endif
10844#ifdef FEAT_AUTOCMD
10845 /* Don't copy 'filetype', it must be detected */
10846 buf->b_p_ft = empty_option;
10847#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010848 buf->b_p_pi = p_pi;
10849#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10850 buf->b_p_cinw = vim_strsave(p_cinw);
10851#endif
10852#ifdef FEAT_LISP
10853 buf->b_p_lisp = p_lisp;
10854#endif
10855#ifdef FEAT_SYN_HL
10856 /* Don't copy 'syntax', it must be set */
10857 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010858 buf->b_p_smc = p_smc;
Bram Moolenaarb8060fe2016-01-19 22:29:28 +010010859 buf->b_s.b_syn_isk = empty_option;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010860#endif
10861#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020010862 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010863 (void)compile_cap_prog(&buf->b_s);
10864 buf->b_s.b_p_spf = vim_strsave(p_spf);
10865 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010866#endif
10867#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10868 buf->b_p_inde = vim_strsave(p_inde);
10869 buf->b_p_indk = vim_strsave(p_indk);
10870#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010871#if defined(FEAT_EVAL)
10872 buf->b_p_fex = vim_strsave(p_fex);
10873#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010874#ifdef FEAT_CRYPT
10875 buf->b_p_key = vim_strsave(p_key);
10876#endif
10877#ifdef FEAT_SEARCHPATH
10878 buf->b_p_sua = vim_strsave(p_sua);
10879#endif
10880#ifdef FEAT_KEYMAP
10881 buf->b_p_keymap = vim_strsave(p_keymap);
10882 buf->b_kmap_state |= KEYMAP_INIT;
10883#endif
10884 /* This isn't really an option, but copying the langmap and IME
10885 * state from the current buffer is better than resetting it. */
10886 buf->b_p_iminsert = p_iminsert;
10887 buf->b_p_imsearch = p_imsearch;
10888
10889 /* options that are normally global but also have a local value
10890 * are not copied, start using the global value */
10891 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010892 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010893 buf->b_p_bkc = empty_option;
10894 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010895#ifdef FEAT_QUICKFIX
10896 buf->b_p_gp = empty_option;
10897 buf->b_p_mp = empty_option;
10898 buf->b_p_efm = empty_option;
10899#endif
10900 buf->b_p_ep = empty_option;
10901 buf->b_p_kp = empty_option;
10902 buf->b_p_path = empty_option;
10903 buf->b_p_tags = empty_option;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010904 buf->b_p_tc = empty_option;
10905 buf->b_tc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010906#ifdef FEAT_FIND_ID
10907 buf->b_p_def = empty_option;
10908 buf->b_p_inc = empty_option;
10909# ifdef FEAT_EVAL
10910 buf->b_p_inex = vim_strsave(p_inex);
10911# endif
10912#endif
10913#ifdef FEAT_INS_EXPAND
10914 buf->b_p_dict = empty_option;
10915 buf->b_p_tsr = empty_option;
10916#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010917#ifdef FEAT_TEXTOBJ
10918 buf->b_p_qe = vim_strsave(p_qe);
10919#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010920#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10921 buf->b_p_bexpr = empty_option;
10922#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010923#if defined(FEAT_CRYPT)
10924 buf->b_p_cm = empty_option;
10925#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010926#ifdef FEAT_PERSISTENT_UNDO
10927 buf->b_p_udf = p_udf;
10928#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010929#ifdef FEAT_LISP
10930 buf->b_p_lw = empty_option;
10931#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010932
10933 /*
10934 * Don't copy the options set by ex_help(), use the saved values,
10935 * when going from a help buffer to a non-help buffer.
10936 * Don't touch these at all when BCO_NOHELP is used and going from
10937 * or to a help buffer.
10938 */
10939 if (dont_do_help)
10940 buf->b_p_isk = save_p_isk;
10941 else
10942 {
10943 buf->b_p_isk = vim_strsave(p_isk);
10944 did_isk = TRUE;
10945 buf->b_p_ts = p_ts;
10946 buf->b_help = FALSE;
10947#ifdef FEAT_QUICKFIX
10948 if (buf->b_p_bt[0] == 'h')
10949 clear_string_option(&buf->b_p_bt);
10950#endif
10951 buf->b_p_ma = p_ma;
10952 }
10953 }
10954
10955 /*
10956 * When the options should be copied (ignoring BCO_ALWAYS), set the
10957 * flag that indicates that the options have been initialized.
10958 */
10959 if (should_copy)
10960 buf->b_p_initialized = TRUE;
10961 }
10962
10963 check_buf_options(buf); /* make sure we don't have NULLs */
10964 if (did_isk)
10965 (void)buf_init_chartab(buf, FALSE);
10966}
10967
10968/*
10969 * Reset the 'modifiable' option and its default value.
10970 */
10971 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010972reset_modifiable(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010973{
10974 int opt_idx;
10975
10976 curbuf->b_p_ma = FALSE;
10977 p_ma = FALSE;
10978 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000010979 if (opt_idx >= 0)
10980 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010981}
10982
10983/*
10984 * Set the global value for 'iminsert' to the local value.
10985 */
10986 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010987set_iminsert_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010988{
10989 p_iminsert = curbuf->b_p_iminsert;
10990}
10991
10992/*
10993 * Set the global value for 'imsearch' to the local value.
10994 */
10995 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010996set_imsearch_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010997{
10998 p_imsearch = curbuf->b_p_imsearch;
10999}
11000
11001#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
11002static int expand_option_idx = -1;
11003static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
11004static int expand_option_flags = 0;
11005
11006 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011007set_context_in_set_cmd(
11008 expand_T *xp,
11009 char_u *arg,
11010 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011011{
11012 int nextchar;
11013 long_u flags = 0; /* init for GCC */
11014 int opt_idx = 0; /* init for GCC */
11015 char_u *p;
11016 char_u *s;
11017 int is_term_option = FALSE;
11018 int key;
11019
11020 expand_option_flags = opt_flags;
11021
11022 xp->xp_context = EXPAND_SETTINGS;
11023 if (*arg == NUL)
11024 {
11025 xp->xp_pattern = arg;
11026 return;
11027 }
11028 p = arg + STRLEN(arg) - 1;
11029 if (*p == ' ' && *(p - 1) != '\\')
11030 {
11031 xp->xp_pattern = p + 1;
11032 return;
11033 }
11034 while (p > arg)
11035 {
11036 s = p;
11037 /* count number of backslashes before ' ' or ',' */
11038 if (*p == ' ' || *p == ',')
11039 {
11040 while (s > arg && *(s - 1) == '\\')
11041 --s;
11042 }
11043 /* break at a space with an even number of backslashes */
11044 if (*p == ' ' && ((p - s) & 1) == 0)
11045 {
11046 ++p;
11047 break;
11048 }
11049 --p;
11050 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000011051 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011052 {
11053 xp->xp_context = EXPAND_BOOL_SETTINGS;
11054 p += 2;
11055 }
11056 if (STRNCMP(p, "inv", 3) == 0)
11057 {
11058 xp->xp_context = EXPAND_BOOL_SETTINGS;
11059 p += 3;
11060 }
11061 xp->xp_pattern = arg = p;
11062 if (*arg == '<')
11063 {
11064 while (*p != '>')
11065 if (*p++ == NUL) /* expand terminal option name */
11066 return;
11067 key = get_special_key_code(arg + 1);
11068 if (key == 0) /* unknown name */
11069 {
11070 xp->xp_context = EXPAND_NOTHING;
11071 return;
11072 }
11073 nextchar = *++p;
11074 is_term_option = TRUE;
11075 expand_option_name[2] = KEY2TERMCAP0(key);
11076 expand_option_name[3] = KEY2TERMCAP1(key);
11077 }
11078 else
11079 {
11080 if (p[0] == 't' && p[1] == '_')
11081 {
11082 p += 2;
11083 if (*p != NUL)
11084 ++p;
11085 if (*p == NUL)
11086 return; /* expand option name */
11087 nextchar = *++p;
11088 is_term_option = TRUE;
11089 expand_option_name[2] = p[-2];
11090 expand_option_name[3] = p[-1];
11091 }
11092 else
11093 {
11094 /* Allow * wildcard */
11095 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
11096 p++;
11097 if (*p == NUL)
11098 return;
11099 nextchar = *p;
11100 *p = NUL;
11101 opt_idx = findoption(arg);
11102 *p = nextchar;
11103 if (opt_idx == -1 || options[opt_idx].var == NULL)
11104 {
11105 xp->xp_context = EXPAND_NOTHING;
11106 return;
11107 }
11108 flags = options[opt_idx].flags;
11109 if (flags & P_BOOL)
11110 {
11111 xp->xp_context = EXPAND_NOTHING;
11112 return;
11113 }
11114 }
11115 }
11116 /* handle "-=" and "+=" */
11117 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
11118 {
11119 ++p;
11120 nextchar = '=';
11121 }
11122 if ((nextchar != '=' && nextchar != ':')
11123 || xp->xp_context == EXPAND_BOOL_SETTINGS)
11124 {
11125 xp->xp_context = EXPAND_UNSUCCESSFUL;
11126 return;
11127 }
11128 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
11129 {
11130 xp->xp_context = EXPAND_OLD_SETTING;
11131 if (is_term_option)
11132 expand_option_idx = -1;
11133 else
11134 expand_option_idx = opt_idx;
11135 xp->xp_pattern = p + 1;
11136 return;
11137 }
11138 xp->xp_context = EXPAND_NOTHING;
11139 if (is_term_option || (flags & P_NUM))
11140 return;
11141
11142 xp->xp_pattern = p + 1;
11143
11144 if (flags & P_EXPAND)
11145 {
11146 p = options[opt_idx].var;
11147 if (p == (char_u *)&p_bdir
11148 || p == (char_u *)&p_dir
11149 || p == (char_u *)&p_path
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +010011150 || p == (char_u *)&p_pp
Bram Moolenaar071d4272004-06-13 20:20:40 +000011151 || p == (char_u *)&p_rtp
11152#ifdef FEAT_SEARCHPATH
11153 || p == (char_u *)&p_cdpath
11154#endif
11155#ifdef FEAT_SESSION
11156 || p == (char_u *)&p_vdir
11157#endif
11158 )
11159 {
11160 xp->xp_context = EXPAND_DIRECTORIES;
11161 if (p == (char_u *)&p_path
11162#ifdef FEAT_SEARCHPATH
11163 || p == (char_u *)&p_cdpath
11164#endif
11165 )
11166 xp->xp_backslash = XP_BS_THREE;
11167 else
11168 xp->xp_backslash = XP_BS_ONE;
11169 }
11170 else
11171 {
11172 xp->xp_context = EXPAND_FILES;
11173 /* for 'tags' need three backslashes for a space */
11174 if (p == (char_u *)&p_tags)
11175 xp->xp_backslash = XP_BS_THREE;
11176 else
11177 xp->xp_backslash = XP_BS_ONE;
11178 }
11179 }
11180
11181 /* For an option that is a list of file names, find the start of the
11182 * last file name. */
11183 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11184 {
11185 /* count number of backslashes before ' ' or ',' */
11186 if (*p == ' ' || *p == ',')
11187 {
11188 s = p;
11189 while (s > xp->xp_pattern && *(s - 1) == '\\')
11190 --s;
11191 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11192 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11193 {
11194 xp->xp_pattern = p + 1;
11195 break;
11196 }
11197 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011198
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011199#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011200 /* for 'spellsuggest' start at "file:" */
11201 if (options[opt_idx].var == (char_u *)&p_sps
11202 && STRNCMP(p, "file:", 5) == 0)
11203 {
11204 xp->xp_pattern = p + 5;
11205 break;
11206 }
11207#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011208 }
11209
11210 return;
11211}
11212
11213 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011214ExpandSettings(
11215 expand_T *xp,
11216 regmatch_T *regmatch,
11217 int *num_file,
11218 char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011219{
11220 int num_normal = 0; /* Nr of matching non-term-code settings */
11221 int num_term = 0; /* Nr of matching terminal code settings */
11222 int opt_idx;
11223 int match;
11224 int count = 0;
11225 char_u *str;
11226 int loop;
11227 int is_term_opt;
11228 char_u name_buf[MAX_KEY_NAME_LEN];
11229 static char *(names[]) = {"all", "termcap"};
11230 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11231
11232 /* do this loop twice:
11233 * loop == 0: count the number of matching options
11234 * loop == 1: copy the matching options into allocated memory
11235 */
11236 for (loop = 0; loop <= 1; ++loop)
11237 {
11238 regmatch->rm_ic = ic;
11239 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11240 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011241 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11242 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011243 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11244 {
11245 if (loop == 0)
11246 num_normal++;
11247 else
11248 (*file)[count++] = vim_strsave((char_u *)names[match]);
11249 }
11250 }
11251 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11252 opt_idx++)
11253 {
11254 if (options[opt_idx].var == NULL)
11255 continue;
11256 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11257 && !(options[opt_idx].flags & P_BOOL))
11258 continue;
11259 is_term_opt = istermoption(&options[opt_idx]);
11260 if (is_term_opt && num_normal > 0)
11261 continue;
11262 match = FALSE;
11263 if (vim_regexec(regmatch, str, (colnr_T)0)
11264 || (options[opt_idx].shortname != NULL
11265 && vim_regexec(regmatch,
11266 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11267 match = TRUE;
11268 else if (is_term_opt)
11269 {
11270 name_buf[0] = '<';
11271 name_buf[1] = 't';
11272 name_buf[2] = '_';
11273 name_buf[3] = str[2];
11274 name_buf[4] = str[3];
11275 name_buf[5] = '>';
11276 name_buf[6] = NUL;
11277 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11278 {
11279 match = TRUE;
11280 str = name_buf;
11281 }
11282 }
11283 if (match)
11284 {
11285 if (loop == 0)
11286 {
11287 if (is_term_opt)
11288 num_term++;
11289 else
11290 num_normal++;
11291 }
11292 else
11293 (*file)[count++] = vim_strsave(str);
11294 }
11295 }
11296 /*
11297 * Check terminal key codes, these are not in the option table
11298 */
11299 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11300 {
11301 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11302 {
11303 if (!isprint(str[0]) || !isprint(str[1]))
11304 continue;
11305
11306 name_buf[0] = 't';
11307 name_buf[1] = '_';
11308 name_buf[2] = str[0];
11309 name_buf[3] = str[1];
11310 name_buf[4] = NUL;
11311
11312 match = FALSE;
11313 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11314 match = TRUE;
11315 else
11316 {
11317 name_buf[0] = '<';
11318 name_buf[1] = 't';
11319 name_buf[2] = '_';
11320 name_buf[3] = str[0];
11321 name_buf[4] = str[1];
11322 name_buf[5] = '>';
11323 name_buf[6] = NUL;
11324
11325 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11326 match = TRUE;
11327 }
11328 if (match)
11329 {
11330 if (loop == 0)
11331 num_term++;
11332 else
11333 (*file)[count++] = vim_strsave(name_buf);
11334 }
11335 }
11336
11337 /*
11338 * Check special key names.
11339 */
11340 regmatch->rm_ic = TRUE; /* ignore case here */
11341 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11342 {
11343 name_buf[0] = '<';
11344 STRCPY(name_buf + 1, str);
11345 STRCAT(name_buf, ">");
11346
11347 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11348 {
11349 if (loop == 0)
11350 num_term++;
11351 else
11352 (*file)[count++] = vim_strsave(name_buf);
11353 }
11354 }
11355 }
11356 if (loop == 0)
11357 {
11358 if (num_normal > 0)
11359 *num_file = num_normal;
11360 else if (num_term > 0)
11361 *num_file = num_term;
11362 else
11363 return OK;
11364 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11365 if (*file == NULL)
11366 {
11367 *file = (char_u **)"";
11368 return FAIL;
11369 }
11370 }
11371 }
11372 return OK;
11373}
11374
11375 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011376ExpandOldSetting(int *num_file, char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011377{
11378 char_u *var = NULL; /* init for GCC */
11379 char_u *buf;
11380
11381 *num_file = 0;
11382 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11383 if (*file == NULL)
11384 return FAIL;
11385
11386 /*
11387 * For a terminal key code expand_option_idx is < 0.
11388 */
11389 if (expand_option_idx < 0)
11390 {
11391 var = find_termcode(expand_option_name + 2);
11392 if (var == NULL)
11393 expand_option_idx = findoption(expand_option_name);
11394 }
11395
11396 if (expand_option_idx >= 0)
11397 {
11398 /* put string of option value in NameBuff */
11399 option_value2string(&options[expand_option_idx], expand_option_flags);
11400 var = NameBuff;
11401 }
11402 else if (var == NULL)
11403 var = (char_u *)"";
11404
11405 /* A backslash is required before some characters. This is the reverse of
11406 * what happens in do_set(). */
11407 buf = vim_strsave_escaped(var, escape_chars);
11408
11409 if (buf == NULL)
11410 {
11411 vim_free(*file);
11412 *file = NULL;
11413 return FAIL;
11414 }
11415
11416#ifdef BACKSLASH_IN_FILENAME
11417 /* For MS-Windows et al. we don't double backslashes at the start and
11418 * before a file name character. */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011419 for (var = buf; *var != NUL; mb_ptr_adv(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011420 if (var[0] == '\\' && var[1] == '\\'
11421 && expand_option_idx >= 0
11422 && (options[expand_option_idx].flags & P_EXPAND)
11423 && vim_isfilec(var[2])
11424 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011425 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011426#endif
11427
11428 *file[0] = buf;
11429 *num_file = 1;
11430 return OK;
11431}
11432#endif
11433
11434/*
11435 * Get the value for the numeric or string option *opp in a nice format into
11436 * NameBuff[]. Must not be called with a hidden option!
11437 */
11438 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011439option_value2string(
11440 struct vimoption *opp,
11441 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011442{
11443 char_u *varp;
11444
11445 varp = get_varp_scope(opp, opt_flags);
11446
11447 if (opp->flags & P_NUM)
11448 {
11449 long wc = 0;
11450
11451 if (wc_use_keyname(varp, &wc))
11452 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11453 else if (wc != 0)
11454 STRCPY(NameBuff, transchar((int)wc));
11455 else
11456 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11457 }
11458 else /* P_STRING */
11459 {
11460 varp = *(char_u **)(varp);
11461 if (varp == NULL) /* just in case */
11462 NameBuff[0] = NUL;
11463#ifdef FEAT_CRYPT
11464 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011465 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011466 STRCPY(NameBuff, "*****");
11467#endif
11468 else if (opp->flags & P_EXPAND)
11469 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11470 /* Translate 'pastetoggle' into special key names */
11471 else if ((char_u **)opp->var == &p_pt)
11472 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11473 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011474 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011475 }
11476}
11477
11478/*
11479 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11480 * printed as a keyname.
11481 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11482 */
11483 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011484wc_use_keyname(char_u *varp, long *wcp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011485{
11486 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11487 {
11488 *wcp = *(long *)varp;
11489 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11490 return TRUE;
11491 }
11492 return FALSE;
11493}
11494
Bram Moolenaar01615492015-02-03 13:00:38 +010011495#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011496/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011497 * Any character has an equivalent 'langmap' character. This is used for
11498 * keyboards that have a special language mode that sends characters above
11499 * 128 (although other characters can be translated too). The "to" field is a
11500 * Vim command character. This avoids having to switch the keyboard back to
11501 * ASCII mode when leaving Insert mode.
11502 *
11503 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11504 * commands.
11505 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11506 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11507 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011508 */
Bram Moolenaar01615492015-02-03 13:00:38 +010011509# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011510/*
11511 * With multi-byte support use growarray for 'langmap' chars >= 256
11512 */
11513typedef struct
11514{
11515 int from;
11516 int to;
11517} langmap_entry_T;
11518
11519static garray_T langmap_mapga;
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +010011520static void langmap_set_entry(int from, int to);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011521
11522/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011523 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11524 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011525 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011526 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011527langmap_set_entry(int from, int to)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011528{
11529 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011530 int a = 0;
11531 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011532
11533 /* Do a binary search for an existing entry. */
11534 while (a != b)
11535 {
11536 int i = (a + b) / 2;
11537 int d = entries[i].from - from;
11538
11539 if (d == 0)
11540 {
11541 entries[i].to = to;
11542 return;
11543 }
11544 if (d < 0)
11545 a = i + 1;
11546 else
11547 b = i;
11548 }
11549
11550 if (ga_grow(&langmap_mapga, 1) != OK)
11551 return; /* out of memory */
11552
11553 /* insert new entry at position "a" */
11554 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11555 mch_memmove(entries + 1, entries,
11556 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11557 ++langmap_mapga.ga_len;
11558 entries[0].from = from;
11559 entries[0].to = to;
11560}
11561
11562/*
11563 * Apply 'langmap' to multi-byte character "c" and return the result.
11564 */
11565 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011566langmap_adjust_mb(int c)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011567{
11568 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11569 int a = 0;
11570 int b = langmap_mapga.ga_len;
11571
11572 while (a != b)
11573 {
11574 int i = (a + b) / 2;
11575 int d = entries[i].from - c;
11576
11577 if (d == 0)
11578 return entries[i].to; /* found matching entry */
11579 if (d < 0)
11580 a = i + 1;
11581 else
11582 b = i;
11583 }
11584 return c; /* no entry found, return "c" unmodified */
11585}
11586# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011587
11588 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011589langmap_init(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011590{
11591 int i;
11592
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011593 for (i = 0; i < 256; i++)
11594 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11595# ifdef FEAT_MBYTE
11596 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11597# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011598}
11599
11600/*
11601 * Called when langmap option is set; the language map can be
11602 * changed at any time!
11603 */
11604 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011605langmap_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011606{
11607 char_u *p;
11608 char_u *p2;
11609 int from, to;
11610
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011611#ifdef FEAT_MBYTE
11612 ga_clear(&langmap_mapga); /* clear the previous map first */
11613#endif
11614 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011615
11616 for (p = p_langmap; p[0] != NUL; )
11617 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011618 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
11619 mb_ptr_adv(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011620 {
11621 if (p2[0] == '\\' && p2[1] != NUL)
11622 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011623 }
11624 if (p2[0] == ';')
11625 ++p2; /* abcd;ABCD form, p2 points to A */
11626 else
11627 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11628 while (p[0])
11629 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011630 if (p[0] == ',')
11631 {
11632 ++p;
11633 break;
11634 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011635 if (p[0] == '\\' && p[1] != NUL)
11636 ++p;
11637#ifdef FEAT_MBYTE
11638 from = (*mb_ptr2char)(p);
11639#else
11640 from = p[0];
11641#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011642 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011643 if (p2 == NULL)
11644 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011645 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011646 if (p[0] != ',')
11647 {
11648 if (p[0] == '\\')
11649 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011650#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011651 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011652#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011653 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011654#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011655 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011656 }
11657 else
11658 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011659 if (p2[0] != ',')
11660 {
11661 if (p2[0] == '\\')
11662 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011663#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011664 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011665#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011666 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011667#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011668 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011669 }
11670 if (to == NUL)
11671 {
11672 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
11673 transchar(from));
11674 return;
11675 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011676
11677#ifdef FEAT_MBYTE
11678 if (from >= 256)
11679 langmap_set_entry(from, to);
11680 else
11681#endif
11682 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011683
11684 /* Advance to next pair */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011685 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011686 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011687 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011688 mb_ptr_adv(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011689 if (*p == ';')
11690 {
11691 p = p2;
11692 if (p[0] != NUL)
11693 {
11694 if (p[0] != ',')
11695 {
11696 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
11697 return;
11698 }
11699 ++p;
11700 }
11701 break;
11702 }
11703 }
11704 }
11705 }
11706}
11707#endif
11708
11709/*
11710 * Return TRUE if format option 'x' is in effect.
11711 * Take care of no formatting when 'paste' is set.
11712 */
11713 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011714has_format_option(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011715{
11716 if (p_paste)
11717 return FALSE;
11718 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
11719}
11720
11721/*
11722 * Return TRUE if "x" is present in 'shortmess' option, or
11723 * 'shortmess' contains 'a' and "x" is present in SHM_A.
11724 */
11725 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011726shortmess(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011727{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010011728 return p_shm != NULL &&
11729 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000011730 || (vim_strchr(p_shm, 'a') != NULL
11731 && vim_strchr((char_u *)SHM_A, x) != NULL));
11732}
11733
11734/*
11735 * paste_option_changed() - Called after p_paste was set or reset.
11736 */
11737 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011738paste_option_changed(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011739{
11740 static int old_p_paste = FALSE;
11741 static int save_sm = 0;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011742 static int save_sta = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011743#ifdef FEAT_CMDL_INFO
11744 static int save_ru = 0;
11745#endif
11746#ifdef FEAT_RIGHTLEFT
11747 static int save_ri = 0;
11748 static int save_hkmap = 0;
11749#endif
11750 buf_T *buf;
11751
11752 if (p_paste)
11753 {
11754 /*
11755 * Paste switched from off to on.
11756 * Save the current values, so they can be restored later.
11757 */
11758 if (!old_p_paste)
11759 {
11760 /* save options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020011761 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011762 {
11763 buf->b_p_tw_nopaste = buf->b_p_tw;
11764 buf->b_p_wm_nopaste = buf->b_p_wm;
11765 buf->b_p_sts_nopaste = buf->b_p_sts;
11766 buf->b_p_ai_nopaste = buf->b_p_ai;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011767 buf->b_p_et_nopaste = buf->b_p_et;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011768 }
11769
11770 /* save global options */
11771 save_sm = p_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011772 save_sta = p_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011773#ifdef FEAT_CMDL_INFO
11774 save_ru = p_ru;
11775#endif
11776#ifdef FEAT_RIGHTLEFT
11777 save_ri = p_ri;
11778 save_hkmap = p_hkmap;
11779#endif
11780 /* save global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011781 p_ai_nopaste = p_ai;
11782 p_et_nopaste = p_et;
11783 p_sts_nopaste = p_sts;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011784 p_tw_nopaste = p_tw;
11785 p_wm_nopaste = p_wm;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011786 }
11787
11788 /*
11789 * Always set the option values, also when 'paste' is set when it is
11790 * already on.
11791 */
11792 /* set options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020011793 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011794 {
11795 buf->b_p_tw = 0; /* textwidth is 0 */
11796 buf->b_p_wm = 0; /* wrapmargin is 0 */
11797 buf->b_p_sts = 0; /* softtabstop is 0 */
11798 buf->b_p_ai = 0; /* no auto-indent */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011799 buf->b_p_et = 0; /* no expandtab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011800 }
11801
11802 /* set global options */
11803 p_sm = 0; /* no showmatch */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011804 p_sta = 0; /* no smarttab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011805#ifdef FEAT_CMDL_INFO
11806# ifdef FEAT_WINDOWS
11807 if (p_ru)
11808 status_redraw_all(); /* redraw to remove the ruler */
11809# endif
11810 p_ru = 0; /* no ruler */
11811#endif
11812#ifdef FEAT_RIGHTLEFT
11813 p_ri = 0; /* no reverse insert */
11814 p_hkmap = 0; /* no Hebrew keyboard */
11815#endif
11816 /* set global values for local buffer options */
11817 p_tw = 0;
11818 p_wm = 0;
11819 p_sts = 0;
11820 p_ai = 0;
11821 }
11822
11823 /*
11824 * Paste switched from on to off: Restore saved values.
11825 */
11826 else if (old_p_paste)
11827 {
11828 /* restore options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020011829 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011830 {
11831 buf->b_p_tw = buf->b_p_tw_nopaste;
11832 buf->b_p_wm = buf->b_p_wm_nopaste;
11833 buf->b_p_sts = buf->b_p_sts_nopaste;
11834 buf->b_p_ai = buf->b_p_ai_nopaste;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011835 buf->b_p_et = buf->b_p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011836 }
11837
11838 /* restore global options */
11839 p_sm = save_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011840 p_sta = save_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011841#ifdef FEAT_CMDL_INFO
11842# ifdef FEAT_WINDOWS
11843 if (p_ru != save_ru)
11844 status_redraw_all(); /* redraw to draw the ruler */
11845# endif
11846 p_ru = save_ru;
11847#endif
11848#ifdef FEAT_RIGHTLEFT
11849 p_ri = save_ri;
11850 p_hkmap = save_hkmap;
11851#endif
11852 /* set global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011853 p_ai = p_ai_nopaste;
11854 p_et = p_et_nopaste;
11855 p_sts = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011856 p_tw = p_tw_nopaste;
11857 p_wm = p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011858 }
11859
11860 old_p_paste = p_paste;
11861}
11862
11863/*
11864 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
11865 *
11866 * Reset 'compatible' and set the values for options that didn't get set yet
11867 * to the Vim defaults.
11868 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011869 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011870 */
11871 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011872vimrc_found(char_u *fname, char_u *envname)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011873{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011874 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000011875 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011876 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011877
11878 if (!option_was_set((char_u *)"cp"))
11879 {
11880 p_cp = FALSE;
11881 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11882 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
11883 set_option_default(opt_idx, OPT_FREE, FALSE);
11884 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020011885 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000011886 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011887
11888 if (fname != NULL)
11889 {
11890 p = vim_getenv(envname, &dofree);
11891 if (p == NULL)
11892 {
11893 /* Set $MYVIMRC to the first vimrc file found. */
11894 p = FullName_save(fname, FALSE);
11895 if (p != NULL)
11896 {
11897 vim_setenv(envname, p);
11898 vim_free(p);
11899 }
11900 }
11901 else if (dofree)
11902 vim_free(p);
11903 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011904}
11905
11906/*
11907 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
11908 */
11909 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011910change_compatible(int on)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011911{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011912 int opt_idx;
11913
Bram Moolenaar071d4272004-06-13 20:20:40 +000011914 if (p_cp != on)
11915 {
11916 p_cp = on;
11917 compatible_set();
11918 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011919 opt_idx = findoption((char_u *)"cp");
11920 if (opt_idx >= 0)
11921 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011922}
11923
11924/*
11925 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020011926 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011927 */
11928 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011929option_was_set(char_u *name)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011930{
11931 int idx;
11932
11933 idx = findoption(name);
11934 if (idx < 0) /* unknown option */
11935 return FALSE;
11936 if (options[idx].flags & P_WAS_SET)
11937 return TRUE;
11938 return FALSE;
11939}
11940
11941/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010011942 * Reset the flag indicating option "name" was set.
11943 */
11944 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011945reset_option_was_set(char_u *name)
Bram Moolenaar15d55de2012-12-05 14:43:02 +010011946{
11947 int idx = findoption(name);
11948
11949 if (idx >= 0)
11950 options[idx].flags &= ~P_WAS_SET;
11951}
11952
11953/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011954 * compatible_set() - Called when 'compatible' has been set or unset.
11955 *
11956 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
11957 * flag) to a Vi compatible value.
11958 * When 'compatible' is unset: Set all options that have a different default
11959 * for Vim (without the P_VI_DEF flag) to that default.
11960 */
11961 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011962compatible_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011963{
11964 int opt_idx;
11965
11966 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11967 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
11968 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
11969 set_option_default(opt_idx, OPT_FREE, p_cp);
11970 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020011971 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000011972}
11973
11974#ifdef FEAT_LINEBREAK
11975
11976# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
11977 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011978 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011979# endif
11980
11981/*
11982 * fill_breakat_flags() -- called when 'breakat' changes value.
11983 */
11984 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011985fill_breakat_flags(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011986{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011987 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011988 int i;
11989
11990 for (i = 0; i < 256; i++)
11991 breakat_flags[i] = FALSE;
11992
11993 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011994 for (p = p_breakat; *p; p++)
11995 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011996}
11997
11998# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011999 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012000# endif
12001
12002#endif
12003
12004/*
12005 * Check an option that can be a range of string values.
12006 *
12007 * Return OK for correct value, FAIL otherwise.
12008 * Empty is always OK.
12009 */
12010 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012011check_opt_strings(
12012 char_u *val,
12013 char **values,
12014 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012015{
12016 return opt_strings_flags(val, values, NULL, list);
12017}
12018
12019/*
12020 * Handle an option that can be a range of string values.
12021 * Set a flag in "*flagp" for each string present.
12022 *
12023 * Return OK for correct value, FAIL otherwise.
12024 * Empty is always OK.
12025 */
12026 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012027opt_strings_flags(
12028 char_u *val, /* new value */
12029 char **values, /* array of valid string values */
12030 unsigned *flagp,
12031 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012032{
12033 int i;
12034 int len;
12035 unsigned new_flags = 0;
12036
12037 while (*val)
12038 {
12039 for (i = 0; ; ++i)
12040 {
12041 if (values[i] == NULL) /* val not found in values[] */
12042 return FAIL;
12043
12044 len = (int)STRLEN(values[i]);
12045 if (STRNCMP(values[i], val, len) == 0
12046 && ((list && val[len] == ',') || val[len] == NUL))
12047 {
12048 val += len + (val[len] == ',');
12049 new_flags |= (1 << i);
12050 break; /* check next item in val list */
12051 }
12052 }
12053 }
12054 if (flagp != NULL)
12055 *flagp = new_flags;
12056
12057 return OK;
12058}
12059
12060/*
12061 * Read the 'wildmode' option, fill wim_flags[].
12062 */
12063 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012064check_opt_wim(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012065{
12066 char_u new_wim_flags[4];
12067 char_u *p;
12068 int i;
12069 int idx = 0;
12070
12071 for (i = 0; i < 4; ++i)
12072 new_wim_flags[i] = 0;
12073
12074 for (p = p_wim; *p; ++p)
12075 {
12076 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
12077 ;
12078 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
12079 return FAIL;
12080 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
12081 new_wim_flags[idx] |= WIM_LONGEST;
12082 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
12083 new_wim_flags[idx] |= WIM_FULL;
12084 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
12085 new_wim_flags[idx] |= WIM_LIST;
12086 else
12087 return FAIL;
12088 p += i;
12089 if (*p == NUL)
12090 break;
12091 if (*p == ',')
12092 {
12093 if (idx == 3)
12094 return FAIL;
12095 ++idx;
12096 }
12097 }
12098
12099 /* fill remaining entries with last flag */
12100 while (idx < 3)
12101 {
12102 new_wim_flags[idx + 1] = new_wim_flags[idx];
12103 ++idx;
12104 }
12105
12106 /* only when there are no errors, wim_flags[] is changed */
12107 for (i = 0; i < 4; ++i)
12108 wim_flags[i] = new_wim_flags[i];
12109 return OK;
12110}
12111
12112/*
12113 * Check if backspacing over something is allowed.
12114 */
12115 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012116can_bs(
12117 int what) /* BS_INDENT, BS_EOL or BS_START */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012118{
12119 switch (*p_bs)
12120 {
12121 case '2': return TRUE;
12122 case '1': return (what != BS_START);
12123 case '0': return FALSE;
12124 }
12125 return vim_strchr(p_bs, what) != NULL;
12126}
12127
12128/*
12129 * Save the current values of 'fileformat' and 'fileencoding', so that we know
12130 * the file must be considered changed when the value is different.
12131 */
12132 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012133save_file_ff(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012134{
12135 buf->b_start_ffc = *buf->b_p_ff;
12136 buf->b_start_eol = buf->b_p_eol;
12137#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012138 buf->b_start_bomb = buf->b_p_bomb;
12139
Bram Moolenaar071d4272004-06-13 20:20:40 +000012140 /* Only use free/alloc when necessary, they take time. */
12141 if (buf->b_start_fenc == NULL
12142 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
12143 {
12144 vim_free(buf->b_start_fenc);
12145 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
12146 }
12147#endif
12148}
12149
12150/*
12151 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
12152 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012153 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
12154 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012155 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012156 * When "ignore_empty" is true don't consider a new, empty buffer to be
12157 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012158 */
12159 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012160file_ff_differs(buf_T *buf, int ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012161{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012162 /* In a buffer that was never loaded the options are not valid. */
12163 if (buf->b_flags & BF_NEVERLOADED)
12164 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012165 if (ignore_empty
12166 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012167 && buf->b_ml.ml_line_count == 1
12168 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12169 return FALSE;
12170 if (buf->b_start_ffc != *buf->b_p_ff)
12171 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012172 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012173 return TRUE;
12174#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012175 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12176 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012177 if (buf->b_start_fenc == NULL)
12178 return (*buf->b_p_fenc != NUL);
12179 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12180#else
12181 return FALSE;
12182#endif
12183}
12184
12185/*
12186 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12187 */
12188 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012189check_ff_value(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012190{
12191 return check_opt_strings(p, p_ff_values, FALSE);
12192}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012193
12194/*
12195 * Return the effective shiftwidth value for current buffer, using the
12196 * 'tabstop' value when 'shiftwidth' is zero.
12197 */
12198 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012199get_sw_value(buf_T *buf)
Bram Moolenaar14f24742012-08-08 18:01:05 +020012200{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012201 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012202}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012203
12204/*
12205 * Return the effective softtabstop value for the current buffer, using the
12206 * 'tabstop' value when 'softtabstop' is negative.
12207 */
12208 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012209get_sts_value(void)
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012210{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012211 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012212}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012213
12214/*
12215 * Check matchpairs option for "*initc".
12216 * If there is a match set "*initc" to the matching character and "*findc" to
12217 * the opposite character. Set "*backwards" to the direction.
12218 * When "switchit" is TRUE swap the direction.
12219 */
12220 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012221find_mps_values(
12222 int *initc,
12223 int *findc,
12224 int *backwards,
12225 int switchit)
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012226{
12227 char_u *ptr;
12228
12229 ptr = curbuf->b_p_mps;
12230 while (*ptr != NUL)
12231 {
12232#ifdef FEAT_MBYTE
12233 if (has_mbyte)
12234 {
12235 char_u *prev;
12236
12237 if (mb_ptr2char(ptr) == *initc)
12238 {
12239 if (switchit)
12240 {
12241 *findc = *initc;
12242 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12243 *backwards = TRUE;
12244 }
12245 else
12246 {
12247 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12248 *backwards = FALSE;
12249 }
12250 return;
12251 }
12252 prev = ptr;
12253 ptr += mb_ptr2len(ptr) + 1;
12254 if (mb_ptr2char(ptr) == *initc)
12255 {
12256 if (switchit)
12257 {
12258 *findc = *initc;
12259 *initc = mb_ptr2char(prev);
12260 *backwards = FALSE;
12261 }
12262 else
12263 {
12264 *findc = mb_ptr2char(prev);
12265 *backwards = TRUE;
12266 }
12267 return;
12268 }
12269 ptr += mb_ptr2len(ptr);
12270 }
12271 else
12272#endif
12273 {
12274 if (*ptr == *initc)
12275 {
12276 if (switchit)
12277 {
12278 *backwards = TRUE;
12279 *findc = *initc;
12280 *initc = ptr[2];
12281 }
12282 else
12283 {
12284 *backwards = FALSE;
12285 *findc = ptr[2];
12286 }
12287 return;
12288 }
12289 ptr += 2;
12290 if (*ptr == *initc)
12291 {
12292 if (switchit)
12293 {
12294 *backwards = FALSE;
12295 *findc = *initc;
12296 *initc = ptr[-2];
12297 }
12298 else
12299 {
12300 *backwards = TRUE;
12301 *findc = ptr[-2];
12302 }
12303 return;
12304 }
12305 ++ptr;
12306 }
12307 if (*ptr == ',')
12308 ++ptr;
12309 }
12310}
Bram Moolenaar597a4222014-06-25 14:39:50 +020012311
12312#if defined(FEAT_LINEBREAK) || defined(PROTO)
12313/*
12314 * This is called when 'breakindentopt' is changed and when a window is
12315 * initialized.
12316 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012317 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012318briopt_check(win_T *wp)
Bram Moolenaar597a4222014-06-25 14:39:50 +020012319{
12320 char_u *p;
12321 int bri_shift = 0;
12322 long bri_min = 20;
12323 int bri_sbr = FALSE;
12324
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012325 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012326 while (*p != NUL)
12327 {
12328 if (STRNCMP(p, "shift:", 6) == 0
12329 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
12330 {
12331 p += 6;
12332 bri_shift = getdigits(&p);
12333 }
12334 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
12335 {
12336 p += 4;
12337 bri_min = getdigits(&p);
12338 }
12339 else if (STRNCMP(p, "sbr", 3) == 0)
12340 {
12341 p += 3;
12342 bri_sbr = TRUE;
12343 }
12344 if (*p != ',' && *p != NUL)
12345 return FAIL;
12346 if (*p == ',')
12347 ++p;
12348 }
12349
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012350 wp->w_p_brishift = bri_shift;
12351 wp->w_p_brimin = bri_min;
12352 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012353
12354 return OK;
12355}
12356#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012357
12358/*
12359 * Get the local or global value of 'backupcopy'.
12360 */
12361 unsigned int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012362get_bkc_value(buf_T *buf)
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012363{
12364 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
12365}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020012366
12367#if defined(FEAT_SIGNS) || defined(PROTO)
12368/*
12369 * Return TRUE when window "wp" has a column to draw signs in.
12370 */
12371 int
12372signcolumn_on(win_T *wp)
12373{
12374 if (*wp->w_p_scl == 'n')
12375 return FALSE;
12376 if (*wp->w_p_scl == 'y')
12377 return TRUE;
12378 return (wp->w_buffer->b_signlist != NULL
12379# ifdef FEAT_NETBEANS_INTG
12380 || wp->w_buffer->b_has_sign_column
12381# endif
12382 );
12383}
12384#endif
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012385
12386#if defined(FEAT_EVAL) || defined(PROTO)
12387/*
12388 * Get window or buffer local options.
12389 */
12390 dict_T *
12391get_winbuf_options(int bufopt)
12392{
12393 dict_T *d;
12394 int opt_idx;
12395
12396 d = dict_alloc();
12397 if (d == NULL)
12398 return NULL;
12399
12400 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12401 {
12402 struct vimoption *opt = &options[opt_idx];
12403
12404 if ((bufopt && (opt->indir & PV_BUF))
12405 || (!bufopt && (opt->indir & PV_WIN)))
12406 {
12407 char_u *varp = get_varp(opt);
12408
12409 if (varp != NULL)
12410 {
12411 if (opt->flags & P_STRING)
12412 dict_add_nr_str(d, opt->fullname, 0L, *(char_u **)varp);
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012413 else if (opt->flags & P_NUM)
12414 dict_add_nr_str(d, opt->fullname, *(long *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012415 else
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012416 dict_add_nr_str(d, opt->fullname, *(int *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012417 }
12418 }
12419 }
12420
12421 return d;
12422}
12423#endif