blob: 8097a7f99bc370de98ed1d445bc05ed75bc3b192 [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 Moolenaar9be7c042017-01-14 14:28:30 +0100110#define PV_FP OPT_BOTH(OPT_BUF(BV_FP))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000111#ifdef FEAT_EVAL
112# define PV_FEX OPT_BUF(BV_FEX)
113#endif
114#define PV_FF OPT_BUF(BV_FF)
115#define PV_FLP OPT_BUF(BV_FLP)
116#define PV_FO OPT_BUF(BV_FO)
117#ifdef FEAT_AUTOCMD
118# define PV_FT OPT_BUF(BV_FT)
119#endif
120#define PV_IMI OPT_BUF(BV_IMI)
121#define PV_IMS OPT_BUF(BV_IMS)
122#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
123# define PV_INDE OPT_BUF(BV_INDE)
124# define PV_INDK OPT_BUF(BV_INDK)
125#endif
126#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
127# define PV_INEX OPT_BUF(BV_INEX)
128#endif
129#define PV_INF OPT_BUF(BV_INF)
130#define PV_ISK OPT_BUF(BV_ISK)
131#ifdef FEAT_CRYPT
132# define PV_KEY OPT_BUF(BV_KEY)
133#endif
134#ifdef FEAT_KEYMAP
135# define PV_KMAP OPT_BUF(BV_KMAP)
136#endif
137#define PV_KP OPT_BOTH(OPT_BUF(BV_KP))
138#ifdef FEAT_LISP
139# define PV_LISP OPT_BUF(BV_LISP)
Bram Moolenaaraf6c1312014-03-12 18:55:58 +0100140# define PV_LW OPT_BOTH(OPT_BUF(BV_LW))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000141#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +0100142#ifdef FEAT_MBYTE
143# define PV_MENC OPT_BOTH(OPT_BUF(BV_MENC))
144#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000145#define PV_MA OPT_BUF(BV_MA)
146#define PV_ML OPT_BUF(BV_ML)
147#define PV_MOD OPT_BUF(BV_MOD)
148#define PV_MPS OPT_BUF(BV_MPS)
149#define PV_NF OPT_BUF(BV_NF)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000150#ifdef FEAT_COMPL_FUNC
151# define PV_OFU OPT_BUF(BV_OFU)
152#endif
153#define PV_PATH OPT_BOTH(OPT_BUF(BV_PATH))
154#define PV_PI OPT_BUF(BV_PI)
155#ifdef FEAT_TEXTOBJ
156# define PV_QE OPT_BUF(BV_QE)
157#endif
158#define PV_RO OPT_BUF(BV_RO)
159#ifdef FEAT_SMARTINDENT
160# define PV_SI OPT_BUF(BV_SI)
161#endif
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100162#define PV_SN OPT_BUF(BV_SN)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000163#ifdef FEAT_SYN_HL
164# define PV_SMC OPT_BUF(BV_SMC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000165# define PV_SYN OPT_BUF(BV_SYN)
166#endif
167#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000168# define PV_SPC OPT_BUF(BV_SPC)
169# define PV_SPF OPT_BUF(BV_SPF)
170# define PV_SPL OPT_BUF(BV_SPL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000171#endif
172#define PV_STS OPT_BUF(BV_STS)
173#ifdef FEAT_SEARCHPATH
174# define PV_SUA OPT_BUF(BV_SUA)
175#endif
176#define PV_SW OPT_BUF(BV_SW)
177#define PV_SWF OPT_BUF(BV_SWF)
178#define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS))
Bram Moolenaar0f6562e2015-11-24 18:48:14 +0100179#define PV_TC OPT_BOTH(OPT_BUF(BV_TC))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000180#define PV_TS OPT_BUF(BV_TS)
181#define PV_TW OPT_BUF(BV_TW)
182#define PV_TX OPT_BUF(BV_TX)
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200183#ifdef FEAT_PERSISTENT_UNDO
184# define PV_UDF OPT_BUF(BV_UDF)
185#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000186#define PV_WM OPT_BUF(BV_WM)
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000187
188/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000189 * Definition of the PV_ values for window-local options.
190 * The WV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000191 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000192#define PV_LIST OPT_WIN(WV_LIST)
193#ifdef FEAT_ARABIC
194# define PV_ARAB OPT_WIN(WV_ARAB)
195#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +0200196#ifdef FEAT_LINEBREAK
197# define PV_BRI OPT_WIN(WV_BRI)
198# define PV_BRIOPT OPT_WIN(WV_BRIOPT)
199#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000200#ifdef FEAT_DIFF
201# define PV_DIFF OPT_WIN(WV_DIFF)
202#endif
203#ifdef FEAT_FOLDING
204# define PV_FDC OPT_WIN(WV_FDC)
205# define PV_FEN OPT_WIN(WV_FEN)
206# define PV_FDI OPT_WIN(WV_FDI)
207# define PV_FDL OPT_WIN(WV_FDL)
208# define PV_FDM OPT_WIN(WV_FDM)
209# define PV_FML OPT_WIN(WV_FML)
210# define PV_FDN OPT_WIN(WV_FDN)
211# ifdef FEAT_EVAL
212# define PV_FDE OPT_WIN(WV_FDE)
213# define PV_FDT OPT_WIN(WV_FDT)
214# endif
215# define PV_FMR OPT_WIN(WV_FMR)
216#endif
217#ifdef FEAT_LINEBREAK
218# define PV_LBR OPT_WIN(WV_LBR)
219#endif
220#define PV_NU OPT_WIN(WV_NU)
Bram Moolenaar64486672010-05-16 15:46:46 +0200221#define PV_RNU OPT_WIN(WV_RNU)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000222#ifdef FEAT_LINEBREAK
223# define PV_NUW OPT_WIN(WV_NUW)
224#endif
225#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
226# define PV_PVW OPT_WIN(WV_PVW)
227#endif
228#ifdef FEAT_RIGHTLEFT
229# define PV_RL OPT_WIN(WV_RL)
230# define PV_RLC OPT_WIN(WV_RLC)
231#endif
232#ifdef FEAT_SCROLLBIND
233# define PV_SCBIND OPT_WIN(WV_SCBIND)
234#endif
235#define PV_SCROLL OPT_WIN(WV_SCROLL)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000236#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000237# define PV_SPELL OPT_WIN(WV_SPELL)
238#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000239#ifdef FEAT_SYN_HL
240# define PV_CUC OPT_WIN(WV_CUC)
241# define PV_CUL OPT_WIN(WV_CUL)
Bram Moolenaar1a384422010-07-14 19:53:30 +0200242# define PV_CC OPT_WIN(WV_CC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000243#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000244#ifdef FEAT_STL_OPT
245# define PV_STL OPT_BOTH(OPT_WIN(WV_STL))
246#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +0100247#define PV_UL OPT_BOTH(OPT_BUF(BV_UL))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000248#ifdef FEAT_WINDOWS
249# define PV_WFH OPT_WIN(WV_WFH)
Bram Moolenaar97b2ad32006-03-18 21:40:56 +0000250# define PV_WFW OPT_WIN(WV_WFW)
251#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000252#define PV_WRAP OPT_WIN(WV_WRAP)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200253#ifdef FEAT_CURSORBIND
254# define PV_CRBIND OPT_WIN(WV_CRBIND)
255#endif
256#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200257# define PV_COCU OPT_WIN(WV_COCU)
258# define PV_COLE OPT_WIN(WV_COLE)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200259#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +0200260#ifdef FEAT_SIGNS
261# define PV_SCL OPT_WIN(WV_SCL)
262#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000263
264/* WV_ and BV_ values get typecasted to this for the "indir" field */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000265typedef enum
266{
Bram Moolenaar7d96acd2008-06-09 15:07:54 +0000267 PV_NONE = 0,
268 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000269} idopt_T;
270
271/*
272 * Options local to a window have a value local to a buffer and global to all
273 * buffers. Indicate this by setting "var" to VAR_WIN.
274 */
275#define VAR_WIN ((char_u *)-1)
276
277/*
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000278 * These are the global values for options which are also local to a buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000279 * Only to be used in option.c!
280 */
281static int p_ai;
282static int p_bin;
283#ifdef FEAT_MBYTE
284static int p_bomb;
285#endif
286#if defined(FEAT_QUICKFIX)
287static char_u *p_bh;
288static char_u *p_bt;
289#endif
290static int p_bl;
291static int p_ci;
292#ifdef FEAT_CINDENT
293static int p_cin;
294static char_u *p_cink;
295static char_u *p_cino;
296#endif
297#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
298static char_u *p_cinw;
299#endif
300#ifdef FEAT_COMMENTS
301static char_u *p_com;
302#endif
303#ifdef FEAT_FOLDING
304static char_u *p_cms;
305#endif
306#ifdef FEAT_INS_EXPAND
307static char_u *p_cpt;
308#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000309#ifdef FEAT_COMPL_FUNC
310static char_u *p_cfu;
Bram Moolenaare344bea2005-09-01 20:46:49 +0000311static char_u *p_ofu;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000312#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000313static int p_eol;
Bram Moolenaar34d72d42015-07-17 14:18:08 +0200314static int p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000315static int p_et;
316#ifdef FEAT_MBYTE
317static char_u *p_fenc;
318#endif
319static char_u *p_ff;
320static char_u *p_fo;
Bram Moolenaar86b68352004-12-27 21:59:20 +0000321static char_u *p_flp;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000322#ifdef FEAT_AUTOCMD
323static char_u *p_ft;
324#endif
325static long p_iminsert;
326static long p_imsearch;
327#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
328static char_u *p_inex;
329#endif
330#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
331static char_u *p_inde;
332static char_u *p_indk;
333#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +0000334#if defined(FEAT_EVAL)
335static char_u *p_fex;
336#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000337static int p_inf;
338static char_u *p_isk;
339#ifdef FEAT_CRYPT
340static char_u *p_key;
341#endif
342#ifdef FEAT_LISP
343static int p_lisp;
344#endif
345static int p_ml;
346static int p_ma;
347static int p_mod;
348static char_u *p_mps;
349static char_u *p_nf;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000350static int p_pi;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000351#ifdef FEAT_TEXTOBJ
352static char_u *p_qe;
353#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000354static int p_ro;
355#ifdef FEAT_SMARTINDENT
356static int p_si;
357#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000358static int p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000359static long p_sts;
360#if defined(FEAT_SEARCHPATH)
361static char_u *p_sua;
362#endif
363static long p_sw;
364static int p_swf;
365#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +0000366static long p_smc;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000367static char_u *p_syn;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000368#endif
369#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000370static char_u *p_spc;
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000371static char_u *p_spf;
Bram Moolenaar217ad922005-03-20 22:37:15 +0000372static char_u *p_spl;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000373#endif
374static long p_ts;
375static long p_tw;
376static int p_tx;
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200377#ifdef FEAT_PERSISTENT_UNDO
378static int p_udf;
379#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000380static long p_wm;
381#ifdef FEAT_KEYMAP
382static char_u *p_keymap;
383#endif
384
385/* Saved values for when 'bin' is set. */
386static int p_et_nobin;
387static int p_ml_nobin;
388static long p_tw_nobin;
389static long p_wm_nobin;
390
391/* Saved values for when 'paste' is set */
Bram Moolenaar54f018c2015-09-15 17:30:40 +0200392static int p_ai_nopaste;
393static int p_et_nopaste;
394static long p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000395static long p_tw_nopaste;
396static long p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000397
398struct vimoption
399{
400 char *fullname; /* full option name */
401 char *shortname; /* permissible abbreviation */
402 long_u flags; /* see below */
403 char_u *var; /* global option: pointer to variable;
404 * window-local option: VAR_WIN;
405 * buffer-local option: global value */
406 idopt_T indir; /* global option: PV_NONE;
407 * local option: indirect option index */
408 char_u *def_val[2]; /* default values for variable (vi and vim) */
409#ifdef FEAT_EVAL
410 scid_T scriptID; /* script in which the option was last set */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000411# define SCRIPTID_INIT , 0
412#else
413# define SCRIPTID_INIT
Bram Moolenaar071d4272004-06-13 20:20:40 +0000414#endif
415};
416
417#define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */
418#define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */
419
420/*
421 * Flags
422 */
423#define P_BOOL 0x01 /* the option is boolean */
424#define P_NUM 0x02 /* the option is numeric */
425#define P_STRING 0x04 /* the option is a string */
426#define P_ALLOCED 0x08 /* the string option is in allocated memory,
Bram Moolenaar363cb672009-07-22 12:28:17 +0000427 must use free_string_option() when
428 assigning new value. Not set if default is
429 the same. */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000430#define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
431 never be used for local or hidden options! */
432#define P_NODEFAULT 0x40 /* don't set to default value */
433#define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must
434 use vim_free() when assigning new value */
435#define P_WAS_SET 0x100 /* option has been set/reset */
436#define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */
437#define P_VI_DEF 0x400 /* Use Vi default for Vim */
438#define P_VIM 0x800 /* Vim option, reset when 'cp' set */
439
440 /* when option changed, what to display: */
441#define P_RSTAT 0x1000 /* redraw status lines */
Bram Moolenaara2477fd2016-12-03 15:13:20 +0100442#define P_RWIN 0x2000 /* redraw current window and recompute text */
443#define P_RBUF 0x4000 /* redraw current buffer and recompute text */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000444#define P_RALL 0x6000 /* redraw all windows */
445#define P_RCLR 0x7000 /* clear and redraw all */
446
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200447#define P_COMMA 0x8000 /* comma separated list */
448#define P_ONECOMMA 0x18000L /* P_COMMA and cannot have two consecutive
449 * commas */
450#define P_NODUP 0x20000L /* don't allow duplicate strings */
451#define P_FLAGLIST 0x40000L /* list of single-char flags */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000452
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200453#define P_SECURE 0x80000L /* cannot change in modeline or secure mode */
454#define P_GETTEXT 0x100000L /* expand default value with _() */
455#define P_NOGLOB 0x200000L /* do not use local value for global vimrc */
456#define P_NFNAME 0x400000L /* only normal file name chars allowed */
457#define P_INSECURE 0x800000L /* option was set from a modeline */
458#define P_PRI_MKRC 0x1000000L /* priority for :mkvimrc (setting option has
Bram Moolenaar7554da42016-11-25 22:04:13 +0100459 side effects) */
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200460#define P_NO_ML 0x2000000L /* not allowed in modeline */
461#define P_CURSWANT 0x4000000L /* update curswant required; not needed when
Bram Moolenaar913077c2012-03-28 19:59:04 +0200462 * there is a redraw flag */
Bram Moolenaar7554da42016-11-25 22:04:13 +0100463#define P_NDNAME 0x8000000L /* only normal dir name chars allowed */
Bram Moolenaara2477fd2016-12-03 15:13:20 +0100464#define P_RWINONLY 0x10000000L /* only redraw current window */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000465
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000466#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
467
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000468/* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used
469 * for the currency sign. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100470#if defined(MSWIN)
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000471# define ISP_LATIN1 (char_u *)"@,~-255"
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000472#else
473# define ISP_LATIN1 (char_u *)"@,161-255"
474#endif
475
Bram Moolenaar44a2f922016-03-19 22:11:51 +0100476/* Make the string as short as possible when compiling with few features. */
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000477#if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
Bram Moolenaar44a2f922016-03-19 22:11:51 +0100478 || defined(FEAT_WINDOWS) || defined(FEAT_CLIPBOARD) \
Bram Moolenaar21020352017-06-13 17:21:04 +0200479 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) \
480 || defined(FEAT_CONCEAL) || defined(FEAT_QUICKFIX)
481# 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,q:QuickFixLine"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000482#else
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100483# 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 +0000484#endif
485
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +0100486/* Default python version for pyx* commands */
487#if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3)
488# define DEFAULT_PYTHON_VER 0
489#elif defined(FEAT_PYTHON3)
490# define DEFAULT_PYTHON_VER 3
491#elif defined(FEAT_PYTHON)
492# define DEFAULT_PYTHON_VER 2
493#else
494# define DEFAULT_PYTHON_VER 0
495#endif
496
Bram Moolenaar071d4272004-06-13 20:20:40 +0000497/*
498 * options[] is initialized here.
499 * The order of the options MUST be alphabetic for ":set all" and findoption().
500 * All option names MUST start with a lowercase letter (for findoption()).
501 * Exception: "t_" options are at the end.
502 * The options with a NULL variable are 'hidden': a set command for them is
503 * ignored and they are not printed.
504 */
Bram Moolenaare89ff042016-02-20 22:17:05 +0100505static struct vimoption options[] =
Bram Moolenaar071d4272004-06-13 20:20:40 +0000506{
Bram Moolenaar913077c2012-03-28 19:59:04 +0200507 {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000508#ifdef FEAT_RIGHTLEFT
509 (char_u *)&p_aleph, PV_NONE,
510#else
511 (char_u *)NULL, PV_NONE,
512#endif
513 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100514#if (defined(WIN3264)) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000515 (char_u *)128L,
516#else
517 (char_u *)224L,
518#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000519 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000520 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
521#if defined(FEAT_GUI) && defined(MACOS_X)
522 (char_u *)&p_antialias, PV_NONE,
523 {(char_u *)FALSE, (char_u *)FALSE}
524#else
525 (char_u *)NULL, PV_NONE,
526 {(char_u *)FALSE, (char_u *)FALSE}
527#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000528 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200529 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000530#ifdef FEAT_ARABIC
531 (char_u *)VAR_WIN, PV_ARAB,
532#else
533 (char_u *)NULL, PV_NONE,
534#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000535 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000536 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
537#ifdef FEAT_ARABIC
538 (char_u *)&p_arshape, PV_NONE,
539#else
540 (char_u *)NULL, PV_NONE,
541#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000542 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000543 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
544#ifdef FEAT_RIGHTLEFT
545 (char_u *)&p_ari, PV_NONE,
546#else
547 (char_u *)NULL, PV_NONE,
548#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000549 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000550 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
551#ifdef FEAT_FKMAP
552 (char_u *)&p_altkeymap, PV_NONE,
553#else
554 (char_u *)NULL, PV_NONE,
555#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000556 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000557 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
558#if defined(FEAT_MBYTE)
559 (char_u *)&p_ambw, PV_NONE,
560 {(char_u *)"single", (char_u *)0L}
561#else
562 (char_u *)NULL, PV_NONE,
563 {(char_u *)0L, (char_u *)0L}
564#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000565 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000566 {"autochdir", "acd", P_BOOL|P_VI_DEF,
Bram Moolenaara713ff82017-02-25 22:18:43 +0100567#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +0000568 (char_u *)&p_acd, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +0100569 {(char_u *)FALSE, (char_u *)0L}
570#else
571 (char_u *)NULL, PV_NONE,
572 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000573#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +0100574 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000575 {"autoindent", "ai", P_BOOL|P_VI_DEF,
576 (char_u *)&p_ai, PV_AI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000577 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000578 {"autoprint", "ap", P_BOOL|P_VI_DEF,
579 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000580 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000581 {"autoread", "ar", P_BOOL|P_VI_DEF,
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000582 (char_u *)&p_ar, PV_AR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000583 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000584 {"autowrite", "aw", P_BOOL|P_VI_DEF,
585 (char_u *)&p_aw, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000586 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000587 {"autowriteall","awa", P_BOOL|P_VI_DEF,
588 (char_u *)&p_awa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000589 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000590 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
591 (char_u *)&p_bg, PV_NONE,
592 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100593#if (defined(WIN3264)) && !defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000594 (char_u *)"dark",
595#else
596 (char_u *)"light",
597#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000598 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200599 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000600 (char_u *)&p_bs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000601 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000602 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
603 (char_u *)&p_bk, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000604 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200605 {"backupcopy", "bkc", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +0200606 (char_u *)&p_bkc, PV_BKC,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000607#ifdef UNIX
608 {(char_u *)"yes", (char_u *)"auto"}
609#else
610 {(char_u *)"auto", (char_u *)"auto"}
611#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000612 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200613 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
614 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000615 (char_u *)&p_bdir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000616 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000617 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000618 (char_u *)&p_bex, PV_NONE,
619 {
620#ifdef VMS
621 (char_u *)"_",
622#else
623 (char_u *)"~",
624#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000625 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200626 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000627#ifdef FEAT_WILDIGN
628 (char_u *)&p_bsk, PV_NONE,
629 {(char_u *)"", (char_u *)0L}
630#else
631 (char_u *)NULL, PV_NONE,
632 {(char_u *)0L, (char_u *)0L}
633#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000634 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000635 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100636#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +0000637 (char_u *)&p_bdlay, PV_NONE,
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100638 {(char_u *)600L, (char_u *)0L}
639#else
640 (char_u *)NULL, PV_NONE,
641 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000642#endif
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100643 SCRIPTID_INIT},
644 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
645#ifdef FEAT_BEVAL
646 (char_u *)&p_beval, PV_NONE,
647 {(char_u *)FALSE, (char_u *)0L}
648#else
649 (char_u *)NULL, PV_NONE,
650 {(char_u *)0L, (char_u *)0L}
651#endif
652 SCRIPTID_INIT},
653 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
654#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
655 (char_u *)&p_bexpr, PV_BEXPR,
656 {(char_u *)"", (char_u *)0L}
657#else
658 (char_u *)NULL, PV_NONE,
659 {(char_u *)0L, (char_u *)0L}
660#endif
661 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000662 {"beautify", "bf", P_BOOL|P_VI_DEF,
663 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000664 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar165bc692015-07-21 17:53:25 +0200665 {"belloff", "bo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
666 (char_u *)&p_bo, PV_NONE,
667 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000668 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
669 (char_u *)&p_bin, PV_BIN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000670 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000671 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000672 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000673 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000674 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
675#ifdef FEAT_MBYTE
676 (char_u *)&p_bomb, PV_BOMB,
677#else
678 (char_u *)NULL, PV_NONE,
679#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000680 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000681 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
682#ifdef FEAT_LINEBREAK
683 (char_u *)&p_breakat, PV_NONE,
684 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
685#else
686 (char_u *)NULL, PV_NONE,
687 {(char_u *)0L, (char_u *)0L}
688#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000689 SCRIPTID_INIT},
Bram Moolenaar597a4222014-06-25 14:39:50 +0200690 {"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
691#ifdef FEAT_LINEBREAK
692 (char_u *)VAR_WIN, PV_BRI,
693 {(char_u *)FALSE, (char_u *)0L}
694#else
695 (char_u *)NULL, PV_NONE,
696 {(char_u *)0L, (char_u *)0L}
697#endif
698 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200699 {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF
700 |P_ONECOMMA|P_NODUP,
Bram Moolenaar597a4222014-06-25 14:39:50 +0200701#ifdef FEAT_LINEBREAK
702 (char_u *)VAR_WIN, PV_BRIOPT,
703 {(char_u *)"", (char_u *)NULL}
704#else
705 (char_u *)NULL, PV_NONE,
706 {(char_u *)"", (char_u *)NULL}
707#endif
708 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000709 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
710#ifdef FEAT_BROWSE
711 (char_u *)&p_bsdir, PV_NONE,
712 {(char_u *)"last", (char_u *)0L}
713#else
714 (char_u *)NULL, PV_NONE,
715 {(char_u *)0L, (char_u *)0L}
716#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000717 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000718 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
719#if defined(FEAT_QUICKFIX)
720 (char_u *)&p_bh, PV_BH,
721 {(char_u *)"", (char_u *)0L}
722#else
723 (char_u *)NULL, PV_NONE,
724 {(char_u *)0L, (char_u *)0L}
725#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000726 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000727 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
728 (char_u *)&p_bl, PV_BL,
729 {(char_u *)1L, (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000730 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000731 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
732#if defined(FEAT_QUICKFIX)
733 (char_u *)&p_bt, PV_BT,
734 {(char_u *)"", (char_u *)0L}
735#else
736 (char_u *)NULL, PV_NONE,
737 {(char_u *)0L, (char_u *)0L}
738#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000739 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200740 {"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000741#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000742 (char_u *)&p_cmp, PV_NONE,
743 {(char_u *)"internal,keepascii", (char_u *)0L}
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000744#else
745 (char_u *)NULL, PV_NONE,
746 {(char_u *)0L, (char_u *)0L}
747#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000748 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000749 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
750#ifdef FEAT_SEARCHPATH
751 (char_u *)&p_cdpath, PV_NONE,
752 {(char_u *)",,", (char_u *)0L}
753#else
754 (char_u *)NULL, PV_NONE,
755 {(char_u *)0L, (char_u *)0L}
756#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000757 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000758 {"cedit", NULL, P_STRING,
759#ifdef FEAT_CMDWIN
760 (char_u *)&p_cedit, PV_NONE,
761 {(char_u *)"", (char_u *)CTRL_F_STR}
762#else
763 (char_u *)NULL, PV_NONE,
764 {(char_u *)0L, (char_u *)0L}
765#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000766 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000767 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
768#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
769 (char_u *)&p_ccv, PV_NONE,
770 {(char_u *)"", (char_u *)0L}
771#else
772 (char_u *)NULL, PV_NONE,
773 {(char_u *)0L, (char_u *)0L}
774#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000775 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000776 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
777#ifdef FEAT_CINDENT
778 (char_u *)&p_cin, PV_CIN,
779#else
780 (char_u *)NULL, PV_NONE,
781#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000782 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200783 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000784#ifdef FEAT_CINDENT
785 (char_u *)&p_cink, PV_CINK,
786 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
787#else
788 (char_u *)NULL, PV_NONE,
789 {(char_u *)0L, (char_u *)0L}
790#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000791 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200792 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000793#ifdef FEAT_CINDENT
794 (char_u *)&p_cino, PV_CINO,
795#else
796 (char_u *)NULL, PV_NONE,
797#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000798 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200799 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000800#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
801 (char_u *)&p_cinw, PV_CINW,
802 {(char_u *)"if,else,while,do,for,switch",
803 (char_u *)0L}
804#else
805 (char_u *)NULL, PV_NONE,
806 {(char_u *)0L, (char_u *)0L}
807#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000808 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200809 {"clipboard", "cb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000810#ifdef FEAT_CLIPBOARD
811 (char_u *)&p_cb, PV_NONE,
812# ifdef FEAT_XCLIPBOARD
813 {(char_u *)"autoselect,exclude:cons\\|linux",
814 (char_u *)0L}
815# else
816 {(char_u *)"", (char_u *)0L}
817# endif
818#else
819 (char_u *)NULL, PV_NONE,
820 {(char_u *)"", (char_u *)0L}
821#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000822 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000823 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
824 (char_u *)&p_ch, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000825 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000826 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
827#ifdef FEAT_CMDWIN
828 (char_u *)&p_cwh, PV_NONE,
829#else
830 (char_u *)NULL, PV_NONE,
831#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000832 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200833 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar1a384422010-07-14 19:53:30 +0200834#ifdef FEAT_SYN_HL
835 (char_u *)VAR_WIN, PV_CC,
836#else
837 (char_u *)NULL, PV_NONE,
838#endif
839 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000840 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
841 (char_u *)&Columns, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000842 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200843 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
844 |P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000845#ifdef FEAT_COMMENTS
846 (char_u *)&p_com, PV_COM,
847 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
848 (char_u *)0L}
849#else
850 (char_u *)NULL, PV_NONE,
851 {(char_u *)0L, (char_u *)0L}
852#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000853 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200854 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000855#ifdef FEAT_FOLDING
856 (char_u *)&p_cms, PV_CMS,
857 {(char_u *)"/*%s*/", (char_u *)0L}
858#else
859 (char_u *)NULL, PV_NONE,
860 {(char_u *)0L, (char_u *)0L}
861#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000862 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000863 /* P_PRI_MKRC isn't needed here, optval_default()
864 * always returns TRUE for 'compatible' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000865 {"compatible", "cp", P_BOOL|P_RALL,
866 (char_u *)&p_cp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000867 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200868 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000869#ifdef FEAT_INS_EXPAND
870 (char_u *)&p_cpt, PV_CPT,
871 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
872#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 Moolenaarf5963f72010-07-23 22:10:27 +0200877 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200878#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200879 (char_u *)VAR_WIN, PV_COCU,
880 {(char_u *)"", (char_u *)NULL}
881#else
882 (char_u *)NULL, PV_NONE,
883 {(char_u *)NULL, (char_u *)0L}
884#endif
885 SCRIPTID_INIT},
886 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
887#ifdef FEAT_CONCEAL
888 (char_u *)VAR_WIN, PV_COLE,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200889#else
890 (char_u *)NULL, PV_NONE,
891#endif
892 {(char_u *)0L, (char_u *)0L}
893 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000894 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
895#ifdef FEAT_COMPL_FUNC
896 (char_u *)&p_cfu, PV_CFU,
897 {(char_u *)"", (char_u *)0L}
898#else
899 (char_u *)NULL, PV_NONE,
900 {(char_u *)0L, (char_u *)0L}
901#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000902 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200903 {"completeopt", "cot", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000904#ifdef FEAT_INS_EXPAND
905 (char_u *)&p_cot, PV_NONE,
Bram Moolenaarc270d802006-03-11 21:29:41 +0000906 {(char_u *)"menu,preview", (char_u *)0L}
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000907#else
908 (char_u *)NULL, PV_NONE,
909 {(char_u *)0L, (char_u *)0L}
910#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000911 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000912 {"confirm", "cf", P_BOOL|P_VI_DEF,
913#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
914 (char_u *)&p_confirm, PV_NONE,
915#else
916 (char_u *)NULL, PV_NONE,
917#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000918 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000919 {"conskey", "consk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000920 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000921 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000922 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
923 (char_u *)&p_ci, PV_CI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000924 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000925 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
926 (char_u *)&p_cpo, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000927 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
928 SCRIPTID_INIT},
Bram Moolenaar49771f42010-07-20 17:32:38 +0200929 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200930#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200931 (char_u *)&p_cm, PV_CM,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200932 {(char_u *)"zip", (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200933#else
934 (char_u *)NULL, PV_NONE,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200935 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200936#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +0200937 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000938 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
939#ifdef FEAT_CSCOPE
940 (char_u *)&p_cspc, PV_NONE,
941#else
942 (char_u *)NULL, PV_NONE,
943#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000944 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000945 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
946#ifdef FEAT_CSCOPE
947 (char_u *)&p_csprg, PV_NONE,
948 {(char_u *)"cscope", (char_u *)0L}
949#else
950 (char_u *)NULL, PV_NONE,
951 {(char_u *)0L, (char_u *)0L}
952#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000953 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200954 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000955#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
956 (char_u *)&p_csqf, PV_NONE,
957 {(char_u *)"", (char_u *)0L}
958#else
959 (char_u *)NULL, PV_NONE,
960 {(char_u *)0L, (char_u *)0L}
961#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000962 SCRIPTID_INIT},
Bram Moolenaarf7befa92011-06-12 22:13:40 +0200963 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM,
964#ifdef FEAT_CSCOPE
965 (char_u *)&p_csre, PV_NONE,
966#else
967 (char_u *)NULL, PV_NONE,
968#endif
969 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000970 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
971#ifdef FEAT_CSCOPE
972 (char_u *)&p_cst, PV_NONE,
973#else
974 (char_u *)NULL, PV_NONE,
975#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000976 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000977 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
978#ifdef FEAT_CSCOPE
979 (char_u *)&p_csto, PV_NONE,
980#else
981 (char_u *)NULL, PV_NONE,
982#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000983 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000984 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
985#ifdef FEAT_CSCOPE
986 (char_u *)&p_csverbose, PV_NONE,
987#else
988 (char_u *)NULL, PV_NONE,
989#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000990 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200991 {"cursorbind", "crb", P_BOOL|P_VI_DEF,
992#ifdef FEAT_CURSORBIND
993 (char_u *)VAR_WIN, PV_CRBIND,
994#else
995 (char_u *)NULL, PV_NONE,
996#endif
997 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000998 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
999#ifdef FEAT_SYN_HL
1000 (char_u *)VAR_WIN, PV_CUC,
1001#else
1002 (char_u *)NULL, PV_NONE,
1003#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001004 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara2477fd2016-12-03 15:13:20 +01001005 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWINONLY,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001006#ifdef FEAT_SYN_HL
1007 (char_u *)VAR_WIN, PV_CUL,
1008#else
1009 (char_u *)NULL, PV_NONE,
1010#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001011 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001012 {"debug", NULL, P_STRING|P_VI_DEF,
1013 (char_u *)&p_debug, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001014 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001015 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001016#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001017 (char_u *)&p_def, PV_DEF,
Bram Moolenaard4755bb2004-09-02 19:12:26 +00001018 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001019#else
1020 (char_u *)NULL, PV_NONE,
1021 {(char_u *)NULL, (char_u *)0L}
1022#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001023 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001024 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
1025#ifdef FEAT_MBYTE
1026 (char_u *)&p_deco, PV_NONE,
1027#else
1028 (char_u *)NULL, PV_NONE,
1029#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001030 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7554da42016-11-25 22:04:13 +01001031 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001032#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001033 (char_u *)&p_dict, PV_DICT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001034#else
1035 (char_u *)NULL, PV_NONE,
1036#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001037 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001038 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
1039#ifdef FEAT_DIFF
1040 (char_u *)VAR_WIN, PV_DIFF,
1041#else
1042 (char_u *)NULL, PV_NONE,
1043#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001044 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001045 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001046#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1047 (char_u *)&p_dex, PV_NONE,
1048 {(char_u *)"", (char_u *)0L}
1049#else
1050 (char_u *)NULL, PV_NONE,
1051 {(char_u *)0L, (char_u *)0L}
1052#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001053 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001054 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_ONECOMMA
1055 |P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001056#ifdef FEAT_DIFF
1057 (char_u *)&p_dip, PV_NONE,
1058 {(char_u *)"filler", (char_u *)NULL}
1059#else
1060 (char_u *)NULL, PV_NONE,
1061 {(char_u *)"", (char_u *)NULL}
1062#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001063 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001064 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
1065#ifdef FEAT_DIGRAPHS
1066 (char_u *)&p_dg, PV_NONE,
1067#else
1068 (char_u *)NULL, PV_NONE,
1069#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001070 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001071 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
1072 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001073 (char_u *)&p_dir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001074 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001075 {"display", "dy", P_STRING|P_VI_DEF|P_ONECOMMA|P_RALL|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001076 (char_u *)&p_dy, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001077 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001078 {"eadirection", "ead", P_STRING|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01001079#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001080 (char_u *)&p_ead, PV_NONE,
1081 {(char_u *)"both", (char_u *)0L}
1082#else
1083 (char_u *)NULL, PV_NONE,
1084 {(char_u *)NULL, (char_u *)0L}
1085#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001086 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001087 {"edcompatible","ed", P_BOOL|P_VI_DEF,
1088 (char_u *)&p_ed, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001089 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3848e002016-03-19 18:42:29 +01001090 {"emoji", "emo", P_BOOL|P_VI_DEF|P_RCLR,
1091#if defined(FEAT_MBYTE)
1092 (char_u *)&p_emoji, PV_NONE,
1093 {(char_u *)TRUE, (char_u *)0L}
1094#else
1095 (char_u *)NULL, PV_NONE,
1096 {(char_u *)0L, (char_u *)0L}
1097#endif
1098 SCRIPTID_INIT},
Bram Moolenaar865242e2010-07-14 21:12:05 +02001099 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001100#ifdef FEAT_MBYTE
1101 (char_u *)&p_enc, PV_NONE,
1102 {(char_u *)ENC_DFLT, (char_u *)0L}
1103#else
1104 (char_u *)NULL, PV_NONE,
1105 {(char_u *)0L, (char_u *)0L}
1106#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001107 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001108 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1109 (char_u *)&p_eol, PV_EOL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001110 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001111 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1112 (char_u *)&p_ea, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001113 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001114 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001115 (char_u *)&p_ep, PV_EP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001116 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001117 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1118 (char_u *)&p_eb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001119 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001120 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1121#ifdef FEAT_QUICKFIX
1122 (char_u *)&p_ef, PV_NONE,
1123 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1124#else
1125 (char_u *)NULL, PV_NONE,
1126 {(char_u *)NULL, (char_u *)0L}
1127#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001128 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001129 {"errorformat", "efm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001130#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001131 (char_u *)&p_efm, PV_EFM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001132 {(char_u *)DFLT_EFM, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001133#else
1134 (char_u *)NULL, PV_NONE,
1135 {(char_u *)NULL, (char_u *)0L}
1136#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001137 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001138 {"esckeys", "ek", P_BOOL|P_VIM,
1139 (char_u *)&p_ek, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001140 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001141 {"eventignore", "ei", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001142#ifdef FEAT_AUTOCMD
1143 (char_u *)&p_ei, PV_NONE,
1144#else
1145 (char_u *)NULL, PV_NONE,
1146#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001147 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001148 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1149 (char_u *)&p_et, PV_ET,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001150 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001151 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1152 (char_u *)&p_exrc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001153 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001154 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF
1155 |P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001156#ifdef FEAT_MBYTE
1157 (char_u *)&p_fenc, PV_FENC,
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 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001165#ifdef FEAT_MBYTE
1166 (char_u *)&p_fencs, PV_NONE,
1167 {(char_u *)"ucs-bom", (char_u *)0L}
1168#else
1169 (char_u *)NULL, PV_NONE,
1170 {(char_u *)0L, (char_u *)0L}
1171#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001172 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001173 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC
1174 |P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001175 (char_u *)&p_ff, PV_FF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001176 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001177 {"fileformats", "ffs", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001178 (char_u *)&p_ffs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001179 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1180 SCRIPTID_INIT},
Bram Moolenaar71afbfe2013-03-19 16:49:16 +01001181 {"fileignorecase", "fic", P_BOOL|P_VI_DEF,
1182 (char_u *)&p_fic, PV_NONE,
1183 {
1184#ifdef CASE_INSENSITIVE_FILENAME
1185 (char_u *)TRUE,
1186#else
1187 (char_u *)FALSE,
1188#endif
1189 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001190 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001191#ifdef FEAT_AUTOCMD
1192 (char_u *)&p_ft, PV_FT,
1193 {(char_u *)"", (char_u *)0L}
1194#else
1195 (char_u *)NULL, PV_NONE,
1196 {(char_u *)0L, (char_u *)0L}
1197#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001198 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001199 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001200#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1201 (char_u *)&p_fcs, PV_NONE,
1202 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1203#else
1204 (char_u *)NULL, PV_NONE,
1205 {(char_u *)"", (char_u *)0L}
1206#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001207 SCRIPTID_INIT},
Bram Moolenaar34d72d42015-07-17 14:18:08 +02001208 {"fixendofline", "fixeol", P_BOOL|P_VI_DEF|P_RSTAT,
1209 (char_u *)&p_fixeol, PV_FIXEOL,
1210 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001211 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1212#ifdef FEAT_FKMAP
1213 (char_u *)&p_fkmap, PV_NONE,
1214#else
1215 (char_u *)NULL, PV_NONE,
1216#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001217 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001218 {"flash", "fl", P_BOOL|P_VI_DEF,
1219 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001220 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001221 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001222#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001223 (char_u *)&p_fcl, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001224 {(char_u *)"", (char_u *)0L}
1225#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001226 (char_u *)NULL, PV_NONE,
1227 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001228#endif
1229 SCRIPTID_INIT},
1230 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1231#ifdef FEAT_FOLDING
1232 (char_u *)VAR_WIN, PV_FDC,
1233 {(char_u *)FALSE, (char_u *)0L}
1234#else
1235 (char_u *)NULL, PV_NONE,
1236 {(char_u *)NULL, (char_u *)0L}
1237#endif
1238 SCRIPTID_INIT},
1239 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1240#ifdef FEAT_FOLDING
1241 (char_u *)VAR_WIN, PV_FEN,
1242 {(char_u *)TRUE, (char_u *)0L}
1243#else
1244 (char_u *)NULL, PV_NONE,
1245 {(char_u *)NULL, (char_u *)0L}
1246#endif
1247 SCRIPTID_INIT},
1248 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1249#if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
1250 (char_u *)VAR_WIN, PV_FDE,
1251 {(char_u *)"0", (char_u *)NULL}
1252#else
1253 (char_u *)NULL, PV_NONE,
1254 {(char_u *)NULL, (char_u *)0L}
1255#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001256 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001257 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001258#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001259 (char_u *)VAR_WIN, PV_FDI,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001260 {(char_u *)"#", (char_u *)NULL}
1261#else
1262 (char_u *)NULL, PV_NONE,
1263 {(char_u *)NULL, (char_u *)0L}
1264#endif
1265 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001266 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001267#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001268 (char_u *)VAR_WIN, PV_FDL,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001269 {(char_u *)0L, (char_u *)0L}
1270#else
1271 (char_u *)NULL, PV_NONE,
1272 {(char_u *)NULL, (char_u *)0L}
1273#endif
1274 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001275 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001276#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001277 (char_u *)&p_fdls, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001278 {(char_u *)-1L, (char_u *)0L}
1279#else
1280 (char_u *)NULL, PV_NONE,
1281 {(char_u *)NULL, (char_u *)0L}
1282#endif
1283 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001284 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001285 P_RWIN|P_ONECOMMA|P_NODUP,
Bram Moolenaar37640762017-02-25 22:37:15 +01001286#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001287 (char_u *)VAR_WIN, PV_FMR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001288 {(char_u *)"{{{,}}}", (char_u *)NULL}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001289#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001290 (char_u *)NULL, PV_NONE,
1291 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001292#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01001293 SCRIPTID_INIT},
1294 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1295#ifdef FEAT_FOLDING
1296 (char_u *)VAR_WIN, PV_FDM,
1297 {(char_u *)"manual", (char_u *)NULL}
1298#else
1299 (char_u *)NULL, PV_NONE,
1300 {(char_u *)NULL, (char_u *)0L}
1301#endif
1302 SCRIPTID_INIT},
1303 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1304#ifdef FEAT_FOLDING
1305 (char_u *)VAR_WIN, PV_FML,
1306 {(char_u *)1L, (char_u *)0L}
1307#else
1308 (char_u *)NULL, PV_NONE,
1309 {(char_u *)NULL, (char_u *)0L}
1310#endif
1311 SCRIPTID_INIT},
1312 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1313#ifdef FEAT_FOLDING
1314 (char_u *)VAR_WIN, PV_FDN,
1315 {(char_u *)20L, (char_u *)0L}
1316#else
1317 (char_u *)NULL, PV_NONE,
1318 {(char_u *)NULL, (char_u *)0L}
1319#endif
1320 SCRIPTID_INIT},
1321 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT,
1322#ifdef FEAT_FOLDING
1323 (char_u *)&p_fdo, PV_NONE,
1324 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
1325 (char_u *)0L}
1326#else
1327 (char_u *)NULL, PV_NONE,
1328 {(char_u *)NULL, (char_u *)0L}
1329#endif
1330 SCRIPTID_INIT},
1331 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1332#if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
1333 (char_u *)VAR_WIN, PV_FDT,
1334 {(char_u *)"foldtext()", (char_u *)NULL}
1335#else
1336 (char_u *)NULL, PV_NONE,
1337 {(char_u *)NULL, (char_u *)0L}
1338#endif
1339 SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001340 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001341#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001342 (char_u *)&p_fex, PV_FEX,
1343 {(char_u *)"", (char_u *)0L}
1344#else
1345 (char_u *)NULL, PV_NONE,
1346 {(char_u *)0L, (char_u *)0L}
1347#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001348 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001349 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1350 (char_u *)&p_fo, PV_FO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001351 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1352 SCRIPTID_INIT},
Bram Moolenaar86b68352004-12-27 21:59:20 +00001353 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1354 (char_u *)&p_flp, PV_FLP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001355 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1356 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001357 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar9be7c042017-01-14 14:28:30 +01001358 (char_u *)&p_fp, PV_FP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001359 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001360 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1361#ifdef HAVE_FSYNC
1362 (char_u *)&p_fs, PV_NONE,
1363 {(char_u *)TRUE, (char_u *)0L}
1364#else
1365 (char_u *)NULL, PV_NONE,
1366 {(char_u *)FALSE, (char_u *)0L}
1367#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001368 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001369 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1370 (char_u *)&p_gd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001371 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001372 {"graphic", "gr", P_BOOL|P_VI_DEF,
1373 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001374 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001375 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001376#ifdef FEAT_QUICKFIX
1377 (char_u *)&p_gefm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001378 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001379#else
1380 (char_u *)NULL, PV_NONE,
1381 {(char_u *)NULL, (char_u *)0L}
1382#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001383 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001384 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1385#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001386 (char_u *)&p_gp, PV_GP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001387 {
1388# ifdef WIN3264
1389 /* may be changed to "grep -n" in os_win32.c */
1390 (char_u *)"findstr /n",
1391# else
1392# ifdef UNIX
1393 /* Add an extra file name so that grep will always
1394 * insert a file name in the match line. */
1395 (char_u *)"grep -n $* /dev/null",
1396# else
1397# ifdef VMS
1398 (char_u *)"SEARCH/NUMBERS ",
1399# else
1400 (char_u *)"grep -n ",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001401# endif
1402# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001403# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001404 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001405#else
1406 (char_u *)NULL, PV_NONE,
1407 {(char_u *)NULL, (char_u *)0L}
1408#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001409 SCRIPTID_INIT},
Bram Moolenaar8a633e32016-04-21 21:10:14 +02001410 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001411#ifdef CURSOR_SHAPE
1412 (char_u *)&p_guicursor, PV_NONE,
1413 {
1414# ifdef FEAT_GUI
1415 (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 +01001416# else /* Win32 console */
Bram Moolenaar071d4272004-06-13 20:20:40 +00001417 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1418# endif
1419 (char_u *)0L}
1420#else
1421 (char_u *)NULL, PV_NONE,
1422 {(char_u *)NULL, (char_u *)0L}
1423#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001424 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001425 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001426#ifdef FEAT_GUI
1427 (char_u *)&p_guifont, PV_NONE,
1428 {(char_u *)"", (char_u *)0L}
1429#else
1430 (char_u *)NULL, PV_NONE,
1431 {(char_u *)NULL, (char_u *)0L}
1432#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001433 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001434 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001435#if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1436 (char_u *)&p_guifontset, PV_NONE,
1437 {(char_u *)"", (char_u *)0L}
1438#else
1439 (char_u *)NULL, PV_NONE,
1440 {(char_u *)NULL, (char_u *)0L}
1441#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001442 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001443 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001444#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1445 (char_u *)&p_guifontwide, PV_NONE,
1446 {(char_u *)"", (char_u *)0L}
1447#else
1448 (char_u *)NULL, PV_NONE,
1449 {(char_u *)NULL, (char_u *)0L}
1450#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001451 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001452 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001453#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001454 (char_u *)&p_ghr, PV_NONE,
1455#else
1456 (char_u *)NULL, PV_NONE,
1457#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001458 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001459 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001460#if defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001461 (char_u *)&p_go, PV_NONE,
1462# if defined(UNIX) && !defined(MACOS)
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001463 {(char_u *)"aegimrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001464# else
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001465 {(char_u *)"egmrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001466# endif
1467#else
1468 (char_u *)NULL, PV_NONE,
1469 {(char_u *)NULL, (char_u *)0L}
1470#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001471 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001472 {"guipty", NULL, P_BOOL|P_VI_DEF,
1473#if defined(FEAT_GUI)
1474 (char_u *)&p_guipty, PV_NONE,
1475#else
1476 (char_u *)NULL, PV_NONE,
1477#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001478 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar18144c82006-04-12 21:52:12 +00001479 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00001480#if defined(FEAT_GUI_TABLINE)
1481 (char_u *)&p_gtl, PV_NONE,
1482 {(char_u *)"", (char_u *)0L}
1483#else
1484 (char_u *)NULL, PV_NONE,
1485 {(char_u *)NULL, (char_u *)0L}
1486#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001487 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001488 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar57657d82006-04-21 22:12:41 +00001489#if defined(FEAT_GUI_TABLINE)
1490 (char_u *)&p_gtt, PV_NONE,
1491 {(char_u *)"", (char_u *)0L}
1492#else
1493 (char_u *)NULL, PV_NONE,
1494 {(char_u *)NULL, (char_u *)0L}
1495#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001496 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001497 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1498 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001499 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001500 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1501 (char_u *)&p_hf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001502 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1503 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001504 {"helpheight", "hh", P_NUM|P_VI_DEF,
1505#ifdef FEAT_WINDOWS
1506 (char_u *)&p_hh, PV_NONE,
1507#else
1508 (char_u *)NULL, PV_NONE,
1509#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001510 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001511 {"helplang", "hlg", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001512#ifdef FEAT_MULTI_LANG
1513 (char_u *)&p_hlg, PV_NONE,
1514 {(char_u *)"", (char_u *)0L}
1515#else
1516 (char_u *)NULL, PV_NONE,
1517 {(char_u *)0L, (char_u *)0L}
1518#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001519 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001520 {"hidden", "hid", P_BOOL|P_VI_DEF,
1521 (char_u *)&p_hid, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001522 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001523 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001524 (char_u *)&p_hl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001525 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1526 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001527 {"history", "hi", P_NUM|P_VIM,
1528 (char_u *)&p_hi, PV_NONE,
Bram Moolenaar78159bb2014-06-25 11:48:54 +02001529 {(char_u *)0L, (char_u *)50L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001530 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1531#ifdef FEAT_RIGHTLEFT
1532 (char_u *)&p_hkmap, PV_NONE,
1533#else
1534 (char_u *)NULL, PV_NONE,
1535#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001536 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001537 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1538#ifdef FEAT_RIGHTLEFT
1539 (char_u *)&p_hkmapp, PV_NONE,
1540#else
1541 (char_u *)NULL, PV_NONE,
1542#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001543 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001544 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1545 (char_u *)&p_hls, 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 {"icon", NULL, P_BOOL|P_VI_DEF,
1548#ifdef FEAT_TITLE
1549 (char_u *)&p_icon, PV_NONE,
1550#else
1551 (char_u *)NULL, PV_NONE,
1552#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001553 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001554 {"iconstring", NULL, P_STRING|P_VI_DEF,
1555#ifdef FEAT_TITLE
1556 (char_u *)&p_iconstring, PV_NONE,
1557#else
1558 (char_u *)NULL, PV_NONE,
1559#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001560 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001561 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1562 (char_u *)&p_ic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001563 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001564 {"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
1565# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1566 (char_u *)&p_imaf, PV_NONE,
1567 {(char_u *)"", (char_u *)NULL}
1568# else
1569 (char_u *)NULL, PV_NONE,
1570 {(char_u *)NULL, (char_u *)0L}
1571# endif
1572 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001573 {"imactivatekey","imak",P_STRING|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001574#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001575 (char_u *)&p_imak, PV_NONE,
1576#else
1577 (char_u *)NULL, PV_NONE,
1578#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001579 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001580 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1581#ifdef USE_IM_CONTROL
1582 (char_u *)&p_imcmdline, PV_NONE,
1583#else
1584 (char_u *)NULL, PV_NONE,
1585#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001586 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001587 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1588#ifdef USE_IM_CONTROL
1589 (char_u *)&p_imdisable, PV_NONE,
1590#else
1591 (char_u *)NULL, PV_NONE,
1592#endif
1593#ifdef __sgi
1594 {(char_u *)TRUE, (char_u *)0L}
1595#else
1596 {(char_u *)FALSE, (char_u *)0L}
1597#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001598 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001599 {"iminsert", "imi", P_NUM|P_VI_DEF,
1600 (char_u *)&p_iminsert, PV_IMI,
1601#ifdef B_IMODE_IM
1602 {(char_u *)B_IMODE_IM, (char_u *)0L}
1603#else
1604 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1605#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001606 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001607 {"imsearch", "ims", P_NUM|P_VI_DEF,
1608 (char_u *)&p_imsearch, PV_IMS,
1609#ifdef B_IMODE_IM
1610 {(char_u *)B_IMODE_IM, (char_u *)0L}
1611#else
1612 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1613#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001614 SCRIPTID_INIT},
Bram Moolenaar4a460702013-06-29 14:42:26 +02001615 {"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001616# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1617 (char_u *)&p_imsf, PV_NONE,
1618 {(char_u *)"", (char_u *)NULL}
1619# else
1620 (char_u *)NULL, PV_NONE,
1621 {(char_u *)NULL, (char_u *)0L}
1622# endif
1623 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001624 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1625#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001626 (char_u *)&p_inc, PV_INC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001627 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1628#else
1629 (char_u *)NULL, PV_NONE,
1630 {(char_u *)0L, (char_u *)0L}
1631#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001632 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001633 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1634#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1635 (char_u *)&p_inex, PV_INEX,
1636 {(char_u *)"", (char_u *)0L}
1637#else
1638 (char_u *)NULL, PV_NONE,
1639 {(char_u *)0L, (char_u *)0L}
1640#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001641 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001642 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1643 (char_u *)&p_is, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001644 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001645 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1646#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1647 (char_u *)&p_inde, PV_INDE,
1648 {(char_u *)"", (char_u *)0L}
1649#else
1650 (char_u *)NULL, PV_NONE,
1651 {(char_u *)0L, (char_u *)0L}
1652#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001653 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001654 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001655#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1656 (char_u *)&p_indk, PV_INDK,
1657 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1658#else
1659 (char_u *)NULL, PV_NONE,
1660 {(char_u *)0L, (char_u *)0L}
1661#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001662 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001663 {"infercase", "inf", P_BOOL|P_VI_DEF,
1664 (char_u *)&p_inf, PV_INF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001665 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001666 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1667 (char_u *)&p_im, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001668 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001669 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1670 (char_u *)&p_isf, PV_NONE,
1671 {
1672#ifdef BACKSLASH_IN_FILENAME
1673 /* Excluded are: & and ^ are special in cmd.exe
1674 * ( and ) are used in text separating fnames */
1675 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1676#else
1677# ifdef AMIGA
1678 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1679# else
1680# ifdef VMS
1681 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1682# else /* UNIX et al. */
1683# ifdef EBCDIC
1684 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1685# else
1686 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1687# endif
1688# endif
1689# endif
1690#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001691 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001692 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1693 (char_u *)&p_isi, PV_NONE,
1694 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001695#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001696 (char_u *)"@,48-57,_,128-167,224-235",
1697#else
1698# ifdef EBCDIC
1699 /* TODO: EBCDIC Check this! @ == isalpha()*/
1700 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1701 "112-120,128,140-142,156,158,172,"
1702 "174,186,191,203-207,219-225,235-239,"
1703 "251-254",
1704# else
1705 (char_u *)"@,48-57,_,192-255",
1706# endif
1707#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001708 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001709 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1710 (char_u *)&p_isk, PV_ISK,
1711 {
1712#ifdef EBCDIC
1713 (char_u *)"@,240-249,_",
1714 /* TODO: EBCDIC Check this! @ == isalpha()*/
1715 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1716 "112-120,128,140-142,156,158,172,"
1717 "174,186,191,203-207,219-225,235-239,"
1718 "251-254",
1719#else
1720 (char_u *)"@,48-57,_",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001721# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001722 (char_u *)"@,48-57,_,128-167,224-235"
1723# else
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001724 ISK_LATIN1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001725# endif
1726#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001727 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001728 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1729 (char_u *)&p_isp, PV_NONE,
1730 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001731#if defined(MSWIN) || (defined(MACOS) && !defined(MACOS_X)) \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001732 || defined(VMS)
1733 (char_u *)"@,~-255",
1734#else
1735# ifdef EBCDIC
1736 /* all chars above 63 are printable */
1737 (char_u *)"63-255",
1738# else
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00001739 ISP_LATIN1,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001740# endif
1741#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001742 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001743 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1744 (char_u *)&p_js, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001745 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001746 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1747#ifdef FEAT_CRYPT
1748 (char_u *)&p_key, PV_KEY,
1749 {(char_u *)"", (char_u *)0L}
1750#else
1751 (char_u *)NULL, PV_NONE,
1752 {(char_u *)0L, (char_u *)0L}
1753#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001754 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001755 {"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 +00001756#ifdef FEAT_KEYMAP
1757 (char_u *)&p_keymap, PV_KMAP,
1758 {(char_u *)"", (char_u *)0L}
1759#else
1760 (char_u *)NULL, PV_NONE,
1761 {(char_u *)"", (char_u *)0L}
1762#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001763 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001764 {"keymodel", "km", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001765 (char_u *)&p_km, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001766 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001767 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001768 (char_u *)&p_kp, PV_KP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001769 {
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +02001770#ifdef MSWIN
Bram Moolenaar071d4272004-06-13 20:20:40 +00001771 (char_u *)":help",
1772#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001773# ifdef VMS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001774 (char_u *)"help",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01001775# else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001776# ifdef USEMAN_S
1777 (char_u *)"man -s",
1778# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001779 (char_u *)"man",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001780# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001781# endif
1782#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001783 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001784 {"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001785#ifdef FEAT_LANGMAP
1786 (char_u *)&p_langmap, PV_NONE,
1787 {(char_u *)"", /* unmatched } */
1788#else
1789 (char_u *)NULL, PV_NONE,
1790 {(char_u *)NULL,
1791#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001792 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001793 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001794#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1795 (char_u *)&p_lm, PV_NONE,
1796#else
1797 (char_u *)NULL, PV_NONE,
1798#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001799 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar4391cf92014-11-05 17:44:52 +01001800 {"langnoremap", "lnr", P_BOOL|P_VI_DEF,
1801#ifdef FEAT_LANGMAP
1802 (char_u *)&p_lnr, PV_NONE,
1803#else
1804 (char_u *)NULL, PV_NONE,
1805#endif
1806 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar920694c2016-08-21 17:45:02 +02001807 {"langremap", "lrm", P_BOOL|P_VI_DEF,
1808#ifdef FEAT_LANGMAP
1809 (char_u *)&p_lrm, PV_NONE,
1810#else
1811 (char_u *)NULL, PV_NONE,
1812#endif
Bram Moolenaarda9ce2c2016-09-02 19:34:10 +02001813 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001814 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1815#ifdef FEAT_WINDOWS
1816 (char_u *)&p_ls, PV_NONE,
1817#else
1818 (char_u *)NULL, PV_NONE,
1819#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001820 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001821 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1822 (char_u *)&p_lz, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001823 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001824 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1825#ifdef FEAT_LINEBREAK
1826 (char_u *)VAR_WIN, PV_LBR,
1827#else
1828 (char_u *)NULL, PV_NONE,
1829#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001830 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001831 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1832 (char_u *)&Rows, PV_NONE,
1833 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001834#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001835 (char_u *)25L,
1836#else
1837 (char_u *)24L,
1838#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001839 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001840 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1841#ifdef FEAT_GUI
1842 (char_u *)&p_linespace, PV_NONE,
1843#else
1844 (char_u *)NULL, PV_NONE,
1845#endif
1846#ifdef FEAT_GUI_W32
1847 {(char_u *)1L, (char_u *)0L}
1848#else
1849 {(char_u *)0L, (char_u *)0L}
1850#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001851 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001852 {"lisp", NULL, P_BOOL|P_VI_DEF,
1853#ifdef FEAT_LISP
1854 (char_u *)&p_lisp, PV_LISP,
1855#else
1856 (char_u *)NULL, PV_NONE,
1857#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001858 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001859 {"lispwords", "lw", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001860#ifdef FEAT_LISP
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01001861 (char_u *)&p_lispwords, PV_LW,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001862 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1863#else
1864 (char_u *)NULL, PV_NONE,
1865 {(char_u *)"", (char_u *)0L}
1866#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001867 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001868 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1869 (char_u *)VAR_WIN, PV_LIST,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001870 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001871 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001872 (char_u *)&p_lcs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001873 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001874 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1875 (char_u *)&p_lpl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001876 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02001877 {"luadll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001878#if defined(DYNAMIC_LUA)
Bram Moolenaard94464e2015-11-02 15:28:18 +01001879 (char_u *)&p_luadll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001880 {(char_u *)DYNAMIC_LUA_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001881#else
1882 (char_u *)NULL, PV_NONE,
1883 {(char_u *)"", (char_u *)0L}
1884#endif
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001885 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001886 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001887#ifdef FEAT_GUI_MAC
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001888 (char_u *)&p_macatsui, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001889 {(char_u *)TRUE, (char_u *)0L}
1890#else
1891 (char_u *)NULL, PV_NONE,
1892 {(char_u *)"", (char_u *)0L}
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001893#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01001894 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001895 {"magic", NULL, P_BOOL|P_VI_DEF,
1896 (char_u *)&p_magic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001897 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00001898 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001899#ifdef FEAT_QUICKFIX
1900 (char_u *)&p_mef, PV_NONE,
1901 {(char_u *)"", (char_u *)0L}
1902#else
1903 (char_u *)NULL, PV_NONE,
1904 {(char_u *)NULL, (char_u *)0L}
1905#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001906 SCRIPTID_INIT},
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01001907 {"makeencoding","menc", P_STRING|P_VI_DEF,
1908#ifdef FEAT_MBYTE
1909 (char_u *)&p_menc, PV_MENC,
1910 {(char_u *)"", (char_u *)0L}
1911#else
1912 (char_u *)NULL, PV_NONE,
1913 {(char_u *)0L, (char_u *)0L}
1914#endif
1915 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001916 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1917#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001918 (char_u *)&p_mp, PV_MP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001919# ifdef VMS
1920 {(char_u *)"MMS", (char_u *)0L}
1921# else
1922 {(char_u *)"make", (char_u *)0L}
1923# endif
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 Moolenaar0e7c4b92015-06-20 15:30:03 +02001929 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001930 (char_u *)&p_mps, PV_MPS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001931 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1932 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001933 {"matchtime", "mat", P_NUM|P_VI_DEF,
1934 (char_u *)&p_mat, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001935 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001936 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001937#ifdef FEAT_MBYTE
1938 (char_u *)&p_mco, PV_NONE,
1939#else
1940 (char_u *)NULL, PV_NONE,
1941#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001942 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001943 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1944#ifdef FEAT_EVAL
1945 (char_u *)&p_mfd, PV_NONE,
1946#else
1947 (char_u *)NULL, PV_NONE,
1948#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001949 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001950 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1951 (char_u *)&p_mmd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001952 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001953 {"maxmem", "mm", P_NUM|P_VI_DEF,
1954 (char_u *)&p_mm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001955 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1956 SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00001957 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1958 (char_u *)&p_mmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001959 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001960 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1961 (char_u *)&p_mmt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001962 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1963 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001964 {"menuitems", "mis", P_NUM|P_VI_DEF,
1965#ifdef FEAT_MENU
1966 (char_u *)&p_mis, PV_NONE,
1967#else
1968 (char_u *)NULL, PV_NONE,
1969#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001970 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001971 {"mesg", NULL, P_BOOL|P_VI_DEF,
1972 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001973 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001974 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001975#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001976 (char_u *)&p_msm, PV_NONE,
1977 {(char_u *)"460000,2000,500", (char_u *)0L}
1978#else
1979 (char_u *)NULL, PV_NONE,
1980 {(char_u *)0L, (char_u *)0L}
1981#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001982 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001983 {"modeline", "ml", P_BOOL|P_VIM,
1984 (char_u *)&p_ml, PV_ML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001985 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001986 {"modelines", "mls", P_NUM|P_VI_DEF,
1987 (char_u *)&p_mls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001988 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001989 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1990 (char_u *)&p_ma, PV_MA,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001991 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001992 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1993 (char_u *)&p_mod, PV_MOD,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001994 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001995 {"more", NULL, P_BOOL|P_VIM,
1996 (char_u *)&p_more, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001997 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001998 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
1999 (char_u *)&p_mouse, PV_NONE,
2000 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002001#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002002 (char_u *)"a",
2003#else
2004 (char_u *)"",
2005#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002006 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002007 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
2008#ifdef FEAT_GUI
2009 (char_u *)&p_mousef, PV_NONE,
2010#else
2011 (char_u *)NULL, PV_NONE,
2012#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002013 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002014 {"mousehide", "mh", P_BOOL|P_VI_DEF,
2015#ifdef FEAT_GUI
2016 (char_u *)&p_mh, PV_NONE,
2017#else
2018 (char_u *)NULL, PV_NONE,
2019#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002020 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002021 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
2022 (char_u *)&p_mousem, PV_NONE,
2023 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002024#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002025 (char_u *)"popup",
2026#else
2027# if defined(MACOS)
2028 (char_u *)"popup_setpos",
2029# else
2030 (char_u *)"extend",
2031# endif
2032#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002033 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002034 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002035#ifdef FEAT_MOUSESHAPE
2036 (char_u *)&p_mouseshape, PV_NONE,
2037 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
2038#else
2039 (char_u *)NULL, PV_NONE,
2040 {(char_u *)NULL, (char_u *)0L}
2041#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002042 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002043 {"mousetime", "mouset", P_NUM|P_VI_DEF,
2044 (char_u *)&p_mouset, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002045 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002046 {"mzquantum", "mzq", P_NUM,
2047#ifdef FEAT_MZSCHEME
2048 (char_u *)&p_mzq, PV_NONE,
2049#else
2050 (char_u *)NULL, PV_NONE,
2051#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002052 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002053 {"novice", NULL, P_BOOL|P_VI_DEF,
2054 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002055 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002056 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002057 (char_u *)&p_nf, PV_NF,
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01002058 {(char_u *)"bin,octal,hex", (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002059 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002060 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
2061 (char_u *)VAR_WIN, PV_NU,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002062 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002063 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
2064#ifdef FEAT_LINEBREAK
2065 (char_u *)VAR_WIN, PV_NUW,
2066#else
2067 (char_u *)NULL, PV_NONE,
2068#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002069 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
Bram Moolenaarf75a9632005-09-13 21:20:47 +00002070 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
Bram Moolenaare344bea2005-09-01 20:46:49 +00002071#ifdef FEAT_COMPL_FUNC
2072 (char_u *)&p_ofu, PV_OFU,
2073 {(char_u *)"", (char_u *)0L}
2074#else
2075 (char_u *)NULL, PV_NONE,
2076 {(char_u *)0L, (char_u *)0L}
2077#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002078 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002079 {"open", NULL, P_BOOL|P_VI_DEF,
2080 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002081 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar043545e2006-10-10 16:44:07 +00002082 {"opendevice", "odev", P_BOOL|P_VI_DEF,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002083#if defined(MSWIN)
Bram Moolenaar043545e2006-10-10 16:44:07 +00002084 (char_u *)&p_odev, PV_NONE,
2085#else
2086 (char_u *)NULL, PV_NONE,
2087#endif
2088 {(char_u *)FALSE, (char_u *)FALSE}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002089 SCRIPTID_INIT},
Bram Moolenaar2c7a29c2005-12-12 22:02:31 +00002090 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
2091 (char_u *)&p_opfunc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002092 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002093 {"optimize", "opt", P_BOOL|P_VI_DEF,
2094 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002095 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002096 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002097 (char_u *)NULL, PV_NONE,
Bram Moolenaarb07269a2011-05-19 13:41:14 +02002098 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +01002099 {"packpath", "pp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2100 |P_SECURE,
2101 (char_u *)&p_pp, PV_NONE,
2102 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2103 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002104 {"paragraphs", "para", P_STRING|P_VI_DEF,
2105 (char_u *)&p_para, PV_NONE,
Bram Moolenaar57e48462008-03-12 16:38:55 +00002106 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002107 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00002108 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002109 (char_u *)&p_paste, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002110 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002111 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
2112 (char_u *)&p_pt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002113 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002114 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
2115#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
2116 (char_u *)&p_pex, PV_NONE,
2117 {(char_u *)"", (char_u *)0L}
2118#else
2119 (char_u *)NULL, PV_NONE,
2120 {(char_u *)0L, (char_u *)0L}
2121#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002122 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002123 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002124 (char_u *)&p_pm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002125 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002126 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002127 (char_u *)&p_path, PV_PATH,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002128 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002129#if defined(AMIGA) || defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002130 (char_u *)".,,",
2131#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002132 (char_u *)".,/usr/include,,",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002133#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002134 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002135 {"perldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002136#if defined(DYNAMIC_PERL)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002137 (char_u *)&p_perldll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002138 {(char_u *)DYNAMIC_PERL_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002139#else
2140 (char_u *)NULL, PV_NONE,
2141 {(char_u *)0L, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002142#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002143 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002144 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
2145 (char_u *)&p_pi, PV_PI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002146 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002147 {"previewheight", "pvh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002148#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2149 (char_u *)&p_pvh, PV_NONE,
2150#else
2151 (char_u *)NULL, PV_NONE,
2152#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002153 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002154 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2155#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2156 (char_u *)VAR_WIN, PV_PVW,
2157#else
2158 (char_u *)NULL, PV_NONE,
2159#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002160 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002161 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002162#ifdef FEAT_PRINTER
2163 (char_u *)&p_pdev, PV_NONE,
2164 {(char_u *)"", (char_u *)0L}
2165#else
2166 (char_u *)NULL, PV_NONE,
2167 {(char_u *)NULL, (char_u *)0L}
2168#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002169 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002170 {"printencoding", "penc", P_STRING|P_VI_DEF,
2171#ifdef FEAT_POSTSCRIPT
2172 (char_u *)&p_penc, PV_NONE,
2173 {(char_u *)"", (char_u *)0L}
2174#else
2175 (char_u *)NULL, PV_NONE,
2176 {(char_u *)NULL, (char_u *)0L}
2177#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002178 SCRIPTID_INIT},
Bram Moolenaar031cb742016-11-24 21:46:19 +01002179 {"printexpr", "pexpr", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002180#ifdef FEAT_POSTSCRIPT
2181 (char_u *)&p_pexpr, PV_NONE,
2182 {(char_u *)"", (char_u *)0L}
2183#else
2184 (char_u *)NULL, PV_NONE,
2185 {(char_u *)NULL, (char_u *)0L}
2186#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002187 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002188 {"printfont", "pfn", P_STRING|P_VI_DEF,
2189#ifdef FEAT_PRINTER
2190 (char_u *)&p_pfn, PV_NONE,
2191 {
2192# ifdef MSWIN
2193 (char_u *)"Courier_New:h10",
2194# else
2195 (char_u *)"courier",
2196# endif
2197 (char_u *)0L}
2198#else
2199 (char_u *)NULL, PV_NONE,
2200 {(char_u *)NULL, (char_u *)0L}
2201#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002202 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002203 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
2204#ifdef FEAT_PRINTER
2205 (char_u *)&p_header, PV_NONE,
2206 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
2207#else
2208 (char_u *)NULL, PV_NONE,
2209 {(char_u *)NULL, (char_u *)0L}
2210#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002211 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002212 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
2213#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2214 (char_u *)&p_pmcs, PV_NONE,
2215 {(char_u *)"", (char_u *)0L}
2216#else
2217 (char_u *)NULL, PV_NONE,
2218 {(char_u *)NULL, (char_u *)0L}
2219#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002220 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002221 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2222#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2223 (char_u *)&p_pmfn, PV_NONE,
2224 {(char_u *)"", (char_u *)0L}
2225#else
2226 (char_u *)NULL, PV_NONE,
2227 {(char_u *)NULL, (char_u *)0L}
2228#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002229 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002230 {"printoptions", "popt", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002231#ifdef FEAT_PRINTER
2232 (char_u *)&p_popt, PV_NONE,
2233 {(char_u *)"", (char_u *)0L}
2234#else
2235 (char_u *)NULL, PV_NONE,
2236 {(char_u *)NULL, (char_u *)0L}
2237#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002238 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002239 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002240 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002241 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002242 {"pumheight", "ph", P_NUM|P_VI_DEF,
2243#ifdef FEAT_INS_EXPAND
2244 (char_u *)&p_ph, PV_NONE,
2245#else
2246 (char_u *)NULL, PV_NONE,
2247#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002248 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002249 {"pythonthreedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002250#if defined(DYNAMIC_PYTHON3)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002251 (char_u *)&p_py3dll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002252 {(char_u *)DYNAMIC_PYTHON3_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002253#else
2254 (char_u *)NULL, PV_NONE,
2255 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002256#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002257 SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002258 {"pythondll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002259#if defined(DYNAMIC_PYTHON)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002260 (char_u *)&p_pydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002261 {(char_u *)DYNAMIC_PYTHON_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002262#else
2263 (char_u *)NULL, PV_NONE,
2264 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002265#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002266 SCRIPTID_INIT},
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +01002267 {"pyxversion", "pyx", P_NUM|P_VI_DEF|P_SECURE,
2268#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
2269 (char_u *)&p_pyx, PV_NONE,
2270#else
2271 (char_u *)NULL, PV_NONE,
2272#endif
2273 {(char_u *)DEFAULT_PYTHON_VER, (char_u *)0L}
2274 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002275 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2276#ifdef FEAT_TEXTOBJ
2277 (char_u *)&p_qe, PV_QE,
2278 {(char_u *)"\\", (char_u *)0L}
2279#else
2280 (char_u *)NULL, PV_NONE,
2281 {(char_u *)NULL, (char_u *)0L}
2282#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002283 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002284 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2285 (char_u *)&p_ro, PV_RO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002286 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002287 {"redraw", NULL, P_BOOL|P_VI_DEF,
2288 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002289 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002290 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2291#ifdef FEAT_RELTIME
2292 (char_u *)&p_rdt, PV_NONE,
2293#else
2294 (char_u *)NULL, PV_NONE,
2295#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002296 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02002297 {"regexpengine", "re", P_NUM|P_VI_DEF,
2298 (char_u *)&p_re, PV_NONE,
2299 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002300 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2301 (char_u *)VAR_WIN, PV_RNU,
2302 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002303 {"remap", NULL, P_BOOL|P_VI_DEF,
2304 (char_u *)&p_remap, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002305 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002306 {"renderoptions", "rop", P_STRING|P_ONECOMMA|P_RCLR|P_VI_DEF,
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02002307#ifdef FEAT_RENDER_OPTIONS
2308 (char_u *)&p_rop, PV_NONE,
2309 {(char_u *)"", (char_u *)0L}
2310#else
2311 (char_u *)NULL, PV_NONE,
2312 {(char_u *)NULL, (char_u *)0L}
2313#endif
2314 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002315 {"report", NULL, P_NUM|P_VI_DEF,
2316 (char_u *)&p_report, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002317 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002318 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2319#ifdef WIN3264
2320 (char_u *)&p_rs, PV_NONE,
2321#else
2322 (char_u *)NULL, PV_NONE,
2323#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002324 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002325 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2326#ifdef FEAT_RIGHTLEFT
2327 (char_u *)&p_ri, PV_NONE,
2328#else
2329 (char_u *)NULL, PV_NONE,
2330#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002331 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002332 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2333#ifdef FEAT_RIGHTLEFT
2334 (char_u *)VAR_WIN, PV_RL,
2335#else
2336 (char_u *)NULL, PV_NONE,
2337#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002338 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002339 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2340#ifdef FEAT_RIGHTLEFT
2341 (char_u *)VAR_WIN, PV_RLC,
2342 {(char_u *)"search", (char_u *)NULL}
2343#else
2344 (char_u *)NULL, PV_NONE,
2345 {(char_u *)NULL, (char_u *)0L}
2346#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002347 SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002348 {"rubydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002349#if defined(DYNAMIC_RUBY)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002350 (char_u *)&p_rubydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002351 {(char_u *)DYNAMIC_RUBY_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002352#else
2353 (char_u *)NULL, PV_NONE,
2354 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002355#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002356 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002357 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2358#ifdef FEAT_CMDL_INFO
2359 (char_u *)&p_ru, PV_NONE,
2360#else
2361 (char_u *)NULL, PV_NONE,
2362#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002363 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002364 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2365#ifdef FEAT_STL_OPT
2366 (char_u *)&p_ruf, PV_NONE,
2367#else
2368 (char_u *)NULL, PV_NONE,
2369#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002370 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002371 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2372 |P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002373 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002374 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2375 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002376 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2377 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002378 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002379 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2380#ifdef FEAT_SCROLLBIND
2381 (char_u *)VAR_WIN, PV_SCBIND,
2382#else
2383 (char_u *)NULL, PV_NONE,
2384#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002385 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002386 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2387 (char_u *)&p_sj, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002388 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002389 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2390 (char_u *)&p_so, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002391 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002392 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002393#ifdef FEAT_SCROLLBIND
2394 (char_u *)&p_sbo, PV_NONE,
2395 {(char_u *)"ver,jump", (char_u *)0L}
2396#else
2397 (char_u *)NULL, PV_NONE,
2398 {(char_u *)0L, (char_u *)0L}
2399#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002400 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002401 {"sections", "sect", P_STRING|P_VI_DEF,
2402 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002403 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2404 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002405 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2406 (char_u *)&p_secure, 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 {"selection", "sel", P_STRING|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002409 (char_u *)&p_sel, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002410 {(char_u *)"inclusive", (char_u *)0L}
2411 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002412 {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002413 (char_u *)&p_slm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002414 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002415 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002416#ifdef FEAT_SESSION
2417 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002418 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002419 (char_u *)0L}
2420#else
2421 (char_u *)NULL, PV_NONE,
2422 {(char_u *)0L, (char_u *)0L}
2423#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002424 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002425 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2426 (char_u *)&p_sh, PV_NONE,
2427 {
2428#ifdef VMS
2429 (char_u *)"-",
2430#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002431# if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002432 (char_u *)"", /* set in set_init_1() */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002433# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002434 (char_u *)"sh",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002435# endif
2436#endif /* VMS */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002437 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002438 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2439 (char_u *)&p_shcf, PV_NONE,
2440 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002441#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002442 (char_u *)"/c",
2443#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002444 (char_u *)"-c",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002445#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002446 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002447 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2448#ifdef FEAT_QUICKFIX
2449 (char_u *)&p_sp, PV_NONE,
2450 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002451#if defined(UNIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002452 (char_u *)"| tee",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002453#else
2454 (char_u *)">",
2455#endif
2456 (char_u *)0L}
2457#else
2458 (char_u *)NULL, PV_NONE,
2459 {(char_u *)0L, (char_u *)0L}
2460#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002461 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002462 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2463 (char_u *)&p_shq, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002464 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002465 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2466 (char_u *)&p_srr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002467 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002468 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2469#ifdef BACKSLASH_IN_FILENAME
2470 (char_u *)&p_ssl, PV_NONE,
2471#else
2472 (char_u *)NULL, PV_NONE,
2473#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002474 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002475 {"shelltemp", "stmp", P_BOOL,
2476 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002477 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002478 {"shelltype", "st", P_NUM|P_VI_DEF,
2479#ifdef AMIGA
2480 (char_u *)&p_st, PV_NONE,
2481#else
2482 (char_u *)NULL, PV_NONE,
2483#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002484 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002485 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2486 (char_u *)&p_sxq, PV_NONE,
2487 {
Bram Moolenaara06ecab2016-07-16 14:47:36 +02002488#if defined(UNIX) && defined(USE_SYSTEM)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002489 (char_u *)"\"",
2490#else
2491 (char_u *)"",
2492#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002493 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002494 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
2495 (char_u *)&p_sxe, PV_NONE,
2496 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002497#if defined(WIN3264)
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002498 (char_u *)"\"&|<>()@^",
2499#else
2500 (char_u *)"",
2501#endif
2502 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002503 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2504 (char_u *)&p_sr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002505 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002506 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2507 (char_u *)&p_sw, PV_SW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002508 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002509 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2510 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002511 {(char_u *)"", (char_u *)"filnxtToO"}
2512 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002513 {"shortname", "sn", P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002514 (char_u *)&p_sn, PV_SN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002515 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002516 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2517#ifdef FEAT_LINEBREAK
2518 (char_u *)&p_sbr, PV_NONE,
2519#else
2520 (char_u *)NULL, PV_NONE,
2521#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002522 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002523 {"showcmd", "sc", P_BOOL|P_VIM,
2524#ifdef FEAT_CMDL_INFO
2525 (char_u *)&p_sc, PV_NONE,
2526#else
2527 (char_u *)NULL, PV_NONE,
2528#endif
2529 {(char_u *)FALSE,
2530#ifdef UNIX
2531 (char_u *)FALSE
2532#else
2533 (char_u *)TRUE
2534#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002535 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002536 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2537 (char_u *)&p_sft, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002538 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002539 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2540 (char_u *)&p_sm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002541 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002542 {"showmode", "smd", P_BOOL|P_VIM,
2543 (char_u *)&p_smd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002544 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002545 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2546#ifdef FEAT_WINDOWS
2547 (char_u *)&p_stal, PV_NONE,
2548#else
2549 (char_u *)NULL, PV_NONE,
2550#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002551 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002552 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2553 (char_u *)&p_ss, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002554 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002555 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2556 (char_u *)&p_siso, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002557 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002558 {"signcolumn", "scl", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2559#ifdef FEAT_SIGNS
2560 (char_u *)VAR_WIN, PV_SCL,
Bram Moolenaarb3384832016-08-12 18:51:58 +02002561 {(char_u *)"auto", (char_u *)0L}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002562#else
2563 (char_u *)NULL, PV_NONE,
2564 {(char_u *)NULL, (char_u *)0L}
2565#endif
Bram Moolenaarb3384832016-08-12 18:51:58 +02002566 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002567 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2568 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002569 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002570 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2571 (char_u *)&p_scs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002572 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002573 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2574#ifdef FEAT_SMARTINDENT
2575 (char_u *)&p_si, PV_SI,
2576#else
2577 (char_u *)NULL, PV_NONE,
2578#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002579 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002580 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2581 (char_u *)&p_sta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002582 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002583 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2584 (char_u *)&p_sts, PV_STS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002585 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002586 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2587 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002588 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002589 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002590#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002591 (char_u *)VAR_WIN, PV_SPELL,
2592#else
2593 (char_u *)NULL, PV_NONE,
2594#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002595 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002596 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002597#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002598 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002599 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002600#else
2601 (char_u *)NULL, PV_NONE,
2602 {(char_u *)0L, (char_u *)0L}
2603#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002604 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002605 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE
2606 |P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002607#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002608 (char_u *)&p_spf, PV_SPF,
2609 {(char_u *)"", (char_u *)0L}
2610#else
2611 (char_u *)NULL, PV_NONE,
2612 {(char_u *)0L, (char_u *)0L}
2613#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002614 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002615 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
2616 |P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002617#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002618 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002619 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002620#else
2621 (char_u *)NULL, PV_NONE,
2622 {(char_u *)0L, (char_u *)0L}
2623#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002624 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002625 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002626#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002627 (char_u *)&p_sps, PV_NONE,
2628 {(char_u *)"best", (char_u *)0L}
2629#else
2630 (char_u *)NULL, PV_NONE,
2631 {(char_u *)0L, (char_u *)0L}
2632#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002633 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002634 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2635#ifdef FEAT_WINDOWS
2636 (char_u *)&p_sb, PV_NONE,
2637#else
2638 (char_u *)NULL, PV_NONE,
2639#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002640 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002641 {"splitright", "spr", P_BOOL|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002642#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002643 (char_u *)&p_spr, PV_NONE,
2644#else
2645 (char_u *)NULL, PV_NONE,
2646#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002647 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002648 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2649 (char_u *)&p_sol, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002650 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002651 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2652#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002653 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002654#else
2655 (char_u *)NULL, PV_NONE,
2656#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002657 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002658 {"suffixes", "su", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002659 (char_u *)&p_su, PV_NONE,
2660 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002661 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002662 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002663#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002664 (char_u *)&p_sua, PV_SUA,
2665 {(char_u *)"", (char_u *)0L}
2666#else
2667 (char_u *)NULL, PV_NONE,
2668 {(char_u *)0L, (char_u *)0L}
2669#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002670 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002671 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2672 (char_u *)&p_swf, PV_SWF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002673 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002674 {"swapsync", "sws", P_STRING|P_VI_DEF,
2675 (char_u *)&p_sws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002676 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002677 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002678 (char_u *)&p_swb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002679 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002680 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2681#ifdef FEAT_SYN_HL
2682 (char_u *)&p_smc, PV_SMC,
2683 {(char_u *)3000L, (char_u *)0L}
2684#else
2685 (char_u *)NULL, PV_NONE,
2686 {(char_u *)0L, (char_u *)0L}
2687#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002688 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002689 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002690#ifdef FEAT_SYN_HL
2691 (char_u *)&p_syn, PV_SYN,
2692 {(char_u *)"", (char_u *)0L}
2693#else
2694 (char_u *)NULL, PV_NONE,
2695 {(char_u *)0L, (char_u *)0L}
2696#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002697 SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002698 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2699#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002700 (char_u *)&p_tal, PV_NONE,
2701#else
2702 (char_u *)NULL, PV_NONE,
2703#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002704 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002705 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2706#ifdef FEAT_WINDOWS
2707 (char_u *)&p_tpm, PV_NONE,
2708#else
2709 (char_u *)NULL, PV_NONE,
2710#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002711 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002712 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2713 (char_u *)&p_ts, PV_TS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002714 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002715 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2716 (char_u *)&p_tbs, PV_NONE,
2717#ifdef VMS /* binary searching doesn't appear to work on VMS */
2718 {(char_u *)0L, (char_u *)0L}
2719#else
2720 {(char_u *)TRUE, (char_u *)0L}
2721#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002722 SCRIPTID_INIT},
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01002723 {"tagcase", "tc", P_STRING|P_VIM,
2724 (char_u *)&p_tc, PV_TC,
2725 {(char_u *)"followic", (char_u *)"followic"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002726 {"taglength", "tl", P_NUM|P_VI_DEF,
2727 (char_u *)&p_tl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002728 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002729 {"tagrelative", "tr", P_BOOL|P_VIM,
2730 (char_u *)&p_tr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002731 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002732 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002733 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002734 {
2735#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2736 (char_u *)"./tags,./TAGS,tags,TAGS",
2737#else
2738 (char_u *)"./tags,tags",
2739#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002740 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002741 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2742 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002743 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002744 {"tcldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002745#if defined(DYNAMIC_TCL)
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002746 (char_u *)&p_tcldll, PV_NONE,
2747 {(char_u *)DYNAMIC_TCL_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002748#else
2749 (char_u *)NULL, PV_NONE,
2750 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002751#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002752 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002753 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2754 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002755 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002756 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2757#ifdef FEAT_ARABIC
2758 (char_u *)&p_tbidi, PV_NONE,
2759#else
2760 (char_u *)NULL, PV_NONE,
2761#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002762 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002763 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2764#ifdef FEAT_MBYTE
2765 (char_u *)&p_tenc, PV_NONE,
2766 {(char_u *)"", (char_u *)0L}
2767#else
2768 (char_u *)NULL, PV_NONE,
2769 {(char_u *)0L, (char_u *)0L}
2770#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002771 SCRIPTID_INIT},
Bram Moolenaar61be73b2016-04-29 22:59:22 +02002772 {"termguicolors", "tgc", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
2773#ifdef FEAT_TERMGUICOLORS
2774 (char_u *)&p_tgc, PV_NONE,
2775 {(char_u *)FALSE, (char_u *)FALSE}
2776#else
2777 (char_u*)NULL, PV_NONE,
2778 {(char_u *)FALSE, (char_u *)FALSE}
2779#endif
2780 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002781 {"terse", NULL, P_BOOL|P_VI_DEF,
2782 (char_u *)&p_terse, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002783 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002784 {"textauto", "ta", P_BOOL|P_VIM,
2785 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002786 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2787 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002788 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2789 (char_u *)&p_tx, PV_TX,
2790 {
2791#ifdef USE_CRNL
2792 (char_u *)TRUE,
2793#else
2794 (char_u *)FALSE,
2795#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002796 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +02002797 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002798 (char_u *)&p_tw, PV_TW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002799 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf422bcc2016-11-26 17:45:53 +01002800 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002801#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002802 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002803#else
2804 (char_u *)NULL, PV_NONE,
2805#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002806 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002807 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2808 (char_u *)&p_to, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002809 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002810 {"timeout", "to", P_BOOL|P_VI_DEF,
2811 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002812 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002813 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2814 (char_u *)&p_tm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002815 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002816 {"title", NULL, P_BOOL|P_VI_DEF,
2817#ifdef FEAT_TITLE
2818 (char_u *)&p_title, PV_NONE,
2819#else
2820 (char_u *)NULL, PV_NONE,
2821#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002822 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002823 {"titlelen", NULL, P_NUM|P_VI_DEF,
2824#ifdef FEAT_TITLE
2825 (char_u *)&p_titlelen, PV_NONE,
2826#else
2827 (char_u *)NULL, PV_NONE,
2828#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002829 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002830 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002831#ifdef FEAT_TITLE
2832 (char_u *)&p_titleold, PV_NONE,
2833 {(char_u *)N_("Thanks for flying Vim"),
2834 (char_u *)0L}
2835#else
2836 (char_u *)NULL, PV_NONE,
2837 {(char_u *)0L, (char_u *)0L}
2838#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002839 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002840 {"titlestring", NULL, P_STRING|P_VI_DEF,
2841#ifdef FEAT_TITLE
2842 (char_u *)&p_titlestring, PV_NONE,
2843#else
2844 (char_u *)NULL, PV_NONE,
2845#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002846 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002847 {"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002848#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002849 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002850 {(char_u *)"icons,tooltips", (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002851#else
2852 (char_u *)NULL, PV_NONE,
2853 {(char_u *)0L, (char_u *)0L}
2854#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002855 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002856 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002857#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002858 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002859 {(char_u *)"small", (char_u *)0L}
2860#else
2861 (char_u *)NULL, PV_NONE,
2862 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002863#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002864 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002865 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2866 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002867 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002868 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2869 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002870 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002871 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2872 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002873 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002874 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2875 (char_u *)&p_tf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002876 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002877 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2878#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2879 (char_u *)&p_ttym, PV_NONE,
2880#else
2881 (char_u *)NULL, PV_NONE,
2882#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002883 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002884 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2885 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002886 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002887 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2888 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002889 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002890 {"undodir", "udir", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP|P_SECURE
2891 |P_VI_DEF,
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002892#ifdef FEAT_PERSISTENT_UNDO
2893 (char_u *)&p_udir, PV_NONE,
2894 {(char_u *)".", (char_u *)0L}
2895#else
2896 (char_u *)NULL, PV_NONE,
2897 {(char_u *)0L, (char_u *)0L}
2898#endif
2899 SCRIPTID_INIT},
2900 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2901#ifdef FEAT_PERSISTENT_UNDO
2902 (char_u *)&p_udf, PV_UDF,
2903#else
2904 (char_u *)NULL, PV_NONE,
2905#endif
2906 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002907 {"undolevels", "ul", P_NUM|P_VI_DEF,
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01002908 (char_u *)&p_ul, PV_UL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002909 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002910#if defined(UNIX) || defined(WIN3264) || defined(VMS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002911 (char_u *)1000L,
2912#else
2913 (char_u *)100L,
2914#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002915 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar59f931e2010-07-24 20:27:03 +02002916 {"undoreload", "ur", P_NUM|P_VI_DEF,
2917 (char_u *)&p_ur, PV_NONE,
2918 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002919 {"updatecount", "uc", P_NUM|P_VI_DEF,
2920 (char_u *)&p_uc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002921 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002922 {"updatetime", "ut", P_NUM|P_VI_DEF,
2923 (char_u *)&p_ut, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002924 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002925 {"verbose", "vbs", P_NUM|P_VI_DEF,
2926 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002927 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002928 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2929 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002930 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002931 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2932#ifdef FEAT_SESSION
2933 (char_u *)&p_vdir, PV_NONE,
2934 {(char_u *)DFLT_VDIR, (char_u *)0L}
2935#else
2936 (char_u *)NULL, PV_NONE,
2937 {(char_u *)0L, (char_u *)0L}
2938#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002939 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002940 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002941#ifdef FEAT_SESSION
2942 (char_u *)&p_vop, PV_NONE,
2943 {(char_u *)"folds,options,cursor", (char_u *)0L}
2944#else
2945 (char_u *)NULL, PV_NONE,
2946 {(char_u *)0L, (char_u *)0L}
2947#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002948 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002949 {"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002950#ifdef FEAT_VIMINFO
2951 (char_u *)&p_viminfo, PV_NONE,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002952#if defined(MSWIN)
Bram Moolenaard812df62008-11-09 12:46:09 +00002953 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002954#else
2955# ifdef AMIGA
2956 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002957 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002958# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002959 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002960# endif
2961#endif
2962#else
2963 (char_u *)NULL, PV_NONE,
2964 {(char_u *)0L, (char_u *)0L}
2965#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002966 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002967 {"virtualedit", "ve", P_STRING|P_ONECOMMA|P_NODUP|P_VI_DEF
2968 |P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002969#ifdef FEAT_VIRTUALEDIT
2970 (char_u *)&p_ve, PV_NONE,
2971 {(char_u *)"", (char_u *)""}
2972#else
2973 (char_u *)NULL, PV_NONE,
2974 {(char_u *)0L, (char_u *)0L}
2975#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002976 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002977 {"visualbell", "vb", P_BOOL|P_VI_DEF,
2978 (char_u *)&p_vb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002979 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002980 {"w300", NULL, P_NUM|P_VI_DEF,
2981 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002982 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002983 {"w1200", NULL, P_NUM|P_VI_DEF,
2984 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002985 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002986 {"w9600", NULL, P_NUM|P_VI_DEF,
2987 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002988 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002989 {"warn", NULL, P_BOOL|P_VI_DEF,
2990 (char_u *)&p_warn, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002991 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002992 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
2993 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002994 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002995 {"whichwrap", "ww", P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002996 (char_u *)&p_ww, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002997 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002998 {"wildchar", "wc", P_NUM|P_VIM,
2999 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003000 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
3001 SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01003002 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003003 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003004 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003005 {"wildignore", "wig", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003006#ifdef FEAT_WILDIGN
3007 (char_u *)&p_wig, PV_NONE,
3008#else
3009 (char_u *)NULL, PV_NONE,
3010#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003011 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01003012 {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
3013 (char_u *)&p_wic, PV_NONE,
3014 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003015 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
3016#ifdef FEAT_WILDMENU
3017 (char_u *)&p_wmnu, PV_NONE,
3018#else
3019 (char_u *)NULL, PV_NONE,
3020#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003021 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003022 {"wildmode", "wim", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003023 (char_u *)&p_wim, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003024 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003025 {"wildoptions", "wop", P_STRING|P_VI_DEF,
3026#ifdef FEAT_CMDL_COMPL
3027 (char_u *)&p_wop, PV_NONE,
3028 {(char_u *)"", (char_u *)0L}
3029#else
3030 (char_u *)NULL, PV_NONE,
3031 {(char_u *)NULL, (char_u *)0L}
3032#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003033 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003034 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
3035#ifdef FEAT_WAK
3036 (char_u *)&p_wak, PV_NONE,
3037 {(char_u *)"menu", (char_u *)0L}
3038#else
3039 (char_u *)NULL, PV_NONE,
3040 {(char_u *)NULL, (char_u *)0L}
3041#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003042 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003043 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003044 (char_u *)&p_window, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003045 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003046 {"winheight", "wh", P_NUM|P_VI_DEF,
3047#ifdef FEAT_WINDOWS
3048 (char_u *)&p_wh, PV_NONE,
3049#else
3050 (char_u *)NULL, PV_NONE,
3051#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003052 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003053 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003054#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003055 (char_u *)VAR_WIN, PV_WFH,
3056#else
3057 (char_u *)NULL, PV_NONE,
3058#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003059 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00003060 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003061#ifdef FEAT_WINDOWS
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00003062 (char_u *)VAR_WIN, PV_WFW,
3063#else
3064 (char_u *)NULL, PV_NONE,
3065#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003066 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003067 {"winminheight", "wmh", P_NUM|P_VI_DEF,
3068#ifdef FEAT_WINDOWS
3069 (char_u *)&p_wmh, PV_NONE,
3070#else
3071 (char_u *)NULL, PV_NONE,
3072#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003073 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003074 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003075#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003076 (char_u *)&p_wmw, PV_NONE,
3077#else
3078 (char_u *)NULL, PV_NONE,
3079#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003080 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003081 {"winwidth", "wiw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003082#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003083 (char_u *)&p_wiw, PV_NONE,
3084#else
3085 (char_u *)NULL, PV_NONE,
3086#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003087 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003088 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
3089 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003090 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003091 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
3092 (char_u *)&p_wm, PV_WM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003093 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003094 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
3095 (char_u *)&p_ws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003096 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003097 {"write", NULL, P_BOOL|P_VI_DEF,
3098 (char_u *)&p_write, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003099 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003100 {"writeany", "wa", P_BOOL|P_VI_DEF,
3101 (char_u *)&p_wa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003102 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003103 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
3104 (char_u *)&p_wb, PV_NONE,
3105 {
3106#ifdef FEAT_WRITEBACKUP
3107 (char_u *)TRUE,
3108#else
3109 (char_u *)FALSE,
3110#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003111 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003112 {"writedelay", "wd", P_NUM|P_VI_DEF,
3113 (char_u *)&p_wd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003114 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003115
3116/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00003117#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00003118 (char_u *)&vvv, PV_NONE, \
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003119 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003120
3121 p_term("t_AB", T_CAB)
3122 p_term("t_AF", T_CAF)
3123 p_term("t_AL", T_CAL)
3124 p_term("t_al", T_AL)
3125 p_term("t_bc", T_BC)
3126 p_term("t_cd", T_CD)
3127 p_term("t_ce", T_CE)
3128 p_term("t_cl", T_CL)
3129 p_term("t_cm", T_CM)
Bram Moolenaar450ca432015-11-10 13:30:39 +01003130 p_term("t_Ce", T_UCE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003131 p_term("t_Co", T_CCO)
3132 p_term("t_CS", T_CCS)
Bram Moolenaar450ca432015-11-10 13:30:39 +01003133 p_term("t_Cs", T_UCS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003134 p_term("t_cs", T_CS)
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003135#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003136 p_term("t_CV", T_CSV)
3137#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003138 p_term("t_da", T_DA)
3139 p_term("t_db", T_DB)
3140 p_term("t_DL", T_CDL)
3141 p_term("t_dl", T_DL)
Bram Moolenaare5401222015-06-25 19:16:56 +02003142 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003143 p_term("t_fs", T_FS)
3144 p_term("t_IE", T_CIE)
3145 p_term("t_IS", T_CIS)
3146 p_term("t_ke", T_KE)
3147 p_term("t_ks", T_KS)
3148 p_term("t_le", T_LE)
3149 p_term("t_mb", T_MB)
3150 p_term("t_md", T_MD)
3151 p_term("t_me", T_ME)
3152 p_term("t_mr", T_MR)
3153 p_term("t_ms", T_MS)
3154 p_term("t_nd", T_ND)
3155 p_term("t_op", T_OP)
Bram Moolenaare5401222015-06-25 19:16:56 +02003156 p_term("t_RB", T_RBG)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003157 p_term("t_RI", T_CRI)
3158 p_term("t_RV", T_CRV)
3159 p_term("t_Sb", T_CSB)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003160 p_term("t_se", T_SE)
Bram Moolenaare5401222015-06-25 19:16:56 +02003161 p_term("t_Sf", T_CSF)
3162 p_term("t_SI", T_CSI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003163 p_term("t_so", T_SO)
Bram Moolenaare5401222015-06-25 19:16:56 +02003164 p_term("t_SR", T_CSR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003165 p_term("t_sr", T_SR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003166 p_term("t_te", T_TE)
3167 p_term("t_ti", T_TI)
Bram Moolenaare5401222015-06-25 19:16:56 +02003168 p_term("t_ts", T_TS)
3169 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003170 p_term("t_ue", T_UE)
3171 p_term("t_us", T_US)
Bram Moolenaare5401222015-06-25 19:16:56 +02003172 p_term("t_ut", T_UT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003173 p_term("t_vb", T_VB)
3174 p_term("t_ve", T_VE)
3175 p_term("t_vi", T_VI)
3176 p_term("t_vs", T_VS)
3177 p_term("t_WP", T_CWP)
Bram Moolenaar9f928862017-04-11 22:44:05 +02003178 p_term("t_GP", T_CGP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003179 p_term("t_WS", T_CWS)
Bram Moolenaar494838a2015-02-10 19:20:37 +01003180 p_term("t_xn", T_XN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003181 p_term("t_xs", T_XS)
3182 p_term("t_ZH", T_CZH)
3183 p_term("t_ZR", T_CZR)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02003184 p_term("t_8f", T_8F)
3185 p_term("t_8b", T_8B)
Bram Moolenaarec2da362017-01-21 20:04:22 +01003186 p_term("t_BE", T_BE)
3187 p_term("t_BD", T_BD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003188
3189/* terminal key codes are not in here */
3190
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003191 /* end marker */
3192 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00003193};
3194
3195#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
3196
3197#ifdef FEAT_MBYTE
3198static char *(p_ambw_values[]) = {"single", "double", NULL};
3199#endif
3200static char *(p_bg_values[]) = {"light", "dark", NULL};
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01003201static char *(p_nf_values[]) = {"bin", "octal", "hex", "alpha", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003202static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003203#ifdef FEAT_CRYPT
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02003204static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2", NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003205#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003206#ifdef FEAT_CMDL_COMPL
3207static char *(p_wop_values[]) = {"tagfile", NULL};
3208#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003209#ifdef FEAT_WAK
3210static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
3211#endif
3212static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003213static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
3214static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003215static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003216#ifdef FEAT_BROWSE
3217static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
3218#endif
3219#ifdef FEAT_SCROLLBIND
3220static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
3221#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00003222static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003223#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003224static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
3225#endif
3226#if defined(FEAT_QUICKFIX)
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003227# ifdef FEAT_AUTOCMD
3228static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
3229# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003230static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003231# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003232static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
3233#endif
3234static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
3235#ifdef FEAT_FOLDING
3236static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003237# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00003238 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003239# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003240 NULL};
3241static char *(p_fcl_values[]) = {"all", NULL};
3242#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003243#ifdef FEAT_INS_EXPAND
Bram Moolenaarb6be1e22015-07-10 18:18:40 +02003244static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003245#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02003246#ifdef FEAT_SIGNS
3247static char *(p_scl_values[]) = {"yes", "no", "auto", NULL};
3248#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003249
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003250static void set_option_default(int, int opt_flags, int compatible);
3251static void set_options_default(int opt_flags);
3252static char_u *term_bg_default(void);
3253static void did_set_option(int opt_idx, int opt_flags, int new_value);
3254static char_u *illegal_char(char_u *, int);
3255static int string_to_key(char_u *arg);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003256#ifdef FEAT_CMDWIN
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003257static char_u *check_cedit(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003258#endif
3259#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003260static void did_set_title(int icon);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003261#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003262static char_u *option_expand(int opt_idx, char_u *val);
3263static void didset_options(void);
3264static void didset_options2(void);
3265static void check_string_option(char_u **pp);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003266#if defined(FEAT_EVAL) || defined(PROTO)
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003267static long_u *insecure_flag(int opt_idx, int opt_flags);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003268#else
3269# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3270#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003271static void set_string_option_global(int opt_idx, char_u **varp);
3272static char_u *set_string_option(int opt_idx, char_u *value, int opt_flags);
3273static 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);
3274static char_u *set_chars_option(char_u **varp);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003275#ifdef FEAT_SYN_HL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003276static int int_cmp(const void *a, const void *b);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003277#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003278#ifdef FEAT_CLIPBOARD
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003279static char_u *check_clipboard_option(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003280#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003281#ifdef FEAT_SPELL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003282static char_u *did_set_spell_option(int is_spellfile);
3283static char_u *compile_cap_prog(synblock_T *synblock);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003284#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003285#ifdef FEAT_EVAL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003286static void set_option_scriptID_idx(int opt_idx, int opt_flags, int id);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003287#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003288static char_u *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags);
3289static char_u *set_num_option(int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags);
3290static void check_redraw(long_u flags);
3291static int findoption(char_u *);
3292static int find_key_option(char_u *);
3293static void showoptions(int all, int opt_flags);
3294static int optval_default(struct vimoption *, char_u *varp);
3295static void showoneopt(struct vimoption *, int opt_flags);
3296static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int expand);
3297static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep);
3298static int put_setbool(FILE *fd, char *cmd, char *name, int value);
3299static int istermoption(struct vimoption *);
3300static char_u *get_varp_scope(struct vimoption *p, int opt_flags);
3301static char_u *get_varp(struct vimoption *);
3302static void option_value2string(struct vimoption *, int opt_flags);
3303static void check_winopt(winopt_T *wop);
3304static int wc_use_keyname(char_u *varp, long *wcp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003305#ifdef FEAT_LANGMAP
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003306static void langmap_init(void);
3307static void langmap_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003308#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003309static void paste_option_changed(void);
3310static void compatible_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003311#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003312static void fill_breakat_flags(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003313#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003314static int opt_strings_flags(char_u *val, char **values, unsigned *flagp, int list);
3315static int check_opt_strings(char_u *val, char **values, int);
3316static int check_opt_wim(void);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003317#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003318static int briopt_check(win_T *wp);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003319#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003320
3321/*
3322 * Initialize the options, first part.
3323 *
3324 * Called only once from main(), just after creating the first buffer.
3325 */
3326 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003327set_init_1(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003328{
3329 char_u *p;
3330 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003331 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003332
3333#ifdef FEAT_LANGMAP
3334 langmap_init();
3335#endif
3336
3337 /* Be Vi compatible by default */
3338 p_cp = TRUE;
3339
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003340 /* Use POSIX compatibility when $VIM_POSIX is set. */
3341 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003342 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003343 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003344 set_string_default("shm", (char_u *)"A");
3345 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003346
Bram Moolenaar071d4272004-06-13 20:20:40 +00003347 /*
3348 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003349 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003350 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003351 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003352#if defined(MSWIN)
Bram Moolenaar7c626922005-02-07 22:01:03 +00003353 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003354# ifdef WIN3264
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003355 || ((p = (char_u *)default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003356# endif
3357#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003358 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003359 set_string_default("sh", p);
3360
3361#ifdef FEAT_WILDIGN
3362 /*
3363 * Set the default for 'backupskip' to include environment variables for
3364 * temp files.
3365 */
3366 {
3367# ifdef UNIX
3368 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3369# else
3370 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3371# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003372 int len;
3373 garray_T ga;
3374 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003375
3376 ga_init2(&ga, 1, 100);
3377 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3378 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003379 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003380# ifdef UNIX
3381 if (*names[n] == NUL)
3382 p = (char_u *)"/tmp";
3383 else
3384# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003385 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003386 if (p != NULL && *p != NUL)
3387 {
3388 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003389 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003390 if (ga_grow(&ga, len) == OK)
3391 {
3392 if (ga.ga_len > 0)
3393 STRCAT(ga.ga_data, ",");
3394 STRCAT(ga.ga_data, p);
3395 add_pathsep(ga.ga_data);
3396 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003397 ga.ga_len += len;
3398 }
3399 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003400 if (mustfree)
3401 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003402 }
3403 if (ga.ga_data != NULL)
3404 {
3405 set_string_default("bsk", ga.ga_data);
3406 vim_free(ga.ga_data);
3407 }
3408 }
3409#endif
3410
3411 /*
3412 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3413 */
3414 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003415 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003416 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003417#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3418 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3419#endif
3420 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003421#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003422 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003423 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003424#else
3425# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003426 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003427 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003428# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003429 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003430# endif
3431#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003432 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003433 opt_idx = findoption((char_u *)"maxmem");
3434 if (opt_idx >= 0)
3435 {
3436#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
Bram Moolenaar35be4532015-12-11 22:38:36 +01003437 if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n
3438 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L)
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003439#endif
3440 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3441 }
3442 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003443 }
3444
Bram Moolenaar071d4272004-06-13 20:20:40 +00003445#ifdef FEAT_SEARCHPATH
3446 {
3447 char_u *cdpath;
3448 char_u *buf;
3449 int i;
3450 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003451 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003452
3453 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003454 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003455 if (cdpath != NULL)
3456 {
3457 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3458 if (buf != NULL)
3459 {
3460 buf[0] = ','; /* start with ",", current dir first */
3461 j = 1;
3462 for (i = 0; cdpath[i] != NUL; ++i)
3463 {
3464 if (vim_ispathlistsep(cdpath[i]))
3465 buf[j++] = ',';
3466 else
3467 {
3468 if (cdpath[i] == ' ' || cdpath[i] == ',')
3469 buf[j++] = '\\';
3470 buf[j++] = cdpath[i];
3471 }
3472 }
3473 buf[j] = NUL;
3474 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003475 if (opt_idx >= 0)
3476 {
3477 options[opt_idx].def_val[VI_DEFAULT] = buf;
3478 options[opt_idx].flags |= P_DEF_ALLOCED;
3479 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003480 else
3481 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003482 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003483 if (mustfree)
3484 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003485 }
3486 }
3487#endif
3488
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003489#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003490 /* Set print encoding on platforms that don't default to latin1 */
3491 set_string_default("penc",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003492# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003493 (char_u *)"cp1252"
3494# else
3495# ifdef VMS
3496 (char_u *)"dec-mcs"
3497# else
3498# ifdef EBCDIC
3499 (char_u *)"ebcdic-uk"
3500# else
3501# ifdef MAC
3502 (char_u *)"mac-roman"
3503# else /* HPUX */
3504 (char_u *)"hp-roman8"
3505# endif
3506# endif
3507# endif
3508# endif
3509 );
3510#endif
3511
3512#ifdef FEAT_POSTSCRIPT
3513 /* 'printexpr' must be allocated to be able to evaluate it. */
3514 set_string_default("pexpr",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003515# if defined(MSWIN)
Bram Moolenaared203462004-06-16 11:19:22 +00003516 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003517# else
3518# ifdef VMS
3519 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3520
3521# else
3522 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3523# endif
3524# endif
3525 );
3526#endif
3527
3528 /*
3529 * Set all the options (except the terminal options) to their default
3530 * value. Also set the global value for local options.
3531 */
3532 set_options_default(0);
3533
3534#ifdef FEAT_GUI
3535 if (found_reverse_arg)
3536 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3537#endif
3538
3539 curbuf->b_p_initialized = TRUE;
3540 curbuf->b_p_ar = -1; /* no local 'autoread' value */
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01003541 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003542 check_buf_options(curbuf);
3543 check_win_options(curwin);
3544 check_options();
3545
3546 /* Must be before option_expand(), because that one needs vim_isIDc() */
3547 didset_options();
3548
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003549#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003550 /* Use the current chartab for the generic chartab. This is not in
3551 * didset_options() because it only depends on 'encoding'. */
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003552 init_spell_chartab();
3553#endif
3554
Bram Moolenaar071d4272004-06-13 20:20:40 +00003555 /*
3556 * Expand environment variables and things like "~" for the defaults.
3557 * If option_expand() returns non-NULL the variable is expanded. This can
3558 * only happen for non-indirect options.
3559 * Also set the default to the expanded value, so ":set" does not list
3560 * them.
3561 * Don't set the P_ALLOCED flag, because we don't want to free the
3562 * default.
3563 */
3564 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3565 {
3566 if ((options[opt_idx].flags & P_GETTEXT)
3567 && options[opt_idx].var != NULL)
3568 p = (char_u *)_(*(char **)options[opt_idx].var);
3569 else
3570 p = option_expand(opt_idx, NULL);
3571 if (p != NULL && (p = vim_strsave(p)) != NULL)
3572 {
3573 *(char_u **)options[opt_idx].var = p;
3574 /* VIMEXP
3575 * Defaults for all expanded options are currently the same for Vi
3576 * and Vim. When this changes, add some code here! Also need to
3577 * split P_DEF_ALLOCED in two.
3578 */
3579 if (options[opt_idx].flags & P_DEF_ALLOCED)
3580 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3581 options[opt_idx].def_val[VI_DEFAULT] = p;
3582 options[opt_idx].flags |= P_DEF_ALLOCED;
3583 }
3584 }
3585
Bram Moolenaar071d4272004-06-13 20:20:40 +00003586 save_file_ff(curbuf); /* Buffer is unchanged */
3587
Bram Moolenaar071d4272004-06-13 20:20:40 +00003588#if defined(FEAT_ARABIC)
3589 /* Detect use of mlterm.
3590 * Mlterm is a terminal emulator akin to xterm that has some special
3591 * abilities (bidi namely).
3592 * NOTE: mlterm's author is being asked to 'set' a variable
3593 * instead of an environment variable due to inheritance.
3594 */
3595 if (mch_getenv((char_u *)"MLTERM") != NULL)
3596 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3597#endif
3598
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003599 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003600
3601#ifdef FEAT_MBYTE
3602# if defined(WIN3264) && defined(FEAT_GETTEXT)
3603 /*
3604 * If $LANG isn't set, try to get a good value for it. This makes the
3605 * right language be used automatically. Don't do this for English.
3606 */
3607 if (mch_getenv((char_u *)"LANG") == NULL)
3608 {
3609 char buf[20];
3610
3611 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3612 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3613 * only the first two. */
3614 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3615 (LPTSTR)buf, 20);
3616 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3617 {
3618 /* There are a few exceptions (probably more) */
3619 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3620 STRCPY(buf, "zh_TW");
3621 else if (STRNICMP(buf, "chs", 3) == 0
3622 || STRNICMP(buf, "zhc", 3) == 0)
3623 STRCPY(buf, "zh_CN");
3624 else if (STRNICMP(buf, "jp", 2) == 0)
3625 STRCPY(buf, "ja");
3626 else
3627 buf[2] = NUL; /* truncate to two-letter code */
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003628 vim_setenv((char_u *)"LANG", (char_u *)buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003629 }
3630 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003631# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003632# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003633 /* Moved to os_mac_conv.c to avoid dependency problems. */
3634 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003635# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003636# endif
3637
3638 /* enc_locale() will try to find the encoding of the current locale. */
3639 p = enc_locale();
3640 if (p != NULL)
3641 {
3642 char_u *save_enc;
3643
3644 /* Try setting 'encoding' and check if the value is valid.
3645 * If not, go back to the default "latin1". */
3646 save_enc = p_enc;
3647 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003648 if (STRCMP(p_enc, "gb18030") == 0)
3649 {
3650 /* We don't support "gb18030", but "cp936" is a good substitute
3651 * for practical purposes, thus use that. It's not an alias to
3652 * still support conversion between gb18030 and utf-8. */
3653 p_enc = vim_strsave((char_u *)"cp936");
3654 vim_free(p);
3655 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003656 if (mb_init() == NULL)
3657 {
3658 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003659 if (opt_idx >= 0)
3660 {
3661 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3662 options[opt_idx].flags |= P_DEF_ALLOCED;
3663 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003664
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003665#if defined(MSWIN) || defined(MACOS) || defined(VMS)
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003666 if (STRCMP(p_enc, "latin1") == 0
3667# ifdef FEAT_MBYTE
3668 || enc_utf8
3669# endif
3670 )
3671 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003672 /* Adjust the default for 'isprint' and 'iskeyword' to match
3673 * latin1. Also set the defaults for when 'nocompatible' is
3674 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003675 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003676 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003677 set_string_option_direct((char_u *)"isk", -1,
3678 ISK_LATIN1, OPT_FREE, SID_NONE);
3679 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003680 if (opt_idx >= 0)
3681 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003682 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003683 if (opt_idx >= 0)
3684 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003685 (void)init_chartab();
3686 }
3687#endif
3688
Bram Moolenaar071d4272004-06-13 20:20:40 +00003689# if defined(WIN3264) && !defined(FEAT_GUI)
3690 /* Win32 console: When GetACP() returns a different value from
3691 * GetConsoleCP() set 'termencoding'. */
3692 if (GetACP() != GetConsoleCP())
3693 {
3694 char buf[50];
3695
3696 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3697 p_tenc = vim_strsave((char_u *)buf);
3698 if (p_tenc != NULL)
3699 {
3700 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003701 if (opt_idx >= 0)
3702 {
3703 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3704 options[opt_idx].flags |= P_DEF_ALLOCED;
3705 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003706 convert_setup(&input_conv, p_tenc, p_enc);
3707 convert_setup(&output_conv, p_enc, p_tenc);
3708 }
3709 else
3710 p_tenc = empty_option;
3711 }
3712# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003713# if defined(WIN3264) && defined(FEAT_MBYTE)
3714 /* $HOME may have characters in active code page. */
3715 init_homedir();
3716# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003717 }
3718 else
3719 {
3720 vim_free(p_enc);
3721 p_enc = save_enc;
3722 }
3723 }
3724#endif
3725
3726#ifdef FEAT_MULTI_LANG
3727 /* Set the default for 'helplang'. */
3728 set_helplang_default(get_mess_lang());
3729#endif
3730}
3731
3732/*
3733 * Set an option to its default value.
3734 * This does not take care of side effects!
3735 */
3736 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003737set_option_default(
3738 int opt_idx,
3739 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3740 int compatible) /* use Vi default value */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003741{
3742 char_u *varp; /* pointer to variable for current option */
3743 int dvi; /* index in def_val[] */
3744 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003745 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003746 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3747
3748 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3749 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003750 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003751 {
3752 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3753 if (flags & P_STRING)
3754 {
3755 /* Use set_string_option_direct() for local options to handle
3756 * freeing and allocating the value. */
3757 if (options[opt_idx].indir != PV_NONE)
3758 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003759 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003760 else
3761 {
3762 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3763 free_string_option(*(char_u **)(varp));
3764 *(char_u **)varp = options[opt_idx].def_val[dvi];
3765 options[opt_idx].flags &= ~P_ALLOCED;
3766 }
3767 }
3768 else if (flags & P_NUM)
3769 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003770 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003771 win_comp_scroll(curwin);
3772 else
3773 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003774 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003775 /* May also set global value for local option. */
3776 if (both)
3777 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3778 *(long *)varp;
3779 }
3780 }
3781 else /* P_BOOL */
3782 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003783 /* the cast to long is required for Manx C, long_i is needed for
3784 * MSVC */
3785 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003786#ifdef UNIX
3787 /* 'modeline' defaults to off for root */
3788 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3789 *(int *)varp = FALSE;
3790#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003791 /* May also set global value for local option. */
3792 if (both)
3793 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3794 *(int *)varp;
3795 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003796
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003797 /* The default value is not insecure. */
3798 flagsp = insecure_flag(opt_idx, opt_flags);
3799 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003800 }
3801
3802#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003803 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003804#endif
3805}
3806
3807/*
3808 * Set all options (except terminal options) to their default value.
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003809 * When "opt_flags" is non-zero skip 'encoding'.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003810 */
3811 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003812set_options_default(
3813 int opt_flags) /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003814{
3815 int i;
3816#ifdef FEAT_WINDOWS
3817 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003818 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003819#endif
3820
3821 for (i = 0; !istermoption(&options[i]); i++)
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003822 if (!(options[i].flags & P_NODEFAULT)
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003823#if defined(FEAT_MBYTE) || defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003824 && (opt_flags == 0
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003825 || (TRUE
3826# if defined(FEAT_MBYTE)
3827 && options[i].var != (char_u *)&p_enc
3828# endif
3829# if defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003830 && options[i].var != (char_u *)&p_cm
Bram Moolenaar80606872015-08-25 21:27:35 +02003831 && options[i].var != (char_u *)&p_key
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003832# endif
3833 ))
Bram Moolenaar80606872015-08-25 21:27:35 +02003834#endif
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003835 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003836 set_option_default(i, opt_flags, p_cp);
3837
3838#ifdef FEAT_WINDOWS
3839 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003840 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003841 win_comp_scroll(wp);
3842#else
3843 win_comp_scroll(curwin);
3844#endif
Bram Moolenaar5a4eceb2014-09-09 17:33:07 +02003845#ifdef FEAT_CINDENT
3846 parse_cino(curbuf);
3847#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003848}
3849
3850/*
3851 * Set the Vi-default value of a string option.
3852 * Used for 'sh', 'backupskip' and 'term'.
3853 */
3854 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003855set_string_default(char *name, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003856{
3857 char_u *p;
3858 int opt_idx;
3859
3860 p = vim_strsave(val);
3861 if (p != NULL) /* we don't want a NULL */
3862 {
3863 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003864 if (opt_idx >= 0)
3865 {
3866 if (options[opt_idx].flags & P_DEF_ALLOCED)
3867 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3868 options[opt_idx].def_val[VI_DEFAULT] = p;
3869 options[opt_idx].flags |= P_DEF_ALLOCED;
3870 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003871 }
3872}
3873
3874/*
3875 * Set the Vi-default value of a number option.
3876 * Used for 'lines' and 'columns'.
3877 */
3878 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003879set_number_default(char *name, long val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003880{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003881 int opt_idx;
3882
3883 opt_idx = findoption((char_u *)name);
3884 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003885 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003886}
3887
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003888#if defined(EXITFREE) || defined(PROTO)
3889/*
3890 * Free all options.
3891 */
3892 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003893free_all_options(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003894{
3895 int i;
3896
3897 for (i = 0; !istermoption(&options[i]); i++)
3898 {
3899 if (options[i].indir == PV_NONE)
3900 {
3901 /* global option: free value and default value. */
Bram Moolenaar67391142017-02-19 21:07:04 +01003902 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003903 free_string_option(*(char_u **)options[i].var);
3904 if (options[i].flags & P_DEF_ALLOCED)
3905 free_string_option(options[i].def_val[VI_DEFAULT]);
3906 }
3907 else if (options[i].var != VAR_WIN
3908 && (options[i].flags & P_STRING))
3909 /* buffer-local option: free global value */
3910 free_string_option(*(char_u **)options[i].var);
3911 }
3912}
3913#endif
3914
3915
Bram Moolenaar071d4272004-06-13 20:20:40 +00003916/*
3917 * Initialize the options, part two: After getting Rows and Columns and
3918 * setting 'term'.
3919 */
3920 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003921set_init_2(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003922{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003923 int idx;
3924
Bram Moolenaar071d4272004-06-13 20:20:40 +00003925 /*
3926 * 'scroll' defaults to half the window height. Note that this default is
3927 * wrong when the window height changes.
3928 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003929 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003930 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003931 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003932 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003933 comp_col();
3934
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003935 /*
3936 * 'window' is only for backwards compatibility with Vi.
3937 * Default is Rows - 1.
3938 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003939 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003940 p_window = Rows - 1;
3941 set_number_default("window", Rows - 1);
3942
Bram Moolenaarf740b292006-02-16 22:11:02 +00003943 /* For DOS console the default is always black. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003944#if !((defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003945 /*
3946 * If 'background' wasn't set by the user, try guessing the value,
3947 * depending on the terminal name. Only need to check for terminals
3948 * with a dark background, that can handle color.
3949 */
3950 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003951 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3952 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003953 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003954 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003955 /* don't mark it as set, when starting the GUI it may be
3956 * changed again */
3957 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003958 }
3959#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003960
3961#ifdef CURSOR_SHAPE
3962 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3963#endif
3964#ifdef FEAT_MOUSESHAPE
3965 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3966#endif
3967#ifdef FEAT_PRINTER
3968 (void)parse_printoptions(); /* parse 'printoptions' default value */
3969#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003970}
3971
3972/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00003973 * Return "dark" or "light" depending on the kind of terminal.
3974 * This is just guessing! Recognized are:
3975 * "linux" Linux console
3976 * "screen.linux" Linux console with screen
3977 * "cygwin" Cygwin shell
3978 * "putty" Putty program
3979 * We also check the COLORFGBG environment variable, which is set by
3980 * rxvt and derivatives. This variable contains either two or three
3981 * values separated by semicolons; we want the last value in either
3982 * case. If this value is 0-6 or 8, our background is dark.
3983 */
3984 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01003985term_bg_default(void)
Bram Moolenaarf740b292006-02-16 22:11:02 +00003986{
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003987#if defined(WIN3264)
Bram Moolenaarf740b292006-02-16 22:11:02 +00003988 /* DOS console nearly always black */
3989 return (char_u *)"dark";
3990#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00003991 char_u *p;
3992
Bram Moolenaarf740b292006-02-16 22:11:02 +00003993 if (STRCMP(T_NAME, "linux") == 0
3994 || STRCMP(T_NAME, "screen.linux") == 0
3995 || STRCMP(T_NAME, "cygwin") == 0
3996 || STRCMP(T_NAME, "putty") == 0
3997 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
3998 && (p = vim_strrchr(p, ';')) != NULL
3999 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
4000 && p[2] == NUL))
4001 return (char_u *)"dark";
4002 return (char_u *)"light";
4003#endif
4004}
4005
4006/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004007 * Initialize the options, part three: After reading the .vimrc
4008 */
4009 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004010set_init_3(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004011{
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004012#if defined(UNIX) || defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004013/*
4014 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
4015 * This is done after other initializations, where 'shell' might have been
4016 * set, but only if they have not been set before.
4017 */
4018 char_u *p;
4019 int idx_srr;
4020 int do_srr;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004021# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00004022 int idx_sp;
4023 int do_sp;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004024# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004025
4026 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004027 if (idx_srr < 0)
4028 do_srr = FALSE;
4029 else
4030 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004031# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00004032 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004033 if (idx_sp < 0)
4034 do_sp = FALSE;
4035 else
4036 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004037# endif
Bram Moolenaar75a8d742014-05-07 15:10:21 +02004038 p = get_isolated_shell_name();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004039 if (p != NULL)
4040 {
4041 /*
4042 * Default for p_sp is "| tee", for p_srr is ">".
4043 * For known shells it is changed here to include stderr.
4044 */
4045 if ( fnamecmp(p, "csh") == 0
4046 || fnamecmp(p, "tcsh") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004047# if defined(WIN3264) /* also check with .exe extension */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004048 || fnamecmp(p, "csh.exe") == 0
4049 || fnamecmp(p, "tcsh.exe") == 0
4050# endif
4051 )
4052 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004053# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004054 if (do_sp)
4055 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004056# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004057 p_sp = (char_u *)">&";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004058# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00004059 p_sp = (char_u *)"|& tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004060# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004061 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
4062 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004063# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004064 if (do_srr)
4065 {
4066 p_srr = (char_u *)">&";
4067 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
4068 }
4069 }
4070 else
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004071 /* Always use bourne shell style redirection if we reach this */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004072 if ( fnamecmp(p, "sh") == 0
4073 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02004074 || fnamecmp(p, "mksh") == 0
4075 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004076 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00004077 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004078 || fnamecmp(p, "bash") == 0
Bram Moolenaar75a8d742014-05-07 15:10:21 +02004079 || fnamecmp(p, "fish") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004080# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004081 || fnamecmp(p, "cmd") == 0
4082 || fnamecmp(p, "sh.exe") == 0
4083 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02004084 || fnamecmp(p, "mksh.exe") == 0
4085 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004086 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00004087 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004088 || fnamecmp(p, "bash.exe") == 0
4089 || fnamecmp(p, "cmd.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004090# endif
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004091 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00004092 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004093# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004094 if (do_sp)
4095 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004096# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004097 p_sp = (char_u *)">%s 2>&1";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004098# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00004099 p_sp = (char_u *)"2>&1| tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004100# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004101 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
4102 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004103# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004104 if (do_srr)
4105 {
4106 p_srr = (char_u *)">%s 2>&1";
4107 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
4108 }
4109 }
4110 vim_free(p);
4111 }
4112#endif
4113
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004114#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004115 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01004116 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
4117 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004118 * This is done after other initializations, where 'shell' might have been
4119 * set, but only if they have not been set before. Default for p_shcf is
4120 * "/c", for p_shq is "". For "sh" like shells it is changed here to
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004121 * "-c" and "\"". And for Win32 we need to set p_sxq instead.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004122 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00004123 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004124 {
4125 int idx3;
4126
4127 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004128 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004129 {
4130 p_shcf = (char_u *)"-c";
4131 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4132 }
4133
Bram Moolenaar071d4272004-06-13 20:20:40 +00004134 /* Somehow Win32 requires the quotes around the redirection too */
4135 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004136 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004137 {
4138 p_sxq = (char_u *)"\"";
4139 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4140 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004141 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01004142 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
4143 {
4144 int idx3;
4145
4146 /*
4147 * cmd.exe on Windows will strip the first and last double quote given
4148 * on the command line, e.g. most of the time things like:
4149 * cmd /c "my path/to/echo" "my args to echo"
4150 * become:
4151 * my path/to/echo" "my args to echo
4152 * when executed.
4153 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01004154 * To avoid this, set shellxquote to surround the command in
4155 * parenthesis. This appears to make most commands work, without
4156 * breaking commands that worked previously, such as
4157 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01004158 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01004159 idx3 = findoption((char_u *)"sxq");
4160 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4161 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004162 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004163 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4164 }
4165
Bram Moolenaara64ba222012-02-12 23:23:31 +01004166 idx3 = findoption((char_u *)"shcf");
4167 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4168 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004169 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004170 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4171 }
4172 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004173#endif
4174
Bram Moolenaarb5aedf32017-03-12 18:23:53 +01004175 if (BUFEMPTY())
Bram Moolenaar364fa5c2016-03-20 17:53:25 +01004176 {
4177 int idx_ffs = findoption((char_u *)"ffs");
4178
4179 /* Apply the first entry of 'fileformats' to the initial buffer. */
4180 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET))
4181 set_fileformat(default_fileformat(), OPT_LOCAL);
4182 }
4183
Bram Moolenaar071d4272004-06-13 20:20:40 +00004184#ifdef FEAT_TITLE
4185 set_title_defaults();
4186#endif
4187}
4188
4189#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4190/*
4191 * When 'helplang' is still at its default value, set it to "lang".
4192 * Only the first two characters of "lang" are used.
4193 */
4194 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004195set_helplang_default(char_u *lang)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004196{
4197 int idx;
4198
4199 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4200 return;
4201 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004202 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004203 {
4204 if (options[idx].flags & P_ALLOCED)
4205 free_string_option(p_hlg);
4206 p_hlg = vim_strsave(lang);
4207 if (p_hlg == NULL)
4208 p_hlg = empty_option;
4209 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004210 {
4211 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4212 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4213 {
4214 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4215 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4216 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004217 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004218 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004219 options[idx].flags |= P_ALLOCED;
4220 }
4221}
4222#endif
4223
4224#ifdef FEAT_GUI
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01004225static char_u *gui_bg_default(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004226
4227 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01004228gui_bg_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004229{
4230 if (gui_get_lightness(gui.back_pixel) < 127)
4231 return (char_u *)"dark";
4232 return (char_u *)"light";
4233}
4234
4235/*
4236 * Option initializations that can only be done after opening the GUI window.
4237 */
4238 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004239init_gui_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004240{
4241 /* Set the 'background' option according to the lightness of the
4242 * background color, unless the user has set it already. */
4243 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4244 {
4245 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4246 highlight_changed();
4247 }
4248}
4249#endif
4250
4251#ifdef FEAT_TITLE
4252/*
4253 * 'title' and 'icon' only default to true if they have not been set or reset
4254 * in .vimrc and we can read the old value.
4255 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4256 * they can be reset. This reduces startup time when using X on a remote
4257 * machine.
4258 */
4259 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004260set_title_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004261{
4262 int idx1;
4263 long val;
4264
4265 /*
4266 * If GUI is (going to be) used, we can always set the window title and
4267 * icon name. Saves a bit of time, because the X11 display server does
4268 * not need to be contacted.
4269 */
4270 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004271 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004272 {
4273#ifdef FEAT_GUI
4274 if (gui.starting || gui.in_use)
4275 val = TRUE;
4276 else
4277#endif
4278 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004279 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004280 p_title = val;
4281 }
4282 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004283 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004284 {
4285#ifdef FEAT_GUI
4286 if (gui.starting || gui.in_use)
4287 val = TRUE;
4288 else
4289#endif
4290 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004291 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004292 p_icon = val;
4293 }
4294}
4295#endif
4296
Bram Moolenaar182a17b2017-06-25 20:57:18 +02004297#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4298 static void
4299trigger_optionsset_string(
4300 int opt_idx,
4301 int opt_flags,
4302 char_u *oldval,
4303 char_u *newval)
4304{
4305 if (oldval != NULL && newval != NULL)
4306 {
4307 char_u buf_type[7];
4308
4309 sprintf((char *)buf_type, "%s",
4310 (opt_flags & OPT_LOCAL) ? "local" : "global");
4311 set_vim_var_string(VV_OPTION_OLD, oldval, -1);
4312 set_vim_var_string(VV_OPTION_NEW, newval, -1);
4313 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
4314 apply_autocmds(EVENT_OPTIONSET,
4315 (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
4316 reset_v_option_vars();
4317 }
4318 vim_free(oldval);
4319 vim_free(newval);
4320}
4321#endif
4322
Bram Moolenaar071d4272004-06-13 20:20:40 +00004323/*
4324 * Parse 'arg' for option settings.
4325 *
4326 * 'arg' may be IObuff, but only when no errors can be present and option
4327 * does not need to be expanded with option_expand().
4328 * "opt_flags":
4329 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004330 * OPT_GLOBAL for ":setglobal"
4331 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004332 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004333 * OPT_WINONLY to only set window-local options
4334 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004335 *
4336 * returns FAIL if an error is detected, OK otherwise
4337 */
4338 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01004339do_set(
4340 char_u *arg, /* option string (may be written to!) */
4341 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004342{
4343 int opt_idx;
4344 char_u *errmsg;
4345 char_u errbuf[80];
4346 char_u *startarg;
4347 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4348 int nextchar; /* next non-white char after option name */
4349 int afterchar; /* character just after option name */
4350 int len;
4351 int i;
Bram Moolenaar22fcfad2016-07-01 18:17:26 +02004352 varnumber_T value;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004353 int key;
4354 long_u flags; /* flags for current option */
4355 char_u *varp = NULL; /* pointer to variable for current option */
4356 int did_show = FALSE; /* already showed one value */
4357 int adding; /* "opt+=arg" */
4358 int prepending; /* "opt^=arg" */
4359 int removing; /* "opt-=arg" */
4360 int cp_val = 0;
4361 char_u key_name[2];
4362
4363 if (*arg == NUL)
4364 {
4365 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004366 did_show = TRUE;
4367 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004368 }
4369
4370 while (*arg != NUL) /* loop to process all options */
4371 {
4372 errmsg = NULL;
4373 startarg = arg; /* remember for error message */
4374
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004375 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4376 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004377 {
4378 /*
4379 * ":set all" show all options.
4380 * ":set all&" set all options to their default value.
4381 */
4382 arg += 3;
4383 if (*arg == '&')
4384 {
4385 ++arg;
4386 /* Only for :set command set global value of local options. */
4387 set_options_default(OPT_FREE | opt_flags);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02004388 didset_options();
4389 didset_options2();
Bram Moolenaarb341dda2015-08-25 12:56:31 +02004390 redraw_all_later(CLEAR);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004391 }
4392 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004393 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004394 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004395 did_show = TRUE;
4396 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004397 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004398 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004399 {
4400 showoptions(2, opt_flags);
4401 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004402 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004403 arg += 7;
4404 }
4405 else
4406 {
4407 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004408 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004409 {
4410 prefix = 0;
4411 arg += 2;
4412 }
4413 else if (STRNCMP(arg, "inv", 3) == 0)
4414 {
4415 prefix = 2;
4416 arg += 3;
4417 }
4418
4419 /* find end of name */
4420 key = 0;
4421 if (*arg == '<')
4422 {
4423 nextchar = 0;
4424 opt_idx = -1;
4425 /* look out for <t_>;> */
4426 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4427 len = 5;
4428 else
4429 {
4430 len = 1;
4431 while (arg[len] != NUL && arg[len] != '>')
4432 ++len;
4433 }
4434 if (arg[len] != '>')
4435 {
4436 errmsg = e_invarg;
4437 goto skip;
4438 }
4439 arg[len] = NUL; /* put NUL after name */
4440 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4441 opt_idx = findoption(arg + 1);
4442 arg[len++] = '>'; /* restore '>' */
4443 if (opt_idx == -1)
4444 key = find_key_option(arg + 1);
4445 }
4446 else
4447 {
4448 len = 0;
4449 /*
4450 * The two characters after "t_" may not be alphanumeric.
4451 */
4452 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4453 len = 4;
4454 else
4455 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4456 ++len;
4457 nextchar = arg[len];
4458 arg[len] = NUL; /* put NUL after name */
4459 opt_idx = findoption(arg);
4460 arg[len] = nextchar; /* restore nextchar */
4461 if (opt_idx == -1)
4462 key = find_key_option(arg);
4463 }
4464
4465 /* remember character after option name */
4466 afterchar = arg[len];
4467
4468 /* skip white space, allow ":set ai ?" */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004469 while (VIM_ISWHITE(arg[len]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004470 ++len;
4471
4472 adding = FALSE;
4473 prepending = FALSE;
4474 removing = FALSE;
4475 if (arg[len] != NUL && arg[len + 1] == '=')
4476 {
4477 if (arg[len] == '+')
4478 {
4479 adding = TRUE; /* "+=" */
4480 ++len;
4481 }
4482 else if (arg[len] == '^')
4483 {
4484 prepending = TRUE; /* "^=" */
4485 ++len;
4486 }
4487 else if (arg[len] == '-')
4488 {
4489 removing = TRUE; /* "-=" */
4490 ++len;
4491 }
4492 }
4493 nextchar = arg[len];
4494
4495 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4496 {
4497 errmsg = (char_u *)N_("E518: Unknown option");
4498 goto skip;
4499 }
4500
4501 if (opt_idx >= 0)
4502 {
4503 if (options[opt_idx].var == NULL) /* hidden option: skip */
4504 {
4505 /* Only give an error message when requesting the value of
4506 * a hidden option, ignore setting it. */
4507 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4508 && (!(options[opt_idx].flags & P_BOOL)
4509 || nextchar == '?'))
4510 errmsg = (char_u *)N_("E519: Option not supported");
4511 goto skip;
4512 }
4513
4514 flags = options[opt_idx].flags;
4515 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4516 }
4517 else
4518 {
4519 flags = P_STRING;
4520 if (key < 0)
4521 {
4522 key_name[0] = KEY2TERMCAP0(key);
4523 key_name[1] = KEY2TERMCAP1(key);
4524 }
4525 else
4526 {
4527 key_name[0] = KS_KEY;
4528 key_name[1] = (key & 0xff);
4529 }
4530 }
4531
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004532 /* Skip all options that are not window-local (used when showing
4533 * an already loaded buffer in a window). */
4534 if ((opt_flags & OPT_WINONLY)
4535 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4536 goto skip;
4537
Bram Moolenaara3227e22006-03-08 21:32:40 +00004538 /* Skip all options that are window-local (used for :vimgrep). */
4539 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4540 && options[opt_idx].var == VAR_WIN)
4541 goto skip;
4542
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004543 /* Disallow changing some options from modelines. */
4544 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004545 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004546 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004547 {
4548 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4549 goto skip;
4550 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004551#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004552 /* In diff mode some options are overruled. This avoids that
4553 * 'foldmethod' becomes "marker" instead of "diff" and that
4554 * "wrap" gets set. */
4555 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004556 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaara6c07602017-03-05 21:18:27 +01004557 && (
4558#ifdef FEAT_FOLDING
4559 options[opt_idx].indir == PV_FDM ||
4560#endif
4561 options[opt_idx].indir == PV_WRAP))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004562 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004563#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004564 }
4565
4566#ifdef HAVE_SANDBOX
4567 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004568 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004569 {
4570 errmsg = (char_u *)_(e_sandbox);
4571 goto skip;
4572 }
4573#endif
4574
4575 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4576 {
4577 arg += len;
4578 cp_val = p_cp;
4579 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4580 {
4581 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4582 {
4583 cp_val = FALSE;
4584 arg += 3;
4585 }
4586 else /* "opt&vi": set to Vi default */
4587 {
4588 cp_val = TRUE;
4589 arg += 2;
4590 }
4591 }
4592 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
Bram Moolenaar1c465442017-03-12 20:10:05 +01004593 && arg[1] != NUL && !VIM_ISWHITE(arg[1]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004594 {
4595 errmsg = e_trailing;
4596 goto skip;
4597 }
4598 }
4599
4600 /*
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004601 * allow '=' and ':' for hystorical reasons (MSDOS command.com
4602 * allows only one '=' character per "set" command line. grrr. (jw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004603 */
4604 if (nextchar == '?'
4605 || (prefix == 1
4606 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4607 && !(flags & P_BOOL)))
4608 {
4609 /*
4610 * print value
4611 */
4612 if (did_show)
4613 msg_putchar('\n'); /* cursor below last one */
4614 else
4615 {
4616 gotocmdline(TRUE); /* cursor at status line */
4617 did_show = TRUE; /* remember that we did a line */
4618 }
4619 if (opt_idx >= 0)
4620 {
4621 showoneopt(&options[opt_idx], opt_flags);
4622#ifdef FEAT_EVAL
4623 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004624 {
4625 /* Mention where the option was last set. */
4626 if (varp == options[opt_idx].var)
4627 last_set_msg(options[opt_idx].scriptID);
4628 else if ((int)options[opt_idx].indir & PV_WIN)
4629 last_set_msg(curwin->w_p_scriptID[
4630 (int)options[opt_idx].indir & PV_MASK]);
4631 else if ((int)options[opt_idx].indir & PV_BUF)
4632 last_set_msg(curbuf->b_p_scriptID[
4633 (int)options[opt_idx].indir & PV_MASK]);
4634 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004635#endif
4636 }
4637 else
4638 {
4639 char_u *p;
4640
4641 p = find_termcode(key_name);
4642 if (p == NULL)
4643 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004644 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004645 goto skip;
4646 }
4647 else
4648 (void)show_one_termcode(key_name, p, TRUE);
4649 }
4650 if (nextchar != '?'
Bram Moolenaar1c465442017-03-12 20:10:05 +01004651 && nextchar != NUL && !VIM_ISWHITE(afterchar))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004652 errmsg = e_trailing;
4653 }
4654 else
4655 {
4656 if (flags & P_BOOL) /* boolean */
4657 {
4658 if (nextchar == '=' || nextchar == ':')
4659 {
4660 errmsg = e_invarg;
4661 goto skip;
4662 }
4663
4664 /*
4665 * ":set opt!": invert
4666 * ":set opt&": reset to default value
4667 * ":set opt<": reset to global value
4668 */
4669 if (nextchar == '!')
4670 value = *(int *)(varp) ^ 1;
4671 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004672 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004673 ((flags & P_VI_DEF) || cp_val)
4674 ? VI_DEFAULT : VIM_DEFAULT];
4675 else if (nextchar == '<')
4676 {
4677 /* For 'autoread' -1 means to use global value. */
4678 if ((int *)varp == &curbuf->b_p_ar
4679 && opt_flags == OPT_LOCAL)
4680 value = -1;
4681 else
4682 value = *(int *)get_varp_scope(&(options[opt_idx]),
4683 OPT_GLOBAL);
4684 }
4685 else
4686 {
4687 /*
4688 * ":set invopt": invert
4689 * ":set opt" or ":set noopt": set or reset
4690 */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004691 if (nextchar != NUL && !VIM_ISWHITE(afterchar))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004692 {
4693 errmsg = e_trailing;
4694 goto skip;
4695 }
4696 if (prefix == 2) /* inv */
4697 value = *(int *)(varp) ^ 1;
4698 else
4699 value = prefix;
4700 }
4701
4702 errmsg = set_bool_option(opt_idx, varp, (int)value,
4703 opt_flags);
4704 }
4705 else /* numeric or string */
4706 {
4707 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4708 || prefix != 1)
4709 {
4710 errmsg = e_invarg;
4711 goto skip;
4712 }
4713
4714 if (flags & P_NUM) /* numeric */
4715 {
4716 /*
4717 * Different ways to set a number option:
4718 * & set to default value
4719 * < set to global value
4720 * <xx> accept special key codes for 'wildchar'
4721 * c accept any non-digit for 'wildchar'
4722 * [-]0-9 set number
4723 * other error
4724 */
4725 ++arg;
4726 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004727 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004728 ((flags & P_VI_DEF) || cp_val)
4729 ? VI_DEFAULT : VIM_DEFAULT];
4730 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004731 {
4732 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4733 * use the global value. */
4734 if ((long *)varp == &curbuf->b_p_ul
4735 && opt_flags == OPT_LOCAL)
4736 value = NO_LOCAL_UNDOLEVEL;
4737 else
4738 value = *(long *)get_varp_scope(
4739 &(options[opt_idx]), OPT_GLOBAL);
4740 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004741 else if (((long *)varp == &p_wc
4742 || (long *)varp == &p_wcm)
4743 && (*arg == '<'
4744 || *arg == '^'
Bram Moolenaar1c465442017-03-12 20:10:05 +01004745 || (*arg != NUL
4746 && (!arg[1] || VIM_ISWHITE(arg[1]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004747 && !VIM_ISDIGIT(*arg))))
4748 {
4749 value = string_to_key(arg);
4750 if (value == 0 && (long *)varp != &p_wcm)
4751 {
4752 errmsg = e_invarg;
4753 goto skip;
4754 }
4755 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004756 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4757 {
Bram Moolenaar18400e62015-01-27 15:58:40 +01004758 /* Allow negative (for 'undolevels'), octal and
4759 * hex numbers. */
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01004760 vim_str2nr(arg, NULL, &i, STR2NR_ALL,
4761 &value, NULL, 0);
Bram Moolenaar1c465442017-03-12 20:10:05 +01004762 if (arg[i] != NUL && !VIM_ISWHITE(arg[i]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004763 {
4764 errmsg = e_invarg;
4765 goto skip;
4766 }
4767 }
4768 else
4769 {
4770 errmsg = (char_u *)N_("E521: Number required after =");
4771 goto skip;
4772 }
4773
4774 if (adding)
4775 value = *(long *)varp + value;
4776 if (prepending)
4777 value = *(long *)varp * value;
4778 if (removing)
4779 value = *(long *)varp - value;
4780 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004781 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004782 }
4783 else if (opt_idx >= 0) /* string */
4784 {
4785 char_u *save_arg = NULL;
4786 char_u *s = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004787 char_u *oldval = NULL; /* previous value if *varp */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004788 char_u *newval;
Bram Moolenaar53744302015-07-17 17:38:22 +02004789 char_u *origval = NULL;
4790#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4791 char_u *saved_origval = NULL;
Bram Moolenaar182a17b2017-06-25 20:57:18 +02004792 char_u *saved_newval = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004793#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004794 unsigned newlen;
4795 int comma;
4796 int bs;
4797 int new_value_alloced; /* new string option
4798 was allocated */
4799
4800 /* When using ":set opt=val" for a global option
4801 * with a local value the local value will be
4802 * reset, use the global value here. */
4803 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004804 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004805 varp = options[opt_idx].var;
4806
4807 /* The old value is kept until we are sure that the
4808 * new value is valid. */
4809 oldval = *(char_u **)varp;
4810 if (nextchar == '&') /* set to default val */
4811 {
4812 newval = options[opt_idx].def_val[
4813 ((flags & P_VI_DEF) || cp_val)
4814 ? VI_DEFAULT : VIM_DEFAULT];
4815 if ((char_u **)varp == &p_bg)
4816 {
4817 /* guess the value of 'background' */
4818#ifdef FEAT_GUI
4819 if (gui.in_use)
4820 newval = gui_bg_default();
4821 else
4822#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004823 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004824 }
4825
4826 /* expand environment variables and ~ (since the
4827 * default value was already expanded, only
4828 * required when an environment variable was set
4829 * later */
4830 if (newval == NULL)
4831 newval = empty_option;
4832 else
4833 {
4834 s = option_expand(opt_idx, newval);
4835 if (s == NULL)
4836 s = newval;
4837 newval = vim_strsave(s);
4838 }
4839 new_value_alloced = TRUE;
4840 }
4841 else if (nextchar == '<') /* set to global val */
4842 {
4843 newval = vim_strsave(*(char_u **)get_varp_scope(
4844 &(options[opt_idx]), OPT_GLOBAL));
4845 new_value_alloced = TRUE;
4846 }
4847 else
4848 {
4849 ++arg; /* jump to after the '=' or ':' */
4850
4851 /*
4852 * Set 'keywordprg' to ":help" if an empty
4853 * value was passed to :set by the user.
4854 * Misuse errbuf[] for the resulting string.
4855 */
4856 if (varp == (char_u *)&p_kp
4857 && (*arg == NUL || *arg == ' '))
4858 {
4859 STRCPY(errbuf, ":help");
4860 save_arg = arg;
4861 arg = errbuf;
4862 }
4863 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004864 * Convert 'backspace' number to string, for
4865 * adding, prepending and removing string.
4866 */
4867 else if (varp == (char_u *)&p_bs
4868 && VIM_ISDIGIT(**(char_u **)varp))
4869 {
4870 i = getdigits((char_u **)varp);
4871 switch (i)
4872 {
4873 case 0:
4874 *(char_u **)varp = empty_option;
4875 break;
4876 case 1:
4877 *(char_u **)varp = vim_strsave(
4878 (char_u *)"indent,eol");
4879 break;
4880 case 2:
4881 *(char_u **)varp = vim_strsave(
4882 (char_u *)"indent,eol,start");
4883 break;
4884 }
4885 vim_free(oldval);
4886 oldval = *(char_u **)varp;
4887 }
4888 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004889 * Convert 'whichwrap' number to string, for
4890 * backwards compatibility with Vim 3.0.
4891 * Misuse errbuf[] for the resulting string.
4892 */
4893 else if (varp == (char_u *)&p_ww
4894 && VIM_ISDIGIT(*arg))
4895 {
4896 *errbuf = NUL;
4897 i = getdigits(&arg);
4898 if (i & 1)
4899 STRCAT(errbuf, "b,");
4900 if (i & 2)
4901 STRCAT(errbuf, "s,");
4902 if (i & 4)
4903 STRCAT(errbuf, "h,l,");
4904 if (i & 8)
4905 STRCAT(errbuf, "<,>,");
4906 if (i & 16)
4907 STRCAT(errbuf, "[,],");
4908 if (*errbuf != NUL) /* remove trailing , */
4909 errbuf[STRLEN(errbuf) - 1] = NUL;
4910 save_arg = arg;
4911 arg = errbuf;
4912 }
4913 /*
4914 * Remove '>' before 'dir' and 'bdir', for
4915 * backwards compatibility with version 3.0
4916 */
4917 else if ( *arg == '>'
4918 && (varp == (char_u *)&p_dir
4919 || varp == (char_u *)&p_bdir))
4920 {
4921 ++arg;
4922 }
4923
4924 /* When setting the local value of a global
4925 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004926 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004927 && (opt_flags & OPT_LOCAL))
4928 origval = *(char_u **)get_varp(
4929 &options[opt_idx]);
4930 else
4931 origval = oldval;
4932
4933 /*
4934 * Copy the new string into allocated memory.
4935 * Can't use set_string_option_direct(), because
4936 * we need to remove the backslashes.
4937 */
4938 /* get a bit too much */
4939 newlen = (unsigned)STRLEN(arg) + 1;
4940 if (adding || prepending || removing)
4941 newlen += (unsigned)STRLEN(origval) + 1;
4942 newval = alloc(newlen);
4943 if (newval == NULL) /* out of mem, don't change */
4944 break;
4945 s = newval;
4946
4947 /*
4948 * Copy the string, skip over escaped chars.
4949 * For MS-DOS and WIN32 backslashes before normal
4950 * file name characters are not removed, and keep
4951 * backslash at start, for "\\machine\path", but
4952 * do remove it for "\\\\machine\\path".
4953 * The reverse is found in ExpandOldSetting().
4954 */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004955 while (*arg && !VIM_ISWHITE(*arg))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004956 {
4957 if (*arg == '\\' && arg[1] != NUL
4958#ifdef BACKSLASH_IN_FILENAME
4959 && !((flags & P_EXPAND)
4960 && vim_isfilec(arg[1])
4961 && (arg[1] != '\\'
4962 || (s == newval
4963 && arg[2] != '\\')))
4964#endif
4965 )
4966 ++arg; /* remove backslash */
4967#ifdef FEAT_MBYTE
4968 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00004969 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004970 {
4971 /* copy multibyte char */
4972 mch_memmove(s, arg, (size_t)i);
4973 arg += i;
4974 s += i;
4975 }
4976 else
4977#endif
4978 *s++ = *arg++;
4979 }
4980 *s = NUL;
4981
4982 /*
4983 * Expand environment variables and ~.
4984 * Don't do it when adding without inserting a
4985 * comma.
4986 */
4987 if (!(adding || prepending || removing)
4988 || (flags & P_COMMA))
4989 {
4990 s = option_expand(opt_idx, newval);
4991 if (s != NULL)
4992 {
4993 vim_free(newval);
4994 newlen = (unsigned)STRLEN(s) + 1;
4995 if (adding || prepending || removing)
4996 newlen += (unsigned)STRLEN(origval) + 1;
4997 newval = alloc(newlen);
4998 if (newval == NULL)
4999 break;
5000 STRCPY(newval, s);
5001 }
5002 }
5003
5004 /* locate newval[] in origval[] when removing it
5005 * and when adding to avoid duplicates */
5006 i = 0; /* init for GCC */
5007 if (removing || (flags & P_NODUP))
5008 {
5009 i = (int)STRLEN(newval);
5010 bs = 0;
5011 for (s = origval; *s; ++s)
5012 {
5013 if ((!(flags & P_COMMA)
5014 || s == origval
5015 || (s[-1] == ',' && !(bs & 1)))
5016 && STRNCMP(s, newval, i) == 0
5017 && (!(flags & P_COMMA)
5018 || s[i] == ','
5019 || s[i] == NUL))
5020 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01005021 /* Count backslashes. Only a comma with an
Bram Moolenaar8f79acd2016-01-01 14:48:20 +01005022 * even number of backslashes or a single
5023 * backslash preceded by a comma before it
5024 * is recognized as a separator */
5025 if ((s > origval + 1
5026 && s[-1] == '\\'
5027 && s[-2] != ',')
5028 || (s == origval + 1
5029 && s[-1] == '\\'))
5030
Bram Moolenaar071d4272004-06-13 20:20:40 +00005031 ++bs;
5032 else
5033 bs = 0;
5034 }
5035
5036 /* do not add if already there */
5037 if ((adding || prepending) && *s)
5038 {
5039 prepending = FALSE;
5040 adding = FALSE;
5041 STRCPY(newval, origval);
5042 }
5043 }
5044
5045 /* concatenate the two strings; add a ',' if
5046 * needed */
5047 if (adding || prepending)
5048 {
5049 comma = ((flags & P_COMMA) && *origval != NUL
5050 && *newval != NUL);
5051 if (adding)
5052 {
5053 i = (int)STRLEN(origval);
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02005054 /* strip a trailing comma, would get 2 */
Bram Moolenaar17467472015-11-10 17:50:24 +01005055 if (comma && i > 1
5056 && (flags & P_ONECOMMA) == P_ONECOMMA
5057 && origval[i - 1] == ','
5058 && origval[i - 2] != '\\')
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02005059 i--;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005060 mch_memmove(newval + i + comma, newval,
5061 STRLEN(newval) + 1);
5062 mch_memmove(newval, origval, (size_t)i);
5063 }
5064 else
5065 {
5066 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00005067 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005068 }
5069 if (comma)
5070 newval[i] = ',';
5071 }
5072
5073 /* Remove newval[] from origval[]. (Note: "i" has
5074 * been set above and is used here). */
5075 if (removing)
5076 {
5077 STRCPY(newval, origval);
5078 if (*s)
5079 {
5080 /* may need to remove a comma */
5081 if (flags & P_COMMA)
5082 {
5083 if (s == origval)
5084 {
5085 /* include comma after string */
5086 if (s[i] == ',')
5087 ++i;
5088 }
5089 else
5090 {
5091 /* include comma before string */
5092 --s;
5093 ++i;
5094 }
5095 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00005096 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005097 }
5098 }
5099
5100 if (flags & P_FLAGLIST)
5101 {
5102 /* Remove flags that appear twice. */
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005103 for (s = newval; *s;)
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005104 {
5105 /* if options have P_FLAGLIST and
5106 * P_ONECOMMA such as 'whichwrap' */
5107 if (flags & P_ONECOMMA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005108 {
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005109 if (*s != ',' && *(s + 1) == ','
5110 && vim_strchr(s + 2, *s) != NULL)
5111 {
5112 /* Remove the duplicated value and
5113 * the next comma. */
5114 STRMOVE(s, s + 2);
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005115 continue;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005116 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005117 }
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005118 else
5119 {
5120 if ((!(flags & P_COMMA) || *s != ',')
5121 && vim_strchr(s + 1, *s) != NULL)
5122 {
5123 STRMOVE(s, s + 1);
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005124 continue;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005125 }
5126 }
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005127 ++s;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005128 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005129 }
5130
5131 if (save_arg != NULL) /* number for 'whichwrap' */
5132 arg = save_arg;
5133 new_value_alloced = TRUE;
5134 }
5135
5136 /* Set the new value. */
5137 *(char_u **)(varp) = newval;
5138
Bram Moolenaar53744302015-07-17 17:38:22 +02005139#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005140 if (!starting
5141# ifdef FEAT_CRYPT
5142 && options[opt_idx].indir != PV_KEY
5143# endif
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005144 && origval != NULL && newval != NULL)
5145 {
Bram Moolenaar53744302015-07-17 17:38:22 +02005146 /* origval may be freed by
5147 * did_set_string_option(), make a copy. */
5148 saved_origval = vim_strsave(origval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005149 /* newval (and varp) may become invalid if the
5150 * buffer is closed by autocommands. */
5151 saved_newval = vim_strsave(newval);
5152 }
Bram Moolenaar53744302015-07-17 17:38:22 +02005153#endif
5154
Bram Moolenaar071d4272004-06-13 20:20:40 +00005155 /* Handle side effects, and set the global value for
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005156 * ":set" on local options. Note: when setting 'syntax'
5157 * or 'filetype' autocommands may be triggered that can
5158 * cause havoc. */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005159 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
5160 new_value_alloced, oldval, errbuf, opt_flags);
5161
5162 /* If error detected, print the error message. */
5163 if (errmsg != NULL)
Bram Moolenaara9884962015-12-13 15:08:56 +01005164 {
5165#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5166 vim_free(saved_origval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005167 vim_free(saved_newval);
Bram Moolenaara9884962015-12-13 15:08:56 +01005168#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005169 goto skip;
Bram Moolenaara9884962015-12-13 15:08:56 +01005170 }
Bram Moolenaar53744302015-07-17 17:38:22 +02005171#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005172 trigger_optionsset_string(opt_idx, opt_flags,
5173 saved_origval, saved_newval);
Bram Moolenaar53744302015-07-17 17:38:22 +02005174#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005175 }
5176 else /* key code option */
5177 {
5178 char_u *p;
5179
5180 if (nextchar == '&')
5181 {
5182 if (add_termcap_entry(key_name, TRUE) == FAIL)
5183 errmsg = (char_u *)N_("E522: Not found in termcap");
5184 }
5185 else
5186 {
5187 ++arg; /* jump to after the '=' or ':' */
Bram Moolenaar1c465442017-03-12 20:10:05 +01005188 for (p = arg; *p && !VIM_ISWHITE(*p); ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005189 if (*p == '\\' && p[1] != NUL)
5190 ++p;
5191 nextchar = *p;
5192 *p = NUL;
5193 add_termcode(key_name, arg, FALSE);
5194 *p = nextchar;
5195 }
5196 if (full_screen)
5197 ttest(FALSE);
5198 redraw_all_later(CLEAR);
5199 }
5200 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005201
Bram Moolenaar071d4272004-06-13 20:20:40 +00005202 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005203 did_set_option(opt_idx, opt_flags,
5204 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005205 }
5206
5207skip:
5208 /*
5209 * Advance to next argument.
5210 * - skip until a blank found, taking care of backslashes
5211 * - skip blanks
5212 * - skip one "=val" argument (for hidden options ":set gfn =xx")
5213 */
5214 for (i = 0; i < 2 ; ++i)
5215 {
Bram Moolenaar1c465442017-03-12 20:10:05 +01005216 while (*arg != NUL && !VIM_ISWHITE(*arg))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005217 if (*arg++ == '\\' && *arg != NUL)
5218 ++arg;
5219 arg = skipwhite(arg);
5220 if (*arg != '=')
5221 break;
5222 }
5223 }
5224
5225 if (errmsg != NULL)
5226 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005227 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005228 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005229 if (i + (arg - startarg) < IOSIZE)
5230 {
5231 /* append the argument with the error */
5232 STRCAT(IObuff, ": ");
5233 mch_memmove(IObuff + i, startarg, (arg - startarg));
5234 IObuff[i + (arg - startarg)] = NUL;
5235 }
5236 /* make sure all characters are printable */
5237 trans_characters(IObuff, IOSIZE);
5238
5239 ++no_wait_return; /* wait_return done later */
5240 emsg(IObuff); /* show error highlighted */
5241 --no_wait_return;
5242
5243 return FAIL;
5244 }
5245
5246 arg = skipwhite(arg);
5247 }
5248
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005249theend:
5250 if (silent_mode && did_show)
5251 {
5252 /* After displaying option values in silent mode. */
5253 silent_mode = FALSE;
5254 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5255 msg_putchar('\n');
5256 cursor_on(); /* msg_start() switches it off */
5257 out_flush();
5258 silent_mode = TRUE;
5259 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5260 }
5261
Bram Moolenaar071d4272004-06-13 20:20:40 +00005262 return OK;
5263}
5264
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005265/*
5266 * Call this when an option has been given a new value through a user command.
5267 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5268 */
5269 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005270did_set_option(
5271 int opt_idx,
5272 int opt_flags, /* possibly with OPT_MODELINE */
5273 int new_value) /* value was replaced completely */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005274{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005275 long_u *p;
5276
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005277 options[opt_idx].flags |= P_WAS_SET;
5278
5279 /* When an option is set in the sandbox, from a modeline or in secure mode
5280 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005281 * flag. */
5282 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005283 if (secure
5284#ifdef HAVE_SANDBOX
5285 || sandbox != 0
5286#endif
5287 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005288 *p = *p | P_INSECURE;
5289 else if (new_value)
5290 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005291}
5292
Bram Moolenaar071d4272004-06-13 20:20:40 +00005293 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005294illegal_char(char_u *errbuf, int c)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005295{
5296 if (errbuf == NULL)
5297 return (char_u *)"";
5298 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005299 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005300 return errbuf;
5301}
5302
5303/*
5304 * Convert a key name or string into a key value.
5305 * Used for 'wildchar' and 'cedit' options.
5306 */
5307 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005308string_to_key(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005309{
5310 if (*arg == '<')
5311 return find_key_option(arg + 1);
5312 if (*arg == '^')
5313 return Ctrl_chr(arg[1]);
5314 return *arg;
5315}
5316
5317#ifdef FEAT_CMDWIN
5318/*
5319 * Check value of 'cedit' and set cedit_key.
5320 * Returns NULL if value is OK, error message otherwise.
5321 */
5322 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005323check_cedit(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005324{
5325 int n;
5326
5327 if (*p_cedit == NUL)
5328 cedit_key = -1;
5329 else
5330 {
5331 n = string_to_key(p_cedit);
5332 if (vim_isprintc(n))
5333 return e_invarg;
5334 cedit_key = n;
5335 }
5336 return NULL;
5337}
5338#endif
5339
5340#ifdef FEAT_TITLE
5341/*
5342 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5343 * maketitle() to create and display it.
5344 * When switching the title or icon off, call mch_restore_title() to get
5345 * the old value back.
5346 */
5347 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005348did_set_title(
5349 int icon) /* Did set icon instead of title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005350{
5351 if (starting != NO_SCREEN
5352#ifdef FEAT_GUI
5353 && !gui.starting
5354#endif
5355 )
5356 {
5357 maketitle();
5358 if (icon)
5359 {
5360 if (!p_icon)
5361 mch_restore_title(2);
5362 }
5363 else
5364 {
5365 if (!p_title)
5366 mch_restore_title(1);
5367 }
5368 }
5369}
5370#endif
5371
5372/*
5373 * set_options_bin - called when 'bin' changes value.
5374 */
5375 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005376set_options_bin(
5377 int oldval,
5378 int newval,
5379 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005380{
5381 /*
5382 * The option values that are changed when 'bin' changes are
5383 * copied when 'bin is set and restored when 'bin' is reset.
5384 */
5385 if (newval)
5386 {
5387 if (!oldval) /* switched on */
5388 {
5389 if (!(opt_flags & OPT_GLOBAL))
5390 {
5391 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5392 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5393 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5394 curbuf->b_p_et_nobin = curbuf->b_p_et;
5395 }
5396 if (!(opt_flags & OPT_LOCAL))
5397 {
5398 p_tw_nobin = p_tw;
5399 p_wm_nobin = p_wm;
5400 p_ml_nobin = p_ml;
5401 p_et_nobin = p_et;
5402 }
5403 }
5404
5405 if (!(opt_flags & OPT_GLOBAL))
5406 {
5407 curbuf->b_p_tw = 0; /* no automatic line wrap */
5408 curbuf->b_p_wm = 0; /* no automatic line wrap */
5409 curbuf->b_p_ml = 0; /* no modelines */
5410 curbuf->b_p_et = 0; /* no expandtab */
5411 }
5412 if (!(opt_flags & OPT_LOCAL))
5413 {
5414 p_tw = 0;
5415 p_wm = 0;
5416 p_ml = FALSE;
5417 p_et = FALSE;
5418 p_bin = TRUE; /* needed when called for the "-b" argument */
5419 }
5420 }
5421 else if (oldval) /* switched off */
5422 {
5423 if (!(opt_flags & OPT_GLOBAL))
5424 {
5425 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5426 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5427 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5428 curbuf->b_p_et = curbuf->b_p_et_nobin;
5429 }
5430 if (!(opt_flags & OPT_LOCAL))
5431 {
5432 p_tw = p_tw_nobin;
5433 p_wm = p_wm_nobin;
5434 p_ml = p_ml_nobin;
5435 p_et = p_et_nobin;
5436 }
5437 }
5438}
5439
5440#ifdef FEAT_VIMINFO
5441/*
5442 * Find the parameter represented by the given character (eg ', :, ", or /),
5443 * and return its associated value in the 'viminfo' string.
5444 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005445 * If the parameter is not specified in the string or there is no following
5446 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005447 */
5448 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005449get_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005450{
5451 char_u *p;
5452
5453 p = find_viminfo_parameter(type);
5454 if (p != NULL && VIM_ISDIGIT(*p))
5455 return atoi((char *)p);
5456 return -1;
5457}
5458
5459/*
5460 * Find the parameter represented by the given character (eg ''', ':', '"', or
5461 * '/') in the 'viminfo' option and return a pointer to the string after it.
5462 * Return NULL if the parameter is not specified in the string.
5463 */
5464 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005465find_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005466{
5467 char_u *p;
5468
5469 for (p = p_viminfo; *p; ++p)
5470 {
5471 if (*p == type)
5472 return p + 1;
5473 if (*p == 'n') /* 'n' is always the last one */
5474 break;
5475 p = vim_strchr(p, ','); /* skip until next ',' */
5476 if (p == NULL) /* hit the end without finding parameter */
5477 break;
5478 }
5479 return NULL;
5480}
5481#endif
5482
5483/*
5484 * Expand environment variables for some string options.
5485 * These string options cannot be indirect!
5486 * If "val" is NULL expand the current value of the option.
5487 * Return pointer to NameBuff, or NULL when not expanded.
5488 */
5489 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005490option_expand(int opt_idx, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005491{
5492 /* if option doesn't need expansion nothing to do */
5493 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5494 return NULL;
5495
5496 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5497 * expand_env() would truncate the string. */
5498 if (val != NULL && STRLEN(val) > MAXPATHL)
5499 return NULL;
5500
5501 if (val == NULL)
5502 val = *(char_u **)options[opt_idx].var;
5503
5504 /*
5505 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5506 * Escape spaces when expanding 'tags', they are used to separate file
5507 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005508 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005509 */
5510 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005511 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005512#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005513 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5514#endif
5515 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005516 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5517 return NULL;
5518
5519 return NameBuff;
5520}
5521
5522/*
5523 * After setting various option values: recompute variables that depend on
5524 * option values.
5525 */
5526 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005527didset_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005528{
5529 /* initialize the table for 'iskeyword' et.al. */
5530 (void)init_chartab();
5531
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005532#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005533 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005534#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005535 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
Bram Moolenaar165bc692015-07-21 17:53:25 +02005536 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005537#ifdef FEAT_SESSION
5538 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5539 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5540#endif
5541#ifdef FEAT_FOLDING
5542 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5543#endif
5544 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005545 (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005546#ifdef FEAT_VIRTUALEDIT
5547 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5548#endif
5549#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5550 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5551#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005552#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005553 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005554 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005555 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005556 (void)did_set_spell_option(TRUE);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005557#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005558#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5559 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5560#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005561#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005562 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5563#endif
5564#ifdef FEAT_CMDWIN
5565 /* set cedit_key */
5566 (void)check_cedit();
5567#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005568#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005569 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005570#endif
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005571#ifdef FEAT_LINEBREAK
5572 /* initialize the table for 'breakat'. */
5573 fill_breakat_flags();
5574#endif
5575
5576}
5577
5578/*
5579 * More side effects of setting options.
5580 */
5581 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005582didset_options2(void)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005583{
5584 /* Initialize the highlight_attr[] table. */
5585 (void)highlight_changed();
5586
5587 /* Parse default for 'wildmode' */
5588 check_opt_wim();
5589
5590 (void)set_chars_option(&p_lcs);
5591#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5592 /* Parse default for 'fillchars'. */
5593 (void)set_chars_option(&p_fcs);
5594#endif
5595
5596#ifdef FEAT_CLIPBOARD
5597 /* Parse default for 'clipboard' */
5598 (void)check_clipboard_option();
5599#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005600}
5601
5602/*
5603 * Check for string options that are NULL (normally only termcap options).
5604 */
5605 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005606check_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005607{
5608 int opt_idx;
5609
5610 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5611 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5612 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5613}
5614
5615/*
5616 * Check string options in a buffer for NULL value.
5617 */
5618 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005619check_buf_options(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005620{
5621#if defined(FEAT_QUICKFIX)
5622 check_string_option(&buf->b_p_bh);
5623 check_string_option(&buf->b_p_bt);
5624#endif
5625#ifdef FEAT_MBYTE
5626 check_string_option(&buf->b_p_fenc);
5627#endif
5628 check_string_option(&buf->b_p_ff);
5629#ifdef FEAT_FIND_ID
5630 check_string_option(&buf->b_p_def);
5631 check_string_option(&buf->b_p_inc);
5632# ifdef FEAT_EVAL
5633 check_string_option(&buf->b_p_inex);
5634# endif
5635#endif
5636#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5637 check_string_option(&buf->b_p_inde);
5638 check_string_option(&buf->b_p_indk);
5639#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005640#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5641 check_string_option(&buf->b_p_bexpr);
5642#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005643#if defined(FEAT_CRYPT)
5644 check_string_option(&buf->b_p_cm);
5645#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +01005646 check_string_option(&buf->b_p_fp);
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005647#if defined(FEAT_EVAL)
5648 check_string_option(&buf->b_p_fex);
5649#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005650#ifdef FEAT_CRYPT
5651 check_string_option(&buf->b_p_key);
5652#endif
5653 check_string_option(&buf->b_p_kp);
5654 check_string_option(&buf->b_p_mps);
5655 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005656 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005657 check_string_option(&buf->b_p_isk);
5658#ifdef FEAT_COMMENTS
5659 check_string_option(&buf->b_p_com);
5660#endif
5661#ifdef FEAT_FOLDING
5662 check_string_option(&buf->b_p_cms);
5663#endif
5664 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005665#ifdef FEAT_TEXTOBJ
5666 check_string_option(&buf->b_p_qe);
5667#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005668#ifdef FEAT_SYN_HL
5669 check_string_option(&buf->b_p_syn);
Bram Moolenaarb8060fe2016-01-19 22:29:28 +01005670 check_string_option(&buf->b_s.b_syn_isk);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005671#endif
5672#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005673 check_string_option(&buf->b_s.b_p_spc);
5674 check_string_option(&buf->b_s.b_p_spf);
5675 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005676#endif
5677#ifdef FEAT_SEARCHPATH
5678 check_string_option(&buf->b_p_sua);
5679#endif
5680#ifdef FEAT_CINDENT
5681 check_string_option(&buf->b_p_cink);
5682 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005683 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005684#endif
5685#ifdef FEAT_AUTOCMD
5686 check_string_option(&buf->b_p_ft);
5687#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005688#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5689 check_string_option(&buf->b_p_cinw);
5690#endif
5691#ifdef FEAT_INS_EXPAND
5692 check_string_option(&buf->b_p_cpt);
5693#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005694#ifdef FEAT_COMPL_FUNC
5695 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005696 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005697#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005698#ifdef FEAT_KEYMAP
5699 check_string_option(&buf->b_p_keymap);
5700#endif
5701#ifdef FEAT_QUICKFIX
5702 check_string_option(&buf->b_p_gp);
5703 check_string_option(&buf->b_p_mp);
5704 check_string_option(&buf->b_p_efm);
5705#endif
5706 check_string_option(&buf->b_p_ep);
5707 check_string_option(&buf->b_p_path);
5708 check_string_option(&buf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005709 check_string_option(&buf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005710#ifdef FEAT_INS_EXPAND
5711 check_string_option(&buf->b_p_dict);
5712 check_string_option(&buf->b_p_tsr);
5713#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005714#ifdef FEAT_LISP
5715 check_string_option(&buf->b_p_lw);
5716#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005717 check_string_option(&buf->b_p_bkc);
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01005718#ifdef FEAT_MBYTE
5719 check_string_option(&buf->b_p_menc);
5720#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005721}
5722
5723/*
5724 * Free the string allocated for an option.
5725 * Checks for the string being empty_option. This may happen if we're out of
5726 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5727 * check_options().
5728 * Does NOT check for P_ALLOCED flag!
5729 */
5730 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005731free_string_option(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005732{
5733 if (p != empty_option)
5734 vim_free(p);
5735}
5736
5737 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005738clear_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005739{
5740 if (*pp != empty_option)
5741 vim_free(*pp);
5742 *pp = empty_option;
5743}
5744
5745 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005746check_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005747{
5748 if (*pp == NULL)
5749 *pp = empty_option;
5750}
5751
5752/*
5753 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5754 */
5755 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005756set_term_option_alloced(char_u **p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005757{
5758 int opt_idx;
5759
5760 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5761 if (options[opt_idx].var == (char_u *)p)
5762 {
5763 options[opt_idx].flags |= P_ALLOCED;
5764 return;
5765 }
5766 return; /* cannot happen: didn't find it! */
5767}
5768
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005769#if defined(FEAT_EVAL) || defined(PROTO)
5770/*
5771 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5772 * Return FALSE when it wasn't.
5773 * Return -1 for an unknown option.
5774 */
5775 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005776was_set_insecurely(char_u *opt, int opt_flags)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005777{
5778 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005779 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005780
5781 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005782 {
5783 flagp = insecure_flag(idx, opt_flags);
5784 return (*flagp & P_INSECURE) != 0;
5785 }
Bram Moolenaar95f09602016-11-10 20:01:45 +01005786 internal_error("was_set_insecurely()");
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005787 return -1;
5788}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005789
5790/*
5791 * Get a pointer to the flags used for the P_INSECURE flag of option
5792 * "opt_idx". For some local options a local flags field is used.
5793 */
5794 static long_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005795insecure_flag(int opt_idx, int opt_flags)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005796{
5797 if (opt_flags & OPT_LOCAL)
5798 switch ((int)options[opt_idx].indir)
5799 {
5800#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005801 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005802#endif
5803#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005804# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005805 case PV_FDE: return &curwin->w_p_fde_flags;
5806 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005807# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005808# ifdef FEAT_BEVAL
5809 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5810# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005811# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005812 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005813# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005814 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005815# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005816 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005817# endif
5818#endif
5819 }
5820
5821 /* Nothing special, return global flags field. */
5822 return &options[opt_idx].flags;
5823}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005824#endif
5825
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005826#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01005827static void redraw_titles(void);
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005828
5829/*
5830 * Redraw the window title and/or tab page text later.
5831 */
Bram Moolenaar9b578142016-01-30 19:39:49 +01005832static void redraw_titles(void)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005833{
5834 need_maketitle = TRUE;
5835# ifdef FEAT_WINDOWS
5836 redraw_tabline = TRUE;
5837# endif
5838}
5839#endif
5840
Bram Moolenaar071d4272004-06-13 20:20:40 +00005841/*
5842 * Set a string option to a new value (without checking the effect).
5843 * The string is copied into allocated memory.
5844 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005845 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005846 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005847 */
5848 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005849set_string_option_direct(
5850 char_u *name,
5851 int opt_idx,
5852 char_u *val,
5853 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
5854 int set_sid UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005855{
5856 char_u *s;
5857 char_u **varp;
5858 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005859 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005860
Bram Moolenaar89d40322006-08-29 15:30:07 +00005861 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005862 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005863 idx = findoption(name);
5864 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005865 {
5866 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar95f09602016-11-10 20:01:45 +01005867 IEMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005868 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005869 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005870 }
5871
Bram Moolenaar89d40322006-08-29 15:30:07 +00005872 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005873 return;
5874
5875 s = vim_strsave(val);
5876 if (s != NULL)
5877 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005878 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005879 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005880 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005881 free_string_option(*varp);
5882 *varp = s;
5883
5884 /* For buffer/window local option may also set the global value. */
5885 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005886 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005887
Bram Moolenaar89d40322006-08-29 15:30:07 +00005888 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005889
5890 /* When setting both values of a global option with a local value,
5891 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005892 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005893 {
5894 free_string_option(*varp);
5895 *varp = empty_option;
5896 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005897# ifdef FEAT_EVAL
5898 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005899 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005900 set_sid == 0 ? current_SID : set_sid);
5901# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005902 }
5903}
5904
5905/*
5906 * Set global value for string option when it's a local option.
5907 */
5908 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005909set_string_option_global(
5910 int opt_idx, /* option index */
5911 char_u **varp) /* pointer to option variable */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005912{
5913 char_u **p, *s;
5914
5915 /* the global value is always allocated */
5916 if (options[opt_idx].var == VAR_WIN)
5917 p = (char_u **)GLOBAL_WO(varp);
5918 else
5919 p = (char_u **)options[opt_idx].var;
5920 if (options[opt_idx].indir != PV_NONE
5921 && p != varp
5922 && (s = vim_strsave(*varp)) != NULL)
5923 {
5924 free_string_option(*p);
5925 *p = s;
5926 }
5927}
5928
5929/*
5930 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005931 *
5932 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005933 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005934 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005935set_string_option(
5936 int opt_idx,
5937 char_u *value,
5938 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005939{
5940 char_u *s;
5941 char_u **varp;
5942 char_u *oldval;
Bram Moolenaar53744302015-07-17 17:38:22 +02005943#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5944 char_u *saved_oldval = NULL;
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005945 char_u *saved_newval = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02005946#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005947 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005948
5949 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005950 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005951
5952 s = vim_strsave(value);
5953 if (s != NULL)
5954 {
5955 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5956 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005957 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005958 ? OPT_GLOBAL : OPT_LOCAL)
5959 : opt_flags);
5960 oldval = *varp;
5961 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02005962
5963#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005964 if (!starting
5965# ifdef FEAT_CRYPT
5966 && options[opt_idx].indir != PV_KEY
5967# endif
5968 )
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005969 {
Bram Moolenaar53744302015-07-17 17:38:22 +02005970 saved_oldval = vim_strsave(oldval);
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005971 saved_newval = vim_strsave(s);
5972 }
Bram Moolenaar53744302015-07-17 17:38:22 +02005973#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005974 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5975 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005976 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02005977
Bram Moolenaar53744302015-07-17 17:38:22 +02005978#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar182a17b2017-06-25 20:57:18 +02005979 /* call autocommand after handling side effects */
5980 trigger_optionsset_string(opt_idx, opt_flags,
5981 saved_oldval, saved_newval);
Bram Moolenaar53744302015-07-17 17:38:22 +02005982#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005983 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005984 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005985}
5986
Bram Moolenaar40d3f132016-11-05 20:13:35 +01005987#if defined(FEAT_KEYMAP) || defined(FEAT_AUTOCMD) || defined(FEAT_SYN_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005988/*
Bram Moolenaard0b51382016-11-04 15:23:45 +01005989 * Return TRUE if "val" is a valid 'filetype' name.
5990 * Also used for 'syntax' and 'keymap'.
5991 */
5992 static int
5993valid_filetype(char_u *val)
5994{
5995 char_u *s;
5996
5997 for (s = val; *s != NUL; ++s)
5998 if (!ASCII_ISALNUM(*s) && vim_strchr((char_u *)".-_", *s) == NULL)
5999 return FALSE;
6000 return TRUE;
6001}
Bram Moolenaar40d3f132016-11-05 20:13:35 +01006002#endif
Bram Moolenaard0b51382016-11-04 15:23:45 +01006003
6004/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00006005 * Handle string options that need some action to perform when changed.
6006 * Returns NULL for success, or an error message for an error.
6007 */
6008 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01006009did_set_string_option(
6010 int opt_idx, /* index in options[] table */
6011 char_u **varp, /* pointer to the option variable */
6012 int new_value_alloced, /* new value was allocated */
6013 char_u *oldval, /* previous value of the option */
6014 char_u *errbuf, /* buffer for errors, or NULL */
6015 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006016{
6017 char_u *errmsg = NULL;
6018 char_u *s, *p;
6019 int did_chartab = FALSE;
6020 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00006021 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006022#ifdef FEAT_GUI
6023 /* set when changing an option that only requires a redraw in the GUI */
6024 int redraw_gui_only = FALSE;
6025#endif
Bram Moolenaar90492982017-06-22 14:16:31 +02006026#ifdef FEAT_AUTOCMD
6027 int ft_changed = FALSE;
6028#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006029
6030 /* Get the global option to compare with, otherwise we would have to check
6031 * two values for all local options. */
6032 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
6033
6034 /* Disallow changing some options from secure mode */
6035 if ((secure
6036#ifdef HAVE_SANDBOX
6037 || sandbox != 0
6038#endif
6039 ) && (options[opt_idx].flags & P_SECURE))
6040 {
6041 errmsg = e_secure;
6042 }
6043
Bram Moolenaar7554da42016-11-25 22:04:13 +01006044 /* Check for a "normal" directory or file name in some options. Disallow a
6045 * path separator (slash and/or backslash), wildcards and characters that
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01006046 * are often illegal in a file name. Be more permissive if "secure" is off.
6047 */
Bram Moolenaar7554da42016-11-25 22:04:13 +01006048 else if (((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01006049 && vim_strpbrk(*varp, (char_u *)(secure
6050 ? "/\\*?[|;&<>\r\n" : "/\\*?[<>\r\n")) != NULL)
Bram Moolenaar7554da42016-11-25 22:04:13 +01006051 || ((options[opt_idx].flags & P_NDNAME)
6052 && vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL))
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00006053 {
6054 errmsg = e_invarg;
6055 }
6056
Bram Moolenaar071d4272004-06-13 20:20:40 +00006057 /* 'term' */
6058 else if (varp == &T_NAME)
6059 {
6060 if (T_NAME[0] == NUL)
6061 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
6062#ifdef FEAT_GUI
6063 if (gui.in_use)
6064 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
6065 else if (term_is_gui(T_NAME))
6066 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
6067#endif
6068 else if (set_termname(T_NAME) == FAIL)
6069 errmsg = (char_u *)N_("E522: Not found in termcap");
6070 else
Bram Moolenaar67391142017-02-19 21:07:04 +01006071 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006072 /* Screen colors may have changed. */
6073 redraw_later_clear();
Bram Moolenaar67391142017-02-19 21:07:04 +01006074
6075 /* Both 'term' and 'ttytype' point to T_NAME, only set the
6076 * P_ALLOCED flag on 'term'. */
6077 opt_idx = findoption((char_u *)"term");
Bram Moolenaar354796c2017-02-23 17:18:37 +01006078 free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaar67391142017-02-19 21:07:04 +01006079 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006080 }
6081
6082 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02006083 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006084 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02006085 char_u *bkc = p_bkc;
6086 unsigned int *flags = &bkc_flags;
6087
6088 if (opt_flags & OPT_LOCAL)
6089 {
6090 bkc = curbuf->b_p_bkc;
6091 flags = &curbuf->b_bkc_flags;
6092 }
6093
Bram Moolenaar84d17a62014-09-29 17:15:18 +02006094 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
6095 /* make the local value empty: use the global value */
6096 *flags = 0;
6097 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00006098 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02006099 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
6100 errmsg = e_invarg;
6101 if ((((int)*flags & BKC_AUTO) != 0)
6102 + (((int)*flags & BKC_YES) != 0)
6103 + (((int)*flags & BKC_NO) != 0) != 1)
6104 {
6105 /* Must have exactly one of "auto", "yes" and "no". */
6106 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
6107 errmsg = e_invarg;
6108 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006109 }
6110 }
6111
6112 /* 'backupext' and 'patchmode' */
6113 else if (varp == &p_bex || varp == &p_pm)
6114 {
6115 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
6116 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
6117 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
6118 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02006119#ifdef FEAT_LINEBREAK
6120 /* 'breakindentopt' */
6121 else if (varp == &curwin->w_p_briopt)
6122 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02006123 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02006124 errmsg = e_invarg;
6125 }
6126#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006127
6128 /*
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01006129 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[]
Bram Moolenaar071d4272004-06-13 20:20:40 +00006130 * If the new option is invalid, use old value. 'lisp' option: refill
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01006131 * g_chartab[] for '-' char
Bram Moolenaar071d4272004-06-13 20:20:40 +00006132 */
6133 else if ( varp == &p_isi
6134 || varp == &(curbuf->b_p_isk)
6135 || varp == &p_isp
6136 || varp == &p_isf)
6137 {
6138 if (init_chartab() == FAIL)
6139 {
6140 did_chartab = TRUE; /* need to restore it below */
6141 errmsg = e_invarg; /* error in value */
6142 }
6143 }
6144
6145 /* 'helpfile' */
6146 else if (varp == &p_hf)
6147 {
6148 /* May compute new values for $VIM and $VIMRUNTIME */
6149 if (didset_vim)
6150 {
6151 vim_setenv((char_u *)"VIM", (char_u *)"");
6152 didset_vim = FALSE;
6153 }
6154 if (didset_vimruntime)
6155 {
6156 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
6157 didset_vimruntime = FALSE;
6158 }
6159 }
6160
Bram Moolenaar1a384422010-07-14 19:53:30 +02006161#ifdef FEAT_SYN_HL
6162 /* 'colorcolumn' */
6163 else if (varp == &curwin->w_p_cc)
6164 errmsg = check_colorcolumn(curwin);
6165#endif
6166
Bram Moolenaar071d4272004-06-13 20:20:40 +00006167#ifdef FEAT_MULTI_LANG
6168 /* 'helplang' */
6169 else if (varp == &p_hlg)
6170 {
6171 /* Check for "", "ab", "ab,cd", etc. */
6172 for (s = p_hlg; *s != NUL; s += 3)
6173 {
6174 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
6175 {
6176 errmsg = e_invarg;
6177 break;
6178 }
6179 if (s[2] == NUL)
6180 break;
6181 }
6182 }
6183#endif
6184
6185 /* 'highlight' */
6186 else if (varp == &p_hl)
6187 {
6188 if (highlight_changed() == FAIL)
6189 errmsg = e_invarg; /* invalid flags */
6190 }
6191
6192 /* 'nrformats' */
6193 else if (gvarp == &p_nf)
6194 {
6195 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
6196 errmsg = e_invarg;
6197 }
6198
6199#ifdef FEAT_SESSION
6200 /* 'sessionoptions' */
6201 else if (varp == &p_ssop)
6202 {
6203 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
6204 errmsg = e_invarg;
6205 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
6206 {
6207 /* Don't allow both "sesdir" and "curdir". */
6208 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
6209 errmsg = e_invarg;
6210 }
6211 }
6212 /* 'viewoptions' */
6213 else if (varp == &p_vop)
6214 {
6215 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
6216 errmsg = e_invarg;
6217 }
6218#endif
6219
6220 /* 'scrollopt' */
6221#ifdef FEAT_SCROLLBIND
6222 else if (varp == &p_sbo)
6223 {
6224 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
6225 errmsg = e_invarg;
6226 }
6227#endif
6228
6229 /* 'ambiwidth' */
6230#ifdef FEAT_MBYTE
Bram Moolenaar3848e002016-03-19 18:42:29 +01006231 else if (varp == &p_ambw || varp == &p_emoji)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006232 {
6233 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
6234 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02006235 else if (set_chars_option(&p_lcs) != NULL)
6236 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
6237# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6238 else if (set_chars_option(&p_fcs) != NULL)
6239 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
6240# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006241 }
6242#endif
6243
6244 /* 'background' */
6245 else if (varp == &p_bg)
6246 {
6247 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
6248 {
6249#ifdef FEAT_EVAL
6250 int dark = (*p_bg == 'd');
6251#endif
6252
6253 init_highlight(FALSE, FALSE);
6254
6255#ifdef FEAT_EVAL
6256 if (dark != (*p_bg == 'd')
6257 && get_var_value((char_u *)"g:colors_name") != NULL)
6258 {
6259 /* The color scheme must have set 'background' back to another
6260 * value, that's not what we want here. Disable the color
6261 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00006262 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006263 free_string_option(p_bg);
6264 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
6265 check_string_option(&p_bg);
6266 init_highlight(FALSE, FALSE);
6267 }
6268#endif
6269 }
6270 else
6271 errmsg = e_invarg;
6272 }
6273
6274 /* 'wildmode' */
6275 else if (varp == &p_wim)
6276 {
6277 if (check_opt_wim() == FAIL)
6278 errmsg = e_invarg;
6279 }
6280
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006281#ifdef FEAT_CMDL_COMPL
6282 /* 'wildoptions' */
6283 else if (varp == &p_wop)
6284 {
6285 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6286 errmsg = e_invarg;
6287 }
6288#endif
6289
Bram Moolenaar071d4272004-06-13 20:20:40 +00006290#ifdef FEAT_WAK
6291 /* 'winaltkeys' */
6292 else if (varp == &p_wak)
6293 {
6294 if (*p_wak == NUL
6295 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6296 errmsg = e_invarg;
6297# ifdef FEAT_MENU
6298# ifdef FEAT_GUI_MOTIF
6299 else if (gui.in_use)
6300 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6301# else
6302# ifdef FEAT_GUI_GTK
6303 else if (gui.in_use)
6304 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6305# endif
6306# endif
6307# endif
6308 }
6309#endif
6310
6311#ifdef FEAT_AUTOCMD
6312 /* 'eventignore' */
6313 else if (varp == &p_ei)
6314 {
6315 if (check_ei() == FAIL)
6316 errmsg = e_invarg;
6317 }
6318#endif
6319
6320#ifdef FEAT_MBYTE
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01006321 /* 'encoding', 'fileencoding', 'termencoding' and 'makeencoding' */
6322 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc
6323 || gvarp == &p_menc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006324 {
6325 if (gvarp == &p_fenc)
6326 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006327 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006328 errmsg = e_modifiable;
6329 else if (vim_strchr(*varp, ',') != NULL)
6330 /* No comma allowed in 'fileencoding'; catches confusing it
6331 * with 'fileencodings'. */
6332 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006333 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006334 {
6335# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006336 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006337 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006338# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006339 /* Add 'fileencoding' to the swap file. */
6340 ml_setflags(curbuf);
6341 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006342 }
6343 if (errmsg == NULL)
6344 {
6345 /* canonize the value, so that STRCMP() can be used on it */
6346 p = enc_canonize(*varp);
6347 if (p != NULL)
6348 {
6349 vim_free(*varp);
6350 *varp = p;
6351 }
6352 if (varp == &p_enc)
6353 {
6354 errmsg = mb_init();
6355# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006356 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006357# endif
6358 }
6359 }
6360
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006361# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006362 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6363 {
6364 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6365 if (STRCMP(p_tenc, "utf-8") != 0)
6366 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6367 }
6368# endif
6369
6370 if (errmsg == NULL)
6371 {
6372# ifdef FEAT_KEYMAP
6373 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6374 * (with another encoding). */
6375 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6376 (void)keymap_init();
6377# endif
6378
6379 /* When 'termencoding' is not empty and 'encoding' changes or when
6380 * 'termencoding' changes, need to setup for keyboard input and
6381 * display output conversion. */
6382 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6383 {
6384 convert_setup(&input_conv, p_tenc, p_enc);
6385 convert_setup(&output_conv, p_enc, p_tenc);
6386 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006387
6388# if defined(WIN3264) && defined(FEAT_MBYTE)
6389 /* $HOME may have characters in active code page. */
6390 if (varp == &p_enc)
6391 init_homedir();
6392# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006393 }
6394 }
6395#endif
6396
6397#if defined(FEAT_POSTSCRIPT)
6398 else if (varp == &p_penc)
6399 {
6400 /* Canonize printencoding if VIM standard one */
6401 p = enc_canonize(p_penc);
6402 if (p != NULL)
6403 {
6404 vim_free(p_penc);
6405 p_penc = p;
6406 }
6407 else
6408 {
6409 /* Ensure lower case and '-' for '_' */
6410 for (s = p_penc; *s != NUL; s++)
6411 {
6412 if (*s == '_')
6413 *s = '-';
6414 else
6415 *s = TOLOWER_ASC(*s);
6416 }
6417 }
6418 }
6419#endif
6420
Bram Moolenaar9372a112005-12-06 19:59:18 +00006421#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006422 else if (varp == &p_imak)
6423 {
Bram Moolenaar86e57922017-04-23 18:44:26 +02006424 if (!im_xim_isvalid_imactivate())
Bram Moolenaar071d4272004-06-13 20:20:40 +00006425 errmsg = e_invarg;
6426 }
6427#endif
6428
6429#ifdef FEAT_KEYMAP
6430 else if (varp == &curbuf->b_p_keymap)
6431 {
Bram Moolenaard0b51382016-11-04 15:23:45 +01006432 if (!valid_filetype(*varp))
6433 errmsg = e_invarg;
6434 else
6435 /* load or unload key mapping tables */
6436 errmsg = keymap_init();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006437
Bram Moolenaarfab06232009-03-04 03:13:35 +00006438 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006439 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006440 if (*curbuf->b_p_keymap != NUL)
6441 {
6442 /* Installed a new keymap, switch on using it. */
6443 curbuf->b_p_iminsert = B_IMODE_LMAP;
6444 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6445 curbuf->b_p_imsearch = B_IMODE_LMAP;
6446 }
6447 else
6448 {
6449 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6450 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6451 curbuf->b_p_iminsert = B_IMODE_NONE;
6452 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6453 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6454 }
6455 if ((opt_flags & OPT_LOCAL) == 0)
6456 {
6457 set_iminsert_global();
6458 set_imsearch_global();
6459 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006460# ifdef FEAT_WINDOWS
6461 status_redraw_curbuf();
6462# endif
6463 }
6464 }
6465#endif
6466
6467 /* 'fileformat' */
6468 else if (gvarp == &p_ff)
6469 {
6470 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6471 errmsg = e_modifiable;
6472 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6473 errmsg = e_invarg;
6474 else
6475 {
6476 /* may also change 'textmode' */
6477 if (get_fileformat(curbuf) == EOL_DOS)
6478 curbuf->b_p_tx = TRUE;
6479 else
6480 curbuf->b_p_tx = FALSE;
6481#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006482 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006483#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006484 /* update flag in swap file */
6485 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006486 /* Redraw needed when switching to/from "mac": a CR in the text
6487 * will be displayed differently. */
6488 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6489 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006490 }
6491 }
6492
6493 /* 'fileformats' */
6494 else if (varp == &p_ffs)
6495 {
6496 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6497 errmsg = e_invarg;
6498 else
6499 {
6500 /* also change 'textauto' */
6501 if (*p_ffs == NUL)
6502 p_ta = FALSE;
6503 else
6504 p_ta = TRUE;
6505 }
6506 }
6507
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006508#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006509 /* 'cryptkey' */
6510 else if (gvarp == &p_key)
6511 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006512# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006513 /* Make sure the ":set" command doesn't show the new value in the
6514 * history. */
6515 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006516# endif
6517 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6518 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006519 ml_set_crypt_key(curbuf, oldval,
6520 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006521 }
6522
6523 else if (gvarp == &p_cm)
6524 {
6525 if (opt_flags & OPT_LOCAL)
6526 p = curbuf->b_p_cm;
6527 else
6528 p = p_cm;
6529 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6530 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006531 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006532 errmsg = e_invarg;
6533 else
6534 {
6535 /* When setting the global value to empty, make it "zip". */
6536 if (*p_cm == NUL)
6537 {
6538 if (new_value_alloced)
6539 free_string_option(p_cm);
6540 p_cm = vim_strsave((char_u *)"zip");
6541 new_value_alloced = TRUE;
6542 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006543 /* When using ":set cm=name" the local value is going to be empty.
6544 * Do that here, otherwise the crypt functions will still use the
6545 * local value. */
6546 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6547 {
6548 free_string_option(curbuf->b_p_cm);
6549 curbuf->b_p_cm = empty_option;
6550 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006551
6552 /* Need to update the swapfile when the effective method changed.
6553 * Set "s" to the effective old value, "p" to the effective new
6554 * method and compare. */
6555 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6556 s = p_cm; /* was previously using the global value */
6557 else
6558 s = oldval;
6559 if (*curbuf->b_p_cm == NUL)
6560 p = p_cm; /* is now using the global value */
6561 else
6562 p = curbuf->b_p_cm;
6563 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006564 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006565
6566 /* If the global value changes need to update the swapfile for all
6567 * buffers using that value. */
6568 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6569 {
6570 buf_T *buf;
6571
Bram Moolenaar29323592016-07-24 22:04:11 +02006572 FOR_ALL_BUFFERS(buf)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006573 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006574 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006575 }
6576 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006577 }
6578#endif
6579
6580 /* 'matchpairs' */
6581 else if (gvarp == &p_mps)
6582 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006583#ifdef FEAT_MBYTE
6584 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006585 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006586 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006587 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006588 int x2 = -1;
6589 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006590
6591 if (*p != NUL)
6592 p += mb_ptr2len(p);
6593 if (*p != NUL)
6594 x2 = *p++;
6595 if (*p != NUL)
6596 {
6597 x3 = mb_ptr2char(p);
6598 p += mb_ptr2len(p);
6599 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006600 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006601 {
6602 errmsg = e_invarg;
6603 break;
6604 }
6605 if (*p == NUL)
6606 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006607 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006608 }
6609 else
6610#endif
6611 {
6612 /* Check for "x:y,x:y" */
6613 for (p = *varp; *p != NUL; p += 4)
6614 {
6615 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6616 {
6617 errmsg = e_invarg;
6618 break;
6619 }
6620 if (p[3] == NUL)
6621 break;
6622 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006623 }
6624 }
6625
6626#ifdef FEAT_COMMENTS
6627 /* 'comments' */
6628 else if (gvarp == &p_com)
6629 {
6630 for (s = *varp; *s; )
6631 {
6632 while (*s && *s != ':')
6633 {
6634 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6635 && !VIM_ISDIGIT(*s) && *s != '-')
6636 {
6637 errmsg = illegal_char(errbuf, *s);
6638 break;
6639 }
6640 ++s;
6641 }
6642 if (*s++ == NUL)
6643 errmsg = (char_u *)N_("E524: Missing colon");
6644 else if (*s == ',' || *s == NUL)
6645 errmsg = (char_u *)N_("E525: Zero length string");
6646 if (errmsg != NULL)
6647 break;
6648 while (*s && *s != ',')
6649 {
6650 if (*s == '\\' && s[1] != NUL)
6651 ++s;
6652 ++s;
6653 }
6654 s = skip_to_option_part(s);
6655 }
6656 }
6657#endif
6658
6659 /* 'listchars' */
6660 else if (varp == &p_lcs)
6661 {
6662 errmsg = set_chars_option(varp);
6663 }
6664
6665#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6666 /* 'fillchars' */
6667 else if (varp == &p_fcs)
6668 {
6669 errmsg = set_chars_option(varp);
6670 }
6671#endif
6672
6673#ifdef FEAT_CMDWIN
6674 /* 'cedit' */
6675 else if (varp == &p_cedit)
6676 {
6677 errmsg = check_cedit();
6678 }
6679#endif
6680
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006681 /* 'verbosefile' */
6682 else if (varp == &p_vfile)
6683 {
6684 verbose_stop();
6685 if (*p_vfile != NUL && verbose_open() == FAIL)
6686 errmsg = e_invarg;
6687 }
6688
Bram Moolenaar071d4272004-06-13 20:20:40 +00006689#ifdef FEAT_VIMINFO
6690 /* 'viminfo' */
6691 else if (varp == &p_viminfo)
6692 {
6693 for (s = p_viminfo; *s;)
6694 {
6695 /* Check it's a valid character */
6696 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6697 {
6698 errmsg = illegal_char(errbuf, *s);
6699 break;
6700 }
6701 if (*s == 'n') /* name is always last one */
6702 {
6703 break;
6704 }
6705 else if (*s == 'r') /* skip until next ',' */
6706 {
6707 while (*++s && *s != ',')
6708 ;
6709 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006710 else if (*s == '%')
6711 {
6712 /* optional number */
6713 while (vim_isdigit(*++s))
6714 ;
6715 }
6716 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006717 ++s; /* no extra chars */
6718 else /* must have a number */
6719 {
6720 while (vim_isdigit(*++s))
6721 ;
6722
6723 if (!VIM_ISDIGIT(*(s - 1)))
6724 {
6725 if (errbuf != NULL)
6726 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006727 sprintf((char *)errbuf,
6728 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006729 transchar_byte(*(s - 1)));
6730 errmsg = errbuf;
6731 }
6732 else
6733 errmsg = (char_u *)"";
6734 break;
6735 }
6736 }
6737 if (*s == ',')
6738 ++s;
6739 else if (*s)
6740 {
6741 if (errbuf != NULL)
6742 errmsg = (char_u *)N_("E527: Missing comma");
6743 else
6744 errmsg = (char_u *)"";
6745 break;
6746 }
6747 }
6748 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6749 errmsg = (char_u *)N_("E528: Must specify a ' value");
6750 }
6751#endif /* FEAT_VIMINFO */
6752
6753 /* terminal options */
6754 else if (istermoption(&options[opt_idx]) && full_screen)
6755 {
6756 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6757 if (varp == &T_CCO)
6758 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006759 int colors = atoi((char *)T_CCO);
6760
6761 /* Only reinitialize colors if t_Co value has really changed to
6762 * avoid expensive reload of colorscheme if t_Co is set to the
6763 * same value multiple times. */
6764 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006765 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006766 t_colors = colors;
6767 if (t_colors <= 1)
6768 {
6769 if (new_value_alloced)
6770 vim_free(T_CCO);
6771 T_CCO = empty_option;
6772 }
6773 /* We now have a different color setup, initialize it again. */
6774 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006775 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006776 }
6777 ttest(FALSE);
6778 if (varp == &T_ME)
6779 {
6780 out_str(T_ME);
6781 redraw_later(CLEAR);
Bram Moolenaar48e330a2016-02-23 14:53:34 +01006782#if defined(WIN3264) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006783 /* Since t_me has been set, this probably means that the user
6784 * wants to use this as default colors. Need to reset default
6785 * background/foreground colors. */
6786 mch_set_normal_colors();
6787#endif
6788 }
Bram Moolenaard9c60642017-01-27 20:03:18 +01006789 if (varp == &T_BE && termcap_active)
6790 {
6791 if (*T_BE == NUL)
6792 /* When clearing t_BE we assume the user no longer wants
6793 * bracketed paste, thus disable it by writing t_BD. */
6794 out_str(T_BD);
6795 else
6796 out_str(T_BE);
6797 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006798 }
6799
6800#ifdef FEAT_LINEBREAK
6801 /* 'showbreak' */
6802 else if (varp == &p_sbr)
6803 {
6804 for (s = p_sbr; *s; )
6805 {
6806 if (ptr2cells(s) != 1)
6807 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar91acfff2017-03-12 19:22:36 +01006808 MB_PTR_ADV(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006809 }
6810 }
6811#endif
6812
6813#ifdef FEAT_GUI
6814 /* 'guifont' */
6815 else if (varp == &p_guifont)
6816 {
6817 if (gui.in_use)
6818 {
6819 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006820# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006821 /*
6822 * Put up a font dialog and let the user select a new value.
6823 * If this is cancelled go back to the old value but don't
6824 * give an error message.
6825 */
6826 if (STRCMP(p, "*") == 0)
6827 {
6828 p = gui_mch_font_dialog(oldval);
6829
6830 if (new_value_alloced)
6831 free_string_option(p_guifont);
6832
6833 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6834 new_value_alloced = TRUE;
6835 }
6836# endif
6837 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6838 {
6839# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6840 if (STRCMP(p_guifont, "*") == 0)
6841 {
6842 /* Dialog was cancelled: Keep the old value without giving
6843 * an error message. */
6844 if (new_value_alloced)
6845 free_string_option(p_guifont);
6846 p_guifont = vim_strsave(oldval);
6847 new_value_alloced = TRUE;
6848 }
6849 else
6850# endif
6851 errmsg = (char_u *)N_("E596: Invalid font(s)");
6852 }
6853 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006854 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006855 }
6856# ifdef FEAT_XFONTSET
6857 else if (varp == &p_guifontset)
6858 {
6859 if (STRCMP(p_guifontset, "*") == 0)
6860 errmsg = (char_u *)N_("E597: can't select fontset");
6861 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6862 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006863 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006864 }
6865# endif
6866# ifdef FEAT_MBYTE
6867 else if (varp == &p_guifontwide)
6868 {
6869 if (STRCMP(p_guifontwide, "*") == 0)
6870 errmsg = (char_u *)N_("E533: can't select wide font");
6871 else if (gui_get_wide_font() == FAIL)
6872 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006873 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006874 }
6875# endif
6876#endif
6877
6878#ifdef CURSOR_SHAPE
6879 /* 'guicursor' */
6880 else if (varp == &p_guicursor)
6881 errmsg = parse_shape_opt(SHAPE_CURSOR);
6882#endif
6883
6884#ifdef FEAT_MOUSESHAPE
6885 /* 'mouseshape' */
6886 else if (varp == &p_mouseshape)
6887 {
6888 errmsg = parse_shape_opt(SHAPE_MOUSE);
6889 update_mouseshape(-1);
6890 }
6891#endif
6892
6893#ifdef FEAT_PRINTER
6894 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006895 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006896# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006897 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006898 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006899# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006900#endif
6901
6902#ifdef FEAT_LANGMAP
6903 /* 'langmap' */
6904 else if (varp == &p_langmap)
6905 langmap_set();
6906#endif
6907
6908#ifdef FEAT_LINEBREAK
6909 /* 'breakat' */
6910 else if (varp == &p_breakat)
6911 fill_breakat_flags();
6912#endif
6913
6914#ifdef FEAT_TITLE
6915 /* 'titlestring' and 'iconstring' */
6916 else if (varp == &p_titlestring || varp == &p_iconstring)
6917 {
6918# ifdef FEAT_STL_OPT
6919 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6920
6921 /* NULL => statusline syntax */
6922 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6923 stl_syntax |= flagval;
6924 else
6925 stl_syntax &= ~flagval;
6926# endif
6927 did_set_title(varp == &p_iconstring);
6928
6929 }
6930#endif
6931
6932#ifdef FEAT_GUI
6933 /* 'guioptions' */
6934 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006935 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006936 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006937 redraw_gui_only = TRUE;
6938 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006939#endif
6940
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006941#if defined(FEAT_GUI_TABLINE)
6942 /* 'guitablabel' */
6943 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006944 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006945 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006946 redraw_gui_only = TRUE;
6947 }
6948 /* 'guitabtooltip' */
6949 else if (varp == &p_gtt)
6950 {
6951 redraw_gui_only = TRUE;
6952 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006953#endif
6954
Bram Moolenaar071d4272004-06-13 20:20:40 +00006955#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6956 /* 'ttymouse' */
6957 else if (varp == &p_ttym)
6958 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006959 /* Switch the mouse off before changing the escape sequences used for
6960 * that. */
6961 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006962 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6963 errmsg = e_invarg;
6964 else
6965 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006966 if (termcap_active)
6967 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006968 }
6969#endif
6970
Bram Moolenaar071d4272004-06-13 20:20:40 +00006971 /* 'selection' */
6972 else if (varp == &p_sel)
6973 {
6974 if (*p_sel == NUL
6975 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6976 errmsg = e_invarg;
6977 }
6978
6979 /* 'selectmode' */
6980 else if (varp == &p_slm)
6981 {
6982 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6983 errmsg = e_invarg;
6984 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006985
6986#ifdef FEAT_BROWSE
6987 /* 'browsedir' */
6988 else if (varp == &p_bsdir)
6989 {
6990 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
6991 && !mch_isdir(p_bsdir))
6992 errmsg = e_invarg;
6993 }
6994#endif
6995
Bram Moolenaar071d4272004-06-13 20:20:40 +00006996 /* 'keymodel' */
6997 else if (varp == &p_km)
6998 {
6999 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
7000 errmsg = e_invarg;
7001 else
7002 {
7003 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
7004 km_startsel = (vim_strchr(p_km, 'a') != NULL);
7005 }
7006 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007007
7008 /* 'mousemodel' */
7009 else if (varp == &p_mousem)
7010 {
7011 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
7012 errmsg = e_invarg;
7013#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
7014 else if (*p_mousem != *oldval)
7015 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
7016 * to create or delete the popup menus. */
7017 gui_motif_update_mousemodel(root_menu);
7018#endif
7019 }
7020
7021 /* 'switchbuf' */
7022 else if (varp == &p_swb)
7023 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007024 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007025 errmsg = e_invarg;
7026 }
7027
7028 /* 'debug' */
7029 else if (varp == &p_debug)
7030 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00007031 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007032 errmsg = e_invarg;
7033 }
7034
7035 /* 'display' */
7036 else if (varp == &p_dy)
7037 {
7038 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
7039 errmsg = e_invarg;
7040 else
7041 (void)init_chartab();
7042
7043 }
7044
Bram Moolenaar44a2f922016-03-19 22:11:51 +01007045#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00007046 /* 'eadirection' */
7047 else if (varp == &p_ead)
7048 {
7049 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
7050 errmsg = e_invarg;
7051 }
7052#endif
7053
7054#ifdef FEAT_CLIPBOARD
7055 /* 'clipboard' */
7056 else if (varp == &p_cb)
7057 errmsg = check_clipboard_option();
7058#endif
7059
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007060#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00007061 /* When 'spelllang' or 'spellfile' is set and there is a window for this
7062 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01007063 else if (varp == &(curwin->w_s->b_p_spl)
7064 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00007065 {
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007066 errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf));
Bram Moolenaar217ad922005-03-20 22:37:15 +00007067 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007068 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007069 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007070 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007071 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007072 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00007073 /* 'spellsuggest' */
7074 else if (varp == &p_sps)
7075 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00007076 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00007077 errmsg = e_invarg;
7078 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00007079 /* 'mkspellmem' */
7080 else if (varp == &p_msm)
7081 {
7082 if (spell_check_msm() != OK)
7083 errmsg = e_invarg;
7084 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00007085#endif
7086
Bram Moolenaar071d4272004-06-13 20:20:40 +00007087#ifdef FEAT_QUICKFIX
7088 /* When 'bufhidden' is set, check for valid value. */
7089 else if (gvarp == &p_bh)
7090 {
7091 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
7092 errmsg = e_invarg;
7093 }
7094
7095 /* When 'buftype' is set, check for valid value. */
7096 else if (gvarp == &p_bt)
7097 {
7098 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
7099 errmsg = e_invarg;
7100 else
7101 {
7102# ifdef FEAT_WINDOWS
7103 if (curwin->w_status_height)
7104 {
7105 curwin->w_redr_status = TRUE;
7106 redraw_later(VALID);
7107 }
7108# endif
7109 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar5075aad2010-01-27 15:58:13 +01007110# ifdef FEAT_TITLE
7111 redraw_titles();
7112# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007113 }
7114 }
7115#endif
7116
7117#ifdef FEAT_STL_OPT
7118 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00007119 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007120 {
7121 int wid;
7122
7123 if (varp == &p_ruf) /* reset ru_wid first */
7124 ru_wid = 0;
7125 s = *varp;
7126 if (varp == &p_ruf && *s == '%')
7127 {
7128 /* set ru_wid if 'ruf' starts with "%99(" */
7129 if (*++s == '-') /* ignore a '-' */
7130 s++;
7131 wid = getdigits(&s);
7132 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
7133 ru_wid = wid;
7134 else
7135 errmsg = check_stl_option(p_ruf);
7136 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00007137 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00007138 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00007139 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00007140 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007141 comp_col();
7142 }
7143#endif
7144
7145#ifdef FEAT_INS_EXPAND
7146 /* check if it is a valid value for 'complete' -- Acevedo */
7147 else if (gvarp == &p_cpt)
7148 {
7149 for (s = *varp; *s;)
7150 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007151 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00007152 s++;
7153 if (!*s)
7154 break;
7155 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
7156 {
7157 errmsg = illegal_char(errbuf, *s);
7158 break;
7159 }
7160 if (*++s != NUL && *s != ',' && *s != ' ')
7161 {
7162 if (s[-1] == 'k' || s[-1] == 's')
7163 {
7164 /* skip optional filename after 'k' and 's' */
7165 while (*s && *s != ',' && *s != ' ')
7166 {
Bram Moolenaar226c5342017-02-17 14:53:15 +01007167 if (*s == '\\' && s[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007168 ++s;
7169 ++s;
7170 }
7171 }
7172 else
7173 {
7174 if (errbuf != NULL)
7175 {
7176 sprintf((char *)errbuf,
7177 _("E535: Illegal character after <%c>"),
7178 *--s);
7179 errmsg = errbuf;
7180 }
7181 else
7182 errmsg = (char_u *)"";
7183 break;
7184 }
7185 }
7186 }
7187 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007188
7189 /* 'completeopt' */
7190 else if (varp == &p_cot)
7191 {
7192 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
7193 errmsg = e_invarg;
Bram Moolenaarc0200422016-04-20 12:02:02 +02007194 else
7195 completeopt_was_set();
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007196 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007197#endif /* FEAT_INS_EXPAND */
7198
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02007199#ifdef FEAT_SIGNS
7200 /* 'signcolumn' */
7201 else if (varp == &curwin->w_p_scl)
7202 {
7203 if (check_opt_strings(*varp, p_scl_values, FALSE) != OK)
7204 errmsg = e_invarg;
7205 }
7206#endif
7207
Bram Moolenaar071d4272004-06-13 20:20:40 +00007208
7209#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007210 /* 'toolbar' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007211 else if (varp == &p_toolbar)
7212 {
7213 if (opt_strings_flags(p_toolbar, p_toolbar_values,
7214 &toolbar_flags, TRUE) != OK)
7215 errmsg = e_invarg;
7216 else
7217 {
7218 out_flush();
7219 gui_mch_show_toolbar((toolbar_flags &
7220 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7221 }
7222 }
7223#endif
7224
Bram Moolenaar182c5be2010-06-25 05:37:59 +02007225#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007226 /* 'toolbariconsize': GTK+ 2 only */
7227 else if (varp == &p_tbis)
7228 {
7229 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
7230 errmsg = e_invarg;
7231 else
7232 {
7233 out_flush();
7234 gui_mch_show_toolbar((toolbar_flags &
7235 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7236 }
7237 }
7238#endif
7239
7240 /* 'pastetoggle': translate key codes like in a mapping */
7241 else if (varp == &p_pt)
7242 {
7243 if (*p_pt)
7244 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00007245 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007246 if (p != NULL)
7247 {
7248 if (new_value_alloced)
7249 free_string_option(p_pt);
7250 p_pt = p;
7251 new_value_alloced = TRUE;
7252 }
7253 }
7254 }
7255
7256 /* 'backspace' */
7257 else if (varp == &p_bs)
7258 {
7259 if (VIM_ISDIGIT(*p_bs))
7260 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01007261 if (*p_bs > '2' || p_bs[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007262 errmsg = e_invarg;
7263 }
7264 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
7265 errmsg = e_invarg;
7266 }
Bram Moolenaar165bc692015-07-21 17:53:25 +02007267 else if (varp == &p_bo)
7268 {
7269 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK)
7270 errmsg = e_invarg;
7271 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007272
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01007273 /* 'tagcase' */
7274 else if (gvarp == &p_tc)
7275 {
7276 unsigned int *flags;
7277
7278 if (opt_flags & OPT_LOCAL)
7279 {
7280 p = curbuf->b_p_tc;
7281 flags = &curbuf->b_tc_flags;
7282 }
7283 else
7284 {
7285 p = p_tc;
7286 flags = &tc_flags;
7287 }
7288
7289 if ((opt_flags & OPT_LOCAL) && *p == NUL)
7290 /* make the local value empty: use the global value */
7291 *flags = 0;
7292 else if (*p == NUL
7293 || opt_strings_flags(p, p_tc_values, flags, FALSE) != OK)
7294 errmsg = e_invarg;
7295 }
7296
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007297#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007298 /* 'casemap' */
7299 else if (varp == &p_cmp)
7300 {
7301 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
7302 errmsg = e_invarg;
7303 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007304#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007305
7306#ifdef FEAT_DIFF
7307 /* 'diffopt' */
7308 else if (varp == &p_dip)
7309 {
7310 if (diffopt_changed() == FAIL)
7311 errmsg = e_invarg;
7312 }
7313#endif
7314
7315#ifdef FEAT_FOLDING
7316 /* 'foldmethod' */
7317 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7318 {
7319 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7320 || *curwin->w_p_fdm == NUL)
7321 errmsg = e_invarg;
7322 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007323 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007324 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007325 if (foldmethodIsDiff(curwin))
7326 newFoldLevel();
7327 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007328 }
7329# ifdef FEAT_EVAL
7330 /* 'foldexpr' */
7331 else if (varp == &curwin->w_p_fde)
7332 {
7333 if (foldmethodIsExpr(curwin))
7334 foldUpdateAll(curwin);
7335 }
7336# endif
7337 /* 'foldmarker' */
7338 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7339 {
7340 p = vim_strchr(*varp, ',');
7341 if (p == NULL)
7342 errmsg = (char_u *)N_("E536: comma required");
7343 else if (p == *varp || p[1] == NUL)
7344 errmsg = e_invarg;
7345 else if (foldmethodIsMarker(curwin))
7346 foldUpdateAll(curwin);
7347 }
7348 /* 'commentstring' */
7349 else if (gvarp == &p_cms)
7350 {
7351 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7352 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7353 }
7354 /* 'foldopen' */
7355 else if (varp == &p_fdo)
7356 {
7357 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7358 errmsg = e_invarg;
7359 }
7360 /* 'foldclose' */
7361 else if (varp == &p_fcl)
7362 {
7363 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7364 errmsg = e_invarg;
7365 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007366 /* 'foldignore' */
7367 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7368 {
7369 if (foldmethodIsIndent(curwin))
7370 foldUpdateAll(curwin);
7371 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007372#endif
7373
7374#ifdef FEAT_VIRTUALEDIT
7375 /* 'virtualedit' */
7376 else if (varp == &p_ve)
7377 {
7378 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7379 errmsg = e_invarg;
7380 else if (STRCMP(p_ve, oldval) != 0)
7381 {
7382 /* Recompute cursor position in case the new 've' setting
7383 * changes something. */
7384 validate_virtcol();
7385 coladvance(curwin->w_virtcol);
7386 }
7387 }
7388#endif
7389
7390#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7391 else if (varp == &p_csqf)
7392 {
7393 if (p_csqf != NULL)
7394 {
7395 p = p_csqf;
7396 while (*p != NUL)
7397 {
7398 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7399 || p[1] == NUL
7400 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7401 || (p[2] != NUL && p[2] != ','))
7402 {
7403 errmsg = e_invarg;
7404 break;
7405 }
7406 else if (p[2] == NUL)
7407 break;
7408 else
7409 p += 3;
7410 }
7411 }
7412 }
7413#endif
7414
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007415#ifdef FEAT_CINDENT
7416 /* 'cinoptions' */
7417 else if (gvarp == &p_cino)
7418 {
7419 /* TODO: recognize errors */
7420 parse_cino(curbuf);
7421 }
7422#endif
7423
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007424#if defined(FEAT_RENDER_OPTIONS)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007425 /* 'renderoptions' */
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007426 else if (varp == &p_rop && gui.in_use)
7427 {
7428 if (!gui_mch_set_rendering_options(p_rop))
7429 errmsg = e_invarg;
7430 }
7431#endif
7432
Bram Moolenaard0b51382016-11-04 15:23:45 +01007433#ifdef FEAT_AUTOCMD
7434 else if (gvarp == &p_ft)
7435 {
7436 if (!valid_filetype(*varp))
7437 errmsg = e_invarg;
Bram Moolenaar90492982017-06-22 14:16:31 +02007438 else
7439 ft_changed = STRCMP(oldval, *varp) != 0;
Bram Moolenaard0b51382016-11-04 15:23:45 +01007440 }
7441#endif
7442
7443#ifdef FEAT_SYN_HL
7444 else if (gvarp == &p_syn)
7445 {
7446 if (!valid_filetype(*varp))
7447 errmsg = e_invarg;
7448 }
7449#endif
7450
Bram Moolenaar071d4272004-06-13 20:20:40 +00007451 /* Options that are a list of flags. */
7452 else
7453 {
7454 p = NULL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007455 if (varp == &p_ww) /* 'whichwrap' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007456 p = (char_u *)WW_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007457 if (varp == &p_shm) /* 'shortmess' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007458 p = (char_u *)SHM_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007459 else if (varp == &(p_cpo)) /* 'cpoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007460 p = (char_u *)CPO_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007461 else if (varp == &(curbuf->b_p_fo)) /* 'formatoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007462 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007463#ifdef FEAT_CONCEAL
Bram Moolenaar031cb742016-11-24 21:46:19 +01007464 else if (varp == &curwin->w_p_cocu) /* 'concealcursor' */
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007465 p = (char_u *)COCU_ALL;
7466#endif
Bram Moolenaar031cb742016-11-24 21:46:19 +01007467 else if (varp == &p_mouse) /* 'mouse' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007468 {
7469#ifdef FEAT_MOUSE
7470 p = (char_u *)MOUSE_ALL;
7471#else
7472 if (*p_mouse != NUL)
7473 errmsg = (char_u *)N_("E538: No mouse support");
7474#endif
7475 }
7476#if defined(FEAT_GUI)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007477 else if (varp == &p_go) /* 'guioptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007478 p = (char_u *)GO_ALL;
7479#endif
7480 if (p != NULL)
7481 {
7482 for (s = *varp; *s; ++s)
7483 if (vim_strchr(p, *s) == NULL)
7484 {
7485 errmsg = illegal_char(errbuf, *s);
7486 break;
7487 }
7488 }
7489 }
7490
7491 /*
7492 * If error detected, restore the previous value.
7493 */
7494 if (errmsg != NULL)
7495 {
7496 if (new_value_alloced)
7497 free_string_option(*varp);
7498 *varp = oldval;
7499 /*
7500 * When resetting some values, need to act on it.
7501 */
7502 if (did_chartab)
7503 (void)init_chartab();
7504 if (varp == &p_hl)
7505 (void)highlight_changed();
7506 }
7507 else
7508 {
7509#ifdef FEAT_EVAL
7510 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007511 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007512#endif
7513 /*
7514 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007515 * Use "free_oldval", because recursiveness may change the flags under
7516 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007517 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007518 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007519 free_string_option(oldval);
7520 if (new_value_alloced)
7521 options[opt_idx].flags |= P_ALLOCED;
7522 else
7523 options[opt_idx].flags &= ~P_ALLOCED;
7524
7525 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007526 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007527 {
7528 /* global option with local value set to use global value; free
7529 * the local value and make it empty */
7530 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7531 free_string_option(*(char_u **)p);
7532 *(char_u **)p = empty_option;
7533 }
7534
7535 /* May set global value for local option. */
7536 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7537 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007538
7539#ifdef FEAT_AUTOCMD
7540 /*
7541 * Trigger the autocommand only after setting the flags.
7542 */
7543# ifdef FEAT_SYN_HL
7544 /* When 'syntax' is set, load the syntax of that name */
7545 if (varp == &(curbuf->b_p_syn))
7546 {
7547 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7548 curbuf->b_fname, TRUE, curbuf);
7549 }
7550# endif
7551 else if (varp == &(curbuf->b_p_ft))
7552 {
Bram Moolenaar90492982017-06-22 14:16:31 +02007553 /* 'filetype' is set, trigger the FileType autocommand.
7554 * Skip this when called from a modeline and the filetype was
7555 * already set to this value. */
7556 if (!(opt_flags & OPT_MODELINE) || ft_changed)
7557 {
7558 did_filetype = TRUE;
7559 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007560 curbuf->b_fname, TRUE, curbuf);
Bram Moolenaar90492982017-06-22 14:16:31 +02007561 }
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007562 }
7563#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007564#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007565 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007566 {
7567 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007568 char_u *q = curwin->w_s->b_p_spl;
7569
7570 /* Skip the first name if it is "cjk". */
7571 if (STRNCMP(q, "cjk,", 4) == 0)
7572 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007573
7574 /*
7575 * Source the spell/LANG.vim in 'runtimepath'.
7576 * They could set 'spellcapcheck' depending on the language.
7577 * Use the first name in 'spelllang' up to '_region' or
7578 * '.encoding'.
7579 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007580 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007581 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7582 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007583 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar7f8989d2016-03-12 22:11:39 +01007584 source_runtime(fname, DIP_ALL);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007585 }
7586#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007587 }
7588
7589#ifdef FEAT_MOUSE
7590 if (varp == &p_mouse)
7591 {
7592# ifdef FEAT_MOUSE_TTY
7593 if (*p_mouse == NUL)
7594 mch_setmouse(FALSE); /* switch mouse off */
7595 else
7596# endif
7597 setmouse(); /* in case 'mouse' changed */
7598 }
7599#endif
7600
Bram Moolenaar913077c2012-03-28 19:59:04 +02007601 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007602 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007603 curwin->w_set_curswant = TRUE;
7604
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007605#ifdef FEAT_GUI
7606 /* check redraw when it's not a GUI option or the GUI is active. */
7607 if (!redraw_gui_only || gui.in_use)
7608#endif
7609 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007610
7611 return errmsg;
7612}
7613
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007614#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007615/*
7616 * Simple int comparison function for use with qsort()
7617 */
7618 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01007619int_cmp(const void *a, const void *b)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007620{
7621 return *(const int *)a - *(const int *)b;
7622}
7623
7624/*
7625 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7626 * Returns error message, NULL if it's OK.
7627 */
7628 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007629check_colorcolumn(win_T *wp)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007630{
7631 char_u *s;
7632 int col;
7633 int count = 0;
7634 int color_cols[256];
7635 int i;
7636 int j = 0;
7637
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007638 if (wp->w_buffer == NULL)
7639 return NULL; /* buffer was closed */
7640
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007641 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007642 {
7643 if (*s == '-' || *s == '+')
7644 {
7645 /* -N and +N: add to 'textwidth' */
7646 col = (*s == '-') ? -1 : 1;
7647 ++s;
7648 if (!VIM_ISDIGIT(*s))
7649 return e_invarg;
7650 col = col * getdigits(&s);
7651 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007652 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007653 col += wp->w_buffer->b_p_tw;
7654 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007655 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007656 }
7657 else if (VIM_ISDIGIT(*s))
7658 col = getdigits(&s);
7659 else
7660 return e_invarg;
7661 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007662skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007663 if (*s == NUL)
7664 break;
7665 if (*s != ',')
7666 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007667 if (*++s == NUL)
7668 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007669 }
7670
7671 vim_free(wp->w_p_cc_cols);
7672 if (count == 0)
7673 wp->w_p_cc_cols = NULL;
7674 else
7675 {
7676 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7677 if (wp->w_p_cc_cols != NULL)
7678 {
7679 /* sort the columns for faster usage on screen redraw inside
7680 * win_line() */
7681 qsort(color_cols, count, sizeof(int), int_cmp);
7682
7683 for (i = 0; i < count; ++i)
7684 /* skip duplicates */
7685 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7686 wp->w_p_cc_cols[j++] = color_cols[i];
7687 wp->w_p_cc_cols[j] = -1; /* end marker */
7688 }
7689 }
7690
7691 return NULL; /* no error */
7692}
7693#endif
7694
Bram Moolenaar071d4272004-06-13 20:20:40 +00007695/*
7696 * Handle setting 'listchars' or 'fillchars'.
7697 * Returns error message, NULL if it's OK.
7698 */
7699 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007700set_chars_option(char_u **varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007701{
7702 int round, i, len, entries;
7703 char_u *p, *s;
7704 int c1, c2 = 0;
7705 struct charstab
7706 {
7707 int *cp;
7708 char *name;
7709 };
7710#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7711 static struct charstab filltab[] =
7712 {
7713 {&fill_stl, "stl"},
7714 {&fill_stlnc, "stlnc"},
7715 {&fill_vert, "vert"},
7716 {&fill_fold, "fold"},
7717 {&fill_diff, "diff"},
7718 };
7719#endif
7720 static struct charstab lcstab[] =
7721 {
7722 {&lcs_eol, "eol"},
7723 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007724 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007725 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007726 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007727 {&lcs_tab2, "tab"},
7728 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007729#ifdef FEAT_CONCEAL
7730 {&lcs_conceal, "conceal"},
7731#else
7732 {NULL, "conceal"},
7733#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007734 };
7735 struct charstab *tab;
7736
7737#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7738 if (varp == &p_lcs)
7739#endif
7740 {
7741 tab = lcstab;
7742 entries = sizeof(lcstab) / sizeof(struct charstab);
7743 }
7744#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7745 else
7746 {
7747 tab = filltab;
7748 entries = sizeof(filltab) / sizeof(struct charstab);
7749 }
7750#endif
7751
7752 /* first round: check for valid value, second round: assign values */
7753 for (round = 0; round <= 1; ++round)
7754 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007755 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007756 {
7757 /* After checking that the value is valid: set defaults: space for
7758 * 'fillchars', NUL for 'listchars' */
7759 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007760 if (tab[i].cp != NULL)
7761 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007762 if (varp == &p_lcs)
7763 lcs_tab1 = NUL;
7764#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7765 else
7766 fill_diff = '-';
7767#endif
7768 }
7769 p = *varp;
7770 while (*p)
7771 {
7772 for (i = 0; i < entries; ++i)
7773 {
7774 len = (int)STRLEN(tab[i].name);
7775 if (STRNCMP(p, tab[i].name, len) == 0
7776 && p[len] == ':'
7777 && p[len + 1] != NUL)
7778 {
7779 s = p + len + 1;
7780#ifdef FEAT_MBYTE
7781 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007782 if (mb_char2cells(c1) > 1)
7783 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007784#else
7785 c1 = *s++;
7786#endif
7787 if (tab[i].cp == &lcs_tab2)
7788 {
7789 if (*s == NUL)
7790 continue;
7791#ifdef FEAT_MBYTE
7792 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007793 if (mb_char2cells(c2) > 1)
7794 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007795#else
7796 c2 = *s++;
7797#endif
7798 }
7799 if (*s == ',' || *s == NUL)
7800 {
7801 if (round)
7802 {
7803 if (tab[i].cp == &lcs_tab2)
7804 {
7805 lcs_tab1 = c1;
7806 lcs_tab2 = c2;
7807 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007808 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007809 *(tab[i].cp) = c1;
7810
7811 }
7812 p = s;
7813 break;
7814 }
7815 }
7816 }
7817
7818 if (i == entries)
7819 return e_invarg;
7820 if (*p == ',')
7821 ++p;
7822 }
7823 }
7824
7825 return NULL; /* no error */
7826}
7827
7828#ifdef FEAT_STL_OPT
7829/*
7830 * Check validity of options with the 'statusline' format.
7831 * Return error message or NULL.
7832 */
7833 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007834check_stl_option(char_u *s)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007835{
7836 int itemcnt = 0;
7837 int groupdepth = 0;
7838 static char_u errbuf[80];
7839
7840 while (*s && itemcnt < STL_MAX_ITEM)
7841 {
7842 /* Check for valid keys after % sequences */
7843 while (*s && *s != '%')
7844 s++;
7845 if (!*s)
7846 break;
7847 s++;
7848 if (*s != '%' && *s != ')')
7849 ++itemcnt;
7850 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7851 {
7852 s++;
7853 continue;
7854 }
7855 if (*s == ')')
7856 {
7857 s++;
7858 if (--groupdepth < 0)
7859 break;
7860 continue;
7861 }
7862 if (*s == '-')
7863 s++;
7864 while (VIM_ISDIGIT(*s))
7865 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007866 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007867 continue;
7868 if (*s == '.')
7869 {
7870 s++;
7871 while (*s && VIM_ISDIGIT(*s))
7872 s++;
7873 }
7874 if (*s == '(')
7875 {
7876 groupdepth++;
7877 continue;
7878 }
7879 if (vim_strchr(STL_ALL, *s) == NULL)
7880 {
7881 return illegal_char(errbuf, *s);
7882 }
7883 if (*s == '{')
7884 {
7885 s++;
7886 while (*s != '}' && *s)
7887 s++;
7888 if (*s != '}')
7889 return (char_u *)N_("E540: Unclosed expression sequence");
7890 }
7891 }
7892 if (itemcnt >= STL_MAX_ITEM)
7893 return (char_u *)N_("E541: too many items");
7894 if (groupdepth != 0)
7895 return (char_u *)N_("E542: unbalanced groups");
7896 return NULL;
7897}
7898#endif
7899
7900#ifdef FEAT_CLIPBOARD
7901/*
7902 * Extract the items in the 'clipboard' option and set global values.
7903 */
7904 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007905check_clipboard_option(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007906{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007907 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007908 int new_autoselect_star = FALSE;
7909 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007910 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007911 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007912 regprog_T *new_exclude_prog = NULL;
7913 char_u *errmsg = NULL;
7914 char_u *p;
7915
7916 for (p = p_cb; *p != NUL; )
7917 {
7918 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7919 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007920 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007921 p += 7;
7922 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007923 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007924 && (p[11] == ',' || p[11] == NUL))
7925 {
7926 new_unnamed |= CLIP_UNNAMED_PLUS;
7927 p += 11;
7928 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007929 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007930 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007931 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007932 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007933 p += 10;
7934 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007935 else if (STRNCMP(p, "autoselectplus", 14) == 0
7936 && (p[14] == ',' || p[14] == NUL))
7937 {
7938 new_autoselect_plus = TRUE;
7939 p += 14;
7940 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007941 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007942 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007943 {
7944 new_autoselectml = TRUE;
7945 p += 12;
7946 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007947 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7948 {
7949 new_html = TRUE;
7950 p += 4;
7951 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007952 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7953 {
7954 p += 8;
7955 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7956 if (new_exclude_prog == NULL)
7957 errmsg = e_invarg;
7958 break;
7959 }
7960 else
7961 {
7962 errmsg = e_invarg;
7963 break;
7964 }
7965 if (*p == ',')
7966 ++p;
7967 }
7968 if (errmsg == NULL)
7969 {
7970 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007971 clip_autoselect_star = new_autoselect_star;
7972 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007973 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007974 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02007975 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007976 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02007977#ifdef FEAT_GUI_GTK
7978 if (gui.in_use)
7979 {
7980 gui_gtk_set_selection_targets();
7981 gui_gtk_set_dnd_targets();
7982 }
7983#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007984 }
7985 else
Bram Moolenaar473de612013-06-08 18:19:48 +02007986 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007987
7988 return errmsg;
7989}
7990#endif
7991
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007992#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007993 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007994did_set_spell_option(int is_spellfile)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007995{
7996 char_u *errmsg = NULL;
7997 win_T *wp;
7998 int l;
7999
8000 if (is_spellfile)
8001 {
8002 l = (int)STRLEN(curwin->w_s->b_p_spf);
8003 if (l > 0 && (l < 4
8004 || STRCMP(curwin->w_s->b_p_spf + l - 4, ".add") != 0))
8005 errmsg = e_invarg;
8006 }
8007
8008 if (errmsg == NULL)
8009 {
8010 FOR_ALL_WINDOWS(wp)
8011 if (wp->w_buffer == curbuf && wp->w_p_spell)
8012 {
8013 errmsg = did_set_spelllang(wp);
8014# ifdef FEAT_WINDOWS
8015 break;
8016# endif
8017 }
8018 }
8019 return errmsg;
8020}
8021
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008022/*
8023 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
8024 * Return error message when failed, NULL when OK.
8025 */
8026 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008027compile_cap_prog(synblock_T *synblock)
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008028{
Bram Moolenaar860cae12010-06-05 23:22:07 +02008029 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008030 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008031
Bram Moolenaar860cae12010-06-05 23:22:07 +02008032 if (*synblock->b_p_spc == NUL)
8033 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008034 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008035 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008036 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02008037 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008038 if (re != NULL)
8039 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008040 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02008041 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02008042 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008043 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008044 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008045 return e_invarg;
8046 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008047 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008048 }
8049
Bram Moolenaar473de612013-06-08 18:19:48 +02008050 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008051 return NULL;
8052}
8053#endif
8054
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008055#if defined(FEAT_EVAL) || defined(PROTO)
8056/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008057 * Set the scriptID for an option, taking care of setting the buffer- or
8058 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008059 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008060 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01008061set_option_scriptID_idx(int opt_idx, int opt_flags, int id)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008062{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008063 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
8064 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008065
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008066 /* Remember where the option was set. For local options need to do that
8067 * in the buffer or window structure. */
8068 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008069 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008070 if (both || (opt_flags & OPT_LOCAL))
8071 {
8072 if (indir & PV_BUF)
8073 curbuf->b_p_scriptID[indir & PV_MASK] = id;
8074 else if (indir & PV_WIN)
8075 curwin->w_p_scriptID[indir & PV_MASK] = id;
8076 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008077}
8078#endif
8079
Bram Moolenaar071d4272004-06-13 20:20:40 +00008080/*
8081 * Set the value of a boolean option, and take care of side effects.
8082 * Returns NULL for success, or an error message for an error.
8083 */
8084 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008085set_bool_option(
8086 int opt_idx, /* index in options[] table */
8087 char_u *varp, /* pointer to the option variable */
8088 int value, /* new value */
8089 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008090{
8091 int old_value = *(int *)varp;
8092
Bram Moolenaar071d4272004-06-13 20:20:40 +00008093 /* Disallow changing some options from secure mode */
8094 if ((secure
8095#ifdef HAVE_SANDBOX
8096 || sandbox != 0
8097#endif
8098 ) && (options[opt_idx].flags & P_SECURE))
8099 return e_secure;
8100
8101 *(int *)varp = value; /* set the new value */
8102#ifdef FEAT_EVAL
8103 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008104 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008105#endif
8106
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008107#ifdef FEAT_GUI
8108 need_mouse_correct = TRUE;
8109#endif
8110
Bram Moolenaar071d4272004-06-13 20:20:40 +00008111 /* May set global value for local option. */
8112 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8113 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
8114
8115 /*
8116 * Handle side effects of changing a bool option.
8117 */
8118
8119 /* 'compatible' */
8120 if ((int *)varp == &p_cp)
8121 {
8122 compatible_set();
8123 }
8124
Bram Moolenaar920694c2016-08-21 17:45:02 +02008125#ifdef FEAT_LANGMAP
8126 if ((int *)varp == &p_lrm)
8127 /* 'langremap' -> !'langnoremap' */
8128 p_lnr = !p_lrm;
8129 else if ((int *)varp == &p_lnr)
8130 /* 'langnoremap' -> !'langremap' */
8131 p_lrm = !p_lnr;
8132#endif
8133
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008134#ifdef FEAT_PERSISTENT_UNDO
8135 /* 'undofile' */
8136 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
8137 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008138 /* Only take action when the option was set. When reset we do not
8139 * delete the undo file, the option may be set again without making
8140 * any changes in between. */
8141 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008142 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008143 char_u hash[UNDO_HASH_SIZE];
8144 buf_T *save_curbuf = curbuf;
8145
Bram Moolenaar29323592016-07-24 22:04:11 +02008146 FOR_ALL_BUFFERS(curbuf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008147 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008148 /* When 'undofile' is set globally: for every buffer, otherwise
8149 * only for the current buffer: Try to read in the undofile,
8150 * if one exists, the buffer wasn't changed and the buffer was
8151 * loaded */
8152 if ((curbuf == save_curbuf
8153 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
8154 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
8155 {
8156 u_compute_hash(hash);
8157 u_read_undo(NULL, hash, curbuf->b_fname);
8158 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008159 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008160 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008161 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008162 }
8163#endif
8164
Bram Moolenaar071d4272004-06-13 20:20:40 +00008165 else if ((int *)varp == &curbuf->b_p_ro)
8166 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00008167 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008168 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
8169 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00008170
8171 /* when 'readonly' is set may give W10 again */
8172 if (curbuf->b_p_ro)
8173 curbuf->b_did_warn = FALSE;
8174
Bram Moolenaar071d4272004-06-13 20:20:40 +00008175#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008176 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008177#endif
8178 }
8179
Bram Moolenaar9c449722010-07-20 18:44:27 +02008180#ifdef FEAT_GUI
8181 else if ((int *)varp == &p_mh)
8182 {
8183 if (!p_mh)
8184 gui_mch_mousehide(FALSE);
8185 }
8186#endif
8187
Bram Moolenaara539df02010-08-01 14:35:05 +02008188#ifdef FEAT_TITLE
8189 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008190 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008191 {
8192 redraw_titles();
8193 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008194 /* when 'endofline' is changed, redraw the window title */
8195 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008196 {
8197 redraw_titles();
8198 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02008199 /* when 'fixeol' is changed, redraw the window title */
8200 else if ((int *)varp == &curbuf->b_p_fixeol)
8201 {
8202 redraw_titles();
8203 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008204# ifdef FEAT_MBYTE
8205 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00008206 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008207 {
8208 redraw_titles();
8209 }
8210# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008211#endif
8212
8213 /* when 'bin' is set also set some other options */
8214 else if ((int *)varp == &curbuf->b_p_bin)
8215 {
8216 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
8217#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008218 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008219#endif
8220 }
8221
8222#ifdef FEAT_AUTOCMD
8223 /* when 'buflisted' changes, trigger autocommands */
8224 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
8225 {
8226 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
8227 NULL, NULL, TRUE, curbuf);
8228 }
8229#endif
8230
8231 /* when 'swf' is set, create swapfile, when reset remove swapfile */
8232 else if ((int *)varp == &curbuf->b_p_swf)
8233 {
8234 if (curbuf->b_p_swf && p_uc)
8235 ml_open_file(curbuf); /* create the swap file */
8236 else
Bram Moolenaard55de222007-05-06 13:38:48 +00008237 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
8238 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008239 mf_close_file(curbuf, TRUE); /* remove the swap file */
8240 }
8241
8242 /* when 'terse' is set change 'shortmess' */
8243 else if ((int *)varp == &p_terse)
8244 {
8245 char_u *p;
8246
8247 p = vim_strchr(p_shm, SHM_SEARCH);
8248
8249 /* insert 's' in p_shm */
8250 if (p_terse && p == NULL)
8251 {
8252 STRCPY(IObuff, p_shm);
8253 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008254 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008255 }
8256 /* remove 's' from p_shm */
8257 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00008258 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008259 }
8260
8261 /* when 'paste' is set or reset also change other options */
8262 else if ((int *)varp == &p_paste)
8263 {
8264 paste_option_changed();
8265 }
8266
8267 /* when 'insertmode' is set from an autocommand need to do work here */
8268 else if ((int *)varp == &p_im)
8269 {
8270 if (p_im)
8271 {
8272 if ((State & INSERT) == 0)
8273 need_start_insertmode = TRUE;
8274 stop_insert_mode = FALSE;
8275 }
Bram Moolenaar00672e12016-06-26 18:38:13 +02008276 /* only reset if it was set previously */
8277 else if (old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008278 {
8279 need_start_insertmode = FALSE;
8280 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00008281 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008282 clear_cmdline = TRUE; /* remove "(insert)" */
8283 restart_edit = 0;
8284 }
8285 }
8286
8287 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
8288 else if ((int *)varp == &p_ic && p_hls)
8289 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008290 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008291 }
8292
8293#ifdef FEAT_SEARCH_EXTRA
8294 /* when 'hlsearch' is set or reset: reset no_hlsearch */
8295 else if ((int *)varp == &p_hls)
8296 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01008297 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008298 }
8299#endif
8300
8301#ifdef FEAT_SCROLLBIND
8302 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
8303 * at the end of normal_cmd() */
8304 else if ((int *)varp == &curwin->w_p_scb)
8305 {
8306 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008307 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00008308 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008309 curwin->w_scbind_pos = curwin->w_topline;
8310 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008311 }
8312#endif
8313
8314#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
8315 /* There can be only one window with 'previewwindow' set. */
8316 else if ((int *)varp == &curwin->w_p_pvw)
8317 {
8318 if (curwin->w_p_pvw)
8319 {
8320 win_T *win;
8321
Bram Moolenaar29323592016-07-24 22:04:11 +02008322 FOR_ALL_WINDOWS(win)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008323 if (win->w_p_pvw && win != curwin)
8324 {
8325 curwin->w_p_pvw = FALSE;
8326 return (char_u *)N_("E590: A preview window already exists");
8327 }
8328 }
8329 }
8330#endif
8331
8332 /* when 'textmode' is set or reset also change 'fileformat' */
8333 else if ((int *)varp == &curbuf->b_p_tx)
8334 {
8335 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
8336 }
8337
8338 /* when 'textauto' is set or reset also change 'fileformats' */
8339 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008340 set_string_option_direct((char_u *)"ffs", -1,
8341 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008342 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008343
8344 /*
8345 * When 'lisp' option changes include/exclude '-' in
8346 * keyword characters.
8347 */
8348#ifdef FEAT_LISP
8349 else if (varp == (char_u *)&(curbuf->b_p_lisp))
8350 {
8351 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
8352 }
8353#endif
8354
8355#ifdef FEAT_TITLE
8356 /* when 'title' changed, may need to change the title; same for 'icon' */
8357 else if ((int *)varp == &p_title)
8358 {
8359 did_set_title(FALSE);
8360 }
8361
8362 else if ((int *)varp == &p_icon)
8363 {
8364 did_set_title(TRUE);
8365 }
8366#endif
8367
8368 else if ((int *)varp == &curbuf->b_changed)
8369 {
8370 if (!value)
8371 save_file_ff(curbuf); /* Buffer is unchanged */
8372#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008373 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008374#endif
8375#ifdef FEAT_AUTOCMD
8376 modified_was_set = value;
8377#endif
8378 }
8379
8380#ifdef BACKSLASH_IN_FILENAME
8381 else if ((int *)varp == &p_ssl)
8382 {
8383 if (p_ssl)
8384 {
8385 psepc = '/';
8386 psepcN = '\\';
8387 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008388 }
8389 else
8390 {
8391 psepc = '\\';
8392 psepcN = '/';
8393 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008394 }
8395
8396 /* need to adjust the file name arguments and buffer names. */
8397 buflist_slash_adjust();
8398 alist_slash_adjust();
8399# ifdef FEAT_EVAL
8400 scriptnames_slash_adjust();
8401# endif
8402 }
8403#endif
8404
8405 /* If 'wrap' is set, set w_leftcol to zero. */
8406 else if ((int *)varp == &curwin->w_p_wrap)
8407 {
8408 if (curwin->w_p_wrap)
8409 curwin->w_leftcol = 0;
8410 }
8411
8412#ifdef FEAT_WINDOWS
8413 else if ((int *)varp == &p_ea)
8414 {
8415 if (p_ea && !old_value)
8416 win_equal(curwin, FALSE, 0);
8417 }
8418#endif
8419
8420 else if ((int *)varp == &p_wiv)
8421 {
8422 /*
8423 * When 'weirdinvert' changed, set/reset 't_xs'.
8424 * Then set 'weirdinvert' according to value of 't_xs'.
8425 */
8426 if (p_wiv && !old_value)
8427 T_XS = (char_u *)"y";
8428 else if (!p_wiv && old_value)
8429 T_XS = empty_option;
8430 p_wiv = (*T_XS != NUL);
8431 }
8432
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00008433#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00008434 else if ((int *)varp == &p_beval)
8435 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008436 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008437 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008438 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008439 gui_mch_disable_beval_area(balloonEval);
8440 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008441#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008442
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008443#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008444 else if ((int *)varp == &p_acd)
8445 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008446 /* Change directories when the 'acd' option is set now. */
8447 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008448 }
8449#endif
8450
8451#ifdef FEAT_DIFF
8452 /* 'diff' */
8453 else if ((int *)varp == &curwin->w_p_diff)
8454 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008455 /* May add or remove the buffer from the list of diff buffers. */
8456 diff_buf_adjust(curwin);
8457# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008458 if (foldmethodIsDiff(curwin))
8459 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008460# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008461 }
8462#endif
8463
8464#ifdef USE_IM_CONTROL
8465 /* 'imdisable' */
8466 else if ((int *)varp == &p_imdisable)
8467 {
8468 /* Only de-activate it here, it will be enabled when changing mode. */
8469 if (p_imdisable)
8470 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008471 else if (State & INSERT)
8472 /* When the option is set from an autocommand, it may need to take
8473 * effect right away. */
8474 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008475 }
8476#endif
8477
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008478#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008479 /* 'spell' */
8480 else if ((int *)varp == &curwin->w_p_spell)
8481 {
8482 if (curwin->w_p_spell)
8483 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008484 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008485 if (errmsg != NULL)
8486 EMSG(_(errmsg));
8487 }
8488 }
8489#endif
8490
Bram Moolenaar071d4272004-06-13 20:20:40 +00008491#ifdef FEAT_FKMAP
8492 else if ((int *)varp == &p_altkeymap)
8493 {
8494 if (old_value != p_altkeymap)
8495 {
8496 if (!p_altkeymap)
8497 {
8498 p_hkmap = p_fkmap;
8499 p_fkmap = 0;
8500 }
8501 else
8502 {
8503 p_fkmap = p_hkmap;
8504 p_hkmap = 0;
8505 }
8506 (void)init_chartab();
8507 }
8508 }
8509
8510 /*
8511 * In case some second language keymapping options have changed, check
8512 * and correct the setting in a consistent way.
8513 */
8514
8515 /*
8516 * If hkmap or fkmap are set, reset Arabic keymapping.
8517 */
8518 if ((p_hkmap || p_fkmap) && p_altkeymap)
8519 {
8520 p_altkeymap = p_fkmap;
8521# ifdef FEAT_ARABIC
8522 curwin->w_p_arab = FALSE;
8523# endif
8524 (void)init_chartab();
8525 }
8526
8527 /*
8528 * If hkmap set, reset Farsi keymapping.
8529 */
8530 if (p_hkmap && p_altkeymap)
8531 {
8532 p_altkeymap = 0;
8533 p_fkmap = 0;
8534# ifdef FEAT_ARABIC
8535 curwin->w_p_arab = FALSE;
8536# endif
8537 (void)init_chartab();
8538 }
8539
8540 /*
8541 * If fkmap set, reset Hebrew keymapping.
8542 */
8543 if (p_fkmap && !p_altkeymap)
8544 {
8545 p_altkeymap = 1;
8546 p_hkmap = 0;
8547# ifdef FEAT_ARABIC
8548 curwin->w_p_arab = FALSE;
8549# endif
8550 (void)init_chartab();
8551 }
8552#endif
8553
8554#ifdef FEAT_ARABIC
8555 if ((int *)varp == &curwin->w_p_arab)
8556 {
8557 if (curwin->w_p_arab)
8558 {
8559 /*
8560 * 'arabic' is set, handle various sub-settings.
8561 */
8562 if (!p_tbidi)
8563 {
8564 /* set rightleft mode */
8565 if (!curwin->w_p_rl)
8566 {
8567 curwin->w_p_rl = TRUE;
8568 changed_window_setting();
8569 }
8570
8571 /* Enable Arabic shaping (major part of what Arabic requires) */
8572 if (!p_arshape)
8573 {
8574 p_arshape = TRUE;
8575 redraw_later_clear();
8576 }
8577 }
8578
8579 /* Arabic requires a utf-8 encoding, inform the user if its not
8580 * set. */
8581 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008582 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008583 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8584
Bram Moolenaar8820b482017-03-16 17:23:31 +01008585 msg_source(HL_ATTR(HLF_W));
8586 MSG_ATTR(_(w_arabic), HL_ATTR(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008587#ifdef FEAT_EVAL
8588 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8589#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008590 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008591
8592# ifdef FEAT_MBYTE
8593 /* set 'delcombine' */
8594 p_deco = TRUE;
8595# endif
8596
8597# ifdef FEAT_KEYMAP
8598 /* Force-set the necessary keymap for arabic */
8599 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8600 OPT_LOCAL);
8601# endif
8602# ifdef FEAT_FKMAP
8603 p_altkeymap = 0;
8604 p_hkmap = 0;
8605 p_fkmap = 0;
8606 (void)init_chartab();
8607# endif
8608 }
8609 else
8610 {
8611 /*
8612 * 'arabic' is reset, handle various sub-settings.
8613 */
8614 if (!p_tbidi)
8615 {
8616 /* reset rightleft mode */
8617 if (curwin->w_p_rl)
8618 {
8619 curwin->w_p_rl = FALSE;
8620 changed_window_setting();
8621 }
8622
8623 /* 'arabicshape' isn't reset, it is a global option and
8624 * another window may still need it "on". */
8625 }
8626
8627 /* 'delcombine' isn't reset, it is a global option and another
8628 * window may still want it "on". */
8629
8630# ifdef FEAT_KEYMAP
8631 /* Revert to the default keymap */
8632 curbuf->b_p_iminsert = B_IMODE_NONE;
8633 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8634# endif
8635 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008636 }
8637
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008638#endif
8639
Bram Moolenaar61be73b2016-04-29 22:59:22 +02008640#ifdef FEAT_TERMGUICOLORS
8641 /* 'termguicolors' */
8642 else if ((int *)varp == &p_tgc)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02008643 {
8644# ifdef FEAT_GUI
8645 if (!gui.in_use && !gui.starting)
8646# endif
8647 highlight_gui_started();
8648 }
8649#endif
8650
Bram Moolenaar071d4272004-06-13 20:20:40 +00008651 /*
8652 * End of handling side effects for bool options.
8653 */
8654
Bram Moolenaar53744302015-07-17 17:38:22 +02008655 /* after handling side effects, call autocommand */
8656
Bram Moolenaar071d4272004-06-13 20:20:40 +00008657 options[opt_idx].flags |= P_WAS_SET;
8658
Bram Moolenaar53744302015-07-17 17:38:22 +02008659#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8660 if (!starting)
8661 {
8662 char_u buf_old[2], buf_new[2], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008663 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8664 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8665 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008666 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8667 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8668 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8669 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8670 reset_v_option_vars();
8671 }
8672#endif
8673
Bram Moolenaar071d4272004-06-13 20:20:40 +00008674 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008675 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008676 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008677 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008678 check_redraw(options[opt_idx].flags);
8679
8680 return NULL;
8681}
8682
8683/*
8684 * Set the value of a number option, and take care of side effects.
8685 * Returns NULL for success, or an error message for an error.
8686 */
8687 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008688set_num_option(
8689 int opt_idx, /* index in options[] table */
8690 char_u *varp, /* pointer to the option variable */
8691 long value, /* new value */
8692 char_u *errbuf, /* buffer for error messages */
8693 size_t errbuflen, /* length of "errbuf" */
8694 int opt_flags) /* OPT_LOCAL, OPT_GLOBAL and
Bram Moolenaar071d4272004-06-13 20:20:40 +00008695 OPT_MODELINE */
8696{
8697 char_u *errmsg = NULL;
8698 long old_value = *(long *)varp;
8699 long old_Rows = Rows; /* remember old Rows */
8700 long old_Columns = Columns; /* remember old Columns */
8701 long *pp = (long *)varp;
8702
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008703 /* Disallow changing some options from secure mode. */
8704 if ((secure
8705#ifdef HAVE_SANDBOX
8706 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008707#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008708 ) && (options[opt_idx].flags & P_SECURE))
8709 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008710
8711 *pp = value;
8712#ifdef FEAT_EVAL
8713 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008714 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008715#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008716#ifdef FEAT_GUI
8717 need_mouse_correct = TRUE;
8718#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008719
Bram Moolenaar14f24742012-08-08 18:01:05 +02008720 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008721 {
8722 errmsg = e_positive;
8723 curbuf->b_p_sw = curbuf->b_p_ts;
8724 }
8725
8726 /*
8727 * Number options that need some action when changed
8728 */
8729#ifdef FEAT_WINDOWS
8730 if (pp == &p_wh || pp == &p_hh)
8731 {
8732 if (p_wh < 1)
8733 {
8734 errmsg = e_positive;
8735 p_wh = 1;
8736 }
8737 if (p_wmh > p_wh)
8738 {
8739 errmsg = e_winheight;
8740 p_wh = p_wmh;
8741 }
8742 if (p_hh < 0)
8743 {
8744 errmsg = e_positive;
8745 p_hh = 0;
8746 }
8747
8748 /* Change window height NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008749 if (!ONE_WINDOW)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008750 {
8751 if (pp == &p_wh && curwin->w_height < p_wh)
8752 win_setheight((int)p_wh);
8753 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8754 win_setheight((int)p_hh);
8755 }
8756 }
8757
8758 /* 'winminheight' */
8759 else if (pp == &p_wmh)
8760 {
8761 if (p_wmh < 0)
8762 {
8763 errmsg = e_positive;
8764 p_wmh = 0;
8765 }
8766 if (p_wmh > p_wh)
8767 {
8768 errmsg = e_winheight;
8769 p_wmh = p_wh;
8770 }
8771 win_setminheight();
8772 }
8773
Bram Moolenaar44a2f922016-03-19 22:11:51 +01008774# ifdef FEAT_WINDOWS
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008775 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008776 {
8777 if (p_wiw < 1)
8778 {
8779 errmsg = e_positive;
8780 p_wiw = 1;
8781 }
8782 if (p_wmw > p_wiw)
8783 {
8784 errmsg = e_winwidth;
8785 p_wiw = p_wmw;
8786 }
8787
8788 /* Change window width NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008789 if (!ONE_WINDOW && curwin->w_width < p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008790 win_setwidth((int)p_wiw);
8791 }
8792
8793 /* 'winminwidth' */
8794 else if (pp == &p_wmw)
8795 {
8796 if (p_wmw < 0)
8797 {
8798 errmsg = e_positive;
8799 p_wmw = 0;
8800 }
8801 if (p_wmw > p_wiw)
8802 {
8803 errmsg = e_winwidth;
8804 p_wmw = p_wiw;
8805 }
8806 win_setminheight();
8807 }
8808# endif
8809
8810#endif
8811
8812#ifdef FEAT_WINDOWS
8813 /* (re)set last window status line */
8814 else if (pp == &p_ls)
8815 {
8816 last_status(FALSE);
8817 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008818
8819 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008820 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008821 {
8822 shell_new_rows(); /* recompute window positions and heights */
8823 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008824#endif
8825
8826#ifdef FEAT_GUI
8827 else if (pp == &p_linespace)
8828 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008829 /* Recompute gui.char_height and resize the Vim window to keep the
8830 * same number of lines. */
8831 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008832 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008833 }
8834#endif
8835
8836#ifdef FEAT_FOLDING
8837 /* 'foldlevel' */
8838 else if (pp == &curwin->w_p_fdl)
8839 {
8840 if (curwin->w_p_fdl < 0)
8841 curwin->w_p_fdl = 0;
8842 newFoldLevel();
8843 }
8844
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008845 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008846 else if (pp == &curwin->w_p_fml)
8847 {
8848 foldUpdateAll(curwin);
8849 }
8850
8851 /* 'foldnestmax' */
8852 else if (pp == &curwin->w_p_fdn)
8853 {
8854 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8855 foldUpdateAll(curwin);
8856 }
8857
8858 /* 'foldcolumn' */
8859 else if (pp == &curwin->w_p_fdc)
8860 {
8861 if (curwin->w_p_fdc < 0)
8862 {
8863 errmsg = e_positive;
8864 curwin->w_p_fdc = 0;
8865 }
8866 else if (curwin->w_p_fdc > 12)
8867 {
8868 errmsg = e_invarg;
8869 curwin->w_p_fdc = 12;
8870 }
8871 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008872#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008873
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008874#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008875 /* 'shiftwidth' or 'tabstop' */
8876 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8877 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008878# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008879 if (foldmethodIsIndent(curwin))
8880 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008881# endif
8882# ifdef FEAT_CINDENT
8883 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8884 * parse 'cinoptions'. */
8885 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8886 parse_cino(curbuf);
8887# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008888 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008889#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008890
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008891#ifdef FEAT_MBYTE
8892 /* 'maxcombine' */
8893 else if (pp == &p_mco)
8894 {
8895 if (p_mco > MAX_MCO)
8896 p_mco = MAX_MCO;
8897 else if (p_mco < 0)
8898 p_mco = 0;
8899 screenclear(); /* will re-allocate the screen */
8900 }
8901#endif
8902
Bram Moolenaar071d4272004-06-13 20:20:40 +00008903 else if (pp == &curbuf->b_p_iminsert)
8904 {
8905 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8906 {
8907 errmsg = e_invarg;
8908 curbuf->b_p_iminsert = B_IMODE_NONE;
8909 }
8910 p_iminsert = curbuf->b_p_iminsert;
8911 if (termcap_active) /* don't do this in the alternate screen */
8912 showmode();
8913#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8914 /* Show/unshow value of 'keymap' in status lines. */
8915 status_redraw_curbuf();
8916#endif
8917 }
8918
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008919 else if (pp == &p_window)
8920 {
8921 if (p_window < 1)
8922 p_window = 1;
8923 else if (p_window >= Rows)
8924 p_window = Rows - 1;
8925 }
8926
Bram Moolenaar071d4272004-06-13 20:20:40 +00008927 else if (pp == &curbuf->b_p_imsearch)
8928 {
8929 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8930 {
8931 errmsg = e_invarg;
8932 curbuf->b_p_imsearch = B_IMODE_NONE;
8933 }
8934 p_imsearch = curbuf->b_p_imsearch;
8935 }
8936
8937#ifdef FEAT_TITLE
8938 /* if 'titlelen' has changed, redraw the title */
8939 else if (pp == &p_titlelen)
8940 {
8941 if (p_titlelen < 0)
8942 {
8943 errmsg = e_positive;
8944 p_titlelen = 85;
8945 }
8946 if (starting != NO_SCREEN && old_value != p_titlelen)
8947 need_maketitle = TRUE;
8948 }
8949#endif
8950
8951 /* if p_ch changed value, change the command line height */
8952 else if (pp == &p_ch)
8953 {
8954 if (p_ch < 1)
8955 {
8956 errmsg = e_positive;
8957 p_ch = 1;
8958 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008959 if (p_ch > Rows - min_rows() + 1)
8960 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008961
8962 /* Only compute the new window layout when startup has been
8963 * completed. Otherwise the frame sizes may be wrong. */
8964 if (p_ch != old_value && full_screen
8965#ifdef FEAT_GUI
8966 && !gui.starting
8967#endif
8968 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008969 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008970 }
8971
8972 /* when 'updatecount' changes from zero to non-zero, open swap files */
8973 else if (pp == &p_uc)
8974 {
8975 if (p_uc < 0)
8976 {
8977 errmsg = e_positive;
8978 p_uc = 100;
8979 }
8980 if (p_uc && !old_value)
8981 ml_open_files();
8982 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008983#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008984 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008985 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008986 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008987 {
8988 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008989 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008990 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008991 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008992 {
8993 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008994 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008995 }
8996 }
8997#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008998#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008999 else if (pp == &p_mzq)
9000 mzvim_reset_timer();
9001#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009002
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +01009003#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
9004 /* 'pyxversion' */
9005 else if (pp == &p_pyx)
9006 {
9007 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3)
9008 errmsg = e_invarg;
9009 }
9010#endif
9011
Bram Moolenaar071d4272004-06-13 20:20:40 +00009012 /* sync undo before 'undolevels' changes */
9013 else if (pp == &p_ul)
9014 {
9015 /* use the old value, otherwise u_sync() may not work properly */
9016 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00009017 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009018 p_ul = value;
9019 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01009020 else if (pp == &curbuf->b_p_ul)
9021 {
9022 /* use the old value, otherwise u_sync() may not work properly */
9023 curbuf->b_p_ul = old_value;
9024 u_sync(TRUE);
9025 curbuf->b_p_ul = value;
9026 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009027
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009028#ifdef FEAT_LINEBREAK
9029 /* 'numberwidth' must be positive */
9030 else if (pp == &curwin->w_p_nuw)
9031 {
9032 if (curwin->w_p_nuw < 1)
9033 {
9034 errmsg = e_positive;
9035 curwin->w_p_nuw = 1;
9036 }
9037 if (curwin->w_p_nuw > 10)
9038 {
9039 errmsg = e_invarg;
9040 curwin->w_p_nuw = 10;
9041 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02009042 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009043 }
9044#endif
9045
Bram Moolenaar1a384422010-07-14 19:53:30 +02009046 else if (pp == &curbuf->b_p_tw)
9047 {
9048 if (curbuf->b_p_tw < 0)
9049 {
9050 errmsg = e_positive;
9051 curbuf->b_p_tw = 0;
9052 }
9053#ifdef FEAT_SYN_HL
9054# ifdef FEAT_WINDOWS
9055 {
9056 win_T *wp;
9057 tabpage_T *tp;
9058
9059 FOR_ALL_TAB_WINDOWS(tp, wp)
9060 check_colorcolumn(wp);
9061 }
9062# else
9063 check_colorcolumn(curwin);
9064# endif
9065#endif
9066 }
9067
Bram Moolenaar071d4272004-06-13 20:20:40 +00009068 /*
9069 * Check the bounds for numeric options here
9070 */
9071 if (Rows < min_rows() && full_screen)
9072 {
9073 if (errbuf != NULL)
9074 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00009075 vim_snprintf((char *)errbuf, errbuflen,
9076 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00009077 errmsg = errbuf;
9078 }
9079 Rows = min_rows();
9080 }
9081 if (Columns < MIN_COLUMNS && full_screen)
9082 {
9083 if (errbuf != NULL)
9084 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00009085 vim_snprintf((char *)errbuf, errbuflen,
9086 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009087 errmsg = errbuf;
9088 }
9089 Columns = MIN_COLUMNS;
9090 }
Bram Moolenaare057d402013-06-30 17:51:51 +02009091 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00009092
Bram Moolenaar071d4272004-06-13 20:20:40 +00009093 /*
9094 * If the screen (shell) height has been changed, assume it is the
9095 * physical screenheight.
9096 */
9097 if (old_Rows != Rows || old_Columns != Columns)
9098 {
9099 /* Changing the screen size is not allowed while updating the screen. */
9100 if (updating_screen)
9101 *pp = old_value;
9102 else if (full_screen
9103#ifdef FEAT_GUI
9104 && !gui.starting
9105#endif
9106 )
9107 set_shellsize((int)Columns, (int)Rows, TRUE);
9108 else
9109 {
9110 /* Postpone the resizing; check the size and cmdline position for
9111 * messages. */
9112 check_shellsize();
9113 if (cmdline_row > Rows - p_ch && Rows > p_ch)
9114 cmdline_row = Rows - p_ch;
9115 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00009116 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00009117 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009118 }
9119
Bram Moolenaar071d4272004-06-13 20:20:40 +00009120 if (curbuf->b_p_ts <= 0)
9121 {
9122 errmsg = e_positive;
9123 curbuf->b_p_ts = 8;
9124 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009125 if (p_tm < 0)
9126 {
9127 errmsg = e_positive;
9128 p_tm = 0;
9129 }
9130 if ((curwin->w_p_scr <= 0
9131 || (curwin->w_p_scr > curwin->w_height
9132 && curwin->w_height > 0))
9133 && full_screen)
9134 {
9135 if (pp == &(curwin->w_p_scr))
9136 {
9137 if (curwin->w_p_scr != 0)
9138 errmsg = e_scroll;
9139 win_comp_scroll(curwin);
9140 }
9141 /* If 'scroll' became invalid because of a side effect silently adjust
9142 * it. */
9143 else if (curwin->w_p_scr <= 0)
9144 curwin->w_p_scr = 1;
9145 else /* curwin->w_p_scr > curwin->w_height */
9146 curwin->w_p_scr = curwin->w_height;
9147 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00009148 if (p_hi < 0)
9149 {
9150 errmsg = e_positive;
9151 p_hi = 0;
9152 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02009153 else if (p_hi > 10000)
9154 {
9155 errmsg = e_invarg;
9156 p_hi = 10000;
9157 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02009158 if (p_re < 0 || p_re > 2)
9159 {
9160 errmsg = e_invarg;
9161 p_re = 0;
9162 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009163 if (p_report < 0)
9164 {
9165 errmsg = e_positive;
9166 p_report = 1;
9167 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00009168 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009169 {
9170 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
9171 p_sj = Rows / 2;
9172 else
9173 {
9174 errmsg = e_scroll;
9175 p_sj = 1;
9176 }
9177 }
9178 if (p_so < 0 && full_screen)
9179 {
9180 errmsg = e_scroll;
9181 p_so = 0;
9182 }
9183 if (p_siso < 0 && full_screen)
9184 {
9185 errmsg = e_positive;
9186 p_siso = 0;
9187 }
9188#ifdef FEAT_CMDWIN
9189 if (p_cwh < 1)
9190 {
9191 errmsg = e_positive;
9192 p_cwh = 1;
9193 }
9194#endif
9195 if (p_ut < 0)
9196 {
9197 errmsg = e_positive;
9198 p_ut = 2000;
9199 }
9200 if (p_ss < 0)
9201 {
9202 errmsg = e_positive;
9203 p_ss = 0;
9204 }
9205
9206 /* May set global value for local option. */
9207 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
9208 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
9209
9210 options[opt_idx].flags |= P_WAS_SET;
9211
Bram Moolenaar53744302015-07-17 17:38:22 +02009212#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
9213 if (!starting && errmsg == NULL)
9214 {
9215 char_u buf_old[11], buf_new[11], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02009216 vim_snprintf((char *)buf_old, 10, "%ld", old_value);
9217 vim_snprintf((char *)buf_new, 10, "%ld", value);
9218 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02009219 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
9220 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
9221 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
9222 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
9223 reset_v_option_vars();
9224 }
9225#endif
9226
Bram Moolenaar071d4272004-06-13 20:20:40 +00009227 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02009228 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01009229 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02009230 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009231 check_redraw(options[opt_idx].flags);
9232
9233 return errmsg;
9234}
9235
9236/*
9237 * Called after an option changed: check if something needs to be redrawn.
9238 */
9239 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009240check_redraw(long_u flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009241{
9242 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009243 int doclear = (flags & P_RCLR) == P_RCLR;
9244 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009245
9246#ifdef FEAT_WINDOWS
9247 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
9248 status_redraw_all();
9249#endif
9250
9251 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
9252 changed_window_setting();
9253 if (flags & P_RBUF)
9254 redraw_curbuf_later(NOT_VALID);
Bram Moolenaara2477fd2016-12-03 15:13:20 +01009255 if (flags & P_RWINONLY)
9256 redraw_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009257 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009258 redraw_all_later(CLEAR);
9259 else if (all)
9260 redraw_all_later(NOT_VALID);
9261}
9262
9263/*
9264 * Find index for option 'arg'.
9265 * Return -1 if not found.
9266 */
9267 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009268findoption(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009269{
9270 int opt_idx;
9271 char *s, *p;
9272 static short quick_tab[27] = {0, 0}; /* quick access table */
9273 int is_term_opt;
9274
9275 /*
9276 * For first call: Initialize the quick-access table.
9277 * It contains the index for the first option that starts with a certain
9278 * letter. There are 26 letters, plus the first "t_" option.
9279 */
9280 if (quick_tab[1] == 0)
9281 {
9282 p = options[0].fullname;
9283 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9284 {
9285 if (s[0] != p[0])
9286 {
9287 if (s[0] == 't' && s[1] == '_')
9288 quick_tab[26] = opt_idx;
9289 else
9290 quick_tab[CharOrdLow(s[0])] = opt_idx;
9291 }
9292 p = s;
9293 }
9294 }
9295
9296 /*
9297 * Check for name starting with an illegal character.
9298 */
9299#ifdef EBCDIC
9300 if (!islower(arg[0]))
9301#else
9302 if (arg[0] < 'a' || arg[0] > 'z')
9303#endif
9304 return -1;
9305
9306 is_term_opt = (arg[0] == 't' && arg[1] == '_');
9307 if (is_term_opt)
9308 opt_idx = quick_tab[26];
9309 else
9310 opt_idx = quick_tab[CharOrdLow(arg[0])];
9311 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9312 {
9313 if (STRCMP(arg, s) == 0) /* match full name */
9314 break;
9315 }
9316 if (s == NULL && !is_term_opt)
9317 {
9318 opt_idx = quick_tab[CharOrdLow(arg[0])];
9319 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
9320 {
9321 s = options[opt_idx].shortname;
9322 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
9323 break;
9324 s = NULL;
9325 }
9326 }
9327 if (s == NULL)
9328 opt_idx = -1;
9329 return opt_idx;
9330}
9331
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009332#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009333/*
9334 * Get the value for an option.
9335 *
9336 * Returns:
9337 * Number or Toggle option: 1, *numval gets value.
9338 * String option: 0, *stringval gets allocated string.
9339 * Hidden Number or Toggle option: -1.
9340 * hidden String option: -2.
9341 * unknown option: -3.
9342 */
9343 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009344get_option_value(
9345 char_u *name,
9346 long *numval,
9347 char_u **stringval, /* NULL when only checking existence */
9348 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009349{
9350 int opt_idx;
9351 char_u *varp;
9352
9353 opt_idx = findoption(name);
9354 if (opt_idx < 0) /* unknown option */
Bram Moolenaare353c402017-02-04 19:49:16 +01009355 {
9356 int key;
9357
9358 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
9359 && (key = find_key_option(name)) != 0)
9360 {
9361 char_u key_name[2];
9362 char_u *p;
9363
9364 if (key < 0)
9365 {
9366 key_name[0] = KEY2TERMCAP0(key);
9367 key_name[1] = KEY2TERMCAP1(key);
9368 }
9369 else
9370 {
9371 key_name[0] = KS_KEY;
9372 key_name[1] = (key & 0xff);
9373 }
9374 p = find_termcode(key_name);
9375 if (p != NULL)
9376 {
9377 if (stringval != NULL)
9378 *stringval = vim_strsave(p);
9379 return 0;
9380 }
9381 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009382 return -3;
Bram Moolenaare353c402017-02-04 19:49:16 +01009383 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009384
9385 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
9386
9387 if (options[opt_idx].flags & P_STRING)
9388 {
9389 if (varp == NULL) /* hidden option */
9390 return -2;
9391 if (stringval != NULL)
9392 {
9393#ifdef FEAT_CRYPT
9394 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00009395 if ((char_u **)varp == &curbuf->b_p_key
9396 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009397 *stringval = vim_strsave((char_u *)"*****");
9398 else
9399#endif
9400 *stringval = vim_strsave(*(char_u **)(varp));
9401 }
9402 return 0;
9403 }
9404
9405 if (varp == NULL) /* hidden option */
9406 return -1;
9407 if (options[opt_idx].flags & P_NUM)
9408 *numval = *(long *)varp;
9409 else
9410 {
9411 /* Special case: 'modified' is b_changed, but we also want to consider
9412 * it set when 'ff' or 'fenc' changed. */
9413 if ((int *)varp == &curbuf->b_changed)
9414 *numval = curbufIsChanged();
9415 else
Bram Moolenaar2acfbed2016-07-01 23:14:02 +02009416 *numval = (long) *(int *)varp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009417 }
9418 return 1;
9419}
9420#endif
9421
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009422#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009423/*
9424 * Returns the option attributes and its value. Unlike the above function it
9425 * will return either global value or local value of the option depending on
9426 * what was requested, but it will never return global value if it was
9427 * requested to return local one and vice versa. Neither it will return
9428 * buffer-local value if it was requested to return window-local one.
9429 *
9430 * Pretends that option is absent if it is not present in the requested scope
9431 * (i.e. has no global, window-local or buffer-local value depending on
9432 * opt_type). Uses
9433 *
9434 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009435 * 0 hidden or unknown option, also option that does not have requested
9436 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009437 * see SOPT_* in vim.h for other flags
9438 *
9439 * Possible opt_type values: see SREQ_* in vim.h
9440 */
9441 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009442get_option_value_strict(
9443 char_u *name,
9444 long *numval,
9445 char_u **stringval, /* NULL when only obtaining attributes */
9446 int opt_type,
9447 void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009448{
9449 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009450 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009451 struct vimoption *p;
9452 int r = 0;
9453
9454 opt_idx = findoption(name);
9455 if (opt_idx < 0)
9456 return 0;
9457
9458 p = &(options[opt_idx]);
9459
9460 /* Hidden option */
9461 if (p->var == NULL)
9462 return 0;
9463
9464 if (p->flags & P_BOOL)
9465 r |= SOPT_BOOL;
9466 else if (p->flags & P_NUM)
9467 r |= SOPT_NUM;
9468 else if (p->flags & P_STRING)
9469 r |= SOPT_STRING;
9470
9471 if (p->indir == PV_NONE)
9472 {
9473 if (opt_type == SREQ_GLOBAL)
9474 r |= SOPT_GLOBAL;
9475 else
9476 return 0; /* Did not request global-only option */
9477 }
9478 else
9479 {
9480 if (p->indir & PV_BOTH)
9481 r |= SOPT_GLOBAL;
9482 else if (opt_type == SREQ_GLOBAL)
9483 return 0; /* Requested global option */
9484
9485 if (p->indir & PV_WIN)
9486 {
9487 if (opt_type == SREQ_BUF)
9488 return 0; /* Did not request window-local option */
9489 else
9490 r |= SOPT_WIN;
9491 }
9492 else if (p->indir & PV_BUF)
9493 {
9494 if (opt_type == SREQ_WIN)
9495 return 0; /* Did not request buffer-local option */
9496 else
9497 r |= SOPT_BUF;
9498 }
9499 }
9500
9501 if (stringval == NULL)
9502 return r;
9503
9504 if (opt_type == SREQ_GLOBAL)
9505 varp = p->var;
9506 else
9507 {
9508 if (opt_type == SREQ_BUF)
9509 {
9510 /* Special case: 'modified' is b_changed, but we also want to
9511 * consider it set when 'ff' or 'fenc' changed. */
9512 if (p->indir == PV_MOD)
9513 {
9514 *numval = bufIsChanged((buf_T *) from);
9515 varp = NULL;
9516 }
9517#ifdef FEAT_CRYPT
9518 else if (p->indir == PV_KEY)
9519 {
9520 /* never return the value of the crypt key */
9521 *stringval = NULL;
9522 varp = NULL;
9523 }
9524#endif
9525 else
9526 {
9527 aco_save_T aco;
9528 aucmd_prepbuf(&aco, (buf_T *) from);
9529 varp = get_varp(p);
9530 aucmd_restbuf(&aco);
9531 }
9532 }
9533 else if (opt_type == SREQ_WIN)
9534 {
9535 win_T *save_curwin;
9536 save_curwin = curwin;
9537 curwin = (win_T *) from;
9538 curbuf = curwin->w_buffer;
9539 varp = get_varp(p);
9540 curwin = save_curwin;
9541 curbuf = curwin->w_buffer;
9542 }
9543 if (varp == p->var)
9544 return (r | SOPT_UNSET);
9545 }
9546
9547 if (varp != NULL)
9548 {
9549 if (p->flags & P_STRING)
9550 *stringval = vim_strsave(*(char_u **)(varp));
9551 else if (p->flags & P_NUM)
9552 *numval = *(long *) varp;
9553 else
9554 *numval = *(int *)varp;
9555 }
9556
9557 return r;
9558}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009559
9560/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009561 * Iterate over options. First argument is a pointer to a pointer to a
9562 * structure inside options[] array, second is option type like in the above
9563 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009564 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009565 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009566 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009567 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009568 * first argument to NULL.
9569 *
9570 * Returns full option name for current option on each call.
9571 */
9572 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009573option_iter_next(void **option, int opt_type)
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009574{
9575 struct vimoption *ret = NULL;
9576 do
9577 {
9578 if (*option == NULL)
9579 *option = (void *) options;
9580 else if (((struct vimoption *) (*option))->fullname == NULL)
9581 {
9582 *option = NULL;
9583 return NULL;
9584 }
9585 else
9586 *option = (void *) (((struct vimoption *) (*option)) + 1);
9587
9588 ret = ((struct vimoption *) (*option));
9589
9590 /* Hidden option */
9591 if (ret->var == NULL)
9592 {
9593 ret = NULL;
9594 continue;
9595 }
9596
9597 switch (opt_type)
9598 {
9599 case SREQ_GLOBAL:
9600 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9601 ret = NULL;
9602 break;
9603 case SREQ_BUF:
9604 if (!(ret->indir & PV_BUF))
9605 ret = NULL;
9606 break;
9607 case SREQ_WIN:
9608 if (!(ret->indir & PV_WIN))
9609 ret = NULL;
9610 break;
9611 default:
Bram Moolenaar95f09602016-11-10 20:01:45 +01009612 internal_error("option_iter_next()");
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009613 return NULL;
9614 }
9615 }
9616 while (ret == NULL);
9617
9618 return (char_u *)ret->fullname;
9619}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009620#endif
9621
Bram Moolenaar071d4272004-06-13 20:20:40 +00009622/*
9623 * Set the value of option "name".
9624 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009625 *
9626 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009627 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009628 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009629set_option_value(
9630 char_u *name,
9631 long number,
9632 char_u *string,
9633 int opt_flags) /* OPT_LOCAL or 0 (both) */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009634{
9635 int opt_idx;
9636 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009637 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009638
9639 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009640 if (opt_idx < 0)
Bram Moolenaare353c402017-02-04 19:49:16 +01009641 {
9642 int key;
9643
9644 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
9645 && (key = find_key_option(name)) != 0)
9646 {
9647 char_u key_name[2];
9648
9649 if (key < 0)
9650 {
9651 key_name[0] = KEY2TERMCAP0(key);
9652 key_name[1] = KEY2TERMCAP1(key);
9653 }
9654 else
9655 {
9656 key_name[0] = KS_KEY;
9657 key_name[1] = (key & 0xff);
9658 }
9659 add_termcode(key_name, string, FALSE);
9660 if (full_screen)
9661 ttest(FALSE);
9662 redraw_all_later(CLEAR);
9663 return NULL;
9664 }
9665
Bram Moolenaar071d4272004-06-13 20:20:40 +00009666 EMSG2(_("E355: Unknown option: %s"), name);
Bram Moolenaare353c402017-02-04 19:49:16 +01009667 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009668 else
9669 {
9670 flags = options[opt_idx].flags;
9671#ifdef HAVE_SANDBOX
9672 /* Disallow changing some options in the sandbox */
9673 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009674 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009675 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009676 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009677 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009678#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009679 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009680 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009681 else
9682 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009683 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009684 if (varp != NULL) /* hidden option is not changed */
9685 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009686 if (number == 0 && string != NULL)
9687 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009688 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009689
9690 /* Either we are given a string or we are setting option
9691 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009692 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009693 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009694 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009695 {
9696 /* There's another character after zeros or the string
9697 * is empty. In both cases, we are trying to set a
9698 * num option using a string. */
9699 EMSG3(_("E521: Number required: &%s = '%s'"),
9700 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009701 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009702
9703 }
9704 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009705 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009706 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009707 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009708 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009709 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009710 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009711 }
9712 }
9713 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009714 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009715}
9716
9717/*
9718 * Get the terminal code for a terminal option.
9719 * Returns NULL when not found.
9720 */
9721 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009722get_term_code(char_u *tname)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009723{
9724 int opt_idx;
9725 char_u *varp;
9726
9727 if (tname[0] != 't' || tname[1] != '_' ||
9728 tname[2] == NUL || tname[3] == NUL)
9729 return NULL;
9730 if ((opt_idx = findoption(tname)) >= 0)
9731 {
9732 varp = get_varp(&(options[opt_idx]));
9733 if (varp != NULL)
9734 varp = *(char_u **)(varp);
9735 return varp;
9736 }
9737 return find_termcode(tname + 2);
9738}
9739
9740 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009741get_highlight_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009742{
9743 int i;
9744
9745 i = findoption((char_u *)"hl");
9746 if (i >= 0)
9747 return options[i].def_val[VI_DEFAULT];
9748 return (char_u *)NULL;
9749}
9750
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009751#if defined(FEAT_MBYTE) || defined(PROTO)
9752 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009753get_encoding_default(void)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009754{
9755 int i;
9756
9757 i = findoption((char_u *)"enc");
9758 if (i >= 0)
9759 return options[i].def_val[VI_DEFAULT];
9760 return (char_u *)NULL;
9761}
9762#endif
9763
Bram Moolenaar071d4272004-06-13 20:20:40 +00009764/*
9765 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9766 */
9767 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009768find_key_option(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009769{
9770 int key;
9771 int modifiers;
9772
9773 /*
9774 * Don't use get_special_key_code() for t_xx, we don't want it to call
9775 * add_termcap_entry().
9776 */
9777 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9778 key = TERMCAP2KEY(arg[2], arg[3]);
9779 else
9780 {
9781 --arg; /* put arg at the '<' */
9782 modifiers = 0;
Bram Moolenaar35a4cfa2016-08-14 16:07:48 +02009783 key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009784 if (modifiers) /* can't handle modifiers here */
9785 key = 0;
9786 }
9787 return key;
9788}
9789
9790/*
9791 * if 'all' == 0: show changed options
9792 * if 'all' == 1: show all normal options
9793 * if 'all' == 2: show all terminal options
9794 */
9795 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009796showoptions(
9797 int all,
9798 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009799{
9800 struct vimoption *p;
9801 int col;
9802 int isterm;
9803 char_u *varp;
9804 struct vimoption **items;
9805 int item_count;
9806 int run;
9807 int row, rows;
9808 int cols;
9809 int i;
9810 int len;
9811
9812#define INC 20
9813#define GAP 3
9814
9815 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9816 PARAM_COUNT));
9817 if (items == NULL)
9818 return;
9819
9820 /* Highlight title */
9821 if (all == 2)
9822 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9823 else if (opt_flags & OPT_GLOBAL)
9824 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9825 else if (opt_flags & OPT_LOCAL)
9826 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9827 else
9828 MSG_PUTS_TITLE(_("\n--- Options ---"));
9829
9830 /*
9831 * do the loop two times:
9832 * 1. display the short items
9833 * 2. display the long items (only strings and numbers)
9834 */
9835 for (run = 1; run <= 2 && !got_int; ++run)
9836 {
9837 /*
9838 * collect the items in items[]
9839 */
9840 item_count = 0;
9841 for (p = &options[0]; p->fullname != NULL; p++)
9842 {
9843 varp = NULL;
9844 isterm = istermoption(p);
9845 if (opt_flags != 0)
9846 {
9847 if (p->indir != PV_NONE && !isterm)
9848 varp = get_varp_scope(p, opt_flags);
9849 }
9850 else
9851 varp = get_varp(p);
9852 if (varp != NULL
9853 && ((all == 2 && isterm)
9854 || (all == 1 && !isterm)
9855 || (all == 0 && !optval_default(p, varp))))
9856 {
9857 if (p->flags & P_BOOL)
9858 len = 1; /* a toggle option fits always */
9859 else
9860 {
9861 option_value2string(p, opt_flags);
9862 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9863 }
9864 if ((len <= INC - GAP && run == 1) ||
9865 (len > INC - GAP && run == 2))
9866 items[item_count++] = p;
9867 }
9868 }
9869
9870 /*
9871 * display the items
9872 */
9873 if (run == 1)
9874 {
9875 cols = (Columns + GAP - 3) / INC;
9876 if (cols == 0)
9877 cols = 1;
9878 rows = (item_count + cols - 1) / cols;
9879 }
9880 else /* run == 2 */
9881 rows = item_count;
9882 for (row = 0; row < rows && !got_int; ++row)
9883 {
9884 msg_putchar('\n'); /* go to next line */
9885 if (got_int) /* 'q' typed in more */
9886 break;
9887 col = 0;
9888 for (i = row; i < item_count; i += rows)
9889 {
9890 msg_col = col; /* make columns */
9891 showoneopt(items[i], opt_flags);
9892 col += INC;
9893 }
9894 out_flush();
9895 ui_breakcheck();
9896 }
9897 }
9898 vim_free(items);
9899}
9900
9901/*
9902 * Return TRUE if option "p" has its default value.
9903 */
9904 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009905optval_default(struct vimoption *p, char_u *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009906{
9907 int dvi;
9908
9909 if (varp == NULL)
9910 return TRUE; /* hidden option is always at default */
9911 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9912 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009913 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009914 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009915 /* the cast to long is required for Manx C, long_i is
9916 * needed for MSVC */
9917 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009918 /* P_STRING */
9919 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9920}
9921
9922/*
9923 * showoneopt: show the value of one option
9924 * must not be called with a hidden option!
9925 */
9926 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009927showoneopt(
9928 struct vimoption *p,
9929 int opt_flags) /* OPT_LOCAL or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009930{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009931 char_u *varp;
9932 int save_silent = silent_mode;
9933
9934 silent_mode = FALSE;
9935 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009936
9937 varp = get_varp_scope(p, opt_flags);
9938
9939 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9940 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9941 ? !curbufIsChanged() : !*(int *)varp))
9942 MSG_PUTS("no");
9943 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9944 MSG_PUTS("--");
9945 else
9946 MSG_PUTS(" ");
9947 MSG_PUTS(p->fullname);
9948 if (!(p->flags & P_BOOL))
9949 {
9950 msg_putchar('=');
9951 /* put value string in NameBuff */
9952 option_value2string(p, opt_flags);
9953 msg_outtrans(NameBuff);
9954 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009955
9956 silent_mode = save_silent;
9957 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009958}
9959
9960/*
9961 * Write modified options as ":set" commands to a file.
9962 *
9963 * There are three values for "opt_flags":
9964 * OPT_GLOBAL: Write global option values and fresh values of
9965 * buffer-local options (used for start of a session
9966 * file).
9967 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
9968 * curwin (used for a vimrc file).
9969 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
9970 * and local values for window-local options of
9971 * curwin. Local values are also written when at the
9972 * default value, because a modeline or autocommand
9973 * may have set them when doing ":edit file" and the
9974 * user has set them back at the default or fresh
9975 * value.
9976 * When "local_only" is TRUE, don't write fresh
9977 * values, only local values (for ":mkview").
9978 * (fresh value = value used for a new buffer or window for a local option).
9979 *
9980 * Return FAIL on error, OK otherwise.
9981 */
9982 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009983makeset(FILE *fd, int opt_flags, int local_only)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009984{
9985 struct vimoption *p;
9986 char_u *varp; /* currently used value */
9987 char_u *varp_fresh; /* local value */
9988 char_u *varp_local = NULL; /* fresh value */
9989 char *cmd;
9990 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009991 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009992
9993 /*
9994 * The options that don't have a default (terminal name, columns, lines)
9995 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009996 * Do the loop over "options[]" twice: once for options with the
9997 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009998 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009999 for (pri = 1; pri >= 0; --pri)
10000 {
10001 for (p = &options[0]; !istermoption(p); p++)
10002 if (!(p->flags & P_NO_MKRC)
10003 && !istermoption(p)
10004 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010005 {
10006 /* skip global option when only doing locals */
10007 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
10008 continue;
10009
10010 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
10011 * file, they are always buffer-specific. */
10012 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
10013 continue;
10014
10015 /* Global values are only written when not at the default value. */
10016 varp = get_varp_scope(p, opt_flags);
10017 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
10018 continue;
10019
10020 round = 2;
10021 if (p->indir != PV_NONE)
10022 {
10023 if (p->var == VAR_WIN)
10024 {
10025 /* skip window-local option when only doing globals */
10026 if (!(opt_flags & OPT_LOCAL))
10027 continue;
10028 /* When fresh value of window-local option is not at the
10029 * default, need to write it too. */
10030 if (!(opt_flags & OPT_GLOBAL) && !local_only)
10031 {
10032 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
10033 if (!optval_default(p, varp_fresh))
10034 {
10035 round = 1;
10036 varp_local = varp;
10037 varp = varp_fresh;
10038 }
10039 }
10040 }
10041 }
10042
10043 /* Round 1: fresh value for window-local options.
10044 * Round 2: other values */
10045 for ( ; round <= 2; varp = varp_local, ++round)
10046 {
10047 if (round == 1 || (opt_flags & OPT_GLOBAL))
10048 cmd = "set";
10049 else
10050 cmd = "setlocal";
10051
10052 if (p->flags & P_BOOL)
10053 {
10054 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
10055 return FAIL;
10056 }
10057 else if (p->flags & P_NUM)
10058 {
10059 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
10060 return FAIL;
10061 }
10062 else /* P_STRING */
10063 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010064#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
10065 int do_endif = FALSE;
10066
Bram Moolenaar071d4272004-06-13 20:20:40 +000010067 /* Don't set 'syntax' and 'filetype' again if the value is
10068 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010069 if (
10070# if defined(FEAT_SYN_HL)
10071 p->indir == PV_SYN
10072# if defined(FEAT_AUTOCMD)
10073 ||
10074# endif
10075# endif
10076# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +000010077 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010078# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +000010079 )
Bram Moolenaar071d4272004-06-13 20:20:40 +000010080 {
10081 if (fprintf(fd, "if &%s != '%s'", p->fullname,
10082 *(char_u **)(varp)) < 0
10083 || put_eol(fd) < 0)
10084 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010085 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010086 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010087#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010088 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
10089 (p->flags & P_EXPAND) != 0) == FAIL)
10090 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010091#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
10092 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010093 {
10094 if (put_line(fd, "endif") == FAIL)
10095 return FAIL;
10096 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010097#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010098 }
10099 }
10100 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010101 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000010102 return OK;
10103}
10104
10105#if defined(FEAT_FOLDING) || defined(PROTO)
10106/*
10107 * Generate set commands for the local fold options only. Used when
10108 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
10109 */
10110 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010111makefoldset(FILE *fd)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010112{
10113 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
10114# ifdef FEAT_EVAL
10115 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
10116 == FAIL
10117# endif
10118 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
10119 == FAIL
10120 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
10121 == FAIL
10122 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
10123 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
10124 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
10125 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
10126 )
10127 return FAIL;
10128
10129 return OK;
10130}
10131#endif
10132
10133 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010134put_setstring(
10135 FILE *fd,
10136 char *cmd,
10137 char *name,
10138 char_u **valuep,
10139 int expand)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010140{
10141 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +020010142 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010143
10144 if (fprintf(fd, "%s %s=", cmd, name) < 0)
10145 return FAIL;
10146 if (*valuep != NULL)
10147 {
10148 /* Output 'pastetoggle' as key names. For other
10149 * options some characters have to be escaped with
10150 * CTRL-V or backslash */
10151 if (valuep == &p_pt)
10152 {
10153 s = *valuep;
10154 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +000010155 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010156 return FAIL;
10157 }
10158 else if (expand)
10159 {
Bram Moolenaarf8441472011-04-28 17:24:58 +020010160 buf = alloc(MAXPATHL);
10161 if (buf == NULL)
10162 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010163 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
10164 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +020010165 {
10166 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010167 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +020010168 }
10169 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010170 }
10171 else if (put_escstr(fd, *valuep, 2) == FAIL)
10172 return FAIL;
10173 }
10174 if (put_eol(fd) < 0)
10175 return FAIL;
10176 return OK;
10177}
10178
10179 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010180put_setnum(
10181 FILE *fd,
10182 char *cmd,
10183 char *name,
10184 long *valuep)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010185{
10186 long wc;
10187
10188 if (fprintf(fd, "%s %s=", cmd, name) < 0)
10189 return FAIL;
10190 if (wc_use_keyname((char_u *)valuep, &wc))
10191 {
10192 /* print 'wildchar' and 'wildcharm' as a key name */
10193 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
10194 return FAIL;
10195 }
10196 else if (fprintf(fd, "%ld", *valuep) < 0)
10197 return FAIL;
10198 if (put_eol(fd) < 0)
10199 return FAIL;
10200 return OK;
10201}
10202
10203 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010204put_setbool(
10205 FILE *fd,
10206 char *cmd,
10207 char *name,
10208 int value)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010209{
Bram Moolenaar893de922007-10-02 18:40:57 +000010210 if (value < 0) /* global/local option using global value */
10211 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010212 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
10213 || put_eol(fd) < 0)
10214 return FAIL;
10215 return OK;
10216}
10217
10218/*
10219 * Clear all the terminal options.
10220 * If the option has been allocated, free the memory.
10221 * Terminal options are never hidden or indirect.
10222 */
10223 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010224clear_termoptions(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010225{
Bram Moolenaar071d4272004-06-13 20:20:40 +000010226 /*
10227 * Reset a few things before clearing the old options. This may cause
10228 * outputting a few things that the terminal doesn't understand, but the
10229 * screen will be cleared later, so this is OK.
10230 */
10231#ifdef FEAT_MOUSE_TTY
10232 mch_setmouse(FALSE); /* switch mouse off */
10233#endif
10234#ifdef FEAT_TITLE
10235 mch_restore_title(3); /* restore window titles */
10236#endif
10237#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
10238 /* When starting the GUI close the display opened for the clipboard.
10239 * After restoring the title, because that will need the display. */
10240 if (gui.starting)
10241 clear_xterm_clip();
10242#endif
Bram Moolenaarcea912a2016-10-12 14:20:24 +020010243 stoptermcap(); /* stop termcap mode */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010244
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000010245 free_termoptions();
10246}
10247
10248 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010249free_termoptions(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000010250{
10251 struct vimoption *p;
10252
Bram Moolenaar071d4272004-06-13 20:20:40 +000010253 for (p = &options[0]; p->fullname != NULL; p++)
10254 if (istermoption(p))
10255 {
10256 if (p->flags & P_ALLOCED)
10257 free_string_option(*(char_u **)(p->var));
10258 if (p->flags & P_DEF_ALLOCED)
10259 free_string_option(p->def_val[VI_DEFAULT]);
10260 *(char_u **)(p->var) = empty_option;
10261 p->def_val[VI_DEFAULT] = empty_option;
10262 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
10263 }
10264 clear_termcodes();
10265}
10266
10267/*
Bram Moolenaar363cb672009-07-22 12:28:17 +000010268 * Free the string for one term option, if it was allocated.
10269 * Set the string to empty_option and clear allocated flag.
10270 * "var" points to the option value.
10271 */
10272 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010273free_one_termoption(char_u *var)
Bram Moolenaar363cb672009-07-22 12:28:17 +000010274{
10275 struct vimoption *p;
10276
10277 for (p = &options[0]; p->fullname != NULL; p++)
10278 if (p->var == var)
10279 {
10280 if (p->flags & P_ALLOCED)
10281 free_string_option(*(char_u **)(p->var));
10282 *(char_u **)(p->var) = empty_option;
10283 p->flags &= ~P_ALLOCED;
10284 break;
10285 }
10286}
10287
10288/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010289 * Set the terminal option defaults to the current value.
10290 * Used after setting the terminal name.
10291 */
10292 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010293set_term_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010294{
10295 struct vimoption *p;
10296
10297 for (p = &options[0]; p->fullname != NULL; p++)
10298 {
10299 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
10300 {
10301 if (p->flags & P_DEF_ALLOCED)
10302 {
10303 free_string_option(p->def_val[VI_DEFAULT]);
10304 p->flags &= ~P_DEF_ALLOCED;
10305 }
10306 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
10307 if (p->flags & P_ALLOCED)
10308 {
10309 p->flags |= P_DEF_ALLOCED;
10310 p->flags &= ~P_ALLOCED; /* don't free the value now */
10311 }
10312 }
10313 }
10314}
10315
10316/*
10317 * return TRUE if 'p' starts with 't_'
10318 */
10319 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010320istermoption(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010321{
10322 return (p->fullname[0] == 't' && p->fullname[1] == '_');
10323}
10324
10325/*
10326 * Compute columns for ruler and shown command. 'sc_col' is also used to
10327 * decide what the maximum length of a message on the status line can be.
10328 * If there is a status line for the last window, 'sc_col' is independent
10329 * of 'ru_col'.
10330 */
10331
10332#define COL_RULER 17 /* columns needed by standard ruler */
10333
10334 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010335comp_col(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010336{
10337#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
Bram Moolenaar459ca562016-11-10 18:16:33 +010010338 int last_has_status = (p_ls == 2 || (p_ls == 1 && !ONE_WINDOW));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010339
10340 sc_col = 0;
10341 ru_col = 0;
10342 if (p_ru)
10343 {
10344#ifdef FEAT_STL_OPT
10345 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
10346#else
10347 ru_col = COL_RULER + 1;
10348#endif
10349 /* no last status line, adjust sc_col */
10350 if (!last_has_status)
10351 sc_col = ru_col;
10352 }
10353 if (p_sc)
10354 {
10355 sc_col += SHOWCMD_COLS;
10356 if (!p_ru || last_has_status) /* no need for separating space */
10357 ++sc_col;
10358 }
10359 sc_col = Columns - sc_col;
10360 ru_col = Columns - ru_col;
10361 if (sc_col <= 0) /* screen too narrow, will become a mess */
10362 sc_col = 1;
10363 if (ru_col <= 0)
10364 ru_col = 1;
10365#else
10366 sc_col = Columns;
10367 ru_col = Columns;
10368#endif
10369}
10370
10371/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010372 * Unset local option value, similar to ":set opt<".
10373 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010374 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010375unset_global_local_option(char_u *name, void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010376{
10377 struct vimoption *p;
10378 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010379 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010380
10381 opt_idx = findoption(name);
Bram Moolenaarbd8539a2015-08-11 18:53:03 +020010382 if (opt_idx < 0)
10383 return;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010384 p = &(options[opt_idx]);
10385
10386 switch ((int)p->indir)
10387 {
10388 /* global option with local value: use local value if it's been set */
10389 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010390 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010391 break;
10392 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010393 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010394 break;
10395 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010396 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010397 break;
10398 case PV_AR:
10399 buf->b_p_ar = -1;
10400 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010401 case PV_BKC:
10402 clear_string_option(&buf->b_p_bkc);
10403 buf->b_bkc_flags = 0;
10404 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010405 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010406 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010407 break;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010408 case PV_TC:
10409 clear_string_option(&buf->b_p_tc);
10410 buf->b_tc_flags = 0;
10411 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010412#ifdef FEAT_FIND_ID
10413 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010414 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010415 break;
10416 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010417 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010418 break;
10419#endif
10420#ifdef FEAT_INS_EXPAND
10421 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010422 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010423 break;
10424 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010425 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010426 break;
10427#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010428 case PV_FP:
10429 clear_string_option(&buf->b_p_fp);
10430 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010431#ifdef FEAT_QUICKFIX
10432 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010433 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010434 break;
10435 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010436 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010437 break;
10438 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010439 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010440 break;
10441#endif
10442#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10443 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010444 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010445 break;
10446#endif
10447#if defined(FEAT_CRYPT)
10448 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010449 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010450 break;
10451#endif
10452#ifdef FEAT_STL_OPT
10453 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010454 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010455 break;
10456#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010457 case PV_UL:
10458 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10459 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010460#ifdef FEAT_LISP
10461 case PV_LW:
10462 clear_string_option(&buf->b_p_lw);
10463 break;
10464#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010465#ifdef FEAT_MBYTE
10466 case PV_MENC:
10467 clear_string_option(&buf->b_p_menc);
10468 break;
10469#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010470 }
10471}
10472
10473/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010474 * Get pointer to option variable, depending on local or global scope.
10475 */
10476 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010477get_varp_scope(struct vimoption *p, int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010478{
10479 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10480 {
10481 if (p->var == VAR_WIN)
10482 return (char_u *)GLOBAL_WO(get_varp(p));
10483 return p->var;
10484 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010485 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010486 {
10487 switch ((int)p->indir)
10488 {
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010489 case PV_FP: return (char_u *)&(curbuf->b_p_fp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010490#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010491 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10492 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10493 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010494#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010495 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10496 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10497 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010498 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010499 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010500 case PV_TC: return (char_u *)&(curbuf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010501#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010502 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10503 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010504#endif
10505#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010506 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10507 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010508#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010509#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10510 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10511#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010512#if defined(FEAT_CRYPT)
10513 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10514#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010515#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010516 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010517#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010518 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010519#ifdef FEAT_LISP
10520 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10521#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010522 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010523#ifdef FEAT_MBYTE
10524 case PV_MENC: return (char_u *)&(curbuf->b_p_menc);
10525#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010526 }
10527 return NULL; /* "cannot happen" */
10528 }
10529 return get_varp(p);
10530}
10531
10532/*
10533 * Get pointer to option variable.
10534 */
10535 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010536get_varp(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010537{
10538 /* hidden option, always return NULL */
10539 if (p->var == NULL)
10540 return NULL;
10541
10542 switch ((int)p->indir)
10543 {
10544 case PV_NONE: return p->var;
10545
10546 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010547 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010548 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010549 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010550 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010551 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010552 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010553 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010554 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010555 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010556 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010557 case PV_TC: return *curbuf->b_p_tc != NUL
10558 ? (char_u *)&(curbuf->b_p_tc) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010559 case PV_BKC: return *curbuf->b_p_bkc != NUL
10560 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010561#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010562 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010563 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010564 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010565 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10566#endif
10567#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010568 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010569 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010570 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010571 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10572#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010573 case PV_FP: return *curbuf->b_p_fp != NUL
10574 ? (char_u *)&(curbuf->b_p_fp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010575#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010576 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010577 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010578 case PV_GP: return *curbuf->b_p_gp != NUL
10579 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10580 case PV_MP: return *curbuf->b_p_mp != NUL
10581 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010582#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010583#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10584 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10585 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10586#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010587#if defined(FEAT_CRYPT)
10588 case PV_CM: return *curbuf->b_p_cm != NUL
10589 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10590#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010591#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010592 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010593 ? (char_u *)&(curwin->w_p_stl) : p->var;
10594#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010595 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10596 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010597#ifdef FEAT_LISP
10598 case PV_LW: return *curbuf->b_p_lw != NUL
10599 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10600#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010601#ifdef FEAT_MBYTE
10602 case PV_MENC: return *curbuf->b_p_menc != NUL
10603 ? (char_u *)&(curbuf->b_p_menc) : p->var;
10604#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010605
10606#ifdef FEAT_ARABIC
10607 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10608#endif
10609 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010610#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010611 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10612#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010613#ifdef FEAT_SYN_HL
10614 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10615 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010616 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010617#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010618#ifdef FEAT_DIFF
10619 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10620#endif
10621#ifdef FEAT_FOLDING
10622 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10623 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10624 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10625 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10626 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10627 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10628 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10629# ifdef FEAT_EVAL
10630 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10631 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10632# endif
10633 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10634#endif
10635 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010636 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010637#ifdef FEAT_LINEBREAK
10638 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10639#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010640#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010641 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010642 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10643#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010644#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10645 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10646#endif
10647#ifdef FEAT_RIGHTLEFT
10648 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10649 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10650#endif
10651 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10652 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10653#ifdef FEAT_LINEBREAK
10654 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010655 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10656 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010657#endif
10658#ifdef FEAT_SCROLLBIND
10659 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10660#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010661#ifdef FEAT_CURSORBIND
10662 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10663#endif
10664#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010665 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10666 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010667#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010668
10669 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10670 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10671#ifdef FEAT_MBYTE
10672 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10673#endif
10674#if defined(FEAT_QUICKFIX)
10675 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10676 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
10677#endif
10678 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10679 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10680#ifdef FEAT_CINDENT
10681 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10682 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10683 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10684#endif
10685#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10686 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10687#endif
10688#ifdef FEAT_COMMENTS
10689 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10690#endif
10691#ifdef FEAT_FOLDING
10692 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10693#endif
10694#ifdef FEAT_INS_EXPAND
10695 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10696#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010697#ifdef FEAT_COMPL_FUNC
10698 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010699 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010700#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010701 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010702 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010703 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10704#ifdef FEAT_MBYTE
10705 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10706#endif
10707 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10708#ifdef FEAT_AUTOCMD
10709 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10710#endif
10711 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010712 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010713 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10714 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10715 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10716 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10717#ifdef FEAT_FIND_ID
10718# ifdef FEAT_EVAL
10719 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10720# endif
10721#endif
10722#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10723 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10724 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10725#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010726#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010727 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10728#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010729#ifdef FEAT_CRYPT
10730 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10731#endif
10732#ifdef FEAT_LISP
10733 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10734#endif
10735 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10736 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10737 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10738 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10739 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010740 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010741#ifdef FEAT_TEXTOBJ
10742 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10743#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010744 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10745#ifdef FEAT_SMARTINDENT
10746 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10747#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010748 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010749 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10750#ifdef FEAT_SEARCHPATH
10751 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10752#endif
10753 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10754#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010755 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010756 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10757#endif
10758#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010759 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10760 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10761 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010762#endif
10763 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10764 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10765 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10766 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010767#ifdef FEAT_PERSISTENT_UNDO
10768 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10769#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010770 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10771#ifdef FEAT_KEYMAP
10772 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10773#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010774#ifdef FEAT_SIGNS
10775 case PV_SCL: return (char_u *)&(curwin->w_p_scl);
10776#endif
Bram Moolenaar95f09602016-11-10 20:01:45 +010010777 default: IEMSG(_("E356: get_varp ERROR"));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010778 }
10779 /* always return a valid pointer to avoid a crash! */
10780 return (char_u *)&(curbuf->b_p_wm);
10781}
10782
10783/*
10784 * Get the value of 'equalprg', either the buffer-local one or the global one.
10785 */
10786 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010787get_equalprg(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010788{
10789 if (*curbuf->b_p_ep == NUL)
10790 return p_ep;
10791 return curbuf->b_p_ep;
10792}
10793
10794#if defined(FEAT_WINDOWS) || defined(PROTO)
10795/*
10796 * Copy options from one window to another.
10797 * Used when splitting a window.
10798 */
10799 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010800win_copy_options(win_T *wp_from, win_T *wp_to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010801{
10802 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10803 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10804# ifdef FEAT_RIGHTLEFT
10805# ifdef FEAT_FKMAP
10806 /* Is this right? */
10807 wp_to->w_farsi = wp_from->w_farsi;
10808# endif
10809# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020010810#if defined(FEAT_LINEBREAK)
10811 briopt_check(wp_to);
10812#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010813}
10814#endif
10815
10816/*
10817 * Copy the options from one winopt_T to another.
10818 * Doesn't free the old option values in "to", use clear_winopt() for that.
10819 * The 'scroll' option is not copied, because it depends on the window height.
10820 * The 'previewwindow' option is reset, there can be only one preview window.
10821 */
10822 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010823copy_winopt(winopt_T *from, winopt_T *to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010824{
10825#ifdef FEAT_ARABIC
10826 to->wo_arab = from->wo_arab;
10827#endif
10828 to->wo_list = from->wo_list;
10829 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010830 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010831#ifdef FEAT_LINEBREAK
10832 to->wo_nuw = from->wo_nuw;
10833#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010834#ifdef FEAT_RIGHTLEFT
10835 to->wo_rl = from->wo_rl;
10836 to->wo_rlc = vim_strsave(from->wo_rlc);
10837#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010838#ifdef FEAT_STL_OPT
10839 to->wo_stl = vim_strsave(from->wo_stl);
10840#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010841 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010842#ifdef FEAT_DIFF
10843 to->wo_wrap_save = from->wo_wrap_save;
10844#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010845#ifdef FEAT_LINEBREAK
10846 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020010847 to->wo_bri = from->wo_bri;
10848 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010849#endif
10850#ifdef FEAT_SCROLLBIND
10851 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010852 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010853#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010854#ifdef FEAT_CURSORBIND
10855 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010856 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010857#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010858#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010859 to->wo_spell = from->wo_spell;
10860#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010861#ifdef FEAT_SYN_HL
10862 to->wo_cuc = from->wo_cuc;
10863 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010864 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010865#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010866#ifdef FEAT_DIFF
10867 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010868 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010869#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010870#ifdef FEAT_CONCEAL
10871 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010872 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010873#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010874#ifdef FEAT_FOLDING
10875 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010876 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010877 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010878 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010879 to->wo_fdi = vim_strsave(from->wo_fdi);
10880 to->wo_fml = from->wo_fml;
10881 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010882 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010883 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010884 to->wo_fdm_save = from->wo_diff_saved
10885 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010886 to->wo_fdn = from->wo_fdn;
10887# ifdef FEAT_EVAL
10888 to->wo_fde = vim_strsave(from->wo_fde);
10889 to->wo_fdt = vim_strsave(from->wo_fdt);
10890# endif
10891 to->wo_fmr = vim_strsave(from->wo_fmr);
10892#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010893#ifdef FEAT_SIGNS
10894 to->wo_scl = vim_strsave(from->wo_scl);
10895#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010896 check_winopt(to); /* don't want NULL pointers */
10897}
10898
10899/*
10900 * Check string options in a window for a NULL value.
10901 */
10902 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010903check_win_options(win_T *win)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010904{
10905 check_winopt(&win->w_onebuf_opt);
10906 check_winopt(&win->w_allbuf_opt);
10907}
10908
10909/*
10910 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10911 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020010912 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010913check_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010914{
10915#ifdef FEAT_FOLDING
10916 check_string_option(&wop->wo_fdi);
10917 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010918 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010919# ifdef FEAT_EVAL
10920 check_string_option(&wop->wo_fde);
10921 check_string_option(&wop->wo_fdt);
10922# endif
10923 check_string_option(&wop->wo_fmr);
10924#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010925#ifdef FEAT_SIGNS
10926 check_string_option(&wop->wo_scl);
10927#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010928#ifdef FEAT_RIGHTLEFT
10929 check_string_option(&wop->wo_rlc);
10930#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010931#ifdef FEAT_STL_OPT
10932 check_string_option(&wop->wo_stl);
10933#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010934#ifdef FEAT_SYN_HL
10935 check_string_option(&wop->wo_cc);
10936#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010937#ifdef FEAT_CONCEAL
10938 check_string_option(&wop->wo_cocu);
10939#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010940#ifdef FEAT_LINEBREAK
10941 check_string_option(&wop->wo_briopt);
10942#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010943}
10944
10945/*
10946 * Free the allocated memory inside a winopt_T.
10947 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010948 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010949clear_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010950{
10951#ifdef FEAT_FOLDING
10952 clear_string_option(&wop->wo_fdi);
10953 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010954 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010955# ifdef FEAT_EVAL
10956 clear_string_option(&wop->wo_fde);
10957 clear_string_option(&wop->wo_fdt);
10958# endif
10959 clear_string_option(&wop->wo_fmr);
10960#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010961#ifdef FEAT_SIGNS
10962 clear_string_option(&wop->wo_scl);
10963#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010964#ifdef FEAT_LINEBREAK
10965 clear_string_option(&wop->wo_briopt);
10966#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010967#ifdef FEAT_RIGHTLEFT
10968 clear_string_option(&wop->wo_rlc);
10969#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010970#ifdef FEAT_STL_OPT
10971 clear_string_option(&wop->wo_stl);
10972#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010973#ifdef FEAT_SYN_HL
10974 clear_string_option(&wop->wo_cc);
10975#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010976#ifdef FEAT_CONCEAL
10977 clear_string_option(&wop->wo_cocu);
10978#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010979}
10980
10981/*
10982 * Copy global option values to local options for one buffer.
10983 * Used when creating a new buffer and sometimes when entering a buffer.
10984 * flags:
10985 * BCO_ENTER We will enter the buf buffer.
10986 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
10987 * appropriate.
10988 * BCO_NOHELP Don't copy the values to a help buffer.
10989 */
10990 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010991buf_copy_options(buf_T *buf, int flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010992{
10993 int should_copy = TRUE;
10994 char_u *save_p_isk = NULL; /* init for GCC */
10995 int dont_do_help;
10996 int did_isk = FALSE;
10997
10998 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010999 * Skip this when the option defaults have not been set yet. Happens when
11000 * main() allocates the first buffer.
11001 */
11002 if (p_cpo != NULL)
11003 {
11004 /*
11005 * Always copy when entering and 'cpo' contains 'S'.
11006 * Don't copy when already initialized.
11007 * Don't copy when 'cpo' contains 's' and not entering.
11008 * 'S' BCO_ENTER initialized 's' should_copy
11009 * yes yes X X TRUE
11010 * yes no yes X FALSE
11011 * no X yes X FALSE
11012 * X no no yes FALSE
11013 * X no no no TRUE
11014 * no yes no X TRUE
11015 */
11016 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
11017 && (buf->b_p_initialized
11018 || (!(flags & BCO_ENTER)
11019 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
11020 should_copy = FALSE;
11021
11022 if (should_copy || (flags & BCO_ALWAYS))
11023 {
11024 /* Don't copy the options specific to a help buffer when
11025 * BCO_NOHELP is given or the options were initialized already
11026 * (jumping back to a help file with CTRL-T or CTRL-O) */
11027 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
11028 || buf->b_p_initialized;
11029 if (dont_do_help) /* don't free b_p_isk */
11030 {
11031 save_p_isk = buf->b_p_isk;
11032 buf->b_p_isk = NULL;
11033 }
11034 /*
11035 * Always free the allocated strings.
11036 * If not already initialized, set 'readonly' and copy 'fileformat'.
11037 */
11038 if (!buf->b_p_initialized)
11039 {
11040 free_buf_options(buf, TRUE);
11041 buf->b_p_ro = FALSE; /* don't copy readonly */
11042 buf->b_p_tx = p_tx;
11043#ifdef FEAT_MBYTE
11044 buf->b_p_fenc = vim_strsave(p_fenc);
11045#endif
Bram Moolenaare8ef3a02016-10-12 17:45:29 +020011046 switch (*p_ffs)
11047 {
11048 case 'm':
11049 buf->b_p_ff = vim_strsave((char_u *)FF_MAC); break;
11050 case 'd':
11051 buf->b_p_ff = vim_strsave((char_u *)FF_DOS); break;
11052 case 'u':
11053 buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); break;
11054 default:
11055 buf->b_p_ff = vim_strsave(p_ff);
11056 }
11057 if (buf->b_p_ff != NULL)
11058 buf->b_start_ffc = *buf->b_p_ff;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011059#if defined(FEAT_QUICKFIX)
11060 buf->b_p_bh = empty_option;
11061 buf->b_p_bt = empty_option;
11062#endif
11063 }
11064 else
11065 free_buf_options(buf, FALSE);
11066
11067 buf->b_p_ai = p_ai;
11068 buf->b_p_ai_nopaste = p_ai_nopaste;
11069 buf->b_p_sw = p_sw;
11070 buf->b_p_tw = p_tw;
11071 buf->b_p_tw_nopaste = p_tw_nopaste;
11072 buf->b_p_tw_nobin = p_tw_nobin;
11073 buf->b_p_wm = p_wm;
11074 buf->b_p_wm_nopaste = p_wm_nopaste;
11075 buf->b_p_wm_nobin = p_wm_nobin;
11076 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000011077#ifdef FEAT_MBYTE
11078 buf->b_p_bomb = p_bomb;
11079#endif
Bram Moolenaarb388be02015-07-22 22:19:38 +020011080 buf->b_p_fixeol = p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011081 buf->b_p_et = p_et;
11082 buf->b_p_et_nobin = p_et_nobin;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011083 buf->b_p_et_nopaste = p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011084 buf->b_p_ml = p_ml;
11085 buf->b_p_ml_nobin = p_ml_nobin;
11086 buf->b_p_inf = p_inf;
Bram Moolenaar3bab9392017-04-07 15:42:25 +020011087 buf->b_p_swf = cmdmod.noswapfile ? FALSE : p_swf;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011088#ifdef FEAT_INS_EXPAND
11089 buf->b_p_cpt = vim_strsave(p_cpt);
11090#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011091#ifdef FEAT_COMPL_FUNC
11092 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000011093 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011094#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011095 buf->b_p_sts = p_sts;
11096 buf->b_p_sts_nopaste = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011097 buf->b_p_sn = p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011098#ifdef FEAT_COMMENTS
11099 buf->b_p_com = vim_strsave(p_com);
11100#endif
11101#ifdef FEAT_FOLDING
11102 buf->b_p_cms = vim_strsave(p_cms);
11103#endif
11104 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000011105 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011106 buf->b_p_nf = vim_strsave(p_nf);
11107 buf->b_p_mps = vim_strsave(p_mps);
11108#ifdef FEAT_SMARTINDENT
11109 buf->b_p_si = p_si;
11110#endif
11111 buf->b_p_ci = p_ci;
11112#ifdef FEAT_CINDENT
11113 buf->b_p_cin = p_cin;
11114 buf->b_p_cink = vim_strsave(p_cink);
11115 buf->b_p_cino = vim_strsave(p_cino);
11116#endif
11117#ifdef FEAT_AUTOCMD
11118 /* Don't copy 'filetype', it must be detected */
11119 buf->b_p_ft = empty_option;
11120#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011121 buf->b_p_pi = p_pi;
11122#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
11123 buf->b_p_cinw = vim_strsave(p_cinw);
11124#endif
11125#ifdef FEAT_LISP
11126 buf->b_p_lisp = p_lisp;
11127#endif
11128#ifdef FEAT_SYN_HL
11129 /* Don't copy 'syntax', it must be set */
11130 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000011131 buf->b_p_smc = p_smc;
Bram Moolenaarb8060fe2016-01-19 22:29:28 +010011132 buf->b_s.b_syn_isk = empty_option;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011133#endif
11134#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020011135 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020011136 (void)compile_cap_prog(&buf->b_s);
11137 buf->b_s.b_p_spf = vim_strsave(p_spf);
11138 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011139#endif
11140#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
11141 buf->b_p_inde = vim_strsave(p_inde);
11142 buf->b_p_indk = vim_strsave(p_indk);
11143#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010011144 buf->b_p_fp = empty_option;
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000011145#if defined(FEAT_EVAL)
11146 buf->b_p_fex = vim_strsave(p_fex);
11147#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011148#ifdef FEAT_CRYPT
11149 buf->b_p_key = vim_strsave(p_key);
11150#endif
11151#ifdef FEAT_SEARCHPATH
11152 buf->b_p_sua = vim_strsave(p_sua);
11153#endif
11154#ifdef FEAT_KEYMAP
11155 buf->b_p_keymap = vim_strsave(p_keymap);
11156 buf->b_kmap_state |= KEYMAP_INIT;
11157#endif
11158 /* This isn't really an option, but copying the langmap and IME
11159 * state from the current buffer is better than resetting it. */
11160 buf->b_p_iminsert = p_iminsert;
11161 buf->b_p_imsearch = p_imsearch;
11162
11163 /* options that are normally global but also have a local value
11164 * are not copied, start using the global value */
11165 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010011166 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020011167 buf->b_p_bkc = empty_option;
11168 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011169#ifdef FEAT_QUICKFIX
11170 buf->b_p_gp = empty_option;
11171 buf->b_p_mp = empty_option;
11172 buf->b_p_efm = empty_option;
11173#endif
11174 buf->b_p_ep = empty_option;
11175 buf->b_p_kp = empty_option;
11176 buf->b_p_path = empty_option;
11177 buf->b_p_tags = empty_option;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010011178 buf->b_p_tc = empty_option;
11179 buf->b_tc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011180#ifdef FEAT_FIND_ID
11181 buf->b_p_def = empty_option;
11182 buf->b_p_inc = empty_option;
11183# ifdef FEAT_EVAL
11184 buf->b_p_inex = vim_strsave(p_inex);
11185# endif
11186#endif
11187#ifdef FEAT_INS_EXPAND
11188 buf->b_p_dict = empty_option;
11189 buf->b_p_tsr = empty_option;
11190#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011191#ifdef FEAT_TEXTOBJ
11192 buf->b_p_qe = vim_strsave(p_qe);
11193#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000011194#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
11195 buf->b_p_bexpr = empty_option;
11196#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020011197#if defined(FEAT_CRYPT)
11198 buf->b_p_cm = empty_option;
11199#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020011200#ifdef FEAT_PERSISTENT_UNDO
11201 buf->b_p_udf = p_udf;
11202#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010011203#ifdef FEAT_LISP
11204 buf->b_p_lw = empty_option;
11205#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010011206#ifdef FEAT_MBYTE
11207 buf->b_p_menc = empty_option;
11208#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011209
11210 /*
11211 * Don't copy the options set by ex_help(), use the saved values,
11212 * when going from a help buffer to a non-help buffer.
11213 * Don't touch these at all when BCO_NOHELP is used and going from
11214 * or to a help buffer.
11215 */
11216 if (dont_do_help)
11217 buf->b_p_isk = save_p_isk;
11218 else
11219 {
11220 buf->b_p_isk = vim_strsave(p_isk);
11221 did_isk = TRUE;
11222 buf->b_p_ts = p_ts;
11223 buf->b_help = FALSE;
11224#ifdef FEAT_QUICKFIX
11225 if (buf->b_p_bt[0] == 'h')
11226 clear_string_option(&buf->b_p_bt);
11227#endif
11228 buf->b_p_ma = p_ma;
11229 }
11230 }
11231
11232 /*
11233 * When the options should be copied (ignoring BCO_ALWAYS), set the
11234 * flag that indicates that the options have been initialized.
11235 */
11236 if (should_copy)
11237 buf->b_p_initialized = TRUE;
11238 }
11239
11240 check_buf_options(buf); /* make sure we don't have NULLs */
11241 if (did_isk)
11242 (void)buf_init_chartab(buf, FALSE);
11243}
11244
11245/*
11246 * Reset the 'modifiable' option and its default value.
11247 */
11248 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011249reset_modifiable(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011250{
11251 int opt_idx;
11252
11253 curbuf->b_p_ma = FALSE;
11254 p_ma = FALSE;
11255 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011256 if (opt_idx >= 0)
11257 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011258}
11259
11260/*
11261 * Set the global value for 'iminsert' to the local value.
11262 */
11263 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011264set_iminsert_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011265{
11266 p_iminsert = curbuf->b_p_iminsert;
11267}
11268
11269/*
11270 * Set the global value for 'imsearch' to the local value.
11271 */
11272 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011273set_imsearch_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011274{
11275 p_imsearch = curbuf->b_p_imsearch;
11276}
11277
11278#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
11279static int expand_option_idx = -1;
11280static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
11281static int expand_option_flags = 0;
11282
11283 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011284set_context_in_set_cmd(
11285 expand_T *xp,
11286 char_u *arg,
11287 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011288{
11289 int nextchar;
11290 long_u flags = 0; /* init for GCC */
11291 int opt_idx = 0; /* init for GCC */
11292 char_u *p;
11293 char_u *s;
11294 int is_term_option = FALSE;
11295 int key;
11296
11297 expand_option_flags = opt_flags;
11298
11299 xp->xp_context = EXPAND_SETTINGS;
11300 if (*arg == NUL)
11301 {
11302 xp->xp_pattern = arg;
11303 return;
11304 }
11305 p = arg + STRLEN(arg) - 1;
11306 if (*p == ' ' && *(p - 1) != '\\')
11307 {
11308 xp->xp_pattern = p + 1;
11309 return;
11310 }
11311 while (p > arg)
11312 {
11313 s = p;
11314 /* count number of backslashes before ' ' or ',' */
11315 if (*p == ' ' || *p == ',')
11316 {
11317 while (s > arg && *(s - 1) == '\\')
11318 --s;
11319 }
11320 /* break at a space with an even number of backslashes */
11321 if (*p == ' ' && ((p - s) & 1) == 0)
11322 {
11323 ++p;
11324 break;
11325 }
11326 --p;
11327 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000011328 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011329 {
11330 xp->xp_context = EXPAND_BOOL_SETTINGS;
11331 p += 2;
11332 }
11333 if (STRNCMP(p, "inv", 3) == 0)
11334 {
11335 xp->xp_context = EXPAND_BOOL_SETTINGS;
11336 p += 3;
11337 }
11338 xp->xp_pattern = arg = p;
11339 if (*arg == '<')
11340 {
11341 while (*p != '>')
11342 if (*p++ == NUL) /* expand terminal option name */
11343 return;
11344 key = get_special_key_code(arg + 1);
11345 if (key == 0) /* unknown name */
11346 {
11347 xp->xp_context = EXPAND_NOTHING;
11348 return;
11349 }
11350 nextchar = *++p;
11351 is_term_option = TRUE;
11352 expand_option_name[2] = KEY2TERMCAP0(key);
11353 expand_option_name[3] = KEY2TERMCAP1(key);
11354 }
11355 else
11356 {
11357 if (p[0] == 't' && p[1] == '_')
11358 {
11359 p += 2;
11360 if (*p != NUL)
11361 ++p;
11362 if (*p == NUL)
11363 return; /* expand option name */
11364 nextchar = *++p;
11365 is_term_option = TRUE;
11366 expand_option_name[2] = p[-2];
11367 expand_option_name[3] = p[-1];
11368 }
11369 else
11370 {
11371 /* Allow * wildcard */
11372 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
11373 p++;
11374 if (*p == NUL)
11375 return;
11376 nextchar = *p;
11377 *p = NUL;
11378 opt_idx = findoption(arg);
11379 *p = nextchar;
11380 if (opt_idx == -1 || options[opt_idx].var == NULL)
11381 {
11382 xp->xp_context = EXPAND_NOTHING;
11383 return;
11384 }
11385 flags = options[opt_idx].flags;
11386 if (flags & P_BOOL)
11387 {
11388 xp->xp_context = EXPAND_NOTHING;
11389 return;
11390 }
11391 }
11392 }
11393 /* handle "-=" and "+=" */
11394 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
11395 {
11396 ++p;
11397 nextchar = '=';
11398 }
11399 if ((nextchar != '=' && nextchar != ':')
11400 || xp->xp_context == EXPAND_BOOL_SETTINGS)
11401 {
11402 xp->xp_context = EXPAND_UNSUCCESSFUL;
11403 return;
11404 }
11405 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
11406 {
11407 xp->xp_context = EXPAND_OLD_SETTING;
11408 if (is_term_option)
11409 expand_option_idx = -1;
11410 else
11411 expand_option_idx = opt_idx;
11412 xp->xp_pattern = p + 1;
11413 return;
11414 }
11415 xp->xp_context = EXPAND_NOTHING;
11416 if (is_term_option || (flags & P_NUM))
11417 return;
11418
11419 xp->xp_pattern = p + 1;
11420
11421 if (flags & P_EXPAND)
11422 {
11423 p = options[opt_idx].var;
11424 if (p == (char_u *)&p_bdir
11425 || p == (char_u *)&p_dir
11426 || p == (char_u *)&p_path
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +010011427 || p == (char_u *)&p_pp
Bram Moolenaar071d4272004-06-13 20:20:40 +000011428 || p == (char_u *)&p_rtp
11429#ifdef FEAT_SEARCHPATH
11430 || p == (char_u *)&p_cdpath
11431#endif
11432#ifdef FEAT_SESSION
11433 || p == (char_u *)&p_vdir
11434#endif
11435 )
11436 {
11437 xp->xp_context = EXPAND_DIRECTORIES;
11438 if (p == (char_u *)&p_path
11439#ifdef FEAT_SEARCHPATH
11440 || p == (char_u *)&p_cdpath
11441#endif
11442 )
11443 xp->xp_backslash = XP_BS_THREE;
11444 else
11445 xp->xp_backslash = XP_BS_ONE;
11446 }
11447 else
11448 {
11449 xp->xp_context = EXPAND_FILES;
11450 /* for 'tags' need three backslashes for a space */
11451 if (p == (char_u *)&p_tags)
11452 xp->xp_backslash = XP_BS_THREE;
11453 else
11454 xp->xp_backslash = XP_BS_ONE;
11455 }
11456 }
11457
11458 /* For an option that is a list of file names, find the start of the
11459 * last file name. */
11460 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11461 {
11462 /* count number of backslashes before ' ' or ',' */
11463 if (*p == ' ' || *p == ',')
11464 {
11465 s = p;
11466 while (s > xp->xp_pattern && *(s - 1) == '\\')
11467 --s;
11468 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11469 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11470 {
11471 xp->xp_pattern = p + 1;
11472 break;
11473 }
11474 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011475
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011476#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011477 /* for 'spellsuggest' start at "file:" */
11478 if (options[opt_idx].var == (char_u *)&p_sps
11479 && STRNCMP(p, "file:", 5) == 0)
11480 {
11481 xp->xp_pattern = p + 5;
11482 break;
11483 }
11484#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011485 }
11486
11487 return;
11488}
11489
11490 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011491ExpandSettings(
11492 expand_T *xp,
11493 regmatch_T *regmatch,
11494 int *num_file,
11495 char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011496{
11497 int num_normal = 0; /* Nr of matching non-term-code settings */
11498 int num_term = 0; /* Nr of matching terminal code settings */
11499 int opt_idx;
11500 int match;
11501 int count = 0;
11502 char_u *str;
11503 int loop;
11504 int is_term_opt;
11505 char_u name_buf[MAX_KEY_NAME_LEN];
11506 static char *(names[]) = {"all", "termcap"};
11507 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11508
11509 /* do this loop twice:
11510 * loop == 0: count the number of matching options
11511 * loop == 1: copy the matching options into allocated memory
11512 */
11513 for (loop = 0; loop <= 1; ++loop)
11514 {
11515 regmatch->rm_ic = ic;
11516 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11517 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011518 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11519 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011520 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11521 {
11522 if (loop == 0)
11523 num_normal++;
11524 else
11525 (*file)[count++] = vim_strsave((char_u *)names[match]);
11526 }
11527 }
11528 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11529 opt_idx++)
11530 {
11531 if (options[opt_idx].var == NULL)
11532 continue;
11533 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11534 && !(options[opt_idx].flags & P_BOOL))
11535 continue;
11536 is_term_opt = istermoption(&options[opt_idx]);
11537 if (is_term_opt && num_normal > 0)
11538 continue;
11539 match = FALSE;
11540 if (vim_regexec(regmatch, str, (colnr_T)0)
11541 || (options[opt_idx].shortname != NULL
11542 && vim_regexec(regmatch,
11543 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11544 match = TRUE;
11545 else if (is_term_opt)
11546 {
11547 name_buf[0] = '<';
11548 name_buf[1] = 't';
11549 name_buf[2] = '_';
11550 name_buf[3] = str[2];
11551 name_buf[4] = str[3];
11552 name_buf[5] = '>';
11553 name_buf[6] = NUL;
11554 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11555 {
11556 match = TRUE;
11557 str = name_buf;
11558 }
11559 }
11560 if (match)
11561 {
11562 if (loop == 0)
11563 {
11564 if (is_term_opt)
11565 num_term++;
11566 else
11567 num_normal++;
11568 }
11569 else
11570 (*file)[count++] = vim_strsave(str);
11571 }
11572 }
11573 /*
11574 * Check terminal key codes, these are not in the option table
11575 */
11576 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11577 {
11578 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11579 {
11580 if (!isprint(str[0]) || !isprint(str[1]))
11581 continue;
11582
11583 name_buf[0] = 't';
11584 name_buf[1] = '_';
11585 name_buf[2] = str[0];
11586 name_buf[3] = str[1];
11587 name_buf[4] = NUL;
11588
11589 match = FALSE;
11590 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11591 match = TRUE;
11592 else
11593 {
11594 name_buf[0] = '<';
11595 name_buf[1] = 't';
11596 name_buf[2] = '_';
11597 name_buf[3] = str[0];
11598 name_buf[4] = str[1];
11599 name_buf[5] = '>';
11600 name_buf[6] = NUL;
11601
11602 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11603 match = TRUE;
11604 }
11605 if (match)
11606 {
11607 if (loop == 0)
11608 num_term++;
11609 else
11610 (*file)[count++] = vim_strsave(name_buf);
11611 }
11612 }
11613
11614 /*
11615 * Check special key names.
11616 */
11617 regmatch->rm_ic = TRUE; /* ignore case here */
11618 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11619 {
11620 name_buf[0] = '<';
11621 STRCPY(name_buf + 1, str);
11622 STRCAT(name_buf, ">");
11623
11624 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11625 {
11626 if (loop == 0)
11627 num_term++;
11628 else
11629 (*file)[count++] = vim_strsave(name_buf);
11630 }
11631 }
11632 }
11633 if (loop == 0)
11634 {
11635 if (num_normal > 0)
11636 *num_file = num_normal;
11637 else if (num_term > 0)
11638 *num_file = num_term;
11639 else
11640 return OK;
11641 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11642 if (*file == NULL)
11643 {
11644 *file = (char_u **)"";
11645 return FAIL;
11646 }
11647 }
11648 }
11649 return OK;
11650}
11651
11652 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011653ExpandOldSetting(int *num_file, char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011654{
11655 char_u *var = NULL; /* init for GCC */
11656 char_u *buf;
11657
11658 *num_file = 0;
11659 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11660 if (*file == NULL)
11661 return FAIL;
11662
11663 /*
11664 * For a terminal key code expand_option_idx is < 0.
11665 */
11666 if (expand_option_idx < 0)
11667 {
11668 var = find_termcode(expand_option_name + 2);
11669 if (var == NULL)
11670 expand_option_idx = findoption(expand_option_name);
11671 }
11672
11673 if (expand_option_idx >= 0)
11674 {
11675 /* put string of option value in NameBuff */
11676 option_value2string(&options[expand_option_idx], expand_option_flags);
11677 var = NameBuff;
11678 }
11679 else if (var == NULL)
11680 var = (char_u *)"";
11681
11682 /* A backslash is required before some characters. This is the reverse of
11683 * what happens in do_set(). */
11684 buf = vim_strsave_escaped(var, escape_chars);
11685
11686 if (buf == NULL)
11687 {
11688 vim_free(*file);
11689 *file = NULL;
11690 return FAIL;
11691 }
11692
11693#ifdef BACKSLASH_IN_FILENAME
11694 /* For MS-Windows et al. we don't double backslashes at the start and
11695 * before a file name character. */
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011696 for (var = buf; *var != NUL; MB_PTR_ADV(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011697 if (var[0] == '\\' && var[1] == '\\'
11698 && expand_option_idx >= 0
11699 && (options[expand_option_idx].flags & P_EXPAND)
11700 && vim_isfilec(var[2])
11701 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011702 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011703#endif
11704
11705 *file[0] = buf;
11706 *num_file = 1;
11707 return OK;
11708}
11709#endif
11710
11711/*
11712 * Get the value for the numeric or string option *opp in a nice format into
11713 * NameBuff[]. Must not be called with a hidden option!
11714 */
11715 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011716option_value2string(
11717 struct vimoption *opp,
11718 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011719{
11720 char_u *varp;
11721
11722 varp = get_varp_scope(opp, opt_flags);
11723
11724 if (opp->flags & P_NUM)
11725 {
11726 long wc = 0;
11727
11728 if (wc_use_keyname(varp, &wc))
11729 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11730 else if (wc != 0)
11731 STRCPY(NameBuff, transchar((int)wc));
11732 else
11733 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11734 }
11735 else /* P_STRING */
11736 {
11737 varp = *(char_u **)(varp);
11738 if (varp == NULL) /* just in case */
11739 NameBuff[0] = NUL;
11740#ifdef FEAT_CRYPT
11741 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011742 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011743 STRCPY(NameBuff, "*****");
11744#endif
11745 else if (opp->flags & P_EXPAND)
11746 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11747 /* Translate 'pastetoggle' into special key names */
11748 else if ((char_u **)opp->var == &p_pt)
11749 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11750 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011751 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011752 }
11753}
11754
11755/*
11756 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11757 * printed as a keyname.
11758 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11759 */
11760 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011761wc_use_keyname(char_u *varp, long *wcp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011762{
11763 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11764 {
11765 *wcp = *(long *)varp;
11766 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11767 return TRUE;
11768 }
11769 return FALSE;
11770}
11771
Bram Moolenaar01615492015-02-03 13:00:38 +010011772#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011773/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011774 * Any character has an equivalent 'langmap' character. This is used for
11775 * keyboards that have a special language mode that sends characters above
11776 * 128 (although other characters can be translated too). The "to" field is a
11777 * Vim command character. This avoids having to switch the keyboard back to
11778 * ASCII mode when leaving Insert mode.
11779 *
11780 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11781 * commands.
11782 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11783 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11784 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011785 */
Bram Moolenaar01615492015-02-03 13:00:38 +010011786# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011787/*
11788 * With multi-byte support use growarray for 'langmap' chars >= 256
11789 */
11790typedef struct
11791{
11792 int from;
11793 int to;
11794} langmap_entry_T;
11795
11796static garray_T langmap_mapga;
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +010011797static void langmap_set_entry(int from, int to);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011798
11799/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011800 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11801 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011802 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011803 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011804langmap_set_entry(int from, int to)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011805{
11806 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011807 int a = 0;
11808 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011809
11810 /* Do a binary search for an existing entry. */
11811 while (a != b)
11812 {
11813 int i = (a + b) / 2;
11814 int d = entries[i].from - from;
11815
11816 if (d == 0)
11817 {
11818 entries[i].to = to;
11819 return;
11820 }
11821 if (d < 0)
11822 a = i + 1;
11823 else
11824 b = i;
11825 }
11826
11827 if (ga_grow(&langmap_mapga, 1) != OK)
11828 return; /* out of memory */
11829
11830 /* insert new entry at position "a" */
11831 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11832 mch_memmove(entries + 1, entries,
11833 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11834 ++langmap_mapga.ga_len;
11835 entries[0].from = from;
11836 entries[0].to = to;
11837}
11838
11839/*
11840 * Apply 'langmap' to multi-byte character "c" and return the result.
11841 */
11842 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011843langmap_adjust_mb(int c)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011844{
11845 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11846 int a = 0;
11847 int b = langmap_mapga.ga_len;
11848
11849 while (a != b)
11850 {
11851 int i = (a + b) / 2;
11852 int d = entries[i].from - c;
11853
11854 if (d == 0)
11855 return entries[i].to; /* found matching entry */
11856 if (d < 0)
11857 a = i + 1;
11858 else
11859 b = i;
11860 }
11861 return c; /* no entry found, return "c" unmodified */
11862}
11863# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011864
11865 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011866langmap_init(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011867{
11868 int i;
11869
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011870 for (i = 0; i < 256; i++)
11871 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11872# ifdef FEAT_MBYTE
11873 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11874# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011875}
11876
11877/*
11878 * Called when langmap option is set; the language map can be
11879 * changed at any time!
11880 */
11881 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011882langmap_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011883{
11884 char_u *p;
11885 char_u *p2;
11886 int from, to;
11887
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011888#ifdef FEAT_MBYTE
11889 ga_clear(&langmap_mapga); /* clear the previous map first */
11890#endif
11891 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011892
11893 for (p = p_langmap; p[0] != NUL; )
11894 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011895 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011896 MB_PTR_ADV(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011897 {
11898 if (p2[0] == '\\' && p2[1] != NUL)
11899 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011900 }
11901 if (p2[0] == ';')
11902 ++p2; /* abcd;ABCD form, p2 points to A */
11903 else
11904 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11905 while (p[0])
11906 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011907 if (p[0] == ',')
11908 {
11909 ++p;
11910 break;
11911 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011912 if (p[0] == '\\' && p[1] != NUL)
11913 ++p;
11914#ifdef FEAT_MBYTE
11915 from = (*mb_ptr2char)(p);
11916#else
11917 from = p[0];
11918#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011919 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011920 if (p2 == NULL)
11921 {
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011922 MB_PTR_ADV(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011923 if (p[0] != ',')
11924 {
11925 if (p[0] == '\\')
11926 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011927#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011928 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011929#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011930 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011931#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011932 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011933 }
11934 else
11935 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011936 if (p2[0] != ',')
11937 {
11938 if (p2[0] == '\\')
11939 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011940#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011941 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011942#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011943 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011944#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011945 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011946 }
11947 if (to == NUL)
11948 {
11949 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
11950 transchar(from));
11951 return;
11952 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011953
11954#ifdef FEAT_MBYTE
11955 if (from >= 256)
11956 langmap_set_entry(from, to);
11957 else
11958#endif
11959 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011960
11961 /* Advance to next pair */
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011962 MB_PTR_ADV(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011963 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011964 {
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011965 MB_PTR_ADV(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011966 if (*p == ';')
11967 {
11968 p = p2;
11969 if (p[0] != NUL)
11970 {
11971 if (p[0] != ',')
11972 {
11973 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
11974 return;
11975 }
11976 ++p;
11977 }
11978 break;
11979 }
11980 }
11981 }
11982 }
11983}
11984#endif
11985
11986/*
11987 * Return TRUE if format option 'x' is in effect.
11988 * Take care of no formatting when 'paste' is set.
11989 */
11990 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011991has_format_option(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011992{
11993 if (p_paste)
11994 return FALSE;
11995 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
11996}
11997
11998/*
11999 * Return TRUE if "x" is present in 'shortmess' option, or
12000 * 'shortmess' contains 'a' and "x" is present in SHM_A.
12001 */
12002 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012003shortmess(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012004{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010012005 return p_shm != NULL &&
12006 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000012007 || (vim_strchr(p_shm, 'a') != NULL
12008 && vim_strchr((char_u *)SHM_A, x) != NULL));
12009}
12010
12011/*
12012 * paste_option_changed() - Called after p_paste was set or reset.
12013 */
12014 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012015paste_option_changed(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012016{
12017 static int old_p_paste = FALSE;
12018 static int save_sm = 0;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012019 static int save_sta = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012020#ifdef FEAT_CMDL_INFO
12021 static int save_ru = 0;
12022#endif
12023#ifdef FEAT_RIGHTLEFT
12024 static int save_ri = 0;
12025 static int save_hkmap = 0;
12026#endif
12027 buf_T *buf;
12028
12029 if (p_paste)
12030 {
12031 /*
12032 * Paste switched from off to on.
12033 * Save the current values, so they can be restored later.
12034 */
12035 if (!old_p_paste)
12036 {
12037 /* save options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012038 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012039 {
12040 buf->b_p_tw_nopaste = buf->b_p_tw;
12041 buf->b_p_wm_nopaste = buf->b_p_wm;
12042 buf->b_p_sts_nopaste = buf->b_p_sts;
12043 buf->b_p_ai_nopaste = buf->b_p_ai;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012044 buf->b_p_et_nopaste = buf->b_p_et;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012045 }
12046
12047 /* save global options */
12048 save_sm = p_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012049 save_sta = p_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012050#ifdef FEAT_CMDL_INFO
12051 save_ru = p_ru;
12052#endif
12053#ifdef FEAT_RIGHTLEFT
12054 save_ri = p_ri;
12055 save_hkmap = p_hkmap;
12056#endif
12057 /* save global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012058 p_ai_nopaste = p_ai;
12059 p_et_nopaste = p_et;
12060 p_sts_nopaste = p_sts;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012061 p_tw_nopaste = p_tw;
12062 p_wm_nopaste = p_wm;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012063 }
12064
12065 /*
12066 * Always set the option values, also when 'paste' is set when it is
12067 * already on.
12068 */
12069 /* set options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012070 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012071 {
12072 buf->b_p_tw = 0; /* textwidth is 0 */
12073 buf->b_p_wm = 0; /* wrapmargin is 0 */
12074 buf->b_p_sts = 0; /* softtabstop is 0 */
12075 buf->b_p_ai = 0; /* no auto-indent */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012076 buf->b_p_et = 0; /* no expandtab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012077 }
12078
12079 /* set global options */
12080 p_sm = 0; /* no showmatch */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012081 p_sta = 0; /* no smarttab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012082#ifdef FEAT_CMDL_INFO
12083# ifdef FEAT_WINDOWS
12084 if (p_ru)
12085 status_redraw_all(); /* redraw to remove the ruler */
12086# endif
12087 p_ru = 0; /* no ruler */
12088#endif
12089#ifdef FEAT_RIGHTLEFT
12090 p_ri = 0; /* no reverse insert */
12091 p_hkmap = 0; /* no Hebrew keyboard */
12092#endif
12093 /* set global values for local buffer options */
12094 p_tw = 0;
12095 p_wm = 0;
12096 p_sts = 0;
12097 p_ai = 0;
12098 }
12099
12100 /*
12101 * Paste switched from on to off: Restore saved values.
12102 */
12103 else if (old_p_paste)
12104 {
12105 /* restore options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012106 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012107 {
12108 buf->b_p_tw = buf->b_p_tw_nopaste;
12109 buf->b_p_wm = buf->b_p_wm_nopaste;
12110 buf->b_p_sts = buf->b_p_sts_nopaste;
12111 buf->b_p_ai = buf->b_p_ai_nopaste;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012112 buf->b_p_et = buf->b_p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012113 }
12114
12115 /* restore global options */
12116 p_sm = save_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012117 p_sta = save_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012118#ifdef FEAT_CMDL_INFO
12119# ifdef FEAT_WINDOWS
12120 if (p_ru != save_ru)
12121 status_redraw_all(); /* redraw to draw the ruler */
12122# endif
12123 p_ru = save_ru;
12124#endif
12125#ifdef FEAT_RIGHTLEFT
12126 p_ri = save_ri;
12127 p_hkmap = save_hkmap;
12128#endif
12129 /* set global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012130 p_ai = p_ai_nopaste;
12131 p_et = p_et_nopaste;
12132 p_sts = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012133 p_tw = p_tw_nopaste;
12134 p_wm = p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012135 }
12136
12137 old_p_paste = p_paste;
12138}
12139
12140/*
12141 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
12142 *
12143 * Reset 'compatible' and set the values for options that didn't get set yet
12144 * to the Vim defaults.
12145 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012146 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012147 */
12148 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012149vimrc_found(char_u *fname, char_u *envname)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012150{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012151 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000012152 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012153 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012154
12155 if (!option_was_set((char_u *)"cp"))
12156 {
12157 p_cp = FALSE;
12158 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12159 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
12160 set_option_default(opt_idx, OPT_FREE, FALSE);
12161 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020012162 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000012163 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012164
12165 if (fname != NULL)
12166 {
12167 p = vim_getenv(envname, &dofree);
12168 if (p == NULL)
12169 {
12170 /* Set $MYVIMRC to the first vimrc file found. */
12171 p = FullName_save(fname, FALSE);
12172 if (p != NULL)
12173 {
12174 vim_setenv(envname, p);
12175 vim_free(p);
12176 }
12177 }
12178 else if (dofree)
12179 vim_free(p);
12180 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000012181}
12182
12183/*
12184 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
12185 */
12186 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012187change_compatible(int on)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012188{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000012189 int opt_idx;
12190
Bram Moolenaar071d4272004-06-13 20:20:40 +000012191 if (p_cp != on)
12192 {
12193 p_cp = on;
12194 compatible_set();
12195 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000012196 opt_idx = findoption((char_u *)"cp");
12197 if (opt_idx >= 0)
12198 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012199}
12200
12201/*
12202 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020012203 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012204 */
12205 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012206option_was_set(char_u *name)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012207{
12208 int idx;
12209
12210 idx = findoption(name);
12211 if (idx < 0) /* unknown option */
12212 return FALSE;
12213 if (options[idx].flags & P_WAS_SET)
12214 return TRUE;
12215 return FALSE;
12216}
12217
12218/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012219 * Reset the flag indicating option "name" was set.
12220 */
12221 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012222reset_option_was_set(char_u *name)
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012223{
12224 int idx = findoption(name);
12225
12226 if (idx >= 0)
12227 options[idx].flags &= ~P_WAS_SET;
12228}
12229
12230/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000012231 * compatible_set() - Called when 'compatible' has been set or unset.
12232 *
12233 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
12234 * flag) to a Vi compatible value.
12235 * When 'compatible' is unset: Set all options that have a different default
12236 * for Vim (without the P_VI_DEF flag) to that default.
12237 */
12238 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012239compatible_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012240{
12241 int opt_idx;
12242
12243 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12244 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
12245 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
12246 set_option_default(opt_idx, OPT_FREE, p_cp);
12247 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020012248 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000012249}
12250
12251#ifdef FEAT_LINEBREAK
12252
12253# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
12254 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012255 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012256# endif
12257
12258/*
12259 * fill_breakat_flags() -- called when 'breakat' changes value.
12260 */
12261 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012262fill_breakat_flags(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012263{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000012264 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012265 int i;
12266
12267 for (i = 0; i < 256; i++)
12268 breakat_flags[i] = FALSE;
12269
12270 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000012271 for (p = p_breakat; *p; p++)
12272 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012273}
12274
12275# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012276 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012277# endif
12278
12279#endif
12280
12281/*
12282 * Check an option that can be a range of string values.
12283 *
12284 * Return OK for correct value, FAIL otherwise.
12285 * Empty is always OK.
12286 */
12287 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012288check_opt_strings(
12289 char_u *val,
12290 char **values,
12291 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012292{
12293 return opt_strings_flags(val, values, NULL, list);
12294}
12295
12296/*
12297 * Handle an option that can be a range of string values.
12298 * Set a flag in "*flagp" for each string present.
12299 *
12300 * Return OK for correct value, FAIL otherwise.
12301 * Empty is always OK.
12302 */
12303 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012304opt_strings_flags(
12305 char_u *val, /* new value */
12306 char **values, /* array of valid string values */
12307 unsigned *flagp,
12308 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012309{
12310 int i;
12311 int len;
12312 unsigned new_flags = 0;
12313
12314 while (*val)
12315 {
12316 for (i = 0; ; ++i)
12317 {
12318 if (values[i] == NULL) /* val not found in values[] */
12319 return FAIL;
12320
12321 len = (int)STRLEN(values[i]);
12322 if (STRNCMP(values[i], val, len) == 0
12323 && ((list && val[len] == ',') || val[len] == NUL))
12324 {
12325 val += len + (val[len] == ',');
12326 new_flags |= (1 << i);
12327 break; /* check next item in val list */
12328 }
12329 }
12330 }
12331 if (flagp != NULL)
12332 *flagp = new_flags;
12333
12334 return OK;
12335}
12336
12337/*
12338 * Read the 'wildmode' option, fill wim_flags[].
12339 */
12340 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012341check_opt_wim(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012342{
12343 char_u new_wim_flags[4];
12344 char_u *p;
12345 int i;
12346 int idx = 0;
12347
12348 for (i = 0; i < 4; ++i)
12349 new_wim_flags[i] = 0;
12350
12351 for (p = p_wim; *p; ++p)
12352 {
12353 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
12354 ;
12355 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
12356 return FAIL;
12357 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
12358 new_wim_flags[idx] |= WIM_LONGEST;
12359 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
12360 new_wim_flags[idx] |= WIM_FULL;
12361 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
12362 new_wim_flags[idx] |= WIM_LIST;
12363 else
12364 return FAIL;
12365 p += i;
12366 if (*p == NUL)
12367 break;
12368 if (*p == ',')
12369 {
12370 if (idx == 3)
12371 return FAIL;
12372 ++idx;
12373 }
12374 }
12375
12376 /* fill remaining entries with last flag */
12377 while (idx < 3)
12378 {
12379 new_wim_flags[idx + 1] = new_wim_flags[idx];
12380 ++idx;
12381 }
12382
12383 /* only when there are no errors, wim_flags[] is changed */
12384 for (i = 0; i < 4; ++i)
12385 wim_flags[i] = new_wim_flags[i];
12386 return OK;
12387}
12388
12389/*
12390 * Check if backspacing over something is allowed.
12391 */
12392 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012393can_bs(
12394 int what) /* BS_INDENT, BS_EOL or BS_START */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012395{
12396 switch (*p_bs)
12397 {
12398 case '2': return TRUE;
12399 case '1': return (what != BS_START);
12400 case '0': return FALSE;
12401 }
12402 return vim_strchr(p_bs, what) != NULL;
12403}
12404
12405/*
12406 * Save the current values of 'fileformat' and 'fileencoding', so that we know
12407 * the file must be considered changed when the value is different.
12408 */
12409 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012410save_file_ff(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012411{
12412 buf->b_start_ffc = *buf->b_p_ff;
12413 buf->b_start_eol = buf->b_p_eol;
12414#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012415 buf->b_start_bomb = buf->b_p_bomb;
12416
Bram Moolenaar071d4272004-06-13 20:20:40 +000012417 /* Only use free/alloc when necessary, they take time. */
12418 if (buf->b_start_fenc == NULL
12419 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
12420 {
12421 vim_free(buf->b_start_fenc);
12422 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
12423 }
12424#endif
12425}
12426
12427/*
12428 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
12429 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012430 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
12431 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012432 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012433 * When "ignore_empty" is true don't consider a new, empty buffer to be
12434 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012435 */
12436 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012437file_ff_differs(buf_T *buf, int ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012438{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012439 /* In a buffer that was never loaded the options are not valid. */
12440 if (buf->b_flags & BF_NEVERLOADED)
12441 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012442 if (ignore_empty
12443 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012444 && buf->b_ml.ml_line_count == 1
12445 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12446 return FALSE;
12447 if (buf->b_start_ffc != *buf->b_p_ff)
12448 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012449 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012450 return TRUE;
12451#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012452 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12453 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012454 if (buf->b_start_fenc == NULL)
12455 return (*buf->b_p_fenc != NUL);
12456 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12457#else
12458 return FALSE;
12459#endif
12460}
12461
12462/*
12463 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12464 */
12465 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012466check_ff_value(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012467{
12468 return check_opt_strings(p, p_ff_values, FALSE);
12469}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012470
12471/*
12472 * Return the effective shiftwidth value for current buffer, using the
12473 * 'tabstop' value when 'shiftwidth' is zero.
12474 */
12475 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012476get_sw_value(buf_T *buf)
Bram Moolenaar14f24742012-08-08 18:01:05 +020012477{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012478 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012479}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012480
12481/*
12482 * Return the effective softtabstop value for the current buffer, using the
12483 * 'tabstop' value when 'softtabstop' is negative.
12484 */
12485 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012486get_sts_value(void)
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012487{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012488 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012489}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012490
12491/*
12492 * Check matchpairs option for "*initc".
12493 * If there is a match set "*initc" to the matching character and "*findc" to
12494 * the opposite character. Set "*backwards" to the direction.
12495 * When "switchit" is TRUE swap the direction.
12496 */
12497 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012498find_mps_values(
12499 int *initc,
12500 int *findc,
12501 int *backwards,
12502 int switchit)
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012503{
12504 char_u *ptr;
12505
12506 ptr = curbuf->b_p_mps;
12507 while (*ptr != NUL)
12508 {
12509#ifdef FEAT_MBYTE
12510 if (has_mbyte)
12511 {
12512 char_u *prev;
12513
12514 if (mb_ptr2char(ptr) == *initc)
12515 {
12516 if (switchit)
12517 {
12518 *findc = *initc;
12519 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12520 *backwards = TRUE;
12521 }
12522 else
12523 {
12524 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12525 *backwards = FALSE;
12526 }
12527 return;
12528 }
12529 prev = ptr;
12530 ptr += mb_ptr2len(ptr) + 1;
12531 if (mb_ptr2char(ptr) == *initc)
12532 {
12533 if (switchit)
12534 {
12535 *findc = *initc;
12536 *initc = mb_ptr2char(prev);
12537 *backwards = FALSE;
12538 }
12539 else
12540 {
12541 *findc = mb_ptr2char(prev);
12542 *backwards = TRUE;
12543 }
12544 return;
12545 }
12546 ptr += mb_ptr2len(ptr);
12547 }
12548 else
12549#endif
12550 {
12551 if (*ptr == *initc)
12552 {
12553 if (switchit)
12554 {
12555 *backwards = TRUE;
12556 *findc = *initc;
12557 *initc = ptr[2];
12558 }
12559 else
12560 {
12561 *backwards = FALSE;
12562 *findc = ptr[2];
12563 }
12564 return;
12565 }
12566 ptr += 2;
12567 if (*ptr == *initc)
12568 {
12569 if (switchit)
12570 {
12571 *backwards = FALSE;
12572 *findc = *initc;
12573 *initc = ptr[-2];
12574 }
12575 else
12576 {
12577 *backwards = TRUE;
12578 *findc = ptr[-2];
12579 }
12580 return;
12581 }
12582 ++ptr;
12583 }
12584 if (*ptr == ',')
12585 ++ptr;
12586 }
12587}
Bram Moolenaar597a4222014-06-25 14:39:50 +020012588
12589#if defined(FEAT_LINEBREAK) || defined(PROTO)
12590/*
12591 * This is called when 'breakindentopt' is changed and when a window is
12592 * initialized.
12593 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012594 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012595briopt_check(win_T *wp)
Bram Moolenaar597a4222014-06-25 14:39:50 +020012596{
12597 char_u *p;
12598 int bri_shift = 0;
12599 long bri_min = 20;
12600 int bri_sbr = FALSE;
12601
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012602 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012603 while (*p != NUL)
12604 {
12605 if (STRNCMP(p, "shift:", 6) == 0
12606 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
12607 {
12608 p += 6;
12609 bri_shift = getdigits(&p);
12610 }
12611 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
12612 {
12613 p += 4;
12614 bri_min = getdigits(&p);
12615 }
12616 else if (STRNCMP(p, "sbr", 3) == 0)
12617 {
12618 p += 3;
12619 bri_sbr = TRUE;
12620 }
12621 if (*p != ',' && *p != NUL)
12622 return FAIL;
12623 if (*p == ',')
12624 ++p;
12625 }
12626
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012627 wp->w_p_brishift = bri_shift;
12628 wp->w_p_brimin = bri_min;
12629 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012630
12631 return OK;
12632}
12633#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012634
12635/*
12636 * Get the local or global value of 'backupcopy'.
12637 */
12638 unsigned int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012639get_bkc_value(buf_T *buf)
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012640{
12641 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
12642}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020012643
12644#if defined(FEAT_SIGNS) || defined(PROTO)
12645/*
12646 * Return TRUE when window "wp" has a column to draw signs in.
12647 */
12648 int
12649signcolumn_on(win_T *wp)
12650{
12651 if (*wp->w_p_scl == 'n')
12652 return FALSE;
12653 if (*wp->w_p_scl == 'y')
12654 return TRUE;
12655 return (wp->w_buffer->b_signlist != NULL
12656# ifdef FEAT_NETBEANS_INTG
12657 || wp->w_buffer->b_has_sign_column
12658# endif
12659 );
12660}
12661#endif
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012662
12663#if defined(FEAT_EVAL) || defined(PROTO)
12664/*
12665 * Get window or buffer local options.
12666 */
12667 dict_T *
12668get_winbuf_options(int bufopt)
12669{
12670 dict_T *d;
12671 int opt_idx;
12672
12673 d = dict_alloc();
12674 if (d == NULL)
12675 return NULL;
12676
12677 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12678 {
12679 struct vimoption *opt = &options[opt_idx];
12680
12681 if ((bufopt && (opt->indir & PV_BUF))
12682 || (!bufopt && (opt->indir & PV_WIN)))
12683 {
12684 char_u *varp = get_varp(opt);
12685
12686 if (varp != NULL)
12687 {
12688 if (opt->flags & P_STRING)
12689 dict_add_nr_str(d, opt->fullname, 0L, *(char_u **)varp);
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012690 else if (opt->flags & P_NUM)
12691 dict_add_nr_str(d, opt->fullname, *(long *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012692 else
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012693 dict_add_nr_str(d, opt->fullname, *(int *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012694 }
12695 }
12696 }
12697
12698 return d;
12699}
12700#endif