blob: f9d273479353914424b1d43b63bb983a704906ca [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 Moolenaar860cae12010-06-05 23:22:07 +0200479 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) || defined(FEAT_CONCEAL)
Bram Moolenaar58b85342016-08-14 19:54:54 +0200480# define HIGHLIGHT_INIT "8:SpecialKey,~:EndOfBuffer,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000481#else
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100482# 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 +0000483#endif
484
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +0100485/* Default python version for pyx* commands */
486#if defined(FEAT_PYTHON) && defined(FEAT_PYTHON3)
487# define DEFAULT_PYTHON_VER 0
488#elif defined(FEAT_PYTHON3)
489# define DEFAULT_PYTHON_VER 3
490#elif defined(FEAT_PYTHON)
491# define DEFAULT_PYTHON_VER 2
492#else
493# define DEFAULT_PYTHON_VER 0
494#endif
495
Bram Moolenaar071d4272004-06-13 20:20:40 +0000496/*
497 * options[] is initialized here.
498 * The order of the options MUST be alphabetic for ":set all" and findoption().
499 * All option names MUST start with a lowercase letter (for findoption()).
500 * Exception: "t_" options are at the end.
501 * The options with a NULL variable are 'hidden': a set command for them is
502 * ignored and they are not printed.
503 */
Bram Moolenaare89ff042016-02-20 22:17:05 +0100504static struct vimoption options[] =
Bram Moolenaar071d4272004-06-13 20:20:40 +0000505{
Bram Moolenaar913077c2012-03-28 19:59:04 +0200506 {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000507#ifdef FEAT_RIGHTLEFT
508 (char_u *)&p_aleph, PV_NONE,
509#else
510 (char_u *)NULL, PV_NONE,
511#endif
512 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100513#if (defined(WIN3264)) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000514 (char_u *)128L,
515#else
516 (char_u *)224L,
517#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000518 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000519 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
520#if defined(FEAT_GUI) && defined(MACOS_X)
521 (char_u *)&p_antialias, PV_NONE,
522 {(char_u *)FALSE, (char_u *)FALSE}
523#else
524 (char_u *)NULL, PV_NONE,
525 {(char_u *)FALSE, (char_u *)FALSE}
526#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000527 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200528 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000529#ifdef FEAT_ARABIC
530 (char_u *)VAR_WIN, PV_ARAB,
531#else
532 (char_u *)NULL, PV_NONE,
533#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000534 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000535 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
536#ifdef FEAT_ARABIC
537 (char_u *)&p_arshape, PV_NONE,
538#else
539 (char_u *)NULL, PV_NONE,
540#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000541 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000542 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
543#ifdef FEAT_RIGHTLEFT
544 (char_u *)&p_ari, PV_NONE,
545#else
546 (char_u *)NULL, PV_NONE,
547#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000548 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000549 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
550#ifdef FEAT_FKMAP
551 (char_u *)&p_altkeymap, PV_NONE,
552#else
553 (char_u *)NULL, PV_NONE,
554#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000555 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000556 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
557#if defined(FEAT_MBYTE)
558 (char_u *)&p_ambw, PV_NONE,
559 {(char_u *)"single", (char_u *)0L}
560#else
561 (char_u *)NULL, PV_NONE,
562 {(char_u *)0L, (char_u *)0L}
563#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000564 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000565 {"autochdir", "acd", P_BOOL|P_VI_DEF,
Bram Moolenaara713ff82017-02-25 22:18:43 +0100566#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +0000567 (char_u *)&p_acd, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +0100568 {(char_u *)FALSE, (char_u *)0L}
569#else
570 (char_u *)NULL, PV_NONE,
571 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000572#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +0100573 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000574 {"autoindent", "ai", P_BOOL|P_VI_DEF,
575 (char_u *)&p_ai, PV_AI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000576 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000577 {"autoprint", "ap", P_BOOL|P_VI_DEF,
578 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000579 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000580 {"autoread", "ar", P_BOOL|P_VI_DEF,
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000581 (char_u *)&p_ar, PV_AR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000582 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000583 {"autowrite", "aw", P_BOOL|P_VI_DEF,
584 (char_u *)&p_aw, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000585 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000586 {"autowriteall","awa", P_BOOL|P_VI_DEF,
587 (char_u *)&p_awa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000588 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000589 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
590 (char_u *)&p_bg, PV_NONE,
591 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +0100592#if (defined(WIN3264)) && !defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000593 (char_u *)"dark",
594#else
595 (char_u *)"light",
596#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000597 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200598 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000599 (char_u *)&p_bs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000600 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000601 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
602 (char_u *)&p_bk, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000603 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200604 {"backupcopy", "bkc", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +0200605 (char_u *)&p_bkc, PV_BKC,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000606#ifdef UNIX
607 {(char_u *)"yes", (char_u *)"auto"}
608#else
609 {(char_u *)"auto", (char_u *)"auto"}
610#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000611 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200612 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
613 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000614 (char_u *)&p_bdir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000615 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000616 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000617 (char_u *)&p_bex, PV_NONE,
618 {
619#ifdef VMS
620 (char_u *)"_",
621#else
622 (char_u *)"~",
623#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000624 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200625 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000626#ifdef FEAT_WILDIGN
627 (char_u *)&p_bsk, PV_NONE,
628 {(char_u *)"", (char_u *)0L}
629#else
630 (char_u *)NULL, PV_NONE,
631 {(char_u *)0L, (char_u *)0L}
632#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000633 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000634 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100635#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +0000636 (char_u *)&p_bdlay, PV_NONE,
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100637 {(char_u *)600L, (char_u *)0L}
638#else
639 (char_u *)NULL, PV_NONE,
640 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000641#endif
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100642 SCRIPTID_INIT},
643 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
644#ifdef FEAT_BEVAL
645 (char_u *)&p_beval, PV_NONE,
646 {(char_u *)FALSE, (char_u *)0L}
647#else
648 (char_u *)NULL, PV_NONE,
649 {(char_u *)0L, (char_u *)0L}
650#endif
651 SCRIPTID_INIT},
652 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
653#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
654 (char_u *)&p_bexpr, PV_BEXPR,
655 {(char_u *)"", (char_u *)0L}
656#else
657 (char_u *)NULL, PV_NONE,
658 {(char_u *)0L, (char_u *)0L}
659#endif
660 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000661 {"beautify", "bf", P_BOOL|P_VI_DEF,
662 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000663 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar165bc692015-07-21 17:53:25 +0200664 {"belloff", "bo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
665 (char_u *)&p_bo, PV_NONE,
666 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000667 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
668 (char_u *)&p_bin, PV_BIN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000669 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000670 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000671 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000672 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000673 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
674#ifdef FEAT_MBYTE
675 (char_u *)&p_bomb, PV_BOMB,
676#else
677 (char_u *)NULL, PV_NONE,
678#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000679 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000680 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
681#ifdef FEAT_LINEBREAK
682 (char_u *)&p_breakat, PV_NONE,
683 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
684#else
685 (char_u *)NULL, PV_NONE,
686 {(char_u *)0L, (char_u *)0L}
687#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000688 SCRIPTID_INIT},
Bram Moolenaar597a4222014-06-25 14:39:50 +0200689 {"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
690#ifdef FEAT_LINEBREAK
691 (char_u *)VAR_WIN, PV_BRI,
692 {(char_u *)FALSE, (char_u *)0L}
693#else
694 (char_u *)NULL, PV_NONE,
695 {(char_u *)0L, (char_u *)0L}
696#endif
697 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200698 {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF
699 |P_ONECOMMA|P_NODUP,
Bram Moolenaar597a4222014-06-25 14:39:50 +0200700#ifdef FEAT_LINEBREAK
701 (char_u *)VAR_WIN, PV_BRIOPT,
702 {(char_u *)"", (char_u *)NULL}
703#else
704 (char_u *)NULL, PV_NONE,
705 {(char_u *)"", (char_u *)NULL}
706#endif
707 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000708 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
709#ifdef FEAT_BROWSE
710 (char_u *)&p_bsdir, PV_NONE,
711 {(char_u *)"last", (char_u *)0L}
712#else
713 (char_u *)NULL, PV_NONE,
714 {(char_u *)0L, (char_u *)0L}
715#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000716 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000717 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
718#if defined(FEAT_QUICKFIX)
719 (char_u *)&p_bh, PV_BH,
720 {(char_u *)"", (char_u *)0L}
721#else
722 (char_u *)NULL, PV_NONE,
723 {(char_u *)0L, (char_u *)0L}
724#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000725 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000726 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
727 (char_u *)&p_bl, PV_BL,
728 {(char_u *)1L, (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000729 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000730 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
731#if defined(FEAT_QUICKFIX)
732 (char_u *)&p_bt, PV_BT,
733 {(char_u *)"", (char_u *)0L}
734#else
735 (char_u *)NULL, PV_NONE,
736 {(char_u *)0L, (char_u *)0L}
737#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000738 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200739 {"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000740#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000741 (char_u *)&p_cmp, PV_NONE,
742 {(char_u *)"internal,keepascii", (char_u *)0L}
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000743#else
744 (char_u *)NULL, PV_NONE,
745 {(char_u *)0L, (char_u *)0L}
746#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000747 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000748 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
749#ifdef FEAT_SEARCHPATH
750 (char_u *)&p_cdpath, PV_NONE,
751 {(char_u *)",,", (char_u *)0L}
752#else
753 (char_u *)NULL, PV_NONE,
754 {(char_u *)0L, (char_u *)0L}
755#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000756 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000757 {"cedit", NULL, P_STRING,
758#ifdef FEAT_CMDWIN
759 (char_u *)&p_cedit, PV_NONE,
760 {(char_u *)"", (char_u *)CTRL_F_STR}
761#else
762 (char_u *)NULL, PV_NONE,
763 {(char_u *)0L, (char_u *)0L}
764#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000765 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000766 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
767#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
768 (char_u *)&p_ccv, PV_NONE,
769 {(char_u *)"", (char_u *)0L}
770#else
771 (char_u *)NULL, PV_NONE,
772 {(char_u *)0L, (char_u *)0L}
773#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000774 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000775 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
776#ifdef FEAT_CINDENT
777 (char_u *)&p_cin, PV_CIN,
778#else
779 (char_u *)NULL, PV_NONE,
780#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000781 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200782 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000783#ifdef FEAT_CINDENT
784 (char_u *)&p_cink, PV_CINK,
785 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
786#else
787 (char_u *)NULL, PV_NONE,
788 {(char_u *)0L, (char_u *)0L}
789#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000790 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200791 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000792#ifdef FEAT_CINDENT
793 (char_u *)&p_cino, PV_CINO,
794#else
795 (char_u *)NULL, PV_NONE,
796#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000797 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200798 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000799#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
800 (char_u *)&p_cinw, PV_CINW,
801 {(char_u *)"if,else,while,do,for,switch",
802 (char_u *)0L}
803#else
804 (char_u *)NULL, PV_NONE,
805 {(char_u *)0L, (char_u *)0L}
806#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000807 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200808 {"clipboard", "cb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000809#ifdef FEAT_CLIPBOARD
810 (char_u *)&p_cb, PV_NONE,
811# ifdef FEAT_XCLIPBOARD
812 {(char_u *)"autoselect,exclude:cons\\|linux",
813 (char_u *)0L}
814# else
815 {(char_u *)"", (char_u *)0L}
816# endif
817#else
818 (char_u *)NULL, PV_NONE,
819 {(char_u *)"", (char_u *)0L}
820#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000821 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000822 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
823 (char_u *)&p_ch, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000824 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000825 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
826#ifdef FEAT_CMDWIN
827 (char_u *)&p_cwh, PV_NONE,
828#else
829 (char_u *)NULL, PV_NONE,
830#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000831 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200832 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar1a384422010-07-14 19:53:30 +0200833#ifdef FEAT_SYN_HL
834 (char_u *)VAR_WIN, PV_CC,
835#else
836 (char_u *)NULL, PV_NONE,
837#endif
838 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000839 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
840 (char_u *)&Columns, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000841 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200842 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
843 |P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000844#ifdef FEAT_COMMENTS
845 (char_u *)&p_com, PV_COM,
846 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
847 (char_u *)0L}
848#else
849 (char_u *)NULL, PV_NONE,
850 {(char_u *)0L, (char_u *)0L}
851#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000852 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200853 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000854#ifdef FEAT_FOLDING
855 (char_u *)&p_cms, PV_CMS,
856 {(char_u *)"/*%s*/", (char_u *)0L}
857#else
858 (char_u *)NULL, PV_NONE,
859 {(char_u *)0L, (char_u *)0L}
860#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000861 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000862 /* P_PRI_MKRC isn't needed here, optval_default()
863 * always returns TRUE for 'compatible' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000864 {"compatible", "cp", P_BOOL|P_RALL,
865 (char_u *)&p_cp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000866 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200867 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000868#ifdef FEAT_INS_EXPAND
869 (char_u *)&p_cpt, PV_CPT,
870 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
871#else
872 (char_u *)NULL, PV_NONE,
873 {(char_u *)0L, (char_u *)0L}
874#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000875 SCRIPTID_INIT},
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200876 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200877#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200878 (char_u *)VAR_WIN, PV_COCU,
879 {(char_u *)"", (char_u *)NULL}
880#else
881 (char_u *)NULL, PV_NONE,
882 {(char_u *)NULL, (char_u *)0L}
883#endif
884 SCRIPTID_INIT},
885 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
886#ifdef FEAT_CONCEAL
887 (char_u *)VAR_WIN, PV_COLE,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200888#else
889 (char_u *)NULL, PV_NONE,
890#endif
891 {(char_u *)0L, (char_u *)0L}
892 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000893 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
894#ifdef FEAT_COMPL_FUNC
895 (char_u *)&p_cfu, PV_CFU,
896 {(char_u *)"", (char_u *)0L}
897#else
898 (char_u *)NULL, PV_NONE,
899 {(char_u *)0L, (char_u *)0L}
900#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000901 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200902 {"completeopt", "cot", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000903#ifdef FEAT_INS_EXPAND
904 (char_u *)&p_cot, PV_NONE,
Bram Moolenaarc270d802006-03-11 21:29:41 +0000905 {(char_u *)"menu,preview", (char_u *)0L}
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000906#else
907 (char_u *)NULL, PV_NONE,
908 {(char_u *)0L, (char_u *)0L}
909#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000910 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000911 {"confirm", "cf", P_BOOL|P_VI_DEF,
912#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
913 (char_u *)&p_confirm, PV_NONE,
914#else
915 (char_u *)NULL, PV_NONE,
916#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000917 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000918 {"conskey", "consk",P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000919 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000920 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000921 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
922 (char_u *)&p_ci, PV_CI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000923 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000924 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
925 (char_u *)&p_cpo, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000926 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
927 SCRIPTID_INIT},
Bram Moolenaar49771f42010-07-20 17:32:38 +0200928 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200929#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200930 (char_u *)&p_cm, PV_CM,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200931 {(char_u *)"zip", (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200932#else
933 (char_u *)NULL, PV_NONE,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200934 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200935#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +0200936 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000937 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
938#ifdef FEAT_CSCOPE
939 (char_u *)&p_cspc, PV_NONE,
940#else
941 (char_u *)NULL, PV_NONE,
942#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000943 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000944 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
945#ifdef FEAT_CSCOPE
946 (char_u *)&p_csprg, PV_NONE,
947 {(char_u *)"cscope", (char_u *)0L}
948#else
949 (char_u *)NULL, PV_NONE,
950 {(char_u *)0L, (char_u *)0L}
951#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000952 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200953 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000954#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
955 (char_u *)&p_csqf, PV_NONE,
956 {(char_u *)"", (char_u *)0L}
957#else
958 (char_u *)NULL, PV_NONE,
959 {(char_u *)0L, (char_u *)0L}
960#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000961 SCRIPTID_INIT},
Bram Moolenaarf7befa92011-06-12 22:13:40 +0200962 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM,
963#ifdef FEAT_CSCOPE
964 (char_u *)&p_csre, PV_NONE,
965#else
966 (char_u *)NULL, PV_NONE,
967#endif
968 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000969 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
970#ifdef FEAT_CSCOPE
971 (char_u *)&p_cst, PV_NONE,
972#else
973 (char_u *)NULL, PV_NONE,
974#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000975 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000976 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
977#ifdef FEAT_CSCOPE
978 (char_u *)&p_csto, PV_NONE,
979#else
980 (char_u *)NULL, PV_NONE,
981#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000982 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000983 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
984#ifdef FEAT_CSCOPE
985 (char_u *)&p_csverbose, PV_NONE,
986#else
987 (char_u *)NULL, PV_NONE,
988#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000989 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200990 {"cursorbind", "crb", P_BOOL|P_VI_DEF,
991#ifdef FEAT_CURSORBIND
992 (char_u *)VAR_WIN, PV_CRBIND,
993#else
994 (char_u *)NULL, PV_NONE,
995#endif
996 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000997 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
998#ifdef FEAT_SYN_HL
999 (char_u *)VAR_WIN, PV_CUC,
1000#else
1001 (char_u *)NULL, PV_NONE,
1002#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001003 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara2477fd2016-12-03 15:13:20 +01001004 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWINONLY,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001005#ifdef FEAT_SYN_HL
1006 (char_u *)VAR_WIN, PV_CUL,
1007#else
1008 (char_u *)NULL, PV_NONE,
1009#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001010 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001011 {"debug", NULL, P_STRING|P_VI_DEF,
1012 (char_u *)&p_debug, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001013 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001014 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001015#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001016 (char_u *)&p_def, PV_DEF,
Bram Moolenaard4755bb2004-09-02 19:12:26 +00001017 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001018#else
1019 (char_u *)NULL, PV_NONE,
1020 {(char_u *)NULL, (char_u *)0L}
1021#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001022 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001023 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
1024#ifdef FEAT_MBYTE
1025 (char_u *)&p_deco, PV_NONE,
1026#else
1027 (char_u *)NULL, PV_NONE,
1028#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001029 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7554da42016-11-25 22:04:13 +01001030 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001031#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001032 (char_u *)&p_dict, PV_DICT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001033#else
1034 (char_u *)NULL, PV_NONE,
1035#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001036 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001037 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
1038#ifdef FEAT_DIFF
1039 (char_u *)VAR_WIN, PV_DIFF,
1040#else
1041 (char_u *)NULL, PV_NONE,
1042#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001043 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001044 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001045#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1046 (char_u *)&p_dex, PV_NONE,
1047 {(char_u *)"", (char_u *)0L}
1048#else
1049 (char_u *)NULL, PV_NONE,
1050 {(char_u *)0L, (char_u *)0L}
1051#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001052 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001053 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_ONECOMMA
1054 |P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001055#ifdef FEAT_DIFF
1056 (char_u *)&p_dip, PV_NONE,
1057 {(char_u *)"filler", (char_u *)NULL}
1058#else
1059 (char_u *)NULL, PV_NONE,
1060 {(char_u *)"", (char_u *)NULL}
1061#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001062 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001063 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
1064#ifdef FEAT_DIGRAPHS
1065 (char_u *)&p_dg, PV_NONE,
1066#else
1067 (char_u *)NULL, PV_NONE,
1068#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001069 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001070 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
1071 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001072 (char_u *)&p_dir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001073 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001074 {"display", "dy", P_STRING|P_VI_DEF|P_ONECOMMA|P_RALL|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001075 (char_u *)&p_dy, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001076 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001077 {"eadirection", "ead", P_STRING|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01001078#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001079 (char_u *)&p_ead, PV_NONE,
1080 {(char_u *)"both", (char_u *)0L}
1081#else
1082 (char_u *)NULL, PV_NONE,
1083 {(char_u *)NULL, (char_u *)0L}
1084#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001085 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001086 {"edcompatible","ed", P_BOOL|P_VI_DEF,
1087 (char_u *)&p_ed, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001088 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3848e002016-03-19 18:42:29 +01001089 {"emoji", "emo", P_BOOL|P_VI_DEF|P_RCLR,
1090#if defined(FEAT_MBYTE)
1091 (char_u *)&p_emoji, PV_NONE,
1092 {(char_u *)TRUE, (char_u *)0L}
1093#else
1094 (char_u *)NULL, PV_NONE,
1095 {(char_u *)0L, (char_u *)0L}
1096#endif
1097 SCRIPTID_INIT},
Bram Moolenaar865242e2010-07-14 21:12:05 +02001098 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001099#ifdef FEAT_MBYTE
1100 (char_u *)&p_enc, PV_NONE,
1101 {(char_u *)ENC_DFLT, (char_u *)0L}
1102#else
1103 (char_u *)NULL, PV_NONE,
1104 {(char_u *)0L, (char_u *)0L}
1105#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001106 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001107 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1108 (char_u *)&p_eol, PV_EOL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001109 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001110 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1111 (char_u *)&p_ea, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001112 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001113 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001114 (char_u *)&p_ep, PV_EP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001115 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001116 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1117 (char_u *)&p_eb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001118 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001119 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1120#ifdef FEAT_QUICKFIX
1121 (char_u *)&p_ef, PV_NONE,
1122 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1123#else
1124 (char_u *)NULL, PV_NONE,
1125 {(char_u *)NULL, (char_u *)0L}
1126#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001127 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001128 {"errorformat", "efm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001129#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001130 (char_u *)&p_efm, PV_EFM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001131 {(char_u *)DFLT_EFM, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001132#else
1133 (char_u *)NULL, PV_NONE,
1134 {(char_u *)NULL, (char_u *)0L}
1135#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001136 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001137 {"esckeys", "ek", P_BOOL|P_VIM,
1138 (char_u *)&p_ek, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001139 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001140 {"eventignore", "ei", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001141#ifdef FEAT_AUTOCMD
1142 (char_u *)&p_ei, PV_NONE,
1143#else
1144 (char_u *)NULL, PV_NONE,
1145#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001146 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001147 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1148 (char_u *)&p_et, PV_ET,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001149 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001150 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1151 (char_u *)&p_exrc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001152 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001153 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF
1154 |P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001155#ifdef FEAT_MBYTE
1156 (char_u *)&p_fenc, PV_FENC,
1157 {(char_u *)"", (char_u *)0L}
1158#else
1159 (char_u *)NULL, PV_NONE,
1160 {(char_u *)0L, (char_u *)0L}
1161#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001162 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001163 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001164#ifdef FEAT_MBYTE
1165 (char_u *)&p_fencs, PV_NONE,
1166 {(char_u *)"ucs-bom", (char_u *)0L}
1167#else
1168 (char_u *)NULL, PV_NONE,
1169 {(char_u *)0L, (char_u *)0L}
1170#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001171 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001172 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC
1173 |P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001174 (char_u *)&p_ff, PV_FF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001175 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001176 {"fileformats", "ffs", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001177 (char_u *)&p_ffs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001178 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1179 SCRIPTID_INIT},
Bram Moolenaar71afbfe2013-03-19 16:49:16 +01001180 {"fileignorecase", "fic", P_BOOL|P_VI_DEF,
1181 (char_u *)&p_fic, PV_NONE,
1182 {
1183#ifdef CASE_INSENSITIVE_FILENAME
1184 (char_u *)TRUE,
1185#else
1186 (char_u *)FALSE,
1187#endif
1188 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001189 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001190#ifdef FEAT_AUTOCMD
1191 (char_u *)&p_ft, PV_FT,
1192 {(char_u *)"", (char_u *)0L}
1193#else
1194 (char_u *)NULL, PV_NONE,
1195 {(char_u *)0L, (char_u *)0L}
1196#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001197 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001198 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001199#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1200 (char_u *)&p_fcs, PV_NONE,
1201 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1202#else
1203 (char_u *)NULL, PV_NONE,
1204 {(char_u *)"", (char_u *)0L}
1205#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001206 SCRIPTID_INIT},
Bram Moolenaar34d72d42015-07-17 14:18:08 +02001207 {"fixendofline", "fixeol", P_BOOL|P_VI_DEF|P_RSTAT,
1208 (char_u *)&p_fixeol, PV_FIXEOL,
1209 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001210 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1211#ifdef FEAT_FKMAP
1212 (char_u *)&p_fkmap, PV_NONE,
1213#else
1214 (char_u *)NULL, PV_NONE,
1215#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001216 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001217 {"flash", "fl", P_BOOL|P_VI_DEF,
1218 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001219 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001220 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001221#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001222 (char_u *)&p_fcl, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001223 {(char_u *)"", (char_u *)0L}
1224#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001225 (char_u *)NULL, PV_NONE,
1226 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001227#endif
1228 SCRIPTID_INIT},
1229 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1230#ifdef FEAT_FOLDING
1231 (char_u *)VAR_WIN, PV_FDC,
1232 {(char_u *)FALSE, (char_u *)0L}
1233#else
1234 (char_u *)NULL, PV_NONE,
1235 {(char_u *)NULL, (char_u *)0L}
1236#endif
1237 SCRIPTID_INIT},
1238 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1239#ifdef FEAT_FOLDING
1240 (char_u *)VAR_WIN, PV_FEN,
1241 {(char_u *)TRUE, (char_u *)0L}
1242#else
1243 (char_u *)NULL, PV_NONE,
1244 {(char_u *)NULL, (char_u *)0L}
1245#endif
1246 SCRIPTID_INIT},
1247 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1248#if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
1249 (char_u *)VAR_WIN, PV_FDE,
1250 {(char_u *)"0", (char_u *)NULL}
1251#else
1252 (char_u *)NULL, PV_NONE,
1253 {(char_u *)NULL, (char_u *)0L}
1254#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001255 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001256 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001257#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001258 (char_u *)VAR_WIN, PV_FDI,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001259 {(char_u *)"#", (char_u *)NULL}
1260#else
1261 (char_u *)NULL, PV_NONE,
1262 {(char_u *)NULL, (char_u *)0L}
1263#endif
1264 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001265 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001266#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001267 (char_u *)VAR_WIN, PV_FDL,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001268 {(char_u *)0L, (char_u *)0L}
1269#else
1270 (char_u *)NULL, PV_NONE,
1271 {(char_u *)NULL, (char_u *)0L}
1272#endif
1273 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001274 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001275#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001276 (char_u *)&p_fdls, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001277 {(char_u *)-1L, (char_u *)0L}
1278#else
1279 (char_u *)NULL, PV_NONE,
1280 {(char_u *)NULL, (char_u *)0L}
1281#endif
1282 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001283 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001284 P_RWIN|P_ONECOMMA|P_NODUP,
Bram Moolenaar37640762017-02-25 22:37:15 +01001285#ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00001286 (char_u *)VAR_WIN, PV_FMR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001287 {(char_u *)"{{{,}}}", (char_u *)NULL}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001288#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001289 (char_u *)NULL, PV_NONE,
1290 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001291#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01001292 SCRIPTID_INIT},
1293 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1294#ifdef FEAT_FOLDING
1295 (char_u *)VAR_WIN, PV_FDM,
1296 {(char_u *)"manual", (char_u *)NULL}
1297#else
1298 (char_u *)NULL, PV_NONE,
1299 {(char_u *)NULL, (char_u *)0L}
1300#endif
1301 SCRIPTID_INIT},
1302 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1303#ifdef FEAT_FOLDING
1304 (char_u *)VAR_WIN, PV_FML,
1305 {(char_u *)1L, (char_u *)0L}
1306#else
1307 (char_u *)NULL, PV_NONE,
1308 {(char_u *)NULL, (char_u *)0L}
1309#endif
1310 SCRIPTID_INIT},
1311 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1312#ifdef FEAT_FOLDING
1313 (char_u *)VAR_WIN, PV_FDN,
1314 {(char_u *)20L, (char_u *)0L}
1315#else
1316 (char_u *)NULL, PV_NONE,
1317 {(char_u *)NULL, (char_u *)0L}
1318#endif
1319 SCRIPTID_INIT},
1320 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT,
1321#ifdef FEAT_FOLDING
1322 (char_u *)&p_fdo, PV_NONE,
1323 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
1324 (char_u *)0L}
1325#else
1326 (char_u *)NULL, PV_NONE,
1327 {(char_u *)NULL, (char_u *)0L}
1328#endif
1329 SCRIPTID_INIT},
1330 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1331#if defined(FEAT_FOLDING) && defined(FEAT_EVAL)
1332 (char_u *)VAR_WIN, PV_FDT,
1333 {(char_u *)"foldtext()", (char_u *)NULL}
1334#else
1335 (char_u *)NULL, PV_NONE,
1336 {(char_u *)NULL, (char_u *)0L}
1337#endif
1338 SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001339 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001340#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001341 (char_u *)&p_fex, PV_FEX,
1342 {(char_u *)"", (char_u *)0L}
1343#else
1344 (char_u *)NULL, PV_NONE,
1345 {(char_u *)0L, (char_u *)0L}
1346#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001347 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001348 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1349 (char_u *)&p_fo, PV_FO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001350 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1351 SCRIPTID_INIT},
Bram Moolenaar86b68352004-12-27 21:59:20 +00001352 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1353 (char_u *)&p_flp, PV_FLP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001354 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1355 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001356 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar9be7c042017-01-14 14:28:30 +01001357 (char_u *)&p_fp, PV_FP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001358 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001359 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1360#ifdef HAVE_FSYNC
1361 (char_u *)&p_fs, PV_NONE,
1362 {(char_u *)TRUE, (char_u *)0L}
1363#else
1364 (char_u *)NULL, PV_NONE,
1365 {(char_u *)FALSE, (char_u *)0L}
1366#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001367 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001368 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1369 (char_u *)&p_gd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001370 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001371 {"graphic", "gr", P_BOOL|P_VI_DEF,
1372 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001373 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001374 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001375#ifdef FEAT_QUICKFIX
1376 (char_u *)&p_gefm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001377 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001378#else
1379 (char_u *)NULL, PV_NONE,
1380 {(char_u *)NULL, (char_u *)0L}
1381#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001382 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001383 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1384#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001385 (char_u *)&p_gp, PV_GP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001386 {
1387# ifdef WIN3264
1388 /* may be changed to "grep -n" in os_win32.c */
1389 (char_u *)"findstr /n",
1390# else
1391# ifdef UNIX
1392 /* Add an extra file name so that grep will always
1393 * insert a file name in the match line. */
1394 (char_u *)"grep -n $* /dev/null",
1395# else
1396# ifdef VMS
1397 (char_u *)"SEARCH/NUMBERS ",
1398# else
1399 (char_u *)"grep -n ",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001400# endif
1401# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001402# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001403 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001404#else
1405 (char_u *)NULL, PV_NONE,
1406 {(char_u *)NULL, (char_u *)0L}
1407#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001408 SCRIPTID_INIT},
Bram Moolenaar8a633e32016-04-21 21:10:14 +02001409 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001410#ifdef CURSOR_SHAPE
1411 (char_u *)&p_guicursor, PV_NONE,
1412 {
1413# ifdef FEAT_GUI
1414 (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 +01001415# else /* Win32 console */
Bram Moolenaar071d4272004-06-13 20:20:40 +00001416 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1417# endif
1418 (char_u *)0L}
1419#else
1420 (char_u *)NULL, PV_NONE,
1421 {(char_u *)NULL, (char_u *)0L}
1422#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001423 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001424 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001425#ifdef FEAT_GUI
1426 (char_u *)&p_guifont, PV_NONE,
1427 {(char_u *)"", (char_u *)0L}
1428#else
1429 (char_u *)NULL, PV_NONE,
1430 {(char_u *)NULL, (char_u *)0L}
1431#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001432 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001433 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001434#if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1435 (char_u *)&p_guifontset, PV_NONE,
1436 {(char_u *)"", (char_u *)0L}
1437#else
1438 (char_u *)NULL, PV_NONE,
1439 {(char_u *)NULL, (char_u *)0L}
1440#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001441 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001442 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001443#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1444 (char_u *)&p_guifontwide, PV_NONE,
1445 {(char_u *)"", (char_u *)0L}
1446#else
1447 (char_u *)NULL, PV_NONE,
1448 {(char_u *)NULL, (char_u *)0L}
1449#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001450 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001451 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001452#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001453 (char_u *)&p_ghr, PV_NONE,
1454#else
1455 (char_u *)NULL, PV_NONE,
1456#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001457 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001458 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001459#if defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001460 (char_u *)&p_go, PV_NONE,
1461# if defined(UNIX) && !defined(MACOS)
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001462 {(char_u *)"aegimrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001463# else
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001464 {(char_u *)"egmrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001465# endif
1466#else
1467 (char_u *)NULL, PV_NONE,
1468 {(char_u *)NULL, (char_u *)0L}
1469#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001470 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001471 {"guipty", NULL, P_BOOL|P_VI_DEF,
1472#if defined(FEAT_GUI)
1473 (char_u *)&p_guipty, PV_NONE,
1474#else
1475 (char_u *)NULL, PV_NONE,
1476#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001477 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar18144c82006-04-12 21:52:12 +00001478 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00001479#if defined(FEAT_GUI_TABLINE)
1480 (char_u *)&p_gtl, PV_NONE,
1481 {(char_u *)"", (char_u *)0L}
1482#else
1483 (char_u *)NULL, PV_NONE,
1484 {(char_u *)NULL, (char_u *)0L}
1485#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001486 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001487 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar57657d82006-04-21 22:12:41 +00001488#if defined(FEAT_GUI_TABLINE)
1489 (char_u *)&p_gtt, PV_NONE,
1490 {(char_u *)"", (char_u *)0L}
1491#else
1492 (char_u *)NULL, PV_NONE,
1493 {(char_u *)NULL, (char_u *)0L}
1494#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001495 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001496 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1497 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001498 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001499 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1500 (char_u *)&p_hf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001501 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1502 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001503 {"helpheight", "hh", P_NUM|P_VI_DEF,
1504#ifdef FEAT_WINDOWS
1505 (char_u *)&p_hh, PV_NONE,
1506#else
1507 (char_u *)NULL, PV_NONE,
1508#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001509 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001510 {"helplang", "hlg", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001511#ifdef FEAT_MULTI_LANG
1512 (char_u *)&p_hlg, PV_NONE,
1513 {(char_u *)"", (char_u *)0L}
1514#else
1515 (char_u *)NULL, PV_NONE,
1516 {(char_u *)0L, (char_u *)0L}
1517#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001518 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001519 {"hidden", "hid", P_BOOL|P_VI_DEF,
1520 (char_u *)&p_hid, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001521 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001522 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001523 (char_u *)&p_hl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001524 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1525 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001526 {"history", "hi", P_NUM|P_VIM,
1527 (char_u *)&p_hi, PV_NONE,
Bram Moolenaar78159bb2014-06-25 11:48:54 +02001528 {(char_u *)0L, (char_u *)50L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001529 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1530#ifdef FEAT_RIGHTLEFT
1531 (char_u *)&p_hkmap, PV_NONE,
1532#else
1533 (char_u *)NULL, PV_NONE,
1534#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001535 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001536 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1537#ifdef FEAT_RIGHTLEFT
1538 (char_u *)&p_hkmapp, PV_NONE,
1539#else
1540 (char_u *)NULL, PV_NONE,
1541#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001542 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001543 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1544 (char_u *)&p_hls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001545 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001546 {"icon", NULL, P_BOOL|P_VI_DEF,
1547#ifdef FEAT_TITLE
1548 (char_u *)&p_icon, PV_NONE,
1549#else
1550 (char_u *)NULL, PV_NONE,
1551#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001552 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001553 {"iconstring", NULL, P_STRING|P_VI_DEF,
1554#ifdef FEAT_TITLE
1555 (char_u *)&p_iconstring, PV_NONE,
1556#else
1557 (char_u *)NULL, PV_NONE,
1558#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001559 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001560 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1561 (char_u *)&p_ic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001562 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001563 {"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
1564# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1565 (char_u *)&p_imaf, PV_NONE,
1566 {(char_u *)"", (char_u *)NULL}
1567# else
1568 (char_u *)NULL, PV_NONE,
1569 {(char_u *)NULL, (char_u *)0L}
1570# endif
1571 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001572 {"imactivatekey","imak",P_STRING|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001573#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001574 (char_u *)&p_imak, PV_NONE,
1575#else
1576 (char_u *)NULL, PV_NONE,
1577#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001578 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001579 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1580#ifdef USE_IM_CONTROL
1581 (char_u *)&p_imcmdline, PV_NONE,
1582#else
1583 (char_u *)NULL, PV_NONE,
1584#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001585 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001586 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1587#ifdef USE_IM_CONTROL
1588 (char_u *)&p_imdisable, PV_NONE,
1589#else
1590 (char_u *)NULL, PV_NONE,
1591#endif
1592#ifdef __sgi
1593 {(char_u *)TRUE, (char_u *)0L}
1594#else
1595 {(char_u *)FALSE, (char_u *)0L}
1596#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001597 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001598 {"iminsert", "imi", P_NUM|P_VI_DEF,
1599 (char_u *)&p_iminsert, PV_IMI,
1600#ifdef B_IMODE_IM
1601 {(char_u *)B_IMODE_IM, (char_u *)0L}
1602#else
1603 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1604#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001605 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001606 {"imsearch", "ims", P_NUM|P_VI_DEF,
1607 (char_u *)&p_imsearch, PV_IMS,
1608#ifdef B_IMODE_IM
1609 {(char_u *)B_IMODE_IM, (char_u *)0L}
1610#else
1611 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1612#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001613 SCRIPTID_INIT},
Bram Moolenaar4a460702013-06-29 14:42:26 +02001614 {"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001615# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1616 (char_u *)&p_imsf, PV_NONE,
1617 {(char_u *)"", (char_u *)NULL}
1618# else
1619 (char_u *)NULL, PV_NONE,
1620 {(char_u *)NULL, (char_u *)0L}
1621# endif
1622 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001623 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1624#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001625 (char_u *)&p_inc, PV_INC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001626 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1627#else
1628 (char_u *)NULL, PV_NONE,
1629 {(char_u *)0L, (char_u *)0L}
1630#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001631 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001632 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1633#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1634 (char_u *)&p_inex, PV_INEX,
1635 {(char_u *)"", (char_u *)0L}
1636#else
1637 (char_u *)NULL, PV_NONE,
1638 {(char_u *)0L, (char_u *)0L}
1639#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001640 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001641 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1642 (char_u *)&p_is, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001643 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001644 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1645#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1646 (char_u *)&p_inde, PV_INDE,
1647 {(char_u *)"", (char_u *)0L}
1648#else
1649 (char_u *)NULL, PV_NONE,
1650 {(char_u *)0L, (char_u *)0L}
1651#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001652 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001653 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001654#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1655 (char_u *)&p_indk, PV_INDK,
1656 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1657#else
1658 (char_u *)NULL, PV_NONE,
1659 {(char_u *)0L, (char_u *)0L}
1660#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001661 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001662 {"infercase", "inf", P_BOOL|P_VI_DEF,
1663 (char_u *)&p_inf, PV_INF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001664 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001665 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1666 (char_u *)&p_im, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001667 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001668 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1669 (char_u *)&p_isf, PV_NONE,
1670 {
1671#ifdef BACKSLASH_IN_FILENAME
1672 /* Excluded are: & and ^ are special in cmd.exe
1673 * ( and ) are used in text separating fnames */
1674 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1675#else
1676# ifdef AMIGA
1677 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1678# else
1679# ifdef VMS
1680 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1681# else /* UNIX et al. */
1682# ifdef EBCDIC
1683 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1684# else
1685 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1686# endif
1687# endif
1688# endif
1689#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001690 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001691 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1692 (char_u *)&p_isi, PV_NONE,
1693 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001694#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001695 (char_u *)"@,48-57,_,128-167,224-235",
1696#else
1697# ifdef EBCDIC
1698 /* TODO: EBCDIC Check this! @ == isalpha()*/
1699 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1700 "112-120,128,140-142,156,158,172,"
1701 "174,186,191,203-207,219-225,235-239,"
1702 "251-254",
1703# else
1704 (char_u *)"@,48-57,_,192-255",
1705# endif
1706#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001707 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001708 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1709 (char_u *)&p_isk, PV_ISK,
1710 {
1711#ifdef EBCDIC
1712 (char_u *)"@,240-249,_",
1713 /* TODO: EBCDIC Check this! @ == isalpha()*/
1714 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1715 "112-120,128,140-142,156,158,172,"
1716 "174,186,191,203-207,219-225,235-239,"
1717 "251-254",
1718#else
1719 (char_u *)"@,48-57,_",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001720# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001721 (char_u *)"@,48-57,_,128-167,224-235"
1722# else
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001723 ISK_LATIN1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001724# endif
1725#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001726 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001727 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1728 (char_u *)&p_isp, PV_NONE,
1729 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001730#if defined(MSWIN) || (defined(MACOS) && !defined(MACOS_X)) \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001731 || defined(VMS)
1732 (char_u *)"@,~-255",
1733#else
1734# ifdef EBCDIC
1735 /* all chars above 63 are printable */
1736 (char_u *)"63-255",
1737# else
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00001738 ISP_LATIN1,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001739# endif
1740#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001741 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001742 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1743 (char_u *)&p_js, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001744 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001745 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1746#ifdef FEAT_CRYPT
1747 (char_u *)&p_key, PV_KEY,
1748 {(char_u *)"", (char_u *)0L}
1749#else
1750 (char_u *)NULL, PV_NONE,
1751 {(char_u *)0L, (char_u *)0L}
1752#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001753 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001754 {"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 +00001755#ifdef FEAT_KEYMAP
1756 (char_u *)&p_keymap, PV_KMAP,
1757 {(char_u *)"", (char_u *)0L}
1758#else
1759 (char_u *)NULL, PV_NONE,
1760 {(char_u *)"", (char_u *)0L}
1761#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001762 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001763 {"keymodel", "km", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001764 (char_u *)&p_km, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001765 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001766 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001767 (char_u *)&p_kp, PV_KP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001768 {
Bram Moolenaarfd89d7e2016-06-04 20:25:05 +02001769#ifdef MSWIN
Bram Moolenaar071d4272004-06-13 20:20:40 +00001770 (char_u *)":help",
1771#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001772# ifdef VMS
Bram Moolenaar071d4272004-06-13 20:20:40 +00001773 (char_u *)"help",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01001774# else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001775# ifdef USEMAN_S
1776 (char_u *)"man -s",
1777# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001778 (char_u *)"man",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001779# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001780# endif
1781#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001782 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001783 {"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001784#ifdef FEAT_LANGMAP
1785 (char_u *)&p_langmap, PV_NONE,
1786 {(char_u *)"", /* unmatched } */
1787#else
1788 (char_u *)NULL, PV_NONE,
1789 {(char_u *)NULL,
1790#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001791 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001792 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001793#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1794 (char_u *)&p_lm, PV_NONE,
1795#else
1796 (char_u *)NULL, PV_NONE,
1797#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001798 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar4391cf92014-11-05 17:44:52 +01001799 {"langnoremap", "lnr", P_BOOL|P_VI_DEF,
1800#ifdef FEAT_LANGMAP
1801 (char_u *)&p_lnr, PV_NONE,
1802#else
1803 (char_u *)NULL, PV_NONE,
1804#endif
1805 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar920694c2016-08-21 17:45:02 +02001806 {"langremap", "lrm", P_BOOL|P_VI_DEF,
1807#ifdef FEAT_LANGMAP
1808 (char_u *)&p_lrm, PV_NONE,
1809#else
1810 (char_u *)NULL, PV_NONE,
1811#endif
Bram Moolenaarda9ce2c2016-09-02 19:34:10 +02001812 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001813 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1814#ifdef FEAT_WINDOWS
1815 (char_u *)&p_ls, PV_NONE,
1816#else
1817 (char_u *)NULL, PV_NONE,
1818#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001819 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001820 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1821 (char_u *)&p_lz, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001822 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001823 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1824#ifdef FEAT_LINEBREAK
1825 (char_u *)VAR_WIN, PV_LBR,
1826#else
1827 (char_u *)NULL, PV_NONE,
1828#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001829 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001830 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1831 (char_u *)&Rows, PV_NONE,
1832 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01001833#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001834 (char_u *)25L,
1835#else
1836 (char_u *)24L,
1837#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001838 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001839 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1840#ifdef FEAT_GUI
1841 (char_u *)&p_linespace, PV_NONE,
1842#else
1843 (char_u *)NULL, PV_NONE,
1844#endif
1845#ifdef FEAT_GUI_W32
1846 {(char_u *)1L, (char_u *)0L}
1847#else
1848 {(char_u *)0L, (char_u *)0L}
1849#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001850 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001851 {"lisp", NULL, P_BOOL|P_VI_DEF,
1852#ifdef FEAT_LISP
1853 (char_u *)&p_lisp, PV_LISP,
1854#else
1855 (char_u *)NULL, PV_NONE,
1856#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001857 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001858 {"lispwords", "lw", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001859#ifdef FEAT_LISP
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01001860 (char_u *)&p_lispwords, PV_LW,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001861 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1862#else
1863 (char_u *)NULL, PV_NONE,
1864 {(char_u *)"", (char_u *)0L}
1865#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001866 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001867 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1868 (char_u *)VAR_WIN, PV_LIST,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001869 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001870 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001871 (char_u *)&p_lcs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001872 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001873 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1874 (char_u *)&p_lpl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001875 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02001876 {"luadll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001877#if defined(DYNAMIC_LUA)
Bram Moolenaard94464e2015-11-02 15:28:18 +01001878 (char_u *)&p_luadll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001879 {(char_u *)DYNAMIC_LUA_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01001880#else
1881 (char_u *)NULL, PV_NONE,
1882 {(char_u *)"", (char_u *)0L}
1883#endif
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01001884 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001885 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001886#ifdef FEAT_GUI_MAC
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001887 (char_u *)&p_macatsui, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01001888 {(char_u *)TRUE, (char_u *)0L}
1889#else
1890 (char_u *)NULL, PV_NONE,
1891 {(char_u *)"", (char_u *)0L}
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001892#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01001893 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001894 {"magic", NULL, P_BOOL|P_VI_DEF,
1895 (char_u *)&p_magic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001896 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00001897 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001898#ifdef FEAT_QUICKFIX
1899 (char_u *)&p_mef, PV_NONE,
1900 {(char_u *)"", (char_u *)0L}
1901#else
1902 (char_u *)NULL, PV_NONE,
1903 {(char_u *)NULL, (char_u *)0L}
1904#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001905 SCRIPTID_INIT},
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01001906 {"makeencoding","menc", P_STRING|P_VI_DEF,
1907#ifdef FEAT_MBYTE
1908 (char_u *)&p_menc, PV_MENC,
1909 {(char_u *)"", (char_u *)0L}
1910#else
1911 (char_u *)NULL, PV_NONE,
1912 {(char_u *)0L, (char_u *)0L}
1913#endif
1914 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001915 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1916#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001917 (char_u *)&p_mp, PV_MP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001918# ifdef VMS
1919 {(char_u *)"MMS", (char_u *)0L}
1920# else
1921 {(char_u *)"make", (char_u *)0L}
1922# endif
1923#else
1924 (char_u *)NULL, PV_NONE,
1925 {(char_u *)NULL, (char_u *)0L}
1926#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001927 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001928 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001929 (char_u *)&p_mps, PV_MPS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001930 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1931 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001932 {"matchtime", "mat", P_NUM|P_VI_DEF,
1933 (char_u *)&p_mat, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001934 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001935 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001936#ifdef FEAT_MBYTE
1937 (char_u *)&p_mco, PV_NONE,
1938#else
1939 (char_u *)NULL, PV_NONE,
1940#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001941 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001942 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1943#ifdef FEAT_EVAL
1944 (char_u *)&p_mfd, PV_NONE,
1945#else
1946 (char_u *)NULL, PV_NONE,
1947#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001948 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001949 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1950 (char_u *)&p_mmd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001951 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001952 {"maxmem", "mm", P_NUM|P_VI_DEF,
1953 (char_u *)&p_mm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001954 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1955 SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00001956 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1957 (char_u *)&p_mmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001958 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001959 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1960 (char_u *)&p_mmt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001961 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1962 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001963 {"menuitems", "mis", P_NUM|P_VI_DEF,
1964#ifdef FEAT_MENU
1965 (char_u *)&p_mis, PV_NONE,
1966#else
1967 (char_u *)NULL, PV_NONE,
1968#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001969 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001970 {"mesg", NULL, P_BOOL|P_VI_DEF,
1971 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001972 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001973 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001974#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001975 (char_u *)&p_msm, PV_NONE,
1976 {(char_u *)"460000,2000,500", (char_u *)0L}
1977#else
1978 (char_u *)NULL, PV_NONE,
1979 {(char_u *)0L, (char_u *)0L}
1980#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001981 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001982 {"modeline", "ml", P_BOOL|P_VIM,
1983 (char_u *)&p_ml, PV_ML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001984 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001985 {"modelines", "mls", P_NUM|P_VI_DEF,
1986 (char_u *)&p_mls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001987 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001988 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1989 (char_u *)&p_ma, PV_MA,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001990 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001991 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1992 (char_u *)&p_mod, PV_MOD,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001993 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001994 {"more", NULL, P_BOOL|P_VIM,
1995 (char_u *)&p_more, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001996 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001997 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
1998 (char_u *)&p_mouse, PV_NONE,
1999 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002000#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002001 (char_u *)"a",
2002#else
2003 (char_u *)"",
2004#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002005 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002006 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
2007#ifdef FEAT_GUI
2008 (char_u *)&p_mousef, PV_NONE,
2009#else
2010 (char_u *)NULL, PV_NONE,
2011#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002012 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002013 {"mousehide", "mh", P_BOOL|P_VI_DEF,
2014#ifdef FEAT_GUI
2015 (char_u *)&p_mh, PV_NONE,
2016#else
2017 (char_u *)NULL, PV_NONE,
2018#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002019 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002020 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
2021 (char_u *)&p_mousem, PV_NONE,
2022 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002023#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002024 (char_u *)"popup",
2025#else
2026# if defined(MACOS)
2027 (char_u *)"popup_setpos",
2028# else
2029 (char_u *)"extend",
2030# endif
2031#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002032 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002033 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002034#ifdef FEAT_MOUSESHAPE
2035 (char_u *)&p_mouseshape, PV_NONE,
2036 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
2037#else
2038 (char_u *)NULL, PV_NONE,
2039 {(char_u *)NULL, (char_u *)0L}
2040#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002041 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002042 {"mousetime", "mouset", P_NUM|P_VI_DEF,
2043 (char_u *)&p_mouset, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002044 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar325b7a22004-07-05 15:58:32 +00002045 {"mzquantum", "mzq", P_NUM,
2046#ifdef FEAT_MZSCHEME
2047 (char_u *)&p_mzq, PV_NONE,
2048#else
2049 (char_u *)NULL, PV_NONE,
2050#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002051 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002052 {"novice", NULL, P_BOOL|P_VI_DEF,
2053 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002054 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002055 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002056 (char_u *)&p_nf, PV_NF,
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01002057 {(char_u *)"bin,octal,hex", (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002058 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002059 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
2060 (char_u *)VAR_WIN, PV_NU,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002061 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002062 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
2063#ifdef FEAT_LINEBREAK
2064 (char_u *)VAR_WIN, PV_NUW,
2065#else
2066 (char_u *)NULL, PV_NONE,
2067#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002068 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
Bram Moolenaarf75a9632005-09-13 21:20:47 +00002069 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
Bram Moolenaare344bea2005-09-01 20:46:49 +00002070#ifdef FEAT_COMPL_FUNC
2071 (char_u *)&p_ofu, PV_OFU,
2072 {(char_u *)"", (char_u *)0L}
2073#else
2074 (char_u *)NULL, PV_NONE,
2075 {(char_u *)0L, (char_u *)0L}
2076#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002077 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002078 {"open", NULL, P_BOOL|P_VI_DEF,
2079 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002080 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar043545e2006-10-10 16:44:07 +00002081 {"opendevice", "odev", P_BOOL|P_VI_DEF,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002082#if defined(MSWIN)
Bram Moolenaar043545e2006-10-10 16:44:07 +00002083 (char_u *)&p_odev, PV_NONE,
2084#else
2085 (char_u *)NULL, PV_NONE,
2086#endif
2087 {(char_u *)FALSE, (char_u *)FALSE}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002088 SCRIPTID_INIT},
Bram Moolenaar2c7a29c2005-12-12 22:02:31 +00002089 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
2090 (char_u *)&p_opfunc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002091 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002092 {"optimize", "opt", P_BOOL|P_VI_DEF,
2093 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002094 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002095 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002096 (char_u *)NULL, PV_NONE,
Bram Moolenaarb07269a2011-05-19 13:41:14 +02002097 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +01002098 {"packpath", "pp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2099 |P_SECURE,
2100 (char_u *)&p_pp, PV_NONE,
2101 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2102 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002103 {"paragraphs", "para", P_STRING|P_VI_DEF,
2104 (char_u *)&p_para, PV_NONE,
Bram Moolenaar57e48462008-03-12 16:38:55 +00002105 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002106 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00002107 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002108 (char_u *)&p_paste, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002109 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002110 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
2111 (char_u *)&p_pt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002112 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002113 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
2114#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
2115 (char_u *)&p_pex, PV_NONE,
2116 {(char_u *)"", (char_u *)0L}
2117#else
2118 (char_u *)NULL, PV_NONE,
2119 {(char_u *)0L, (char_u *)0L}
2120#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002121 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002122 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002123 (char_u *)&p_pm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002124 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002125 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002126 (char_u *)&p_path, PV_PATH,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002127 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002128#if defined(AMIGA) || defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002129 (char_u *)".,,",
2130#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002131 (char_u *)".,/usr/include,,",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002132#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002133 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002134 {"perldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002135#if defined(DYNAMIC_PERL)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002136 (char_u *)&p_perldll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002137 {(char_u *)DYNAMIC_PERL_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002138#else
2139 (char_u *)NULL, PV_NONE,
2140 {(char_u *)0L, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002141#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002142 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002143 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
2144 (char_u *)&p_pi, PV_PI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002145 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002146 {"previewheight", "pvh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002147#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2148 (char_u *)&p_pvh, PV_NONE,
2149#else
2150 (char_u *)NULL, PV_NONE,
2151#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002152 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002153 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2154#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2155 (char_u *)VAR_WIN, PV_PVW,
2156#else
2157 (char_u *)NULL, PV_NONE,
2158#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002159 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002160 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002161#ifdef FEAT_PRINTER
2162 (char_u *)&p_pdev, PV_NONE,
2163 {(char_u *)"", (char_u *)0L}
2164#else
2165 (char_u *)NULL, PV_NONE,
2166 {(char_u *)NULL, (char_u *)0L}
2167#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002168 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002169 {"printencoding", "penc", P_STRING|P_VI_DEF,
2170#ifdef FEAT_POSTSCRIPT
2171 (char_u *)&p_penc, PV_NONE,
2172 {(char_u *)"", (char_u *)0L}
2173#else
2174 (char_u *)NULL, PV_NONE,
2175 {(char_u *)NULL, (char_u *)0L}
2176#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002177 SCRIPTID_INIT},
Bram Moolenaar031cb742016-11-24 21:46:19 +01002178 {"printexpr", "pexpr", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002179#ifdef FEAT_POSTSCRIPT
2180 (char_u *)&p_pexpr, PV_NONE,
2181 {(char_u *)"", (char_u *)0L}
2182#else
2183 (char_u *)NULL, PV_NONE,
2184 {(char_u *)NULL, (char_u *)0L}
2185#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002186 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002187 {"printfont", "pfn", P_STRING|P_VI_DEF,
2188#ifdef FEAT_PRINTER
2189 (char_u *)&p_pfn, PV_NONE,
2190 {
2191# ifdef MSWIN
2192 (char_u *)"Courier_New:h10",
2193# else
2194 (char_u *)"courier",
2195# endif
2196 (char_u *)0L}
2197#else
2198 (char_u *)NULL, PV_NONE,
2199 {(char_u *)NULL, (char_u *)0L}
2200#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002201 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002202 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
2203#ifdef FEAT_PRINTER
2204 (char_u *)&p_header, PV_NONE,
2205 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
2206#else
2207 (char_u *)NULL, PV_NONE,
2208 {(char_u *)NULL, (char_u *)0L}
2209#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002210 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002211 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
2212#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2213 (char_u *)&p_pmcs, PV_NONE,
2214 {(char_u *)"", (char_u *)0L}
2215#else
2216 (char_u *)NULL, PV_NONE,
2217 {(char_u *)NULL, (char_u *)0L}
2218#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002219 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002220 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2221#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2222 (char_u *)&p_pmfn, PV_NONE,
2223 {(char_u *)"", (char_u *)0L}
2224#else
2225 (char_u *)NULL, PV_NONE,
2226 {(char_u *)NULL, (char_u *)0L}
2227#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002228 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002229 {"printoptions", "popt", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002230#ifdef FEAT_PRINTER
2231 (char_u *)&p_popt, PV_NONE,
2232 {(char_u *)"", (char_u *)0L}
2233#else
2234 (char_u *)NULL, PV_NONE,
2235 {(char_u *)NULL, (char_u *)0L}
2236#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002237 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002238 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002239 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002240 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002241 {"pumheight", "ph", P_NUM|P_VI_DEF,
2242#ifdef FEAT_INS_EXPAND
2243 (char_u *)&p_ph, PV_NONE,
2244#else
2245 (char_u *)NULL, PV_NONE,
2246#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002247 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002248 {"pythonthreedll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002249#if defined(DYNAMIC_PYTHON3)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002250 (char_u *)&p_py3dll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002251 {(char_u *)DYNAMIC_PYTHON3_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002252#else
2253 (char_u *)NULL, PV_NONE,
2254 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002255#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002256 SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002257 {"pythondll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002258#if defined(DYNAMIC_PYTHON)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002259 (char_u *)&p_pydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002260 {(char_u *)DYNAMIC_PYTHON_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002261#else
2262 (char_u *)NULL, PV_NONE,
2263 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002264#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002265 SCRIPTID_INIT},
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +01002266 {"pyxversion", "pyx", P_NUM|P_VI_DEF|P_SECURE,
2267#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
2268 (char_u *)&p_pyx, PV_NONE,
2269#else
2270 (char_u *)NULL, PV_NONE,
2271#endif
2272 {(char_u *)DEFAULT_PYTHON_VER, (char_u *)0L}
2273 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002274 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2275#ifdef FEAT_TEXTOBJ
2276 (char_u *)&p_qe, PV_QE,
2277 {(char_u *)"\\", (char_u *)0L}
2278#else
2279 (char_u *)NULL, PV_NONE,
2280 {(char_u *)NULL, (char_u *)0L}
2281#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002282 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002283 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2284 (char_u *)&p_ro, PV_RO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002285 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002286 {"redraw", NULL, P_BOOL|P_VI_DEF,
2287 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002288 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002289 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2290#ifdef FEAT_RELTIME
2291 (char_u *)&p_rdt, PV_NONE,
2292#else
2293 (char_u *)NULL, PV_NONE,
2294#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002295 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02002296 {"regexpengine", "re", P_NUM|P_VI_DEF,
2297 (char_u *)&p_re, PV_NONE,
2298 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002299 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2300 (char_u *)VAR_WIN, PV_RNU,
2301 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002302 {"remap", NULL, P_BOOL|P_VI_DEF,
2303 (char_u *)&p_remap, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002304 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002305 {"renderoptions", "rop", P_STRING|P_ONECOMMA|P_RCLR|P_VI_DEF,
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02002306#ifdef FEAT_RENDER_OPTIONS
2307 (char_u *)&p_rop, PV_NONE,
2308 {(char_u *)"", (char_u *)0L}
2309#else
2310 (char_u *)NULL, PV_NONE,
2311 {(char_u *)NULL, (char_u *)0L}
2312#endif
2313 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002314 {"report", NULL, P_NUM|P_VI_DEF,
2315 (char_u *)&p_report, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002316 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002317 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2318#ifdef WIN3264
2319 (char_u *)&p_rs, PV_NONE,
2320#else
2321 (char_u *)NULL, PV_NONE,
2322#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002323 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002324 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2325#ifdef FEAT_RIGHTLEFT
2326 (char_u *)&p_ri, PV_NONE,
2327#else
2328 (char_u *)NULL, PV_NONE,
2329#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002330 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002331 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2332#ifdef FEAT_RIGHTLEFT
2333 (char_u *)VAR_WIN, PV_RL,
2334#else
2335 (char_u *)NULL, PV_NONE,
2336#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002337 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002338 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2339#ifdef FEAT_RIGHTLEFT
2340 (char_u *)VAR_WIN, PV_RLC,
2341 {(char_u *)"search", (char_u *)NULL}
2342#else
2343 (char_u *)NULL, PV_NONE,
2344 {(char_u *)NULL, (char_u *)0L}
2345#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002346 SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002347 {"rubydll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002348#if defined(DYNAMIC_RUBY)
Bram Moolenaard94464e2015-11-02 15:28:18 +01002349 (char_u *)&p_rubydll, PV_NONE,
Bram Moolenaar25e4fcd2016-01-09 14:57:47 +01002350 {(char_u *)DYNAMIC_RUBY_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002351#else
2352 (char_u *)NULL, PV_NONE,
2353 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaard94464e2015-11-02 15:28:18 +01002354#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002355 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002356 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2357#ifdef FEAT_CMDL_INFO
2358 (char_u *)&p_ru, PV_NONE,
2359#else
2360 (char_u *)NULL, PV_NONE,
2361#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002362 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002363 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2364#ifdef FEAT_STL_OPT
2365 (char_u *)&p_ruf, PV_NONE,
2366#else
2367 (char_u *)NULL, PV_NONE,
2368#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002369 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002370 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2371 |P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002372 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002373 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2374 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002375 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2376 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002377 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002378 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2379#ifdef FEAT_SCROLLBIND
2380 (char_u *)VAR_WIN, PV_SCBIND,
2381#else
2382 (char_u *)NULL, PV_NONE,
2383#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002384 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002385 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2386 (char_u *)&p_sj, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002387 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002388 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2389 (char_u *)&p_so, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002390 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002391 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002392#ifdef FEAT_SCROLLBIND
2393 (char_u *)&p_sbo, PV_NONE,
2394 {(char_u *)"ver,jump", (char_u *)0L}
2395#else
2396 (char_u *)NULL, PV_NONE,
2397 {(char_u *)0L, (char_u *)0L}
2398#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002399 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002400 {"sections", "sect", P_STRING|P_VI_DEF,
2401 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002402 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2403 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002404 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2405 (char_u *)&p_secure, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002406 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002407 {"selection", "sel", P_STRING|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002408 (char_u *)&p_sel, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002409 {(char_u *)"inclusive", (char_u *)0L}
2410 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002411 {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002412 (char_u *)&p_slm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002413 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002414 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002415#ifdef FEAT_SESSION
2416 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002417 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002418 (char_u *)0L}
2419#else
2420 (char_u *)NULL, PV_NONE,
2421 {(char_u *)0L, (char_u *)0L}
2422#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002423 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002424 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2425 (char_u *)&p_sh, PV_NONE,
2426 {
2427#ifdef VMS
2428 (char_u *)"-",
2429#else
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002430# if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002431 (char_u *)"", /* set in set_init_1() */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002432# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002433 (char_u *)"sh",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002434# endif
2435#endif /* VMS */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002436 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002437 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2438 (char_u *)&p_shcf, PV_NONE,
2439 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002440#if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002441 (char_u *)"/c",
2442#else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002443 (char_u *)"-c",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002444#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002445 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002446 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2447#ifdef FEAT_QUICKFIX
2448 (char_u *)&p_sp, PV_NONE,
2449 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002450#if defined(UNIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002451 (char_u *)"| tee",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002452#else
2453 (char_u *)">",
2454#endif
2455 (char_u *)0L}
2456#else
2457 (char_u *)NULL, PV_NONE,
2458 {(char_u *)0L, (char_u *)0L}
2459#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002460 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002461 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2462 (char_u *)&p_shq, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002463 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002464 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2465 (char_u *)&p_srr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002466 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002467 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2468#ifdef BACKSLASH_IN_FILENAME
2469 (char_u *)&p_ssl, PV_NONE,
2470#else
2471 (char_u *)NULL, PV_NONE,
2472#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002473 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002474 {"shelltemp", "stmp", P_BOOL,
2475 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002476 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002477 {"shelltype", "st", P_NUM|P_VI_DEF,
2478#ifdef AMIGA
2479 (char_u *)&p_st, PV_NONE,
2480#else
2481 (char_u *)NULL, PV_NONE,
2482#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002483 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002484 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2485 (char_u *)&p_sxq, PV_NONE,
2486 {
Bram Moolenaara06ecab2016-07-16 14:47:36 +02002487#if defined(UNIX) && defined(USE_SYSTEM)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002488 (char_u *)"\"",
2489#else
2490 (char_u *)"",
2491#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002492 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002493 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
2494 (char_u *)&p_sxe, PV_NONE,
2495 {
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002496#if defined(WIN3264)
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002497 (char_u *)"\"&|<>()@^",
2498#else
2499 (char_u *)"",
2500#endif
2501 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002502 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2503 (char_u *)&p_sr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002504 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002505 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2506 (char_u *)&p_sw, PV_SW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002507 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002508 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2509 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002510 {(char_u *)"", (char_u *)"filnxtToO"}
2511 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002512 {"shortname", "sn", P_BOOL|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002513 (char_u *)&p_sn, PV_SN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002514 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002515 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2516#ifdef FEAT_LINEBREAK
2517 (char_u *)&p_sbr, PV_NONE,
2518#else
2519 (char_u *)NULL, PV_NONE,
2520#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002521 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002522 {"showcmd", "sc", P_BOOL|P_VIM,
2523#ifdef FEAT_CMDL_INFO
2524 (char_u *)&p_sc, PV_NONE,
2525#else
2526 (char_u *)NULL, PV_NONE,
2527#endif
2528 {(char_u *)FALSE,
2529#ifdef UNIX
2530 (char_u *)FALSE
2531#else
2532 (char_u *)TRUE
2533#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002534 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002535 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2536 (char_u *)&p_sft, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002537 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002538 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2539 (char_u *)&p_sm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002540 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002541 {"showmode", "smd", P_BOOL|P_VIM,
2542 (char_u *)&p_smd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002543 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002544 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2545#ifdef FEAT_WINDOWS
2546 (char_u *)&p_stal, PV_NONE,
2547#else
2548 (char_u *)NULL, PV_NONE,
2549#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002550 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002551 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2552 (char_u *)&p_ss, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002553 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002554 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2555 (char_u *)&p_siso, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002556 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002557 {"signcolumn", "scl", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2558#ifdef FEAT_SIGNS
2559 (char_u *)VAR_WIN, PV_SCL,
Bram Moolenaarb3384832016-08-12 18:51:58 +02002560 {(char_u *)"auto", (char_u *)0L}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02002561#else
2562 (char_u *)NULL, PV_NONE,
2563 {(char_u *)NULL, (char_u *)0L}
2564#endif
Bram Moolenaarb3384832016-08-12 18:51:58 +02002565 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002566 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2567 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002568 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002569 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2570 (char_u *)&p_scs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002571 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002572 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2573#ifdef FEAT_SMARTINDENT
2574 (char_u *)&p_si, PV_SI,
2575#else
2576 (char_u *)NULL, PV_NONE,
2577#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002578 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002579 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2580 (char_u *)&p_sta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002581 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002582 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2583 (char_u *)&p_sts, PV_STS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002584 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002585 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2586 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002587 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002588 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002589#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002590 (char_u *)VAR_WIN, PV_SPELL,
2591#else
2592 (char_u *)NULL, PV_NONE,
2593#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002594 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002595 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002596#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002597 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002598 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002599#else
2600 (char_u *)NULL, PV_NONE,
2601 {(char_u *)0L, (char_u *)0L}
2602#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002603 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002604 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE
2605 |P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002606#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002607 (char_u *)&p_spf, PV_SPF,
2608 {(char_u *)"", (char_u *)0L}
2609#else
2610 (char_u *)NULL, PV_NONE,
2611 {(char_u *)0L, (char_u *)0L}
2612#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002613 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002614 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
2615 |P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002616#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002617 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002618 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002619#else
2620 (char_u *)NULL, PV_NONE,
2621 {(char_u *)0L, (char_u *)0L}
2622#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002623 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002624 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002625#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002626 (char_u *)&p_sps, PV_NONE,
2627 {(char_u *)"best", (char_u *)0L}
2628#else
2629 (char_u *)NULL, PV_NONE,
2630 {(char_u *)0L, (char_u *)0L}
2631#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002632 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002633 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2634#ifdef FEAT_WINDOWS
2635 (char_u *)&p_sb, PV_NONE,
2636#else
2637 (char_u *)NULL, PV_NONE,
2638#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002639 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002640 {"splitright", "spr", P_BOOL|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01002641#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002642 (char_u *)&p_spr, PV_NONE,
2643#else
2644 (char_u *)NULL, PV_NONE,
2645#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002646 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002647 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2648 (char_u *)&p_sol, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002649 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002650 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2651#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002652 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002653#else
2654 (char_u *)NULL, PV_NONE,
2655#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002656 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002657 {"suffixes", "su", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002658 (char_u *)&p_su, PV_NONE,
2659 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002660 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002661 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002662#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002663 (char_u *)&p_sua, PV_SUA,
2664 {(char_u *)"", (char_u *)0L}
2665#else
2666 (char_u *)NULL, PV_NONE,
2667 {(char_u *)0L, (char_u *)0L}
2668#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002669 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002670 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2671 (char_u *)&p_swf, PV_SWF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002672 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002673 {"swapsync", "sws", P_STRING|P_VI_DEF,
2674 (char_u *)&p_sws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002675 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002676 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002677 (char_u *)&p_swb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002678 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002679 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2680#ifdef FEAT_SYN_HL
2681 (char_u *)&p_smc, PV_SMC,
2682 {(char_u *)3000L, (char_u *)0L}
2683#else
2684 (char_u *)NULL, PV_NONE,
2685 {(char_u *)0L, (char_u *)0L}
2686#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002687 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002688 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002689#ifdef FEAT_SYN_HL
2690 (char_u *)&p_syn, PV_SYN,
2691 {(char_u *)"", (char_u *)0L}
2692#else
2693 (char_u *)NULL, PV_NONE,
2694 {(char_u *)0L, (char_u *)0L}
2695#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002696 SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002697 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2698#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002699 (char_u *)&p_tal, PV_NONE,
2700#else
2701 (char_u *)NULL, PV_NONE,
2702#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002703 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002704 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2705#ifdef FEAT_WINDOWS
2706 (char_u *)&p_tpm, PV_NONE,
2707#else
2708 (char_u *)NULL, PV_NONE,
2709#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002710 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002711 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2712 (char_u *)&p_ts, PV_TS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002713 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002714 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2715 (char_u *)&p_tbs, PV_NONE,
2716#ifdef VMS /* binary searching doesn't appear to work on VMS */
2717 {(char_u *)0L, (char_u *)0L}
2718#else
2719 {(char_u *)TRUE, (char_u *)0L}
2720#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002721 SCRIPTID_INIT},
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01002722 {"tagcase", "tc", P_STRING|P_VIM,
2723 (char_u *)&p_tc, PV_TC,
2724 {(char_u *)"followic", (char_u *)"followic"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002725 {"taglength", "tl", P_NUM|P_VI_DEF,
2726 (char_u *)&p_tl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002727 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002728 {"tagrelative", "tr", P_BOOL|P_VIM,
2729 (char_u *)&p_tr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002730 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002731 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002732 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002733 {
2734#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2735 (char_u *)"./tags,./TAGS,tags,TAGS",
2736#else
2737 (char_u *)"./tags,tags",
2738#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002739 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002740 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2741 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002742 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaara6e42502016-04-20 16:19:52 +02002743 {"tcldll", NULL, P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002744#if defined(DYNAMIC_TCL)
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002745 (char_u *)&p_tcldll, PV_NONE,
2746 {(char_u *)DYNAMIC_TCL_DLL, (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002747#else
2748 (char_u *)NULL, PV_NONE,
2749 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar8a5115c2016-01-09 19:41:11 +01002750#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002751 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002752 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2753 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002754 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002755 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2756#ifdef FEAT_ARABIC
2757 (char_u *)&p_tbidi, PV_NONE,
2758#else
2759 (char_u *)NULL, PV_NONE,
2760#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002761 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002762 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2763#ifdef FEAT_MBYTE
2764 (char_u *)&p_tenc, PV_NONE,
2765 {(char_u *)"", (char_u *)0L}
2766#else
2767 (char_u *)NULL, PV_NONE,
2768 {(char_u *)0L, (char_u *)0L}
2769#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002770 SCRIPTID_INIT},
Bram Moolenaar61be73b2016-04-29 22:59:22 +02002771 {"termguicolors", "tgc", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
2772#ifdef FEAT_TERMGUICOLORS
2773 (char_u *)&p_tgc, PV_NONE,
2774 {(char_u *)FALSE, (char_u *)FALSE}
2775#else
2776 (char_u*)NULL, PV_NONE,
2777 {(char_u *)FALSE, (char_u *)FALSE}
2778#endif
2779 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002780 {"terse", NULL, P_BOOL|P_VI_DEF,
2781 (char_u *)&p_terse, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002782 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002783 {"textauto", "ta", P_BOOL|P_VIM,
2784 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002785 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2786 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002787 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2788 (char_u *)&p_tx, PV_TX,
2789 {
2790#ifdef USE_CRNL
2791 (char_u *)TRUE,
2792#else
2793 (char_u *)FALSE,
2794#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002795 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +02002796 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002797 (char_u *)&p_tw, PV_TW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002798 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf422bcc2016-11-26 17:45:53 +01002799 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002800#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002801 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002802#else
2803 (char_u *)NULL, PV_NONE,
2804#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002805 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002806 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2807 (char_u *)&p_to, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002808 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002809 {"timeout", "to", P_BOOL|P_VI_DEF,
2810 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002811 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002812 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2813 (char_u *)&p_tm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002814 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002815 {"title", NULL, P_BOOL|P_VI_DEF,
2816#ifdef FEAT_TITLE
2817 (char_u *)&p_title, PV_NONE,
2818#else
2819 (char_u *)NULL, PV_NONE,
2820#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002821 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002822 {"titlelen", NULL, P_NUM|P_VI_DEF,
2823#ifdef FEAT_TITLE
2824 (char_u *)&p_titlelen, PV_NONE,
2825#else
2826 (char_u *)NULL, PV_NONE,
2827#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002828 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002829 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002830#ifdef FEAT_TITLE
2831 (char_u *)&p_titleold, PV_NONE,
2832 {(char_u *)N_("Thanks for flying Vim"),
2833 (char_u *)0L}
2834#else
2835 (char_u *)NULL, PV_NONE,
2836 {(char_u *)0L, (char_u *)0L}
2837#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002838 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002839 {"titlestring", NULL, P_STRING|P_VI_DEF,
2840#ifdef FEAT_TITLE
2841 (char_u *)&p_titlestring, PV_NONE,
2842#else
2843 (char_u *)NULL, PV_NONE,
2844#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002845 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002846 {"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002847#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002848 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002849 {(char_u *)"icons,tooltips", (char_u *)0L}
Bram Moolenaara713ff82017-02-25 22:18:43 +01002850#else
2851 (char_u *)NULL, PV_NONE,
2852 {(char_u *)0L, (char_u *)0L}
2853#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002854 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002855 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002856#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002857 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaara713ff82017-02-25 22:18:43 +01002858 {(char_u *)"small", (char_u *)0L}
2859#else
2860 (char_u *)NULL, PV_NONE,
2861 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002862#endif
Bram Moolenaara713ff82017-02-25 22:18:43 +01002863 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002864 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2865 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002866 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002867 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2868 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002869 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002870 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2871 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002872 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002873 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2874 (char_u *)&p_tf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002875 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002876 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2877#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2878 (char_u *)&p_ttym, PV_NONE,
2879#else
2880 (char_u *)NULL, PV_NONE,
2881#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002882 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002883 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2884 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002885 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002886 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2887 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002888 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002889 {"undodir", "udir", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP|P_SECURE
2890 |P_VI_DEF,
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002891#ifdef FEAT_PERSISTENT_UNDO
2892 (char_u *)&p_udir, PV_NONE,
2893 {(char_u *)".", (char_u *)0L}
2894#else
2895 (char_u *)NULL, PV_NONE,
2896 {(char_u *)0L, (char_u *)0L}
2897#endif
2898 SCRIPTID_INIT},
2899 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2900#ifdef FEAT_PERSISTENT_UNDO
2901 (char_u *)&p_udf, PV_UDF,
2902#else
2903 (char_u *)NULL, PV_NONE,
2904#endif
2905 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002906 {"undolevels", "ul", P_NUM|P_VI_DEF,
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01002907 (char_u *)&p_ul, PV_UL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002908 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01002909#if defined(UNIX) || defined(WIN3264) || defined(VMS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002910 (char_u *)1000L,
2911#else
2912 (char_u *)100L,
2913#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002914 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar59f931e2010-07-24 20:27:03 +02002915 {"undoreload", "ur", P_NUM|P_VI_DEF,
2916 (char_u *)&p_ur, PV_NONE,
2917 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002918 {"updatecount", "uc", P_NUM|P_VI_DEF,
2919 (char_u *)&p_uc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002920 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002921 {"updatetime", "ut", P_NUM|P_VI_DEF,
2922 (char_u *)&p_ut, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002923 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002924 {"verbose", "vbs", P_NUM|P_VI_DEF,
2925 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002926 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002927 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2928 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002929 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002930 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2931#ifdef FEAT_SESSION
2932 (char_u *)&p_vdir, PV_NONE,
2933 {(char_u *)DFLT_VDIR, (char_u *)0L}
2934#else
2935 (char_u *)NULL, PV_NONE,
2936 {(char_u *)0L, (char_u *)0L}
2937#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002938 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002939 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002940#ifdef FEAT_SESSION
2941 (char_u *)&p_vop, PV_NONE,
2942 {(char_u *)"folds,options,cursor", (char_u *)0L}
2943#else
2944 (char_u *)NULL, PV_NONE,
2945 {(char_u *)0L, (char_u *)0L}
2946#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002947 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002948 {"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002949#ifdef FEAT_VIMINFO
2950 (char_u *)&p_viminfo, PV_NONE,
Bram Moolenaar48e330a2016-02-23 14:53:34 +01002951#if defined(MSWIN)
Bram Moolenaard812df62008-11-09 12:46:09 +00002952 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002953#else
2954# ifdef AMIGA
2955 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002956 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002957# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002958 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002959# endif
2960#endif
2961#else
2962 (char_u *)NULL, PV_NONE,
2963 {(char_u *)0L, (char_u *)0L}
2964#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002965 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002966 {"virtualedit", "ve", P_STRING|P_ONECOMMA|P_NODUP|P_VI_DEF
2967 |P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002968#ifdef FEAT_VIRTUALEDIT
2969 (char_u *)&p_ve, PV_NONE,
2970 {(char_u *)"", (char_u *)""}
2971#else
2972 (char_u *)NULL, PV_NONE,
2973 {(char_u *)0L, (char_u *)0L}
2974#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002975 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002976 {"visualbell", "vb", P_BOOL|P_VI_DEF,
2977 (char_u *)&p_vb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002978 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002979 {"w300", NULL, P_NUM|P_VI_DEF,
2980 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002981 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002982 {"w1200", NULL, P_NUM|P_VI_DEF,
2983 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002984 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002985 {"w9600", NULL, P_NUM|P_VI_DEF,
2986 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002987 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002988 {"warn", NULL, P_BOOL|P_VI_DEF,
2989 (char_u *)&p_warn, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002990 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002991 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
2992 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002993 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002994 {"whichwrap", "ww", P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002995 (char_u *)&p_ww, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002996 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002997 {"wildchar", "wc", P_NUM|P_VIM,
2998 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002999 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
3000 SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01003001 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003002 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003003 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003004 {"wildignore", "wig", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003005#ifdef FEAT_WILDIGN
3006 (char_u *)&p_wig, PV_NONE,
3007#else
3008 (char_u *)NULL, PV_NONE,
3009#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003010 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01003011 {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
3012 (char_u *)&p_wic, PV_NONE,
3013 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003014 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
3015#ifdef FEAT_WILDMENU
3016 (char_u *)&p_wmnu, PV_NONE,
3017#else
3018 (char_u *)NULL, PV_NONE,
3019#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003020 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02003021 {"wildmode", "wim", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00003022 (char_u *)&p_wim, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003023 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003024 {"wildoptions", "wop", P_STRING|P_VI_DEF,
3025#ifdef FEAT_CMDL_COMPL
3026 (char_u *)&p_wop, PV_NONE,
3027 {(char_u *)"", (char_u *)0L}
3028#else
3029 (char_u *)NULL, PV_NONE,
3030 {(char_u *)NULL, (char_u *)0L}
3031#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003032 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003033 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
3034#ifdef FEAT_WAK
3035 (char_u *)&p_wak, PV_NONE,
3036 {(char_u *)"menu", (char_u *)0L}
3037#else
3038 (char_u *)NULL, PV_NONE,
3039 {(char_u *)NULL, (char_u *)0L}
3040#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003041 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003042 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003043 (char_u *)&p_window, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003044 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003045 {"winheight", "wh", P_NUM|P_VI_DEF,
3046#ifdef FEAT_WINDOWS
3047 (char_u *)&p_wh, PV_NONE,
3048#else
3049 (char_u *)NULL, PV_NONE,
3050#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003051 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003052 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003053#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003054 (char_u *)VAR_WIN, PV_WFH,
3055#else
3056 (char_u *)NULL, PV_NONE,
3057#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003058 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00003059 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003060#ifdef FEAT_WINDOWS
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00003061 (char_u *)VAR_WIN, PV_WFW,
3062#else
3063 (char_u *)NULL, PV_NONE,
3064#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003065 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003066 {"winminheight", "wmh", P_NUM|P_VI_DEF,
3067#ifdef FEAT_WINDOWS
3068 (char_u *)&p_wmh, PV_NONE,
3069#else
3070 (char_u *)NULL, PV_NONE,
3071#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003072 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003073 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003074#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003075 (char_u *)&p_wmw, PV_NONE,
3076#else
3077 (char_u *)NULL, PV_NONE,
3078#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003079 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003080 {"winwidth", "wiw", P_NUM|P_VI_DEF,
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003081#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003082 (char_u *)&p_wiw, PV_NONE,
3083#else
3084 (char_u *)NULL, PV_NONE,
3085#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003086 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003087 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
3088 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003089 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003090 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
3091 (char_u *)&p_wm, PV_WM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003092 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003093 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
3094 (char_u *)&p_ws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003095 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003096 {"write", NULL, P_BOOL|P_VI_DEF,
3097 (char_u *)&p_write, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003098 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003099 {"writeany", "wa", P_BOOL|P_VI_DEF,
3100 (char_u *)&p_wa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003101 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003102 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
3103 (char_u *)&p_wb, PV_NONE,
3104 {
3105#ifdef FEAT_WRITEBACKUP
3106 (char_u *)TRUE,
3107#else
3108 (char_u *)FALSE,
3109#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003110 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003111 {"writedelay", "wd", P_NUM|P_VI_DEF,
3112 (char_u *)&p_wd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003113 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003114
3115/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00003116#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00003117 (char_u *)&vvv, PV_NONE, \
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003118 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00003119
3120 p_term("t_AB", T_CAB)
3121 p_term("t_AF", T_CAF)
3122 p_term("t_AL", T_CAL)
3123 p_term("t_al", T_AL)
3124 p_term("t_bc", T_BC)
3125 p_term("t_cd", T_CD)
3126 p_term("t_ce", T_CE)
3127 p_term("t_cl", T_CL)
3128 p_term("t_cm", T_CM)
Bram Moolenaar450ca432015-11-10 13:30:39 +01003129 p_term("t_Ce", T_UCE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003130 p_term("t_Co", T_CCO)
3131 p_term("t_CS", T_CCS)
Bram Moolenaar450ca432015-11-10 13:30:39 +01003132 p_term("t_Cs", T_UCS)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003133 p_term("t_cs", T_CS)
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003134#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003135 p_term("t_CV", T_CSV)
3136#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003137 p_term("t_da", T_DA)
3138 p_term("t_db", T_DB)
3139 p_term("t_DL", T_CDL)
3140 p_term("t_dl", T_DL)
Bram Moolenaare5401222015-06-25 19:16:56 +02003141 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003142 p_term("t_fs", T_FS)
3143 p_term("t_IE", T_CIE)
3144 p_term("t_IS", T_CIS)
3145 p_term("t_ke", T_KE)
3146 p_term("t_ks", T_KS)
3147 p_term("t_le", T_LE)
3148 p_term("t_mb", T_MB)
3149 p_term("t_md", T_MD)
3150 p_term("t_me", T_ME)
3151 p_term("t_mr", T_MR)
3152 p_term("t_ms", T_MS)
3153 p_term("t_nd", T_ND)
3154 p_term("t_op", T_OP)
Bram Moolenaare5401222015-06-25 19:16:56 +02003155 p_term("t_RB", T_RBG)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003156 p_term("t_RI", T_CRI)
3157 p_term("t_RV", T_CRV)
3158 p_term("t_Sb", T_CSB)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003159 p_term("t_se", T_SE)
Bram Moolenaare5401222015-06-25 19:16:56 +02003160 p_term("t_Sf", T_CSF)
3161 p_term("t_SI", T_CSI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003162 p_term("t_so", T_SO)
Bram Moolenaare5401222015-06-25 19:16:56 +02003163 p_term("t_SR", T_CSR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003164 p_term("t_sr", T_SR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003165 p_term("t_te", T_TE)
3166 p_term("t_ti", T_TI)
Bram Moolenaare5401222015-06-25 19:16:56 +02003167 p_term("t_ts", T_TS)
3168 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003169 p_term("t_ue", T_UE)
3170 p_term("t_us", T_US)
Bram Moolenaare5401222015-06-25 19:16:56 +02003171 p_term("t_ut", T_UT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003172 p_term("t_vb", T_VB)
3173 p_term("t_ve", T_VE)
3174 p_term("t_vi", T_VI)
3175 p_term("t_vs", T_VS)
3176 p_term("t_WP", T_CWP)
Bram Moolenaar9f928862017-04-11 22:44:05 +02003177 p_term("t_GP", T_CGP)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003178 p_term("t_WS", T_CWS)
Bram Moolenaar494838a2015-02-10 19:20:37 +01003179 p_term("t_xn", T_XN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003180 p_term("t_xs", T_XS)
3181 p_term("t_ZH", T_CZH)
3182 p_term("t_ZR", T_CZR)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02003183 p_term("t_8f", T_8F)
3184 p_term("t_8b", T_8B)
Bram Moolenaarec2da362017-01-21 20:04:22 +01003185 p_term("t_BE", T_BE)
3186 p_term("t_BD", T_BD)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003187
3188/* terminal key codes are not in here */
3189
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003190 /* end marker */
3191 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00003192};
3193
3194#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
3195
3196#ifdef FEAT_MBYTE
3197static char *(p_ambw_values[]) = {"single", "double", NULL};
3198#endif
3199static char *(p_bg_values[]) = {"light", "dark", NULL};
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01003200static char *(p_nf_values[]) = {"bin", "octal", "hex", "alpha", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003201static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003202#ifdef FEAT_CRYPT
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02003203static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2", NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003204#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003205#ifdef FEAT_CMDL_COMPL
3206static char *(p_wop_values[]) = {"tagfile", NULL};
3207#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003208#ifdef FEAT_WAK
3209static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
3210#endif
3211static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003212static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
3213static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003214static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003215#ifdef FEAT_BROWSE
3216static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
3217#endif
3218#ifdef FEAT_SCROLLBIND
3219static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
3220#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00003221static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar44a2f922016-03-19 22:11:51 +01003222#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00003223static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
3224#endif
3225#if defined(FEAT_QUICKFIX)
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003226# ifdef FEAT_AUTOCMD
3227static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
3228# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003229static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003230# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003231static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
3232#endif
3233static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
3234#ifdef FEAT_FOLDING
3235static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003236# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00003237 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003238# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003239 NULL};
3240static char *(p_fcl_values[]) = {"all", NULL};
3241#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003242#ifdef FEAT_INS_EXPAND
Bram Moolenaarb6be1e22015-07-10 18:18:40 +02003243static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003244#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02003245#ifdef FEAT_SIGNS
3246static char *(p_scl_values[]) = {"yes", "no", "auto", NULL};
3247#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003248
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003249static void set_option_default(int, int opt_flags, int compatible);
3250static void set_options_default(int opt_flags);
3251static char_u *term_bg_default(void);
3252static void did_set_option(int opt_idx, int opt_flags, int new_value);
3253static char_u *illegal_char(char_u *, int);
3254static int string_to_key(char_u *arg);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003255#ifdef FEAT_CMDWIN
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003256static char_u *check_cedit(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003257#endif
3258#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003259static void did_set_title(int icon);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003260#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003261static char_u *option_expand(int opt_idx, char_u *val);
3262static void didset_options(void);
3263static void didset_options2(void);
3264static void check_string_option(char_u **pp);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003265#if defined(FEAT_EVAL) || defined(PROTO)
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003266static long_u *insecure_flag(int opt_idx, int opt_flags);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003267#else
3268# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3269#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003270static void set_string_option_global(int opt_idx, char_u **varp);
3271static char_u *set_string_option(int opt_idx, char_u *value, int opt_flags);
3272static 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);
3273static char_u *set_chars_option(char_u **varp);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003274#ifdef FEAT_SYN_HL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003275static int int_cmp(const void *a, const void *b);
Bram Moolenaar1a384422010-07-14 19:53:30 +02003276#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003277#ifdef FEAT_CLIPBOARD
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003278static char_u *check_clipboard_option(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003279#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003280#ifdef FEAT_SPELL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003281static char_u *did_set_spell_option(int is_spellfile);
3282static char_u *compile_cap_prog(synblock_T *synblock);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003283#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003284#ifdef FEAT_EVAL
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003285static void set_option_scriptID_idx(int opt_idx, int opt_flags, int id);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003286#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003287static char_u *set_bool_option(int opt_idx, char_u *varp, int value, int opt_flags);
3288static char_u *set_num_option(int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags);
3289static void check_redraw(long_u flags);
3290static int findoption(char_u *);
3291static int find_key_option(char_u *);
3292static void showoptions(int all, int opt_flags);
3293static int optval_default(struct vimoption *, char_u *varp);
3294static void showoneopt(struct vimoption *, int opt_flags);
3295static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int expand);
3296static int put_setnum(FILE *fd, char *cmd, char *name, long *valuep);
3297static int put_setbool(FILE *fd, char *cmd, char *name, int value);
3298static int istermoption(struct vimoption *);
3299static char_u *get_varp_scope(struct vimoption *p, int opt_flags);
3300static char_u *get_varp(struct vimoption *);
3301static void option_value2string(struct vimoption *, int opt_flags);
3302static void check_winopt(winopt_T *wop);
3303static int wc_use_keyname(char_u *varp, long *wcp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003304#ifdef FEAT_LANGMAP
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003305static void langmap_init(void);
3306static void langmap_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003307#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003308static void paste_option_changed(void);
3309static void compatible_set(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003310#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003311static void fill_breakat_flags(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003312#endif
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003313static int opt_strings_flags(char_u *val, char **values, unsigned *flagp, int list);
3314static int check_opt_strings(char_u *val, char **values, int);
3315static int check_opt_wim(void);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003316#ifdef FEAT_LINEBREAK
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01003317static int briopt_check(win_T *wp);
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003318#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003319
3320/*
3321 * Initialize the options, first part.
3322 *
3323 * Called only once from main(), just after creating the first buffer.
3324 */
3325 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003326set_init_1(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003327{
3328 char_u *p;
3329 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003330 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003331
3332#ifdef FEAT_LANGMAP
3333 langmap_init();
3334#endif
3335
3336 /* Be Vi compatible by default */
3337 p_cp = TRUE;
3338
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003339 /* Use POSIX compatibility when $VIM_POSIX is set. */
3340 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003341 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003342 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003343 set_string_default("shm", (char_u *)"A");
3344 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003345
Bram Moolenaar071d4272004-06-13 20:20:40 +00003346 /*
3347 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003348 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003349 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003350 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003351#if defined(MSWIN)
Bram Moolenaar7c626922005-02-07 22:01:03 +00003352 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003353# ifdef WIN3264
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003354 || ((p = (char_u *)default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003355# endif
3356#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003357 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003358 set_string_default("sh", p);
3359
3360#ifdef FEAT_WILDIGN
3361 /*
3362 * Set the default for 'backupskip' to include environment variables for
3363 * temp files.
3364 */
3365 {
3366# ifdef UNIX
3367 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3368# else
3369 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3370# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003371 int len;
3372 garray_T ga;
3373 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003374
3375 ga_init2(&ga, 1, 100);
3376 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3377 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003378 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003379# ifdef UNIX
3380 if (*names[n] == NUL)
3381 p = (char_u *)"/tmp";
3382 else
3383# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003384 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003385 if (p != NULL && *p != NUL)
3386 {
3387 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003388 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003389 if (ga_grow(&ga, len) == OK)
3390 {
3391 if (ga.ga_len > 0)
3392 STRCAT(ga.ga_data, ",");
3393 STRCAT(ga.ga_data, p);
3394 add_pathsep(ga.ga_data);
3395 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003396 ga.ga_len += len;
3397 }
3398 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003399 if (mustfree)
3400 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003401 }
3402 if (ga.ga_data != NULL)
3403 {
3404 set_string_default("bsk", ga.ga_data);
3405 vim_free(ga.ga_data);
3406 }
3407 }
3408#endif
3409
3410 /*
3411 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3412 */
3413 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003414 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003415 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003416#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3417 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3418#endif
3419 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003420#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003421 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003422 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003423#else
3424# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003425 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003426 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003427# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003428 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003429# endif
3430#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003431 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003432 opt_idx = findoption((char_u *)"maxmem");
3433 if (opt_idx >= 0)
3434 {
3435#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
Bram Moolenaar35be4532015-12-11 22:38:36 +01003436 if ((long)(long_i)options[opt_idx].def_val[VI_DEFAULT] > (long)n
3437 || (long)(long_i)options[opt_idx].def_val[VI_DEFAULT] == 0L)
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003438#endif
3439 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3440 }
3441 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003442 }
3443
Bram Moolenaar071d4272004-06-13 20:20:40 +00003444#ifdef FEAT_SEARCHPATH
3445 {
3446 char_u *cdpath;
3447 char_u *buf;
3448 int i;
3449 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003450 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003451
3452 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003453 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003454 if (cdpath != NULL)
3455 {
3456 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3457 if (buf != NULL)
3458 {
3459 buf[0] = ','; /* start with ",", current dir first */
3460 j = 1;
3461 for (i = 0; cdpath[i] != NUL; ++i)
3462 {
3463 if (vim_ispathlistsep(cdpath[i]))
3464 buf[j++] = ',';
3465 else
3466 {
3467 if (cdpath[i] == ' ' || cdpath[i] == ',')
3468 buf[j++] = '\\';
3469 buf[j++] = cdpath[i];
3470 }
3471 }
3472 buf[j] = NUL;
3473 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003474 if (opt_idx >= 0)
3475 {
3476 options[opt_idx].def_val[VI_DEFAULT] = buf;
3477 options[opt_idx].flags |= P_DEF_ALLOCED;
3478 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003479 else
3480 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003481 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003482 if (mustfree)
3483 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003484 }
3485 }
3486#endif
3487
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003488#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003489 /* Set print encoding on platforms that don't default to latin1 */
3490 set_string_default("penc",
Bram Moolenaare7fedb62015-12-31 19:07:19 +01003491# if defined(MSWIN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003492 (char_u *)"cp1252"
3493# else
3494# ifdef VMS
3495 (char_u *)"dec-mcs"
3496# else
3497# ifdef EBCDIC
3498 (char_u *)"ebcdic-uk"
3499# else
3500# ifdef MAC
3501 (char_u *)"mac-roman"
3502# else /* HPUX */
3503 (char_u *)"hp-roman8"
3504# endif
3505# endif
3506# endif
3507# endif
3508 );
3509#endif
3510
3511#ifdef FEAT_POSTSCRIPT
3512 /* 'printexpr' must be allocated to be able to evaluate it. */
3513 set_string_default("pexpr",
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003514# if defined(MSWIN)
Bram Moolenaared203462004-06-16 11:19:22 +00003515 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003516# else
3517# ifdef VMS
3518 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3519
3520# else
3521 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3522# endif
3523# endif
3524 );
3525#endif
3526
3527 /*
3528 * Set all the options (except the terminal options) to their default
3529 * value. Also set the global value for local options.
3530 */
3531 set_options_default(0);
3532
3533#ifdef FEAT_GUI
3534 if (found_reverse_arg)
3535 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3536#endif
3537
3538 curbuf->b_p_initialized = TRUE;
3539 curbuf->b_p_ar = -1; /* no local 'autoread' value */
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01003540 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003541 check_buf_options(curbuf);
3542 check_win_options(curwin);
3543 check_options();
3544
3545 /* Must be before option_expand(), because that one needs vim_isIDc() */
3546 didset_options();
3547
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003548#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003549 /* Use the current chartab for the generic chartab. This is not in
3550 * didset_options() because it only depends on 'encoding'. */
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003551 init_spell_chartab();
3552#endif
3553
Bram Moolenaar071d4272004-06-13 20:20:40 +00003554 /*
3555 * Expand environment variables and things like "~" for the defaults.
3556 * If option_expand() returns non-NULL the variable is expanded. This can
3557 * only happen for non-indirect options.
3558 * Also set the default to the expanded value, so ":set" does not list
3559 * them.
3560 * Don't set the P_ALLOCED flag, because we don't want to free the
3561 * default.
3562 */
3563 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3564 {
3565 if ((options[opt_idx].flags & P_GETTEXT)
3566 && options[opt_idx].var != NULL)
3567 p = (char_u *)_(*(char **)options[opt_idx].var);
3568 else
3569 p = option_expand(opt_idx, NULL);
3570 if (p != NULL && (p = vim_strsave(p)) != NULL)
3571 {
3572 *(char_u **)options[opt_idx].var = p;
3573 /* VIMEXP
3574 * Defaults for all expanded options are currently the same for Vi
3575 * and Vim. When this changes, add some code here! Also need to
3576 * split P_DEF_ALLOCED in two.
3577 */
3578 if (options[opt_idx].flags & P_DEF_ALLOCED)
3579 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3580 options[opt_idx].def_val[VI_DEFAULT] = p;
3581 options[opt_idx].flags |= P_DEF_ALLOCED;
3582 }
3583 }
3584
Bram Moolenaar071d4272004-06-13 20:20:40 +00003585 save_file_ff(curbuf); /* Buffer is unchanged */
3586
Bram Moolenaar071d4272004-06-13 20:20:40 +00003587#if defined(FEAT_ARABIC)
3588 /* Detect use of mlterm.
3589 * Mlterm is a terminal emulator akin to xterm that has some special
3590 * abilities (bidi namely).
3591 * NOTE: mlterm's author is being asked to 'set' a variable
3592 * instead of an environment variable due to inheritance.
3593 */
3594 if (mch_getenv((char_u *)"MLTERM") != NULL)
3595 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3596#endif
3597
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003598 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003599
3600#ifdef FEAT_MBYTE
3601# if defined(WIN3264) && defined(FEAT_GETTEXT)
3602 /*
3603 * If $LANG isn't set, try to get a good value for it. This makes the
3604 * right language be used automatically. Don't do this for English.
3605 */
3606 if (mch_getenv((char_u *)"LANG") == NULL)
3607 {
3608 char buf[20];
3609
3610 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3611 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3612 * only the first two. */
3613 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3614 (LPTSTR)buf, 20);
3615 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3616 {
3617 /* There are a few exceptions (probably more) */
3618 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3619 STRCPY(buf, "zh_TW");
3620 else if (STRNICMP(buf, "chs", 3) == 0
3621 || STRNICMP(buf, "zhc", 3) == 0)
3622 STRCPY(buf, "zh_CN");
3623 else if (STRNICMP(buf, "jp", 2) == 0)
3624 STRCPY(buf, "ja");
3625 else
3626 buf[2] = NUL; /* truncate to two-letter code */
Bram Moolenaar6aa2cd42016-02-16 15:06:59 +01003627 vim_setenv((char_u *)"LANG", (char_u *)buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003628 }
3629 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003630# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003631# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003632 /* Moved to os_mac_conv.c to avoid dependency problems. */
3633 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003634# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003635# endif
3636
3637 /* enc_locale() will try to find the encoding of the current locale. */
3638 p = enc_locale();
3639 if (p != NULL)
3640 {
3641 char_u *save_enc;
3642
3643 /* Try setting 'encoding' and check if the value is valid.
3644 * If not, go back to the default "latin1". */
3645 save_enc = p_enc;
3646 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003647 if (STRCMP(p_enc, "gb18030") == 0)
3648 {
3649 /* We don't support "gb18030", but "cp936" is a good substitute
3650 * for practical purposes, thus use that. It's not an alias to
3651 * still support conversion between gb18030 and utf-8. */
3652 p_enc = vim_strsave((char_u *)"cp936");
3653 vim_free(p);
3654 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003655 if (mb_init() == NULL)
3656 {
3657 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003658 if (opt_idx >= 0)
3659 {
3660 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3661 options[opt_idx].flags |= P_DEF_ALLOCED;
3662 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003663
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003664#if defined(MSWIN) || defined(MACOS) || defined(VMS)
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003665 if (STRCMP(p_enc, "latin1") == 0
3666# ifdef FEAT_MBYTE
3667 || enc_utf8
3668# endif
3669 )
3670 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003671 /* Adjust the default for 'isprint' and 'iskeyword' to match
3672 * latin1. Also set the defaults for when 'nocompatible' is
3673 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003674 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003675 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003676 set_string_option_direct((char_u *)"isk", -1,
3677 ISK_LATIN1, OPT_FREE, SID_NONE);
3678 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003679 if (opt_idx >= 0)
3680 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003681 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003682 if (opt_idx >= 0)
3683 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003684 (void)init_chartab();
3685 }
3686#endif
3687
Bram Moolenaar071d4272004-06-13 20:20:40 +00003688# if defined(WIN3264) && !defined(FEAT_GUI)
3689 /* Win32 console: When GetACP() returns a different value from
3690 * GetConsoleCP() set 'termencoding'. */
3691 if (GetACP() != GetConsoleCP())
3692 {
3693 char buf[50];
3694
3695 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3696 p_tenc = vim_strsave((char_u *)buf);
3697 if (p_tenc != NULL)
3698 {
3699 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003700 if (opt_idx >= 0)
3701 {
3702 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3703 options[opt_idx].flags |= P_DEF_ALLOCED;
3704 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003705 convert_setup(&input_conv, p_tenc, p_enc);
3706 convert_setup(&output_conv, p_enc, p_tenc);
3707 }
3708 else
3709 p_tenc = empty_option;
3710 }
3711# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003712# if defined(WIN3264) && defined(FEAT_MBYTE)
3713 /* $HOME may have characters in active code page. */
3714 init_homedir();
3715# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003716 }
3717 else
3718 {
3719 vim_free(p_enc);
3720 p_enc = save_enc;
3721 }
3722 }
3723#endif
3724
3725#ifdef FEAT_MULTI_LANG
3726 /* Set the default for 'helplang'. */
3727 set_helplang_default(get_mess_lang());
3728#endif
3729}
3730
3731/*
3732 * Set an option to its default value.
3733 * This does not take care of side effects!
3734 */
3735 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003736set_option_default(
3737 int opt_idx,
3738 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3739 int compatible) /* use Vi default value */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003740{
3741 char_u *varp; /* pointer to variable for current option */
3742 int dvi; /* index in def_val[] */
3743 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003744 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003745 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3746
3747 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3748 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003749 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003750 {
3751 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3752 if (flags & P_STRING)
3753 {
3754 /* Use set_string_option_direct() for local options to handle
3755 * freeing and allocating the value. */
3756 if (options[opt_idx].indir != PV_NONE)
3757 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003758 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003759 else
3760 {
3761 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3762 free_string_option(*(char_u **)(varp));
3763 *(char_u **)varp = options[opt_idx].def_val[dvi];
3764 options[opt_idx].flags &= ~P_ALLOCED;
3765 }
3766 }
3767 else if (flags & P_NUM)
3768 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003769 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003770 win_comp_scroll(curwin);
3771 else
3772 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003773 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003774 /* May also set global value for local option. */
3775 if (both)
3776 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3777 *(long *)varp;
3778 }
3779 }
3780 else /* P_BOOL */
3781 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003782 /* the cast to long is required for Manx C, long_i is needed for
3783 * MSVC */
3784 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003785#ifdef UNIX
3786 /* 'modeline' defaults to off for root */
3787 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3788 *(int *)varp = FALSE;
3789#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003790 /* May also set global value for local option. */
3791 if (both)
3792 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3793 *(int *)varp;
3794 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003795
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003796 /* The default value is not insecure. */
3797 flagsp = insecure_flag(opt_idx, opt_flags);
3798 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003799 }
3800
3801#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003802 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003803#endif
3804}
3805
3806/*
3807 * Set all options (except terminal options) to their default value.
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003808 * When "opt_flags" is non-zero skip 'encoding'.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003809 */
3810 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003811set_options_default(
3812 int opt_flags) /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003813{
3814 int i;
3815#ifdef FEAT_WINDOWS
3816 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003817 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003818#endif
3819
3820 for (i = 0; !istermoption(&options[i]); i++)
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003821 if (!(options[i].flags & P_NODEFAULT)
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003822#if defined(FEAT_MBYTE) || defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003823 && (opt_flags == 0
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003824 || (TRUE
3825# if defined(FEAT_MBYTE)
3826 && options[i].var != (char_u *)&p_enc
3827# endif
3828# if defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003829 && options[i].var != (char_u *)&p_cm
Bram Moolenaar80606872015-08-25 21:27:35 +02003830 && options[i].var != (char_u *)&p_key
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003831# endif
3832 ))
Bram Moolenaar80606872015-08-25 21:27:35 +02003833#endif
Bram Moolenaar5ea87a02015-08-26 23:24:09 +02003834 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003835 set_option_default(i, opt_flags, p_cp);
3836
3837#ifdef FEAT_WINDOWS
3838 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003839 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003840 win_comp_scroll(wp);
3841#else
3842 win_comp_scroll(curwin);
3843#endif
Bram Moolenaar5a4eceb2014-09-09 17:33:07 +02003844#ifdef FEAT_CINDENT
3845 parse_cino(curbuf);
3846#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003847}
3848
3849/*
3850 * Set the Vi-default value of a string option.
3851 * Used for 'sh', 'backupskip' and 'term'.
3852 */
3853 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003854set_string_default(char *name, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003855{
3856 char_u *p;
3857 int opt_idx;
3858
3859 p = vim_strsave(val);
3860 if (p != NULL) /* we don't want a NULL */
3861 {
3862 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003863 if (opt_idx >= 0)
3864 {
3865 if (options[opt_idx].flags & P_DEF_ALLOCED)
3866 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3867 options[opt_idx].def_val[VI_DEFAULT] = p;
3868 options[opt_idx].flags |= P_DEF_ALLOCED;
3869 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003870 }
3871}
3872
3873/*
3874 * Set the Vi-default value of a number option.
3875 * Used for 'lines' and 'columns'.
3876 */
3877 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003878set_number_default(char *name, long val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003879{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003880 int opt_idx;
3881
3882 opt_idx = findoption((char_u *)name);
3883 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003884 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003885}
3886
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003887#if defined(EXITFREE) || defined(PROTO)
3888/*
3889 * Free all options.
3890 */
3891 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003892free_all_options(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003893{
3894 int i;
3895
3896 for (i = 0; !istermoption(&options[i]); i++)
3897 {
3898 if (options[i].indir == PV_NONE)
3899 {
3900 /* global option: free value and default value. */
Bram Moolenaar67391142017-02-19 21:07:04 +01003901 if ((options[i].flags & P_ALLOCED) && options[i].var != NULL)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003902 free_string_option(*(char_u **)options[i].var);
3903 if (options[i].flags & P_DEF_ALLOCED)
3904 free_string_option(options[i].def_val[VI_DEFAULT]);
3905 }
3906 else if (options[i].var != VAR_WIN
3907 && (options[i].flags & P_STRING))
3908 /* buffer-local option: free global value */
3909 free_string_option(*(char_u **)options[i].var);
3910 }
3911}
3912#endif
3913
3914
Bram Moolenaar071d4272004-06-13 20:20:40 +00003915/*
3916 * Initialize the options, part two: After getting Rows and Columns and
3917 * setting 'term'.
3918 */
3919 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01003920set_init_2(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003921{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003922 int idx;
3923
Bram Moolenaar071d4272004-06-13 20:20:40 +00003924 /*
3925 * 'scroll' defaults to half the window height. Note that this default is
3926 * wrong when the window height changes.
3927 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003928 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003929 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003930 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003931 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003932 comp_col();
3933
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003934 /*
3935 * 'window' is only for backwards compatibility with Vi.
3936 * Default is Rows - 1.
3937 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003938 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003939 p_window = Rows - 1;
3940 set_number_default("window", Rows - 1);
3941
Bram Moolenaarf740b292006-02-16 22:11:02 +00003942 /* For DOS console the default is always black. */
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003943#if !((defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003944 /*
3945 * If 'background' wasn't set by the user, try guessing the value,
3946 * depending on the terminal name. Only need to check for terminals
3947 * with a dark background, that can handle color.
3948 */
3949 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003950 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3951 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003952 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003953 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003954 /* don't mark it as set, when starting the GUI it may be
3955 * changed again */
3956 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003957 }
3958#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003959
3960#ifdef CURSOR_SHAPE
3961 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3962#endif
3963#ifdef FEAT_MOUSESHAPE
3964 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3965#endif
3966#ifdef FEAT_PRINTER
3967 (void)parse_printoptions(); /* parse 'printoptions' default value */
3968#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003969}
3970
3971/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00003972 * Return "dark" or "light" depending on the kind of terminal.
3973 * This is just guessing! Recognized are:
3974 * "linux" Linux console
3975 * "screen.linux" Linux console with screen
3976 * "cygwin" Cygwin shell
3977 * "putty" Putty program
3978 * We also check the COLORFGBG environment variable, which is set by
3979 * rxvt and derivatives. This variable contains either two or three
3980 * values separated by semicolons; we want the last value in either
3981 * case. If this value is 0-6 or 8, our background is dark.
3982 */
3983 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01003984term_bg_default(void)
Bram Moolenaarf740b292006-02-16 22:11:02 +00003985{
Bram Moolenaar48e330a2016-02-23 14:53:34 +01003986#if defined(WIN3264)
Bram Moolenaarf740b292006-02-16 22:11:02 +00003987 /* DOS console nearly always black */
3988 return (char_u *)"dark";
3989#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00003990 char_u *p;
3991
Bram Moolenaarf740b292006-02-16 22:11:02 +00003992 if (STRCMP(T_NAME, "linux") == 0
3993 || STRCMP(T_NAME, "screen.linux") == 0
3994 || STRCMP(T_NAME, "cygwin") == 0
3995 || STRCMP(T_NAME, "putty") == 0
3996 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
3997 && (p = vim_strrchr(p, ';')) != NULL
3998 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
3999 && p[2] == NUL))
4000 return (char_u *)"dark";
4001 return (char_u *)"light";
4002#endif
4003}
4004
4005/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004006 * Initialize the options, part three: After reading the .vimrc
4007 */
4008 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004009set_init_3(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004010{
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004011#if defined(UNIX) || defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004012/*
4013 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
4014 * This is done after other initializations, where 'shell' might have been
4015 * set, but only if they have not been set before.
4016 */
4017 char_u *p;
4018 int idx_srr;
4019 int do_srr;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004020# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00004021 int idx_sp;
4022 int do_sp;
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004023# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004024
4025 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004026 if (idx_srr < 0)
4027 do_srr = FALSE;
4028 else
4029 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004030# ifdef FEAT_QUICKFIX
Bram Moolenaar071d4272004-06-13 20:20:40 +00004031 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004032 if (idx_sp < 0)
4033 do_sp = FALSE;
4034 else
4035 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004036# endif
Bram Moolenaar75a8d742014-05-07 15:10:21 +02004037 p = get_isolated_shell_name();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004038 if (p != NULL)
4039 {
4040 /*
4041 * Default for p_sp is "| tee", for p_srr is ">".
4042 * For known shells it is changed here to include stderr.
4043 */
4044 if ( fnamecmp(p, "csh") == 0
4045 || fnamecmp(p, "tcsh") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004046# if defined(WIN3264) /* also check with .exe extension */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004047 || fnamecmp(p, "csh.exe") == 0
4048 || fnamecmp(p, "tcsh.exe") == 0
4049# endif
4050 )
4051 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004052# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004053 if (do_sp)
4054 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004055# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004056 p_sp = (char_u *)">&";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004057# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00004058 p_sp = (char_u *)"|& tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004059# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004060 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
4061 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004062# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004063 if (do_srr)
4064 {
4065 p_srr = (char_u *)">&";
4066 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
4067 }
4068 }
4069 else
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004070 /* Always use bourne shell style redirection if we reach this */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004071 if ( fnamecmp(p, "sh") == 0
4072 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02004073 || fnamecmp(p, "mksh") == 0
4074 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004075 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00004076 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004077 || fnamecmp(p, "bash") == 0
Bram Moolenaar75a8d742014-05-07 15:10:21 +02004078 || fnamecmp(p, "fish") == 0
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004079# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004080 || fnamecmp(p, "cmd") == 0
4081 || fnamecmp(p, "sh.exe") == 0
4082 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02004083 || fnamecmp(p, "mksh.exe") == 0
4084 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004085 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00004086 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004087 || fnamecmp(p, "bash.exe") == 0
4088 || fnamecmp(p, "cmd.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00004089# endif
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004090 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00004091 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004092# if defined(FEAT_QUICKFIX)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004093 if (do_sp)
4094 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004095# ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00004096 p_sp = (char_u *)">%s 2>&1";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004097# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00004098 p_sp = (char_u *)"2>&1| tee";
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004099# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004100 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
4101 }
Bram Moolenaare7fedb62015-12-31 19:07:19 +01004102# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004103 if (do_srr)
4104 {
4105 p_srr = (char_u *)">%s 2>&1";
4106 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
4107 }
4108 }
4109 vim_free(p);
4110 }
4111#endif
4112
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004113#if defined(WIN3264)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004114 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01004115 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
4116 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004117 * This is done after other initializations, where 'shell' might have been
4118 * set, but only if they have not been set before. Default for p_shcf is
4119 * "/c", for p_shq is "". For "sh" like shells it is changed here to
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004120 * "-c" and "\"". And for Win32 we need to set p_sxq instead.
Bram Moolenaar071d4272004-06-13 20:20:40 +00004121 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00004122 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004123 {
4124 int idx3;
4125
4126 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004127 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004128 {
4129 p_shcf = (char_u *)"-c";
4130 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4131 }
4132
Bram Moolenaar071d4272004-06-13 20:20:40 +00004133 /* Somehow Win32 requires the quotes around the redirection too */
4134 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004135 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004136 {
4137 p_sxq = (char_u *)"\"";
4138 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4139 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004140 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01004141 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
4142 {
4143 int idx3;
4144
4145 /*
4146 * cmd.exe on Windows will strip the first and last double quote given
4147 * on the command line, e.g. most of the time things like:
4148 * cmd /c "my path/to/echo" "my args to echo"
4149 * become:
4150 * my path/to/echo" "my args to echo
4151 * when executed.
4152 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01004153 * To avoid this, set shellxquote to surround the command in
4154 * parenthesis. This appears to make most commands work, without
4155 * breaking commands that worked previously, such as
4156 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01004157 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01004158 idx3 = findoption((char_u *)"sxq");
4159 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4160 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004161 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004162 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4163 }
4164
Bram Moolenaara64ba222012-02-12 23:23:31 +01004165 idx3 = findoption((char_u *)"shcf");
4166 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4167 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004168 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004169 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4170 }
4171 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004172#endif
4173
Bram Moolenaarb5aedf32017-03-12 18:23:53 +01004174 if (BUFEMPTY())
Bram Moolenaar364fa5c2016-03-20 17:53:25 +01004175 {
4176 int idx_ffs = findoption((char_u *)"ffs");
4177
4178 /* Apply the first entry of 'fileformats' to the initial buffer. */
4179 if (idx_ffs >= 0 && (options[idx_ffs].flags & P_WAS_SET))
4180 set_fileformat(default_fileformat(), OPT_LOCAL);
4181 }
4182
Bram Moolenaar071d4272004-06-13 20:20:40 +00004183#ifdef FEAT_TITLE
4184 set_title_defaults();
4185#endif
4186}
4187
4188#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4189/*
4190 * When 'helplang' is still at its default value, set it to "lang".
4191 * Only the first two characters of "lang" are used.
4192 */
4193 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004194set_helplang_default(char_u *lang)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004195{
4196 int idx;
4197
4198 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4199 return;
4200 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004201 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004202 {
4203 if (options[idx].flags & P_ALLOCED)
4204 free_string_option(p_hlg);
4205 p_hlg = vim_strsave(lang);
4206 if (p_hlg == NULL)
4207 p_hlg = empty_option;
4208 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004209 {
4210 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4211 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4212 {
4213 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4214 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4215 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004216 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004217 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004218 options[idx].flags |= P_ALLOCED;
4219 }
4220}
4221#endif
4222
4223#ifdef FEAT_GUI
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01004224static char_u *gui_bg_default(void);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004225
4226 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01004227gui_bg_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004228{
4229 if (gui_get_lightness(gui.back_pixel) < 127)
4230 return (char_u *)"dark";
4231 return (char_u *)"light";
4232}
4233
4234/*
4235 * Option initializations that can only be done after opening the GUI window.
4236 */
4237 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004238init_gui_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004239{
4240 /* Set the 'background' option according to the lightness of the
4241 * background color, unless the user has set it already. */
4242 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4243 {
4244 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4245 highlight_changed();
4246 }
4247}
4248#endif
4249
4250#ifdef FEAT_TITLE
4251/*
4252 * 'title' and 'icon' only default to true if they have not been set or reset
4253 * in .vimrc and we can read the old value.
4254 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4255 * they can be reset. This reduces startup time when using X on a remote
4256 * machine.
4257 */
4258 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01004259set_title_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004260{
4261 int idx1;
4262 long val;
4263
4264 /*
4265 * If GUI is (going to be) used, we can always set the window title and
4266 * icon name. Saves a bit of time, because the X11 display server does
4267 * not need to be contacted.
4268 */
4269 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004270 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004271 {
4272#ifdef FEAT_GUI
4273 if (gui.starting || gui.in_use)
4274 val = TRUE;
4275 else
4276#endif
4277 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004278 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004279 p_title = val;
4280 }
4281 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004282 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004283 {
4284#ifdef FEAT_GUI
4285 if (gui.starting || gui.in_use)
4286 val = TRUE;
4287 else
4288#endif
4289 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004290 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004291 p_icon = val;
4292 }
4293}
4294#endif
4295
4296/*
4297 * Parse 'arg' for option settings.
4298 *
4299 * 'arg' may be IObuff, but only when no errors can be present and option
4300 * does not need to be expanded with option_expand().
4301 * "opt_flags":
4302 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004303 * OPT_GLOBAL for ":setglobal"
4304 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004305 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004306 * OPT_WINONLY to only set window-local options
4307 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004308 *
4309 * returns FAIL if an error is detected, OK otherwise
4310 */
4311 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01004312do_set(
4313 char_u *arg, /* option string (may be written to!) */
4314 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004315{
4316 int opt_idx;
4317 char_u *errmsg;
4318 char_u errbuf[80];
4319 char_u *startarg;
4320 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4321 int nextchar; /* next non-white char after option name */
4322 int afterchar; /* character just after option name */
4323 int len;
4324 int i;
Bram Moolenaar22fcfad2016-07-01 18:17:26 +02004325 varnumber_T value;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004326 int key;
4327 long_u flags; /* flags for current option */
4328 char_u *varp = NULL; /* pointer to variable for current option */
4329 int did_show = FALSE; /* already showed one value */
4330 int adding; /* "opt+=arg" */
4331 int prepending; /* "opt^=arg" */
4332 int removing; /* "opt-=arg" */
4333 int cp_val = 0;
4334 char_u key_name[2];
4335
4336 if (*arg == NUL)
4337 {
4338 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004339 did_show = TRUE;
4340 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004341 }
4342
4343 while (*arg != NUL) /* loop to process all options */
4344 {
4345 errmsg = NULL;
4346 startarg = arg; /* remember for error message */
4347
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004348 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4349 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004350 {
4351 /*
4352 * ":set all" show all options.
4353 * ":set all&" set all options to their default value.
4354 */
4355 arg += 3;
4356 if (*arg == '&')
4357 {
4358 ++arg;
4359 /* Only for :set command set global value of local options. */
4360 set_options_default(OPT_FREE | opt_flags);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02004361 didset_options();
4362 didset_options2();
Bram Moolenaarb341dda2015-08-25 12:56:31 +02004363 redraw_all_later(CLEAR);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004364 }
4365 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004366 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004367 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004368 did_show = TRUE;
4369 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004370 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004371 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004372 {
4373 showoptions(2, opt_flags);
4374 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004375 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004376 arg += 7;
4377 }
4378 else
4379 {
4380 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004381 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004382 {
4383 prefix = 0;
4384 arg += 2;
4385 }
4386 else if (STRNCMP(arg, "inv", 3) == 0)
4387 {
4388 prefix = 2;
4389 arg += 3;
4390 }
4391
4392 /* find end of name */
4393 key = 0;
4394 if (*arg == '<')
4395 {
4396 nextchar = 0;
4397 opt_idx = -1;
4398 /* look out for <t_>;> */
4399 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4400 len = 5;
4401 else
4402 {
4403 len = 1;
4404 while (arg[len] != NUL && arg[len] != '>')
4405 ++len;
4406 }
4407 if (arg[len] != '>')
4408 {
4409 errmsg = e_invarg;
4410 goto skip;
4411 }
4412 arg[len] = NUL; /* put NUL after name */
4413 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4414 opt_idx = findoption(arg + 1);
4415 arg[len++] = '>'; /* restore '>' */
4416 if (opt_idx == -1)
4417 key = find_key_option(arg + 1);
4418 }
4419 else
4420 {
4421 len = 0;
4422 /*
4423 * The two characters after "t_" may not be alphanumeric.
4424 */
4425 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4426 len = 4;
4427 else
4428 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4429 ++len;
4430 nextchar = arg[len];
4431 arg[len] = NUL; /* put NUL after name */
4432 opt_idx = findoption(arg);
4433 arg[len] = nextchar; /* restore nextchar */
4434 if (opt_idx == -1)
4435 key = find_key_option(arg);
4436 }
4437
4438 /* remember character after option name */
4439 afterchar = arg[len];
4440
4441 /* skip white space, allow ":set ai ?" */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004442 while (VIM_ISWHITE(arg[len]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004443 ++len;
4444
4445 adding = FALSE;
4446 prepending = FALSE;
4447 removing = FALSE;
4448 if (arg[len] != NUL && arg[len + 1] == '=')
4449 {
4450 if (arg[len] == '+')
4451 {
4452 adding = TRUE; /* "+=" */
4453 ++len;
4454 }
4455 else if (arg[len] == '^')
4456 {
4457 prepending = TRUE; /* "^=" */
4458 ++len;
4459 }
4460 else if (arg[len] == '-')
4461 {
4462 removing = TRUE; /* "-=" */
4463 ++len;
4464 }
4465 }
4466 nextchar = arg[len];
4467
4468 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4469 {
4470 errmsg = (char_u *)N_("E518: Unknown option");
4471 goto skip;
4472 }
4473
4474 if (opt_idx >= 0)
4475 {
4476 if (options[opt_idx].var == NULL) /* hidden option: skip */
4477 {
4478 /* Only give an error message when requesting the value of
4479 * a hidden option, ignore setting it. */
4480 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4481 && (!(options[opt_idx].flags & P_BOOL)
4482 || nextchar == '?'))
4483 errmsg = (char_u *)N_("E519: Option not supported");
4484 goto skip;
4485 }
4486
4487 flags = options[opt_idx].flags;
4488 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4489 }
4490 else
4491 {
4492 flags = P_STRING;
4493 if (key < 0)
4494 {
4495 key_name[0] = KEY2TERMCAP0(key);
4496 key_name[1] = KEY2TERMCAP1(key);
4497 }
4498 else
4499 {
4500 key_name[0] = KS_KEY;
4501 key_name[1] = (key & 0xff);
4502 }
4503 }
4504
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004505 /* Skip all options that are not window-local (used when showing
4506 * an already loaded buffer in a window). */
4507 if ((opt_flags & OPT_WINONLY)
4508 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4509 goto skip;
4510
Bram Moolenaara3227e22006-03-08 21:32:40 +00004511 /* Skip all options that are window-local (used for :vimgrep). */
4512 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4513 && options[opt_idx].var == VAR_WIN)
4514 goto skip;
4515
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004516 /* Disallow changing some options from modelines. */
4517 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004518 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004519 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004520 {
4521 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4522 goto skip;
4523 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004524#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004525 /* In diff mode some options are overruled. This avoids that
4526 * 'foldmethod' becomes "marker" instead of "diff" and that
4527 * "wrap" gets set. */
4528 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004529 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaara6c07602017-03-05 21:18:27 +01004530 && (
4531#ifdef FEAT_FOLDING
4532 options[opt_idx].indir == PV_FDM ||
4533#endif
4534 options[opt_idx].indir == PV_WRAP))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004535 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004536#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004537 }
4538
4539#ifdef HAVE_SANDBOX
4540 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004541 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004542 {
4543 errmsg = (char_u *)_(e_sandbox);
4544 goto skip;
4545 }
4546#endif
4547
4548 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4549 {
4550 arg += len;
4551 cp_val = p_cp;
4552 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4553 {
4554 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4555 {
4556 cp_val = FALSE;
4557 arg += 3;
4558 }
4559 else /* "opt&vi": set to Vi default */
4560 {
4561 cp_val = TRUE;
4562 arg += 2;
4563 }
4564 }
4565 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
Bram Moolenaar1c465442017-03-12 20:10:05 +01004566 && arg[1] != NUL && !VIM_ISWHITE(arg[1]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004567 {
4568 errmsg = e_trailing;
4569 goto skip;
4570 }
4571 }
4572
4573 /*
Bram Moolenaar48e330a2016-02-23 14:53:34 +01004574 * allow '=' and ':' for hystorical reasons (MSDOS command.com
4575 * allows only one '=' character per "set" command line. grrr. (jw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004576 */
4577 if (nextchar == '?'
4578 || (prefix == 1
4579 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4580 && !(flags & P_BOOL)))
4581 {
4582 /*
4583 * print value
4584 */
4585 if (did_show)
4586 msg_putchar('\n'); /* cursor below last one */
4587 else
4588 {
4589 gotocmdline(TRUE); /* cursor at status line */
4590 did_show = TRUE; /* remember that we did a line */
4591 }
4592 if (opt_idx >= 0)
4593 {
4594 showoneopt(&options[opt_idx], opt_flags);
4595#ifdef FEAT_EVAL
4596 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004597 {
4598 /* Mention where the option was last set. */
4599 if (varp == options[opt_idx].var)
4600 last_set_msg(options[opt_idx].scriptID);
4601 else if ((int)options[opt_idx].indir & PV_WIN)
4602 last_set_msg(curwin->w_p_scriptID[
4603 (int)options[opt_idx].indir & PV_MASK]);
4604 else if ((int)options[opt_idx].indir & PV_BUF)
4605 last_set_msg(curbuf->b_p_scriptID[
4606 (int)options[opt_idx].indir & PV_MASK]);
4607 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004608#endif
4609 }
4610 else
4611 {
4612 char_u *p;
4613
4614 p = find_termcode(key_name);
4615 if (p == NULL)
4616 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004617 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004618 goto skip;
4619 }
4620 else
4621 (void)show_one_termcode(key_name, p, TRUE);
4622 }
4623 if (nextchar != '?'
Bram Moolenaar1c465442017-03-12 20:10:05 +01004624 && nextchar != NUL && !VIM_ISWHITE(afterchar))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004625 errmsg = e_trailing;
4626 }
4627 else
4628 {
4629 if (flags & P_BOOL) /* boolean */
4630 {
4631 if (nextchar == '=' || nextchar == ':')
4632 {
4633 errmsg = e_invarg;
4634 goto skip;
4635 }
4636
4637 /*
4638 * ":set opt!": invert
4639 * ":set opt&": reset to default value
4640 * ":set opt<": reset to global value
4641 */
4642 if (nextchar == '!')
4643 value = *(int *)(varp) ^ 1;
4644 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004645 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004646 ((flags & P_VI_DEF) || cp_val)
4647 ? VI_DEFAULT : VIM_DEFAULT];
4648 else if (nextchar == '<')
4649 {
4650 /* For 'autoread' -1 means to use global value. */
4651 if ((int *)varp == &curbuf->b_p_ar
4652 && opt_flags == OPT_LOCAL)
4653 value = -1;
4654 else
4655 value = *(int *)get_varp_scope(&(options[opt_idx]),
4656 OPT_GLOBAL);
4657 }
4658 else
4659 {
4660 /*
4661 * ":set invopt": invert
4662 * ":set opt" or ":set noopt": set or reset
4663 */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004664 if (nextchar != NUL && !VIM_ISWHITE(afterchar))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004665 {
4666 errmsg = e_trailing;
4667 goto skip;
4668 }
4669 if (prefix == 2) /* inv */
4670 value = *(int *)(varp) ^ 1;
4671 else
4672 value = prefix;
4673 }
4674
4675 errmsg = set_bool_option(opt_idx, varp, (int)value,
4676 opt_flags);
4677 }
4678 else /* numeric or string */
4679 {
4680 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4681 || prefix != 1)
4682 {
4683 errmsg = e_invarg;
4684 goto skip;
4685 }
4686
4687 if (flags & P_NUM) /* numeric */
4688 {
4689 /*
4690 * Different ways to set a number option:
4691 * & set to default value
4692 * < set to global value
4693 * <xx> accept special key codes for 'wildchar'
4694 * c accept any non-digit for 'wildchar'
4695 * [-]0-9 set number
4696 * other error
4697 */
4698 ++arg;
4699 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004700 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004701 ((flags & P_VI_DEF) || cp_val)
4702 ? VI_DEFAULT : VIM_DEFAULT];
4703 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004704 {
4705 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4706 * use the global value. */
4707 if ((long *)varp == &curbuf->b_p_ul
4708 && opt_flags == OPT_LOCAL)
4709 value = NO_LOCAL_UNDOLEVEL;
4710 else
4711 value = *(long *)get_varp_scope(
4712 &(options[opt_idx]), OPT_GLOBAL);
4713 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004714 else if (((long *)varp == &p_wc
4715 || (long *)varp == &p_wcm)
4716 && (*arg == '<'
4717 || *arg == '^'
Bram Moolenaar1c465442017-03-12 20:10:05 +01004718 || (*arg != NUL
4719 && (!arg[1] || VIM_ISWHITE(arg[1]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004720 && !VIM_ISDIGIT(*arg))))
4721 {
4722 value = string_to_key(arg);
4723 if (value == 0 && (long *)varp != &p_wcm)
4724 {
4725 errmsg = e_invarg;
4726 goto skip;
4727 }
4728 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004729 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4730 {
Bram Moolenaar18400e62015-01-27 15:58:40 +01004731 /* Allow negative (for 'undolevels'), octal and
4732 * hex numbers. */
Bram Moolenaar887c1fe2016-01-02 17:56:35 +01004733 vim_str2nr(arg, NULL, &i, STR2NR_ALL,
4734 &value, NULL, 0);
Bram Moolenaar1c465442017-03-12 20:10:05 +01004735 if (arg[i] != NUL && !VIM_ISWHITE(arg[i]))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004736 {
4737 errmsg = e_invarg;
4738 goto skip;
4739 }
4740 }
4741 else
4742 {
4743 errmsg = (char_u *)N_("E521: Number required after =");
4744 goto skip;
4745 }
4746
4747 if (adding)
4748 value = *(long *)varp + value;
4749 if (prepending)
4750 value = *(long *)varp * value;
4751 if (removing)
4752 value = *(long *)varp - value;
4753 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004754 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004755 }
4756 else if (opt_idx >= 0) /* string */
4757 {
4758 char_u *save_arg = NULL;
4759 char_u *s = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004760 char_u *oldval = NULL; /* previous value if *varp */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004761 char_u *newval;
Bram Moolenaar53744302015-07-17 17:38:22 +02004762 char_u *origval = NULL;
4763#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4764 char_u *saved_origval = NULL;
4765#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004766 unsigned newlen;
4767 int comma;
4768 int bs;
4769 int new_value_alloced; /* new string option
4770 was allocated */
4771
4772 /* When using ":set opt=val" for a global option
4773 * with a local value the local value will be
4774 * reset, use the global value here. */
4775 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004776 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004777 varp = options[opt_idx].var;
4778
4779 /* The old value is kept until we are sure that the
4780 * new value is valid. */
4781 oldval = *(char_u **)varp;
4782 if (nextchar == '&') /* set to default val */
4783 {
4784 newval = options[opt_idx].def_val[
4785 ((flags & P_VI_DEF) || cp_val)
4786 ? VI_DEFAULT : VIM_DEFAULT];
4787 if ((char_u **)varp == &p_bg)
4788 {
4789 /* guess the value of 'background' */
4790#ifdef FEAT_GUI
4791 if (gui.in_use)
4792 newval = gui_bg_default();
4793 else
4794#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004795 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004796 }
4797
4798 /* expand environment variables and ~ (since the
4799 * default value was already expanded, only
4800 * required when an environment variable was set
4801 * later */
4802 if (newval == NULL)
4803 newval = empty_option;
4804 else
4805 {
4806 s = option_expand(opt_idx, newval);
4807 if (s == NULL)
4808 s = newval;
4809 newval = vim_strsave(s);
4810 }
4811 new_value_alloced = TRUE;
4812 }
4813 else if (nextchar == '<') /* set to global val */
4814 {
4815 newval = vim_strsave(*(char_u **)get_varp_scope(
4816 &(options[opt_idx]), OPT_GLOBAL));
4817 new_value_alloced = TRUE;
4818 }
4819 else
4820 {
4821 ++arg; /* jump to after the '=' or ':' */
4822
4823 /*
4824 * Set 'keywordprg' to ":help" if an empty
4825 * value was passed to :set by the user.
4826 * Misuse errbuf[] for the resulting string.
4827 */
4828 if (varp == (char_u *)&p_kp
4829 && (*arg == NUL || *arg == ' '))
4830 {
4831 STRCPY(errbuf, ":help");
4832 save_arg = arg;
4833 arg = errbuf;
4834 }
4835 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004836 * Convert 'backspace' number to string, for
4837 * adding, prepending and removing string.
4838 */
4839 else if (varp == (char_u *)&p_bs
4840 && VIM_ISDIGIT(**(char_u **)varp))
4841 {
4842 i = getdigits((char_u **)varp);
4843 switch (i)
4844 {
4845 case 0:
4846 *(char_u **)varp = empty_option;
4847 break;
4848 case 1:
4849 *(char_u **)varp = vim_strsave(
4850 (char_u *)"indent,eol");
4851 break;
4852 case 2:
4853 *(char_u **)varp = vim_strsave(
4854 (char_u *)"indent,eol,start");
4855 break;
4856 }
4857 vim_free(oldval);
4858 oldval = *(char_u **)varp;
4859 }
4860 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004861 * Convert 'whichwrap' number to string, for
4862 * backwards compatibility with Vim 3.0.
4863 * Misuse errbuf[] for the resulting string.
4864 */
4865 else if (varp == (char_u *)&p_ww
4866 && VIM_ISDIGIT(*arg))
4867 {
4868 *errbuf = NUL;
4869 i = getdigits(&arg);
4870 if (i & 1)
4871 STRCAT(errbuf, "b,");
4872 if (i & 2)
4873 STRCAT(errbuf, "s,");
4874 if (i & 4)
4875 STRCAT(errbuf, "h,l,");
4876 if (i & 8)
4877 STRCAT(errbuf, "<,>,");
4878 if (i & 16)
4879 STRCAT(errbuf, "[,],");
4880 if (*errbuf != NUL) /* remove trailing , */
4881 errbuf[STRLEN(errbuf) - 1] = NUL;
4882 save_arg = arg;
4883 arg = errbuf;
4884 }
4885 /*
4886 * Remove '>' before 'dir' and 'bdir', for
4887 * backwards compatibility with version 3.0
4888 */
4889 else if ( *arg == '>'
4890 && (varp == (char_u *)&p_dir
4891 || varp == (char_u *)&p_bdir))
4892 {
4893 ++arg;
4894 }
4895
4896 /* When setting the local value of a global
4897 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004898 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004899 && (opt_flags & OPT_LOCAL))
4900 origval = *(char_u **)get_varp(
4901 &options[opt_idx]);
4902 else
4903 origval = oldval;
4904
4905 /*
4906 * Copy the new string into allocated memory.
4907 * Can't use set_string_option_direct(), because
4908 * we need to remove the backslashes.
4909 */
4910 /* get a bit too much */
4911 newlen = (unsigned)STRLEN(arg) + 1;
4912 if (adding || prepending || removing)
4913 newlen += (unsigned)STRLEN(origval) + 1;
4914 newval = alloc(newlen);
4915 if (newval == NULL) /* out of mem, don't change */
4916 break;
4917 s = newval;
4918
4919 /*
4920 * Copy the string, skip over escaped chars.
4921 * For MS-DOS and WIN32 backslashes before normal
4922 * file name characters are not removed, and keep
4923 * backslash at start, for "\\machine\path", but
4924 * do remove it for "\\\\machine\\path".
4925 * The reverse is found in ExpandOldSetting().
4926 */
Bram Moolenaar1c465442017-03-12 20:10:05 +01004927 while (*arg && !VIM_ISWHITE(*arg))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004928 {
4929 if (*arg == '\\' && arg[1] != NUL
4930#ifdef BACKSLASH_IN_FILENAME
4931 && !((flags & P_EXPAND)
4932 && vim_isfilec(arg[1])
4933 && (arg[1] != '\\'
4934 || (s == newval
4935 && arg[2] != '\\')))
4936#endif
4937 )
4938 ++arg; /* remove backslash */
4939#ifdef FEAT_MBYTE
4940 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00004941 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004942 {
4943 /* copy multibyte char */
4944 mch_memmove(s, arg, (size_t)i);
4945 arg += i;
4946 s += i;
4947 }
4948 else
4949#endif
4950 *s++ = *arg++;
4951 }
4952 *s = NUL;
4953
4954 /*
4955 * Expand environment variables and ~.
4956 * Don't do it when adding without inserting a
4957 * comma.
4958 */
4959 if (!(adding || prepending || removing)
4960 || (flags & P_COMMA))
4961 {
4962 s = option_expand(opt_idx, newval);
4963 if (s != NULL)
4964 {
4965 vim_free(newval);
4966 newlen = (unsigned)STRLEN(s) + 1;
4967 if (adding || prepending || removing)
4968 newlen += (unsigned)STRLEN(origval) + 1;
4969 newval = alloc(newlen);
4970 if (newval == NULL)
4971 break;
4972 STRCPY(newval, s);
4973 }
4974 }
4975
4976 /* locate newval[] in origval[] when removing it
4977 * and when adding to avoid duplicates */
4978 i = 0; /* init for GCC */
4979 if (removing || (flags & P_NODUP))
4980 {
4981 i = (int)STRLEN(newval);
4982 bs = 0;
4983 for (s = origval; *s; ++s)
4984 {
4985 if ((!(flags & P_COMMA)
4986 || s == origval
4987 || (s[-1] == ',' && !(bs & 1)))
4988 && STRNCMP(s, newval, i) == 0
4989 && (!(flags & P_COMMA)
4990 || s[i] == ','
4991 || s[i] == NUL))
4992 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004993 /* Count backslashes. Only a comma with an
Bram Moolenaar8f79acd2016-01-01 14:48:20 +01004994 * even number of backslashes or a single
4995 * backslash preceded by a comma before it
4996 * is recognized as a separator */
4997 if ((s > origval + 1
4998 && s[-1] == '\\'
4999 && s[-2] != ',')
5000 || (s == origval + 1
5001 && s[-1] == '\\'))
5002
Bram Moolenaar071d4272004-06-13 20:20:40 +00005003 ++bs;
5004 else
5005 bs = 0;
5006 }
5007
5008 /* do not add if already there */
5009 if ((adding || prepending) && *s)
5010 {
5011 prepending = FALSE;
5012 adding = FALSE;
5013 STRCPY(newval, origval);
5014 }
5015 }
5016
5017 /* concatenate the two strings; add a ',' if
5018 * needed */
5019 if (adding || prepending)
5020 {
5021 comma = ((flags & P_COMMA) && *origval != NUL
5022 && *newval != NUL);
5023 if (adding)
5024 {
5025 i = (int)STRLEN(origval);
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02005026 /* strip a trailing comma, would get 2 */
Bram Moolenaar17467472015-11-10 17:50:24 +01005027 if (comma && i > 1
5028 && (flags & P_ONECOMMA) == P_ONECOMMA
5029 && origval[i - 1] == ','
5030 && origval[i - 2] != '\\')
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02005031 i--;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005032 mch_memmove(newval + i + comma, newval,
5033 STRLEN(newval) + 1);
5034 mch_memmove(newval, origval, (size_t)i);
5035 }
5036 else
5037 {
5038 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00005039 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005040 }
5041 if (comma)
5042 newval[i] = ',';
5043 }
5044
5045 /* Remove newval[] from origval[]. (Note: "i" has
5046 * been set above and is used here). */
5047 if (removing)
5048 {
5049 STRCPY(newval, origval);
5050 if (*s)
5051 {
5052 /* may need to remove a comma */
5053 if (flags & P_COMMA)
5054 {
5055 if (s == origval)
5056 {
5057 /* include comma after string */
5058 if (s[i] == ',')
5059 ++i;
5060 }
5061 else
5062 {
5063 /* include comma before string */
5064 --s;
5065 ++i;
5066 }
5067 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00005068 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005069 }
5070 }
5071
5072 if (flags & P_FLAGLIST)
5073 {
5074 /* Remove flags that appear twice. */
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005075 for (s = newval; *s;)
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005076 {
5077 /* if options have P_FLAGLIST and
5078 * P_ONECOMMA such as 'whichwrap' */
5079 if (flags & P_ONECOMMA)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005080 {
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005081 if (*s != ',' && *(s + 1) == ','
5082 && vim_strchr(s + 2, *s) != NULL)
5083 {
5084 /* Remove the duplicated value and
5085 * the next comma. */
5086 STRMOVE(s, s + 2);
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005087 continue;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005088 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005089 }
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005090 else
5091 {
5092 if ((!(flags & P_COMMA) || *s != ',')
5093 && vim_strchr(s + 1, *s) != NULL)
5094 {
5095 STRMOVE(s, s + 1);
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005096 continue;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005097 }
5098 }
Bram Moolenaaraaaf57d2017-02-05 14:13:20 +01005099 ++s;
Bram Moolenaarc8ce6152016-08-07 13:48:20 +02005100 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005101 }
5102
5103 if (save_arg != NULL) /* number for 'whichwrap' */
5104 arg = save_arg;
5105 new_value_alloced = TRUE;
5106 }
5107
5108 /* Set the new value. */
5109 *(char_u **)(varp) = newval;
5110
Bram Moolenaar53744302015-07-17 17:38:22 +02005111#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005112 if (!starting
5113# ifdef FEAT_CRYPT
5114 && options[opt_idx].indir != PV_KEY
5115# endif
Bram Moolenaar53744302015-07-17 17:38:22 +02005116 && origval != NULL)
5117 /* origval may be freed by
5118 * did_set_string_option(), make a copy. */
5119 saved_origval = vim_strsave(origval);
5120#endif
5121
Bram Moolenaar071d4272004-06-13 20:20:40 +00005122 /* Handle side effects, and set the global value for
5123 * ":set" on local options. */
5124 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
5125 new_value_alloced, oldval, errbuf, opt_flags);
5126
5127 /* If error detected, print the error message. */
5128 if (errmsg != NULL)
Bram Moolenaara9884962015-12-13 15:08:56 +01005129 {
5130#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5131 vim_free(saved_origval);
5132#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005133 goto skip;
Bram Moolenaara9884962015-12-13 15:08:56 +01005134 }
Bram Moolenaar53744302015-07-17 17:38:22 +02005135#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5136 if (saved_origval != NULL)
5137 {
5138 char_u buf_type[7];
5139
5140 sprintf((char *)buf_type, "%s",
5141 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02005142 set_vim_var_string(VV_OPTION_NEW,
5143 *(char_u **)varp, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02005144 set_vim_var_string(VV_OPTION_OLD, saved_origval, -1);
5145 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
5146 apply_autocmds(EVENT_OPTIONSET,
5147 (char_u *)options[opt_idx].fullname,
5148 NULL, FALSE, NULL);
5149 reset_v_option_vars();
5150 vim_free(saved_origval);
5151 }
5152#endif
5153
Bram Moolenaar071d4272004-06-13 20:20:40 +00005154 }
5155 else /* key code option */
5156 {
5157 char_u *p;
5158
5159 if (nextchar == '&')
5160 {
5161 if (add_termcap_entry(key_name, TRUE) == FAIL)
5162 errmsg = (char_u *)N_("E522: Not found in termcap");
5163 }
5164 else
5165 {
5166 ++arg; /* jump to after the '=' or ':' */
Bram Moolenaar1c465442017-03-12 20:10:05 +01005167 for (p = arg; *p && !VIM_ISWHITE(*p); ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005168 if (*p == '\\' && p[1] != NUL)
5169 ++p;
5170 nextchar = *p;
5171 *p = NUL;
5172 add_termcode(key_name, arg, FALSE);
5173 *p = nextchar;
5174 }
5175 if (full_screen)
5176 ttest(FALSE);
5177 redraw_all_later(CLEAR);
5178 }
5179 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005180
Bram Moolenaar071d4272004-06-13 20:20:40 +00005181 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005182 did_set_option(opt_idx, opt_flags,
5183 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005184 }
5185
5186skip:
5187 /*
5188 * Advance to next argument.
5189 * - skip until a blank found, taking care of backslashes
5190 * - skip blanks
5191 * - skip one "=val" argument (for hidden options ":set gfn =xx")
5192 */
5193 for (i = 0; i < 2 ; ++i)
5194 {
Bram Moolenaar1c465442017-03-12 20:10:05 +01005195 while (*arg != NUL && !VIM_ISWHITE(*arg))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005196 if (*arg++ == '\\' && *arg != NUL)
5197 ++arg;
5198 arg = skipwhite(arg);
5199 if (*arg != '=')
5200 break;
5201 }
5202 }
5203
5204 if (errmsg != NULL)
5205 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005206 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005207 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005208 if (i + (arg - startarg) < IOSIZE)
5209 {
5210 /* append the argument with the error */
5211 STRCAT(IObuff, ": ");
5212 mch_memmove(IObuff + i, startarg, (arg - startarg));
5213 IObuff[i + (arg - startarg)] = NUL;
5214 }
5215 /* make sure all characters are printable */
5216 trans_characters(IObuff, IOSIZE);
5217
5218 ++no_wait_return; /* wait_return done later */
5219 emsg(IObuff); /* show error highlighted */
5220 --no_wait_return;
5221
5222 return FAIL;
5223 }
5224
5225 arg = skipwhite(arg);
5226 }
5227
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005228theend:
5229 if (silent_mode && did_show)
5230 {
5231 /* After displaying option values in silent mode. */
5232 silent_mode = FALSE;
5233 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5234 msg_putchar('\n');
5235 cursor_on(); /* msg_start() switches it off */
5236 out_flush();
5237 silent_mode = TRUE;
5238 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5239 }
5240
Bram Moolenaar071d4272004-06-13 20:20:40 +00005241 return OK;
5242}
5243
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005244/*
5245 * Call this when an option has been given a new value through a user command.
5246 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5247 */
5248 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005249did_set_option(
5250 int opt_idx,
5251 int opt_flags, /* possibly with OPT_MODELINE */
5252 int new_value) /* value was replaced completely */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005253{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005254 long_u *p;
5255
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005256 options[opt_idx].flags |= P_WAS_SET;
5257
5258 /* When an option is set in the sandbox, from a modeline or in secure mode
5259 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005260 * flag. */
5261 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005262 if (secure
5263#ifdef HAVE_SANDBOX
5264 || sandbox != 0
5265#endif
5266 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005267 *p = *p | P_INSECURE;
5268 else if (new_value)
5269 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005270}
5271
Bram Moolenaar071d4272004-06-13 20:20:40 +00005272 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005273illegal_char(char_u *errbuf, int c)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005274{
5275 if (errbuf == NULL)
5276 return (char_u *)"";
5277 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005278 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005279 return errbuf;
5280}
5281
5282/*
5283 * Convert a key name or string into a key value.
5284 * Used for 'wildchar' and 'cedit' options.
5285 */
5286 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005287string_to_key(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005288{
5289 if (*arg == '<')
5290 return find_key_option(arg + 1);
5291 if (*arg == '^')
5292 return Ctrl_chr(arg[1]);
5293 return *arg;
5294}
5295
5296#ifdef FEAT_CMDWIN
5297/*
5298 * Check value of 'cedit' and set cedit_key.
5299 * Returns NULL if value is OK, error message otherwise.
5300 */
5301 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005302check_cedit(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005303{
5304 int n;
5305
5306 if (*p_cedit == NUL)
5307 cedit_key = -1;
5308 else
5309 {
5310 n = string_to_key(p_cedit);
5311 if (vim_isprintc(n))
5312 return e_invarg;
5313 cedit_key = n;
5314 }
5315 return NULL;
5316}
5317#endif
5318
5319#ifdef FEAT_TITLE
5320/*
5321 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5322 * maketitle() to create and display it.
5323 * When switching the title or icon off, call mch_restore_title() to get
5324 * the old value back.
5325 */
5326 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005327did_set_title(
5328 int icon) /* Did set icon instead of title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005329{
5330 if (starting != NO_SCREEN
5331#ifdef FEAT_GUI
5332 && !gui.starting
5333#endif
5334 )
5335 {
5336 maketitle();
5337 if (icon)
5338 {
5339 if (!p_icon)
5340 mch_restore_title(2);
5341 }
5342 else
5343 {
5344 if (!p_title)
5345 mch_restore_title(1);
5346 }
5347 }
5348}
5349#endif
5350
5351/*
5352 * set_options_bin - called when 'bin' changes value.
5353 */
5354 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005355set_options_bin(
5356 int oldval,
5357 int newval,
5358 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005359{
5360 /*
5361 * The option values that are changed when 'bin' changes are
5362 * copied when 'bin is set and restored when 'bin' is reset.
5363 */
5364 if (newval)
5365 {
5366 if (!oldval) /* switched on */
5367 {
5368 if (!(opt_flags & OPT_GLOBAL))
5369 {
5370 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5371 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5372 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5373 curbuf->b_p_et_nobin = curbuf->b_p_et;
5374 }
5375 if (!(opt_flags & OPT_LOCAL))
5376 {
5377 p_tw_nobin = p_tw;
5378 p_wm_nobin = p_wm;
5379 p_ml_nobin = p_ml;
5380 p_et_nobin = p_et;
5381 }
5382 }
5383
5384 if (!(opt_flags & OPT_GLOBAL))
5385 {
5386 curbuf->b_p_tw = 0; /* no automatic line wrap */
5387 curbuf->b_p_wm = 0; /* no automatic line wrap */
5388 curbuf->b_p_ml = 0; /* no modelines */
5389 curbuf->b_p_et = 0; /* no expandtab */
5390 }
5391 if (!(opt_flags & OPT_LOCAL))
5392 {
5393 p_tw = 0;
5394 p_wm = 0;
5395 p_ml = FALSE;
5396 p_et = FALSE;
5397 p_bin = TRUE; /* needed when called for the "-b" argument */
5398 }
5399 }
5400 else if (oldval) /* switched off */
5401 {
5402 if (!(opt_flags & OPT_GLOBAL))
5403 {
5404 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5405 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5406 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5407 curbuf->b_p_et = curbuf->b_p_et_nobin;
5408 }
5409 if (!(opt_flags & OPT_LOCAL))
5410 {
5411 p_tw = p_tw_nobin;
5412 p_wm = p_wm_nobin;
5413 p_ml = p_ml_nobin;
5414 p_et = p_et_nobin;
5415 }
5416 }
5417}
5418
5419#ifdef FEAT_VIMINFO
5420/*
5421 * Find the parameter represented by the given character (eg ', :, ", or /),
5422 * and return its associated value in the 'viminfo' string.
5423 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005424 * If the parameter is not specified in the string or there is no following
5425 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005426 */
5427 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005428get_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005429{
5430 char_u *p;
5431
5432 p = find_viminfo_parameter(type);
5433 if (p != NULL && VIM_ISDIGIT(*p))
5434 return atoi((char *)p);
5435 return -1;
5436}
5437
5438/*
5439 * Find the parameter represented by the given character (eg ''', ':', '"', or
5440 * '/') in the 'viminfo' option and return a pointer to the string after it.
5441 * Return NULL if the parameter is not specified in the string.
5442 */
5443 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005444find_viminfo_parameter(int type)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005445{
5446 char_u *p;
5447
5448 for (p = p_viminfo; *p; ++p)
5449 {
5450 if (*p == type)
5451 return p + 1;
5452 if (*p == 'n') /* 'n' is always the last one */
5453 break;
5454 p = vim_strchr(p, ','); /* skip until next ',' */
5455 if (p == NULL) /* hit the end without finding parameter */
5456 break;
5457 }
5458 return NULL;
5459}
5460#endif
5461
5462/*
5463 * Expand environment variables for some string options.
5464 * These string options cannot be indirect!
5465 * If "val" is NULL expand the current value of the option.
5466 * Return pointer to NameBuff, or NULL when not expanded.
5467 */
5468 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005469option_expand(int opt_idx, char_u *val)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005470{
5471 /* if option doesn't need expansion nothing to do */
5472 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5473 return NULL;
5474
5475 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5476 * expand_env() would truncate the string. */
5477 if (val != NULL && STRLEN(val) > MAXPATHL)
5478 return NULL;
5479
5480 if (val == NULL)
5481 val = *(char_u **)options[opt_idx].var;
5482
5483 /*
5484 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5485 * Escape spaces when expanding 'tags', they are used to separate file
5486 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005487 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005488 */
5489 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005490 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005491#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005492 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5493#endif
5494 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005495 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5496 return NULL;
5497
5498 return NameBuff;
5499}
5500
5501/*
5502 * After setting various option values: recompute variables that depend on
5503 * option values.
5504 */
5505 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005506didset_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005507{
5508 /* initialize the table for 'iskeyword' et.al. */
5509 (void)init_chartab();
5510
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005511#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005512 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005513#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005514 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
Bram Moolenaar165bc692015-07-21 17:53:25 +02005515 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005516#ifdef FEAT_SESSION
5517 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5518 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5519#endif
5520#ifdef FEAT_FOLDING
5521 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5522#endif
5523 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005524 (void)opt_strings_flags(p_tc, p_tc_values, &tc_flags, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005525#ifdef FEAT_VIRTUALEDIT
5526 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5527#endif
5528#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5529 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5530#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005531#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005532 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005533 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005534 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005535 (void)did_set_spell_option(TRUE);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005536#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005537#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5538 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5539#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005540#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005541 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5542#endif
5543#ifdef FEAT_CMDWIN
5544 /* set cedit_key */
5545 (void)check_cedit();
5546#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005547#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005548 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005549#endif
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005550#ifdef FEAT_LINEBREAK
5551 /* initialize the table for 'breakat'. */
5552 fill_breakat_flags();
5553#endif
5554
5555}
5556
5557/*
5558 * More side effects of setting options.
5559 */
5560 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005561didset_options2(void)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005562{
5563 /* Initialize the highlight_attr[] table. */
5564 (void)highlight_changed();
5565
5566 /* Parse default for 'wildmode' */
5567 check_opt_wim();
5568
5569 (void)set_chars_option(&p_lcs);
5570#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5571 /* Parse default for 'fillchars'. */
5572 (void)set_chars_option(&p_fcs);
5573#endif
5574
5575#ifdef FEAT_CLIPBOARD
5576 /* Parse default for 'clipboard' */
5577 (void)check_clipboard_option();
5578#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005579}
5580
5581/*
5582 * Check for string options that are NULL (normally only termcap options).
5583 */
5584 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005585check_options(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005586{
5587 int opt_idx;
5588
5589 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5590 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5591 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5592}
5593
5594/*
5595 * Check string options in a buffer for NULL value.
5596 */
5597 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005598check_buf_options(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005599{
5600#if defined(FEAT_QUICKFIX)
5601 check_string_option(&buf->b_p_bh);
5602 check_string_option(&buf->b_p_bt);
5603#endif
5604#ifdef FEAT_MBYTE
5605 check_string_option(&buf->b_p_fenc);
5606#endif
5607 check_string_option(&buf->b_p_ff);
5608#ifdef FEAT_FIND_ID
5609 check_string_option(&buf->b_p_def);
5610 check_string_option(&buf->b_p_inc);
5611# ifdef FEAT_EVAL
5612 check_string_option(&buf->b_p_inex);
5613# endif
5614#endif
5615#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5616 check_string_option(&buf->b_p_inde);
5617 check_string_option(&buf->b_p_indk);
5618#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005619#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5620 check_string_option(&buf->b_p_bexpr);
5621#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005622#if defined(FEAT_CRYPT)
5623 check_string_option(&buf->b_p_cm);
5624#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +01005625 check_string_option(&buf->b_p_fp);
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005626#if defined(FEAT_EVAL)
5627 check_string_option(&buf->b_p_fex);
5628#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005629#ifdef FEAT_CRYPT
5630 check_string_option(&buf->b_p_key);
5631#endif
5632 check_string_option(&buf->b_p_kp);
5633 check_string_option(&buf->b_p_mps);
5634 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005635 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005636 check_string_option(&buf->b_p_isk);
5637#ifdef FEAT_COMMENTS
5638 check_string_option(&buf->b_p_com);
5639#endif
5640#ifdef FEAT_FOLDING
5641 check_string_option(&buf->b_p_cms);
5642#endif
5643 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005644#ifdef FEAT_TEXTOBJ
5645 check_string_option(&buf->b_p_qe);
5646#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005647#ifdef FEAT_SYN_HL
5648 check_string_option(&buf->b_p_syn);
Bram Moolenaarb8060fe2016-01-19 22:29:28 +01005649 check_string_option(&buf->b_s.b_syn_isk);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005650#endif
5651#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005652 check_string_option(&buf->b_s.b_p_spc);
5653 check_string_option(&buf->b_s.b_p_spf);
5654 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005655#endif
5656#ifdef FEAT_SEARCHPATH
5657 check_string_option(&buf->b_p_sua);
5658#endif
5659#ifdef FEAT_CINDENT
5660 check_string_option(&buf->b_p_cink);
5661 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005662 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005663#endif
5664#ifdef FEAT_AUTOCMD
5665 check_string_option(&buf->b_p_ft);
5666#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005667#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5668 check_string_option(&buf->b_p_cinw);
5669#endif
5670#ifdef FEAT_INS_EXPAND
5671 check_string_option(&buf->b_p_cpt);
5672#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005673#ifdef FEAT_COMPL_FUNC
5674 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005675 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005676#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005677#ifdef FEAT_KEYMAP
5678 check_string_option(&buf->b_p_keymap);
5679#endif
5680#ifdef FEAT_QUICKFIX
5681 check_string_option(&buf->b_p_gp);
5682 check_string_option(&buf->b_p_mp);
5683 check_string_option(&buf->b_p_efm);
5684#endif
5685 check_string_option(&buf->b_p_ep);
5686 check_string_option(&buf->b_p_path);
5687 check_string_option(&buf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01005688 check_string_option(&buf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005689#ifdef FEAT_INS_EXPAND
5690 check_string_option(&buf->b_p_dict);
5691 check_string_option(&buf->b_p_tsr);
5692#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005693#ifdef FEAT_LISP
5694 check_string_option(&buf->b_p_lw);
5695#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005696 check_string_option(&buf->b_p_bkc);
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01005697#ifdef FEAT_MBYTE
5698 check_string_option(&buf->b_p_menc);
5699#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005700}
5701
5702/*
5703 * Free the string allocated for an option.
5704 * Checks for the string being empty_option. This may happen if we're out of
5705 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5706 * check_options().
5707 * Does NOT check for P_ALLOCED flag!
5708 */
5709 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005710free_string_option(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005711{
5712 if (p != empty_option)
5713 vim_free(p);
5714}
5715
5716 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005717clear_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005718{
5719 if (*pp != empty_option)
5720 vim_free(*pp);
5721 *pp = empty_option;
5722}
5723
5724 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005725check_string_option(char_u **pp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005726{
5727 if (*pp == NULL)
5728 *pp = empty_option;
5729}
5730
5731/*
5732 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5733 */
5734 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005735set_term_option_alloced(char_u **p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005736{
5737 int opt_idx;
5738
5739 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5740 if (options[opt_idx].var == (char_u *)p)
5741 {
5742 options[opt_idx].flags |= P_ALLOCED;
5743 return;
5744 }
5745 return; /* cannot happen: didn't find it! */
5746}
5747
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005748#if defined(FEAT_EVAL) || defined(PROTO)
5749/*
5750 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5751 * Return FALSE when it wasn't.
5752 * Return -1 for an unknown option.
5753 */
5754 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01005755was_set_insecurely(char_u *opt, int opt_flags)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005756{
5757 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005758 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005759
5760 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005761 {
5762 flagp = insecure_flag(idx, opt_flags);
5763 return (*flagp & P_INSECURE) != 0;
5764 }
Bram Moolenaar95f09602016-11-10 20:01:45 +01005765 internal_error("was_set_insecurely()");
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005766 return -1;
5767}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005768
5769/*
5770 * Get a pointer to the flags used for the P_INSECURE flag of option
5771 * "opt_idx". For some local options a local flags field is used.
5772 */
5773 static long_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005774insecure_flag(int opt_idx, int opt_flags)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005775{
5776 if (opt_flags & OPT_LOCAL)
5777 switch ((int)options[opt_idx].indir)
5778 {
5779#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005780 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005781#endif
5782#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005783# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005784 case PV_FDE: return &curwin->w_p_fde_flags;
5785 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005786# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005787# ifdef FEAT_BEVAL
5788 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5789# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005790# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005791 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005792# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005793 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005794# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005795 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005796# endif
5797#endif
5798 }
5799
5800 /* Nothing special, return global flags field. */
5801 return &options[opt_idx].flags;
5802}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005803#endif
5804
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005805#ifdef FEAT_TITLE
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +01005806static void redraw_titles(void);
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005807
5808/*
5809 * Redraw the window title and/or tab page text later.
5810 */
Bram Moolenaar9b578142016-01-30 19:39:49 +01005811static void redraw_titles(void)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005812{
5813 need_maketitle = TRUE;
5814# ifdef FEAT_WINDOWS
5815 redraw_tabline = TRUE;
5816# endif
5817}
5818#endif
5819
Bram Moolenaar071d4272004-06-13 20:20:40 +00005820/*
5821 * Set a string option to a new value (without checking the effect).
5822 * The string is copied into allocated memory.
5823 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005824 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005825 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005826 */
5827 void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005828set_string_option_direct(
5829 char_u *name,
5830 int opt_idx,
5831 char_u *val,
5832 int opt_flags, /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
5833 int set_sid UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005834{
5835 char_u *s;
5836 char_u **varp;
5837 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005838 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005839
Bram Moolenaar89d40322006-08-29 15:30:07 +00005840 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005841 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005842 idx = findoption(name);
5843 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005844 {
5845 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar95f09602016-11-10 20:01:45 +01005846 IEMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005847 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005848 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005849 }
5850
Bram Moolenaar89d40322006-08-29 15:30:07 +00005851 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005852 return;
5853
5854 s = vim_strsave(val);
5855 if (s != NULL)
5856 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005857 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005858 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005859 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005860 free_string_option(*varp);
5861 *varp = s;
5862
5863 /* For buffer/window local option may also set the global value. */
5864 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005865 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005866
Bram Moolenaar89d40322006-08-29 15:30:07 +00005867 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005868
5869 /* When setting both values of a global option with a local value,
5870 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005871 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005872 {
5873 free_string_option(*varp);
5874 *varp = empty_option;
5875 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005876# ifdef FEAT_EVAL
5877 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005878 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005879 set_sid == 0 ? current_SID : set_sid);
5880# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005881 }
5882}
5883
5884/*
5885 * Set global value for string option when it's a local option.
5886 */
5887 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01005888set_string_option_global(
5889 int opt_idx, /* option index */
5890 char_u **varp) /* pointer to option variable */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005891{
5892 char_u **p, *s;
5893
5894 /* the global value is always allocated */
5895 if (options[opt_idx].var == VAR_WIN)
5896 p = (char_u **)GLOBAL_WO(varp);
5897 else
5898 p = (char_u **)options[opt_idx].var;
5899 if (options[opt_idx].indir != PV_NONE
5900 && p != varp
5901 && (s = vim_strsave(*varp)) != NULL)
5902 {
5903 free_string_option(*p);
5904 *p = s;
5905 }
5906}
5907
5908/*
5909 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005910 *
5911 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005912 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005913 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005914set_string_option(
5915 int opt_idx,
5916 char_u *value,
5917 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005918{
5919 char_u *s;
5920 char_u **varp;
5921 char_u *oldval;
Bram Moolenaar53744302015-07-17 17:38:22 +02005922#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5923 char_u *saved_oldval = NULL;
5924#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005925 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005926
5927 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005928 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005929
5930 s = vim_strsave(value);
5931 if (s != NULL)
5932 {
5933 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5934 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005935 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005936 ? OPT_GLOBAL : OPT_LOCAL)
5937 : opt_flags);
5938 oldval = *varp;
5939 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02005940
5941#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005942 if (!starting
5943# ifdef FEAT_CRYPT
5944 && options[opt_idx].indir != PV_KEY
5945# endif
5946 )
Bram Moolenaar53744302015-07-17 17:38:22 +02005947 saved_oldval = vim_strsave(oldval);
5948#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005949 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5950 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005951 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02005952
Bram Moolenaara12e4032017-02-25 21:37:57 +01005953 /* call autocommand after handling side effects */
Bram Moolenaar53744302015-07-17 17:38:22 +02005954#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5955 if (saved_oldval != NULL)
5956 {
5957 char_u buf_type[7];
5958 sprintf((char *)buf_type, "%s",
5959 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02005960 set_vim_var_string(VV_OPTION_NEW, *varp, -1);
5961 set_vim_var_string(VV_OPTION_OLD, saved_oldval, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02005962 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
5963 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
5964 reset_v_option_vars();
5965 vim_free(saved_oldval);
5966 }
5967#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005968 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005969 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005970}
5971
Bram Moolenaar40d3f132016-11-05 20:13:35 +01005972#if defined(FEAT_KEYMAP) || defined(FEAT_AUTOCMD) || defined(FEAT_SYN_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005973/*
Bram Moolenaard0b51382016-11-04 15:23:45 +01005974 * Return TRUE if "val" is a valid 'filetype' name.
5975 * Also used for 'syntax' and 'keymap'.
5976 */
5977 static int
5978valid_filetype(char_u *val)
5979{
5980 char_u *s;
5981
5982 for (s = val; *s != NUL; ++s)
5983 if (!ASCII_ISALNUM(*s) && vim_strchr((char_u *)".-_", *s) == NULL)
5984 return FALSE;
5985 return TRUE;
5986}
Bram Moolenaar40d3f132016-11-05 20:13:35 +01005987#endif
Bram Moolenaard0b51382016-11-04 15:23:45 +01005988
5989/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00005990 * Handle string options that need some action to perform when changed.
5991 * Returns NULL for success, or an error message for an error.
5992 */
5993 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01005994did_set_string_option(
5995 int opt_idx, /* index in options[] table */
5996 char_u **varp, /* pointer to the option variable */
5997 int new_value_alloced, /* new value was allocated */
5998 char_u *oldval, /* previous value of the option */
5999 char_u *errbuf, /* buffer for errors, or NULL */
6000 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006001{
6002 char_u *errmsg = NULL;
6003 char_u *s, *p;
6004 int did_chartab = FALSE;
6005 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00006006 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006007#ifdef FEAT_GUI
6008 /* set when changing an option that only requires a redraw in the GUI */
6009 int redraw_gui_only = FALSE;
6010#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006011
6012 /* Get the global option to compare with, otherwise we would have to check
6013 * two values for all local options. */
6014 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
6015
6016 /* Disallow changing some options from secure mode */
6017 if ((secure
6018#ifdef HAVE_SANDBOX
6019 || sandbox != 0
6020#endif
6021 ) && (options[opt_idx].flags & P_SECURE))
6022 {
6023 errmsg = e_secure;
6024 }
6025
Bram Moolenaar7554da42016-11-25 22:04:13 +01006026 /* Check for a "normal" directory or file name in some options. Disallow a
6027 * path separator (slash and/or backslash), wildcards and characters that
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01006028 * are often illegal in a file name. Be more permissive if "secure" is off.
6029 */
Bram Moolenaar7554da42016-11-25 22:04:13 +01006030 else if (((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar0945eaf2016-11-29 22:10:48 +01006031 && vim_strpbrk(*varp, (char_u *)(secure
6032 ? "/\\*?[|;&<>\r\n" : "/\\*?[<>\r\n")) != NULL)
Bram Moolenaar7554da42016-11-25 22:04:13 +01006033 || ((options[opt_idx].flags & P_NDNAME)
6034 && vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL))
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00006035 {
6036 errmsg = e_invarg;
6037 }
6038
Bram Moolenaar071d4272004-06-13 20:20:40 +00006039 /* 'term' */
6040 else if (varp == &T_NAME)
6041 {
6042 if (T_NAME[0] == NUL)
6043 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
6044#ifdef FEAT_GUI
6045 if (gui.in_use)
6046 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
6047 else if (term_is_gui(T_NAME))
6048 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
6049#endif
6050 else if (set_termname(T_NAME) == FAIL)
6051 errmsg = (char_u *)N_("E522: Not found in termcap");
6052 else
Bram Moolenaar67391142017-02-19 21:07:04 +01006053 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006054 /* Screen colors may have changed. */
6055 redraw_later_clear();
Bram Moolenaar67391142017-02-19 21:07:04 +01006056
6057 /* Both 'term' and 'ttytype' point to T_NAME, only set the
6058 * P_ALLOCED flag on 'term'. */
6059 opt_idx = findoption((char_u *)"term");
Bram Moolenaar354796c2017-02-23 17:18:37 +01006060 free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaar67391142017-02-19 21:07:04 +01006061 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006062 }
6063
6064 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02006065 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006066 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02006067 char_u *bkc = p_bkc;
6068 unsigned int *flags = &bkc_flags;
6069
6070 if (opt_flags & OPT_LOCAL)
6071 {
6072 bkc = curbuf->b_p_bkc;
6073 flags = &curbuf->b_bkc_flags;
6074 }
6075
Bram Moolenaar84d17a62014-09-29 17:15:18 +02006076 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
6077 /* make the local value empty: use the global value */
6078 *flags = 0;
6079 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00006080 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02006081 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
6082 errmsg = e_invarg;
6083 if ((((int)*flags & BKC_AUTO) != 0)
6084 + (((int)*flags & BKC_YES) != 0)
6085 + (((int)*flags & BKC_NO) != 0) != 1)
6086 {
6087 /* Must have exactly one of "auto", "yes" and "no". */
6088 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
6089 errmsg = e_invarg;
6090 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006091 }
6092 }
6093
6094 /* 'backupext' and 'patchmode' */
6095 else if (varp == &p_bex || varp == &p_pm)
6096 {
6097 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
6098 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
6099 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
6100 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02006101#ifdef FEAT_LINEBREAK
6102 /* 'breakindentopt' */
6103 else if (varp == &curwin->w_p_briopt)
6104 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02006105 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02006106 errmsg = e_invarg;
6107 }
6108#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006109
6110 /*
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01006111 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[]
Bram Moolenaar071d4272004-06-13 20:20:40 +00006112 * If the new option is invalid, use old value. 'lisp' option: refill
Bram Moolenaar88e8f9f2016-01-20 22:48:02 +01006113 * g_chartab[] for '-' char
Bram Moolenaar071d4272004-06-13 20:20:40 +00006114 */
6115 else if ( varp == &p_isi
6116 || varp == &(curbuf->b_p_isk)
6117 || varp == &p_isp
6118 || varp == &p_isf)
6119 {
6120 if (init_chartab() == FAIL)
6121 {
6122 did_chartab = TRUE; /* need to restore it below */
6123 errmsg = e_invarg; /* error in value */
6124 }
6125 }
6126
6127 /* 'helpfile' */
6128 else if (varp == &p_hf)
6129 {
6130 /* May compute new values for $VIM and $VIMRUNTIME */
6131 if (didset_vim)
6132 {
6133 vim_setenv((char_u *)"VIM", (char_u *)"");
6134 didset_vim = FALSE;
6135 }
6136 if (didset_vimruntime)
6137 {
6138 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
6139 didset_vimruntime = FALSE;
6140 }
6141 }
6142
Bram Moolenaar1a384422010-07-14 19:53:30 +02006143#ifdef FEAT_SYN_HL
6144 /* 'colorcolumn' */
6145 else if (varp == &curwin->w_p_cc)
6146 errmsg = check_colorcolumn(curwin);
6147#endif
6148
Bram Moolenaar071d4272004-06-13 20:20:40 +00006149#ifdef FEAT_MULTI_LANG
6150 /* 'helplang' */
6151 else if (varp == &p_hlg)
6152 {
6153 /* Check for "", "ab", "ab,cd", etc. */
6154 for (s = p_hlg; *s != NUL; s += 3)
6155 {
6156 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
6157 {
6158 errmsg = e_invarg;
6159 break;
6160 }
6161 if (s[2] == NUL)
6162 break;
6163 }
6164 }
6165#endif
6166
6167 /* 'highlight' */
6168 else if (varp == &p_hl)
6169 {
6170 if (highlight_changed() == FAIL)
6171 errmsg = e_invarg; /* invalid flags */
6172 }
6173
6174 /* 'nrformats' */
6175 else if (gvarp == &p_nf)
6176 {
6177 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
6178 errmsg = e_invarg;
6179 }
6180
6181#ifdef FEAT_SESSION
6182 /* 'sessionoptions' */
6183 else if (varp == &p_ssop)
6184 {
6185 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
6186 errmsg = e_invarg;
6187 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
6188 {
6189 /* Don't allow both "sesdir" and "curdir". */
6190 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
6191 errmsg = e_invarg;
6192 }
6193 }
6194 /* 'viewoptions' */
6195 else if (varp == &p_vop)
6196 {
6197 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
6198 errmsg = e_invarg;
6199 }
6200#endif
6201
6202 /* 'scrollopt' */
6203#ifdef FEAT_SCROLLBIND
6204 else if (varp == &p_sbo)
6205 {
6206 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
6207 errmsg = e_invarg;
6208 }
6209#endif
6210
6211 /* 'ambiwidth' */
6212#ifdef FEAT_MBYTE
Bram Moolenaar3848e002016-03-19 18:42:29 +01006213 else if (varp == &p_ambw || varp == &p_emoji)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006214 {
6215 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
6216 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02006217 else if (set_chars_option(&p_lcs) != NULL)
6218 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
6219# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6220 else if (set_chars_option(&p_fcs) != NULL)
6221 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
6222# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006223 }
6224#endif
6225
6226 /* 'background' */
6227 else if (varp == &p_bg)
6228 {
6229 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
6230 {
6231#ifdef FEAT_EVAL
6232 int dark = (*p_bg == 'd');
6233#endif
6234
6235 init_highlight(FALSE, FALSE);
6236
6237#ifdef FEAT_EVAL
6238 if (dark != (*p_bg == 'd')
6239 && get_var_value((char_u *)"g:colors_name") != NULL)
6240 {
6241 /* The color scheme must have set 'background' back to another
6242 * value, that's not what we want here. Disable the color
6243 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00006244 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006245 free_string_option(p_bg);
6246 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
6247 check_string_option(&p_bg);
6248 init_highlight(FALSE, FALSE);
6249 }
6250#endif
6251 }
6252 else
6253 errmsg = e_invarg;
6254 }
6255
6256 /* 'wildmode' */
6257 else if (varp == &p_wim)
6258 {
6259 if (check_opt_wim() == FAIL)
6260 errmsg = e_invarg;
6261 }
6262
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006263#ifdef FEAT_CMDL_COMPL
6264 /* 'wildoptions' */
6265 else if (varp == &p_wop)
6266 {
6267 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6268 errmsg = e_invarg;
6269 }
6270#endif
6271
Bram Moolenaar071d4272004-06-13 20:20:40 +00006272#ifdef FEAT_WAK
6273 /* 'winaltkeys' */
6274 else if (varp == &p_wak)
6275 {
6276 if (*p_wak == NUL
6277 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6278 errmsg = e_invarg;
6279# ifdef FEAT_MENU
6280# ifdef FEAT_GUI_MOTIF
6281 else if (gui.in_use)
6282 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6283# else
6284# ifdef FEAT_GUI_GTK
6285 else if (gui.in_use)
6286 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6287# endif
6288# endif
6289# endif
6290 }
6291#endif
6292
6293#ifdef FEAT_AUTOCMD
6294 /* 'eventignore' */
6295 else if (varp == &p_ei)
6296 {
6297 if (check_ei() == FAIL)
6298 errmsg = e_invarg;
6299 }
6300#endif
6301
6302#ifdef FEAT_MBYTE
Bram Moolenaar2c7292d2017-03-05 17:43:31 +01006303 /* 'encoding', 'fileencoding', 'termencoding' and 'makeencoding' */
6304 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc
6305 || gvarp == &p_menc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006306 {
6307 if (gvarp == &p_fenc)
6308 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006309 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006310 errmsg = e_modifiable;
6311 else if (vim_strchr(*varp, ',') != NULL)
6312 /* No comma allowed in 'fileencoding'; catches confusing it
6313 * with 'fileencodings'. */
6314 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006315 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006316 {
6317# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006318 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006319 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006320# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006321 /* Add 'fileencoding' to the swap file. */
6322 ml_setflags(curbuf);
6323 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006324 }
6325 if (errmsg == NULL)
6326 {
6327 /* canonize the value, so that STRCMP() can be used on it */
6328 p = enc_canonize(*varp);
6329 if (p != NULL)
6330 {
6331 vim_free(*varp);
6332 *varp = p;
6333 }
6334 if (varp == &p_enc)
6335 {
6336 errmsg = mb_init();
6337# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006338 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006339# endif
6340 }
6341 }
6342
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006343# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006344 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6345 {
6346 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6347 if (STRCMP(p_tenc, "utf-8") != 0)
6348 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6349 }
6350# endif
6351
6352 if (errmsg == NULL)
6353 {
6354# ifdef FEAT_KEYMAP
6355 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6356 * (with another encoding). */
6357 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6358 (void)keymap_init();
6359# endif
6360
6361 /* When 'termencoding' is not empty and 'encoding' changes or when
6362 * 'termencoding' changes, need to setup for keyboard input and
6363 * display output conversion. */
6364 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6365 {
6366 convert_setup(&input_conv, p_tenc, p_enc);
6367 convert_setup(&output_conv, p_enc, p_tenc);
6368 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006369
6370# if defined(WIN3264) && defined(FEAT_MBYTE)
6371 /* $HOME may have characters in active code page. */
6372 if (varp == &p_enc)
6373 init_homedir();
6374# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006375 }
6376 }
6377#endif
6378
6379#if defined(FEAT_POSTSCRIPT)
6380 else if (varp == &p_penc)
6381 {
6382 /* Canonize printencoding if VIM standard one */
6383 p = enc_canonize(p_penc);
6384 if (p != NULL)
6385 {
6386 vim_free(p_penc);
6387 p_penc = p;
6388 }
6389 else
6390 {
6391 /* Ensure lower case and '-' for '_' */
6392 for (s = p_penc; *s != NUL; s++)
6393 {
6394 if (*s == '_')
6395 *s = '-';
6396 else
6397 *s = TOLOWER_ASC(*s);
6398 }
6399 }
6400 }
6401#endif
6402
Bram Moolenaar9372a112005-12-06 19:59:18 +00006403#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006404 else if (varp == &p_imak)
6405 {
Bram Moolenaar86e57922017-04-23 18:44:26 +02006406 if (!im_xim_isvalid_imactivate())
Bram Moolenaar071d4272004-06-13 20:20:40 +00006407 errmsg = e_invarg;
6408 }
6409#endif
6410
6411#ifdef FEAT_KEYMAP
6412 else if (varp == &curbuf->b_p_keymap)
6413 {
Bram Moolenaard0b51382016-11-04 15:23:45 +01006414 if (!valid_filetype(*varp))
6415 errmsg = e_invarg;
6416 else
6417 /* load or unload key mapping tables */
6418 errmsg = keymap_init();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006419
Bram Moolenaarfab06232009-03-04 03:13:35 +00006420 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006421 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006422 if (*curbuf->b_p_keymap != NUL)
6423 {
6424 /* Installed a new keymap, switch on using it. */
6425 curbuf->b_p_iminsert = B_IMODE_LMAP;
6426 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6427 curbuf->b_p_imsearch = B_IMODE_LMAP;
6428 }
6429 else
6430 {
6431 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6432 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6433 curbuf->b_p_iminsert = B_IMODE_NONE;
6434 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6435 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6436 }
6437 if ((opt_flags & OPT_LOCAL) == 0)
6438 {
6439 set_iminsert_global();
6440 set_imsearch_global();
6441 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006442# ifdef FEAT_WINDOWS
6443 status_redraw_curbuf();
6444# endif
6445 }
6446 }
6447#endif
6448
6449 /* 'fileformat' */
6450 else if (gvarp == &p_ff)
6451 {
6452 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6453 errmsg = e_modifiable;
6454 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6455 errmsg = e_invarg;
6456 else
6457 {
6458 /* may also change 'textmode' */
6459 if (get_fileformat(curbuf) == EOL_DOS)
6460 curbuf->b_p_tx = TRUE;
6461 else
6462 curbuf->b_p_tx = FALSE;
6463#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006464 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006465#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006466 /* update flag in swap file */
6467 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006468 /* Redraw needed when switching to/from "mac": a CR in the text
6469 * will be displayed differently. */
6470 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6471 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006472 }
6473 }
6474
6475 /* 'fileformats' */
6476 else if (varp == &p_ffs)
6477 {
6478 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6479 errmsg = e_invarg;
6480 else
6481 {
6482 /* also change 'textauto' */
6483 if (*p_ffs == NUL)
6484 p_ta = FALSE;
6485 else
6486 p_ta = TRUE;
6487 }
6488 }
6489
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006490#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006491 /* 'cryptkey' */
6492 else if (gvarp == &p_key)
6493 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006494# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006495 /* Make sure the ":set" command doesn't show the new value in the
6496 * history. */
6497 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006498# endif
6499 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6500 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006501 ml_set_crypt_key(curbuf, oldval,
6502 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006503 }
6504
6505 else if (gvarp == &p_cm)
6506 {
6507 if (opt_flags & OPT_LOCAL)
6508 p = curbuf->b_p_cm;
6509 else
6510 p = p_cm;
6511 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6512 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006513 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006514 errmsg = e_invarg;
6515 else
6516 {
6517 /* When setting the global value to empty, make it "zip". */
6518 if (*p_cm == NUL)
6519 {
6520 if (new_value_alloced)
6521 free_string_option(p_cm);
6522 p_cm = vim_strsave((char_u *)"zip");
6523 new_value_alloced = TRUE;
6524 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006525 /* When using ":set cm=name" the local value is going to be empty.
6526 * Do that here, otherwise the crypt functions will still use the
6527 * local value. */
6528 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6529 {
6530 free_string_option(curbuf->b_p_cm);
6531 curbuf->b_p_cm = empty_option;
6532 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006533
6534 /* Need to update the swapfile when the effective method changed.
6535 * Set "s" to the effective old value, "p" to the effective new
6536 * method and compare. */
6537 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6538 s = p_cm; /* was previously using the global value */
6539 else
6540 s = oldval;
6541 if (*curbuf->b_p_cm == NUL)
6542 p = p_cm; /* is now using the global value */
6543 else
6544 p = curbuf->b_p_cm;
6545 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006546 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006547
6548 /* If the global value changes need to update the swapfile for all
6549 * buffers using that value. */
6550 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6551 {
6552 buf_T *buf;
6553
Bram Moolenaar29323592016-07-24 22:04:11 +02006554 FOR_ALL_BUFFERS(buf)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006555 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006556 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006557 }
6558 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006559 }
6560#endif
6561
6562 /* 'matchpairs' */
6563 else if (gvarp == &p_mps)
6564 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006565#ifdef FEAT_MBYTE
6566 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006567 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006568 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006569 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006570 int x2 = -1;
6571 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006572
6573 if (*p != NUL)
6574 p += mb_ptr2len(p);
6575 if (*p != NUL)
6576 x2 = *p++;
6577 if (*p != NUL)
6578 {
6579 x3 = mb_ptr2char(p);
6580 p += mb_ptr2len(p);
6581 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006582 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006583 {
6584 errmsg = e_invarg;
6585 break;
6586 }
6587 if (*p == NUL)
6588 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006589 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006590 }
6591 else
6592#endif
6593 {
6594 /* Check for "x:y,x:y" */
6595 for (p = *varp; *p != NUL; p += 4)
6596 {
6597 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6598 {
6599 errmsg = e_invarg;
6600 break;
6601 }
6602 if (p[3] == NUL)
6603 break;
6604 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006605 }
6606 }
6607
6608#ifdef FEAT_COMMENTS
6609 /* 'comments' */
6610 else if (gvarp == &p_com)
6611 {
6612 for (s = *varp; *s; )
6613 {
6614 while (*s && *s != ':')
6615 {
6616 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6617 && !VIM_ISDIGIT(*s) && *s != '-')
6618 {
6619 errmsg = illegal_char(errbuf, *s);
6620 break;
6621 }
6622 ++s;
6623 }
6624 if (*s++ == NUL)
6625 errmsg = (char_u *)N_("E524: Missing colon");
6626 else if (*s == ',' || *s == NUL)
6627 errmsg = (char_u *)N_("E525: Zero length string");
6628 if (errmsg != NULL)
6629 break;
6630 while (*s && *s != ',')
6631 {
6632 if (*s == '\\' && s[1] != NUL)
6633 ++s;
6634 ++s;
6635 }
6636 s = skip_to_option_part(s);
6637 }
6638 }
6639#endif
6640
6641 /* 'listchars' */
6642 else if (varp == &p_lcs)
6643 {
6644 errmsg = set_chars_option(varp);
6645 }
6646
6647#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6648 /* 'fillchars' */
6649 else if (varp == &p_fcs)
6650 {
6651 errmsg = set_chars_option(varp);
6652 }
6653#endif
6654
6655#ifdef FEAT_CMDWIN
6656 /* 'cedit' */
6657 else if (varp == &p_cedit)
6658 {
6659 errmsg = check_cedit();
6660 }
6661#endif
6662
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006663 /* 'verbosefile' */
6664 else if (varp == &p_vfile)
6665 {
6666 verbose_stop();
6667 if (*p_vfile != NUL && verbose_open() == FAIL)
6668 errmsg = e_invarg;
6669 }
6670
Bram Moolenaar071d4272004-06-13 20:20:40 +00006671#ifdef FEAT_VIMINFO
6672 /* 'viminfo' */
6673 else if (varp == &p_viminfo)
6674 {
6675 for (s = p_viminfo; *s;)
6676 {
6677 /* Check it's a valid character */
6678 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6679 {
6680 errmsg = illegal_char(errbuf, *s);
6681 break;
6682 }
6683 if (*s == 'n') /* name is always last one */
6684 {
6685 break;
6686 }
6687 else if (*s == 'r') /* skip until next ',' */
6688 {
6689 while (*++s && *s != ',')
6690 ;
6691 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006692 else if (*s == '%')
6693 {
6694 /* optional number */
6695 while (vim_isdigit(*++s))
6696 ;
6697 }
6698 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006699 ++s; /* no extra chars */
6700 else /* must have a number */
6701 {
6702 while (vim_isdigit(*++s))
6703 ;
6704
6705 if (!VIM_ISDIGIT(*(s - 1)))
6706 {
6707 if (errbuf != NULL)
6708 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006709 sprintf((char *)errbuf,
6710 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006711 transchar_byte(*(s - 1)));
6712 errmsg = errbuf;
6713 }
6714 else
6715 errmsg = (char_u *)"";
6716 break;
6717 }
6718 }
6719 if (*s == ',')
6720 ++s;
6721 else if (*s)
6722 {
6723 if (errbuf != NULL)
6724 errmsg = (char_u *)N_("E527: Missing comma");
6725 else
6726 errmsg = (char_u *)"";
6727 break;
6728 }
6729 }
6730 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6731 errmsg = (char_u *)N_("E528: Must specify a ' value");
6732 }
6733#endif /* FEAT_VIMINFO */
6734
6735 /* terminal options */
6736 else if (istermoption(&options[opt_idx]) && full_screen)
6737 {
6738 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6739 if (varp == &T_CCO)
6740 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006741 int colors = atoi((char *)T_CCO);
6742
6743 /* Only reinitialize colors if t_Co value has really changed to
6744 * avoid expensive reload of colorscheme if t_Co is set to the
6745 * same value multiple times. */
6746 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006747 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006748 t_colors = colors;
6749 if (t_colors <= 1)
6750 {
6751 if (new_value_alloced)
6752 vim_free(T_CCO);
6753 T_CCO = empty_option;
6754 }
6755 /* We now have a different color setup, initialize it again. */
6756 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006757 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006758 }
6759 ttest(FALSE);
6760 if (varp == &T_ME)
6761 {
6762 out_str(T_ME);
6763 redraw_later(CLEAR);
Bram Moolenaar48e330a2016-02-23 14:53:34 +01006764#if defined(WIN3264) && !defined(FEAT_GUI_W32)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006765 /* Since t_me has been set, this probably means that the user
6766 * wants to use this as default colors. Need to reset default
6767 * background/foreground colors. */
6768 mch_set_normal_colors();
6769#endif
6770 }
Bram Moolenaard9c60642017-01-27 20:03:18 +01006771 if (varp == &T_BE && termcap_active)
6772 {
6773 if (*T_BE == NUL)
6774 /* When clearing t_BE we assume the user no longer wants
6775 * bracketed paste, thus disable it by writing t_BD. */
6776 out_str(T_BD);
6777 else
6778 out_str(T_BE);
6779 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006780 }
6781
6782#ifdef FEAT_LINEBREAK
6783 /* 'showbreak' */
6784 else if (varp == &p_sbr)
6785 {
6786 for (s = p_sbr; *s; )
6787 {
6788 if (ptr2cells(s) != 1)
6789 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar91acfff2017-03-12 19:22:36 +01006790 MB_PTR_ADV(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006791 }
6792 }
6793#endif
6794
6795#ifdef FEAT_GUI
6796 /* 'guifont' */
6797 else if (varp == &p_guifont)
6798 {
6799 if (gui.in_use)
6800 {
6801 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006802# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006803 /*
6804 * Put up a font dialog and let the user select a new value.
6805 * If this is cancelled go back to the old value but don't
6806 * give an error message.
6807 */
6808 if (STRCMP(p, "*") == 0)
6809 {
6810 p = gui_mch_font_dialog(oldval);
6811
6812 if (new_value_alloced)
6813 free_string_option(p_guifont);
6814
6815 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6816 new_value_alloced = TRUE;
6817 }
6818# endif
6819 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6820 {
6821# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6822 if (STRCMP(p_guifont, "*") == 0)
6823 {
6824 /* Dialog was cancelled: Keep the old value without giving
6825 * an error message. */
6826 if (new_value_alloced)
6827 free_string_option(p_guifont);
6828 p_guifont = vim_strsave(oldval);
6829 new_value_alloced = TRUE;
6830 }
6831 else
6832# endif
6833 errmsg = (char_u *)N_("E596: Invalid font(s)");
6834 }
6835 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006836 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006837 }
6838# ifdef FEAT_XFONTSET
6839 else if (varp == &p_guifontset)
6840 {
6841 if (STRCMP(p_guifontset, "*") == 0)
6842 errmsg = (char_u *)N_("E597: can't select fontset");
6843 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6844 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006845 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006846 }
6847# endif
6848# ifdef FEAT_MBYTE
6849 else if (varp == &p_guifontwide)
6850 {
6851 if (STRCMP(p_guifontwide, "*") == 0)
6852 errmsg = (char_u *)N_("E533: can't select wide font");
6853 else if (gui_get_wide_font() == FAIL)
6854 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006855 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006856 }
6857# endif
6858#endif
6859
6860#ifdef CURSOR_SHAPE
6861 /* 'guicursor' */
6862 else if (varp == &p_guicursor)
6863 errmsg = parse_shape_opt(SHAPE_CURSOR);
6864#endif
6865
6866#ifdef FEAT_MOUSESHAPE
6867 /* 'mouseshape' */
6868 else if (varp == &p_mouseshape)
6869 {
6870 errmsg = parse_shape_opt(SHAPE_MOUSE);
6871 update_mouseshape(-1);
6872 }
6873#endif
6874
6875#ifdef FEAT_PRINTER
6876 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006877 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006878# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006879 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006880 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006881# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006882#endif
6883
6884#ifdef FEAT_LANGMAP
6885 /* 'langmap' */
6886 else if (varp == &p_langmap)
6887 langmap_set();
6888#endif
6889
6890#ifdef FEAT_LINEBREAK
6891 /* 'breakat' */
6892 else if (varp == &p_breakat)
6893 fill_breakat_flags();
6894#endif
6895
6896#ifdef FEAT_TITLE
6897 /* 'titlestring' and 'iconstring' */
6898 else if (varp == &p_titlestring || varp == &p_iconstring)
6899 {
6900# ifdef FEAT_STL_OPT
6901 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6902
6903 /* NULL => statusline syntax */
6904 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6905 stl_syntax |= flagval;
6906 else
6907 stl_syntax &= ~flagval;
6908# endif
6909 did_set_title(varp == &p_iconstring);
6910
6911 }
6912#endif
6913
6914#ifdef FEAT_GUI
6915 /* 'guioptions' */
6916 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006917 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006918 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006919 redraw_gui_only = TRUE;
6920 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006921#endif
6922
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006923#if defined(FEAT_GUI_TABLINE)
6924 /* 'guitablabel' */
6925 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006926 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006927 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006928 redraw_gui_only = TRUE;
6929 }
6930 /* 'guitabtooltip' */
6931 else if (varp == &p_gtt)
6932 {
6933 redraw_gui_only = TRUE;
6934 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006935#endif
6936
Bram Moolenaar071d4272004-06-13 20:20:40 +00006937#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6938 /* 'ttymouse' */
6939 else if (varp == &p_ttym)
6940 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006941 /* Switch the mouse off before changing the escape sequences used for
6942 * that. */
6943 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006944 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6945 errmsg = e_invarg;
6946 else
6947 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006948 if (termcap_active)
6949 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006950 }
6951#endif
6952
Bram Moolenaar071d4272004-06-13 20:20:40 +00006953 /* 'selection' */
6954 else if (varp == &p_sel)
6955 {
6956 if (*p_sel == NUL
6957 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6958 errmsg = e_invarg;
6959 }
6960
6961 /* 'selectmode' */
6962 else if (varp == &p_slm)
6963 {
6964 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6965 errmsg = e_invarg;
6966 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006967
6968#ifdef FEAT_BROWSE
6969 /* 'browsedir' */
6970 else if (varp == &p_bsdir)
6971 {
6972 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
6973 && !mch_isdir(p_bsdir))
6974 errmsg = e_invarg;
6975 }
6976#endif
6977
Bram Moolenaar071d4272004-06-13 20:20:40 +00006978 /* 'keymodel' */
6979 else if (varp == &p_km)
6980 {
6981 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
6982 errmsg = e_invarg;
6983 else
6984 {
6985 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
6986 km_startsel = (vim_strchr(p_km, 'a') != NULL);
6987 }
6988 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006989
6990 /* 'mousemodel' */
6991 else if (varp == &p_mousem)
6992 {
6993 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
6994 errmsg = e_invarg;
6995#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
6996 else if (*p_mousem != *oldval)
6997 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
6998 * to create or delete the popup menus. */
6999 gui_motif_update_mousemodel(root_menu);
7000#endif
7001 }
7002
7003 /* 'switchbuf' */
7004 else if (varp == &p_swb)
7005 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007006 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007007 errmsg = e_invarg;
7008 }
7009
7010 /* 'debug' */
7011 else if (varp == &p_debug)
7012 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00007013 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007014 errmsg = e_invarg;
7015 }
7016
7017 /* 'display' */
7018 else if (varp == &p_dy)
7019 {
7020 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
7021 errmsg = e_invarg;
7022 else
7023 (void)init_chartab();
7024
7025 }
7026
Bram Moolenaar44a2f922016-03-19 22:11:51 +01007027#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00007028 /* 'eadirection' */
7029 else if (varp == &p_ead)
7030 {
7031 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
7032 errmsg = e_invarg;
7033 }
7034#endif
7035
7036#ifdef FEAT_CLIPBOARD
7037 /* 'clipboard' */
7038 else if (varp == &p_cb)
7039 errmsg = check_clipboard_option();
7040#endif
7041
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007042#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00007043 /* When 'spelllang' or 'spellfile' is set and there is a window for this
7044 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01007045 else if (varp == &(curwin->w_s->b_p_spl)
7046 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00007047 {
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007048 errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf));
Bram Moolenaar217ad922005-03-20 22:37:15 +00007049 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007050 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007051 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007052 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007053 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007054 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00007055 /* 'spellsuggest' */
7056 else if (varp == &p_sps)
7057 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00007058 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00007059 errmsg = e_invarg;
7060 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00007061 /* 'mkspellmem' */
7062 else if (varp == &p_msm)
7063 {
7064 if (spell_check_msm() != OK)
7065 errmsg = e_invarg;
7066 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00007067#endif
7068
Bram Moolenaar071d4272004-06-13 20:20:40 +00007069#ifdef FEAT_QUICKFIX
7070 /* When 'bufhidden' is set, check for valid value. */
7071 else if (gvarp == &p_bh)
7072 {
7073 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
7074 errmsg = e_invarg;
7075 }
7076
7077 /* When 'buftype' is set, check for valid value. */
7078 else if (gvarp == &p_bt)
7079 {
7080 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
7081 errmsg = e_invarg;
7082 else
7083 {
7084# ifdef FEAT_WINDOWS
7085 if (curwin->w_status_height)
7086 {
7087 curwin->w_redr_status = TRUE;
7088 redraw_later(VALID);
7089 }
7090# endif
7091 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar5075aad2010-01-27 15:58:13 +01007092# ifdef FEAT_TITLE
7093 redraw_titles();
7094# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007095 }
7096 }
7097#endif
7098
7099#ifdef FEAT_STL_OPT
7100 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00007101 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007102 {
7103 int wid;
7104
7105 if (varp == &p_ruf) /* reset ru_wid first */
7106 ru_wid = 0;
7107 s = *varp;
7108 if (varp == &p_ruf && *s == '%')
7109 {
7110 /* set ru_wid if 'ruf' starts with "%99(" */
7111 if (*++s == '-') /* ignore a '-' */
7112 s++;
7113 wid = getdigits(&s);
7114 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
7115 ru_wid = wid;
7116 else
7117 errmsg = check_stl_option(p_ruf);
7118 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00007119 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00007120 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00007121 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00007122 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007123 comp_col();
7124 }
7125#endif
7126
7127#ifdef FEAT_INS_EXPAND
7128 /* check if it is a valid value for 'complete' -- Acevedo */
7129 else if (gvarp == &p_cpt)
7130 {
7131 for (s = *varp; *s;)
7132 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007133 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00007134 s++;
7135 if (!*s)
7136 break;
7137 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
7138 {
7139 errmsg = illegal_char(errbuf, *s);
7140 break;
7141 }
7142 if (*++s != NUL && *s != ',' && *s != ' ')
7143 {
7144 if (s[-1] == 'k' || s[-1] == 's')
7145 {
7146 /* skip optional filename after 'k' and 's' */
7147 while (*s && *s != ',' && *s != ' ')
7148 {
Bram Moolenaar226c5342017-02-17 14:53:15 +01007149 if (*s == '\\' && s[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007150 ++s;
7151 ++s;
7152 }
7153 }
7154 else
7155 {
7156 if (errbuf != NULL)
7157 {
7158 sprintf((char *)errbuf,
7159 _("E535: Illegal character after <%c>"),
7160 *--s);
7161 errmsg = errbuf;
7162 }
7163 else
7164 errmsg = (char_u *)"";
7165 break;
7166 }
7167 }
7168 }
7169 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007170
7171 /* 'completeopt' */
7172 else if (varp == &p_cot)
7173 {
7174 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
7175 errmsg = e_invarg;
Bram Moolenaarc0200422016-04-20 12:02:02 +02007176 else
7177 completeopt_was_set();
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00007178 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007179#endif /* FEAT_INS_EXPAND */
7180
Bram Moolenaar95ec9d62016-08-12 18:29:59 +02007181#ifdef FEAT_SIGNS
7182 /* 'signcolumn' */
7183 else if (varp == &curwin->w_p_scl)
7184 {
7185 if (check_opt_strings(*varp, p_scl_values, FALSE) != OK)
7186 errmsg = e_invarg;
7187 }
7188#endif
7189
Bram Moolenaar071d4272004-06-13 20:20:40 +00007190
7191#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007192 /* 'toolbar' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007193 else if (varp == &p_toolbar)
7194 {
7195 if (opt_strings_flags(p_toolbar, p_toolbar_values,
7196 &toolbar_flags, TRUE) != OK)
7197 errmsg = e_invarg;
7198 else
7199 {
7200 out_flush();
7201 gui_mch_show_toolbar((toolbar_flags &
7202 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7203 }
7204 }
7205#endif
7206
Bram Moolenaar182c5be2010-06-25 05:37:59 +02007207#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007208 /* 'toolbariconsize': GTK+ 2 only */
7209 else if (varp == &p_tbis)
7210 {
7211 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
7212 errmsg = e_invarg;
7213 else
7214 {
7215 out_flush();
7216 gui_mch_show_toolbar((toolbar_flags &
7217 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
7218 }
7219 }
7220#endif
7221
7222 /* 'pastetoggle': translate key codes like in a mapping */
7223 else if (varp == &p_pt)
7224 {
7225 if (*p_pt)
7226 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00007227 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007228 if (p != NULL)
7229 {
7230 if (new_value_alloced)
7231 free_string_option(p_pt);
7232 p_pt = p;
7233 new_value_alloced = TRUE;
7234 }
7235 }
7236 }
7237
7238 /* 'backspace' */
7239 else if (varp == &p_bs)
7240 {
7241 if (VIM_ISDIGIT(*p_bs))
7242 {
Bram Moolenaare7fedb62015-12-31 19:07:19 +01007243 if (*p_bs > '2' || p_bs[1] != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007244 errmsg = e_invarg;
7245 }
7246 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
7247 errmsg = e_invarg;
7248 }
Bram Moolenaar165bc692015-07-21 17:53:25 +02007249 else if (varp == &p_bo)
7250 {
7251 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK)
7252 errmsg = e_invarg;
7253 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007254
Bram Moolenaar0f6562e2015-11-24 18:48:14 +01007255 /* 'tagcase' */
7256 else if (gvarp == &p_tc)
7257 {
7258 unsigned int *flags;
7259
7260 if (opt_flags & OPT_LOCAL)
7261 {
7262 p = curbuf->b_p_tc;
7263 flags = &curbuf->b_tc_flags;
7264 }
7265 else
7266 {
7267 p = p_tc;
7268 flags = &tc_flags;
7269 }
7270
7271 if ((opt_flags & OPT_LOCAL) && *p == NUL)
7272 /* make the local value empty: use the global value */
7273 *flags = 0;
7274 else if (*p == NUL
7275 || opt_strings_flags(p, p_tc_values, flags, FALSE) != OK)
7276 errmsg = e_invarg;
7277 }
7278
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007279#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007280 /* 'casemap' */
7281 else if (varp == &p_cmp)
7282 {
7283 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
7284 errmsg = e_invarg;
7285 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007286#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007287
7288#ifdef FEAT_DIFF
7289 /* 'diffopt' */
7290 else if (varp == &p_dip)
7291 {
7292 if (diffopt_changed() == FAIL)
7293 errmsg = e_invarg;
7294 }
7295#endif
7296
7297#ifdef FEAT_FOLDING
7298 /* 'foldmethod' */
7299 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7300 {
7301 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7302 || *curwin->w_p_fdm == NUL)
7303 errmsg = e_invarg;
7304 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007305 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007306 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007307 if (foldmethodIsDiff(curwin))
7308 newFoldLevel();
7309 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007310 }
7311# ifdef FEAT_EVAL
7312 /* 'foldexpr' */
7313 else if (varp == &curwin->w_p_fde)
7314 {
7315 if (foldmethodIsExpr(curwin))
7316 foldUpdateAll(curwin);
7317 }
7318# endif
7319 /* 'foldmarker' */
7320 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7321 {
7322 p = vim_strchr(*varp, ',');
7323 if (p == NULL)
7324 errmsg = (char_u *)N_("E536: comma required");
7325 else if (p == *varp || p[1] == NUL)
7326 errmsg = e_invarg;
7327 else if (foldmethodIsMarker(curwin))
7328 foldUpdateAll(curwin);
7329 }
7330 /* 'commentstring' */
7331 else if (gvarp == &p_cms)
7332 {
7333 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7334 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7335 }
7336 /* 'foldopen' */
7337 else if (varp == &p_fdo)
7338 {
7339 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7340 errmsg = e_invarg;
7341 }
7342 /* 'foldclose' */
7343 else if (varp == &p_fcl)
7344 {
7345 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7346 errmsg = e_invarg;
7347 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007348 /* 'foldignore' */
7349 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7350 {
7351 if (foldmethodIsIndent(curwin))
7352 foldUpdateAll(curwin);
7353 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007354#endif
7355
7356#ifdef FEAT_VIRTUALEDIT
7357 /* 'virtualedit' */
7358 else if (varp == &p_ve)
7359 {
7360 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7361 errmsg = e_invarg;
7362 else if (STRCMP(p_ve, oldval) != 0)
7363 {
7364 /* Recompute cursor position in case the new 've' setting
7365 * changes something. */
7366 validate_virtcol();
7367 coladvance(curwin->w_virtcol);
7368 }
7369 }
7370#endif
7371
7372#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7373 else if (varp == &p_csqf)
7374 {
7375 if (p_csqf != NULL)
7376 {
7377 p = p_csqf;
7378 while (*p != NUL)
7379 {
7380 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7381 || p[1] == NUL
7382 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7383 || (p[2] != NUL && p[2] != ','))
7384 {
7385 errmsg = e_invarg;
7386 break;
7387 }
7388 else if (p[2] == NUL)
7389 break;
7390 else
7391 p += 3;
7392 }
7393 }
7394 }
7395#endif
7396
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007397#ifdef FEAT_CINDENT
7398 /* 'cinoptions' */
7399 else if (gvarp == &p_cino)
7400 {
7401 /* TODO: recognize errors */
7402 parse_cino(curbuf);
7403 }
7404#endif
7405
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007406#if defined(FEAT_RENDER_OPTIONS)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007407 /* 'renderoptions' */
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007408 else if (varp == &p_rop && gui.in_use)
7409 {
7410 if (!gui_mch_set_rendering_options(p_rop))
7411 errmsg = e_invarg;
7412 }
7413#endif
7414
Bram Moolenaard0b51382016-11-04 15:23:45 +01007415#ifdef FEAT_AUTOCMD
7416 else if (gvarp == &p_ft)
7417 {
7418 if (!valid_filetype(*varp))
7419 errmsg = e_invarg;
7420 }
7421#endif
7422
7423#ifdef FEAT_SYN_HL
7424 else if (gvarp == &p_syn)
7425 {
7426 if (!valid_filetype(*varp))
7427 errmsg = e_invarg;
7428 }
7429#endif
7430
Bram Moolenaar071d4272004-06-13 20:20:40 +00007431 /* Options that are a list of flags. */
7432 else
7433 {
7434 p = NULL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007435 if (varp == &p_ww) /* 'whichwrap' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007436 p = (char_u *)WW_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007437 if (varp == &p_shm) /* 'shortmess' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007438 p = (char_u *)SHM_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007439 else if (varp == &(p_cpo)) /* 'cpoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007440 p = (char_u *)CPO_ALL;
Bram Moolenaar031cb742016-11-24 21:46:19 +01007441 else if (varp == &(curbuf->b_p_fo)) /* 'formatoptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007442 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007443#ifdef FEAT_CONCEAL
Bram Moolenaar031cb742016-11-24 21:46:19 +01007444 else if (varp == &curwin->w_p_cocu) /* 'concealcursor' */
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007445 p = (char_u *)COCU_ALL;
7446#endif
Bram Moolenaar031cb742016-11-24 21:46:19 +01007447 else if (varp == &p_mouse) /* 'mouse' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007448 {
7449#ifdef FEAT_MOUSE
7450 p = (char_u *)MOUSE_ALL;
7451#else
7452 if (*p_mouse != NUL)
7453 errmsg = (char_u *)N_("E538: No mouse support");
7454#endif
7455 }
7456#if defined(FEAT_GUI)
Bram Moolenaar031cb742016-11-24 21:46:19 +01007457 else if (varp == &p_go) /* 'guioptions' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007458 p = (char_u *)GO_ALL;
7459#endif
7460 if (p != NULL)
7461 {
7462 for (s = *varp; *s; ++s)
7463 if (vim_strchr(p, *s) == NULL)
7464 {
7465 errmsg = illegal_char(errbuf, *s);
7466 break;
7467 }
7468 }
7469 }
7470
7471 /*
7472 * If error detected, restore the previous value.
7473 */
7474 if (errmsg != NULL)
7475 {
7476 if (new_value_alloced)
7477 free_string_option(*varp);
7478 *varp = oldval;
7479 /*
7480 * When resetting some values, need to act on it.
7481 */
7482 if (did_chartab)
7483 (void)init_chartab();
7484 if (varp == &p_hl)
7485 (void)highlight_changed();
7486 }
7487 else
7488 {
7489#ifdef FEAT_EVAL
7490 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007491 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007492#endif
7493 /*
7494 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007495 * Use "free_oldval", because recursiveness may change the flags under
7496 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007497 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007498 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007499 free_string_option(oldval);
7500 if (new_value_alloced)
7501 options[opt_idx].flags |= P_ALLOCED;
7502 else
7503 options[opt_idx].flags &= ~P_ALLOCED;
7504
7505 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007506 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007507 {
7508 /* global option with local value set to use global value; free
7509 * the local value and make it empty */
7510 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7511 free_string_option(*(char_u **)p);
7512 *(char_u **)p = empty_option;
7513 }
7514
7515 /* May set global value for local option. */
7516 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7517 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007518
7519#ifdef FEAT_AUTOCMD
7520 /*
7521 * Trigger the autocommand only after setting the flags.
7522 */
7523# ifdef FEAT_SYN_HL
7524 /* When 'syntax' is set, load the syntax of that name */
7525 if (varp == &(curbuf->b_p_syn))
7526 {
7527 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7528 curbuf->b_fname, TRUE, curbuf);
7529 }
7530# endif
7531 else if (varp == &(curbuf->b_p_ft))
7532 {
7533 /* 'filetype' is set, trigger the FileType autocommand */
7534 did_filetype = TRUE;
7535 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
7536 curbuf->b_fname, TRUE, curbuf);
7537 }
7538#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007539#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007540 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007541 {
7542 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007543 char_u *q = curwin->w_s->b_p_spl;
7544
7545 /* Skip the first name if it is "cjk". */
7546 if (STRNCMP(q, "cjk,", 4) == 0)
7547 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007548
7549 /*
7550 * Source the spell/LANG.vim in 'runtimepath'.
7551 * They could set 'spellcapcheck' depending on the language.
7552 * Use the first name in 'spelllang' up to '_region' or
7553 * '.encoding'.
7554 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007555 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007556 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7557 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007558 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar7f8989d2016-03-12 22:11:39 +01007559 source_runtime(fname, DIP_ALL);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007560 }
7561#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007562 }
7563
7564#ifdef FEAT_MOUSE
7565 if (varp == &p_mouse)
7566 {
7567# ifdef FEAT_MOUSE_TTY
7568 if (*p_mouse == NUL)
7569 mch_setmouse(FALSE); /* switch mouse off */
7570 else
7571# endif
7572 setmouse(); /* in case 'mouse' changed */
7573 }
7574#endif
7575
Bram Moolenaar913077c2012-03-28 19:59:04 +02007576 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007577 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007578 curwin->w_set_curswant = TRUE;
7579
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007580#ifdef FEAT_GUI
7581 /* check redraw when it's not a GUI option or the GUI is active. */
7582 if (!redraw_gui_only || gui.in_use)
7583#endif
7584 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007585
7586 return errmsg;
7587}
7588
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007589#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007590/*
7591 * Simple int comparison function for use with qsort()
7592 */
7593 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01007594int_cmp(const void *a, const void *b)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007595{
7596 return *(const int *)a - *(const int *)b;
7597}
7598
7599/*
7600 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7601 * Returns error message, NULL if it's OK.
7602 */
7603 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007604check_colorcolumn(win_T *wp)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007605{
7606 char_u *s;
7607 int col;
7608 int count = 0;
7609 int color_cols[256];
7610 int i;
7611 int j = 0;
7612
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007613 if (wp->w_buffer == NULL)
7614 return NULL; /* buffer was closed */
7615
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007616 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007617 {
7618 if (*s == '-' || *s == '+')
7619 {
7620 /* -N and +N: add to 'textwidth' */
7621 col = (*s == '-') ? -1 : 1;
7622 ++s;
7623 if (!VIM_ISDIGIT(*s))
7624 return e_invarg;
7625 col = col * getdigits(&s);
7626 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007627 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007628 col += wp->w_buffer->b_p_tw;
7629 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007630 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007631 }
7632 else if (VIM_ISDIGIT(*s))
7633 col = getdigits(&s);
7634 else
7635 return e_invarg;
7636 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007637skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007638 if (*s == NUL)
7639 break;
7640 if (*s != ',')
7641 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007642 if (*++s == NUL)
7643 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007644 }
7645
7646 vim_free(wp->w_p_cc_cols);
7647 if (count == 0)
7648 wp->w_p_cc_cols = NULL;
7649 else
7650 {
7651 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7652 if (wp->w_p_cc_cols != NULL)
7653 {
7654 /* sort the columns for faster usage on screen redraw inside
7655 * win_line() */
7656 qsort(color_cols, count, sizeof(int), int_cmp);
7657
7658 for (i = 0; i < count; ++i)
7659 /* skip duplicates */
7660 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7661 wp->w_p_cc_cols[j++] = color_cols[i];
7662 wp->w_p_cc_cols[j] = -1; /* end marker */
7663 }
7664 }
7665
7666 return NULL; /* no error */
7667}
7668#endif
7669
Bram Moolenaar071d4272004-06-13 20:20:40 +00007670/*
7671 * Handle setting 'listchars' or 'fillchars'.
7672 * Returns error message, NULL if it's OK.
7673 */
7674 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007675set_chars_option(char_u **varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007676{
7677 int round, i, len, entries;
7678 char_u *p, *s;
7679 int c1, c2 = 0;
7680 struct charstab
7681 {
7682 int *cp;
7683 char *name;
7684 };
7685#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7686 static struct charstab filltab[] =
7687 {
7688 {&fill_stl, "stl"},
7689 {&fill_stlnc, "stlnc"},
7690 {&fill_vert, "vert"},
7691 {&fill_fold, "fold"},
7692 {&fill_diff, "diff"},
7693 };
7694#endif
7695 static struct charstab lcstab[] =
7696 {
7697 {&lcs_eol, "eol"},
7698 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007699 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007700 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007701 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007702 {&lcs_tab2, "tab"},
7703 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007704#ifdef FEAT_CONCEAL
7705 {&lcs_conceal, "conceal"},
7706#else
7707 {NULL, "conceal"},
7708#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007709 };
7710 struct charstab *tab;
7711
7712#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7713 if (varp == &p_lcs)
7714#endif
7715 {
7716 tab = lcstab;
7717 entries = sizeof(lcstab) / sizeof(struct charstab);
7718 }
7719#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7720 else
7721 {
7722 tab = filltab;
7723 entries = sizeof(filltab) / sizeof(struct charstab);
7724 }
7725#endif
7726
7727 /* first round: check for valid value, second round: assign values */
7728 for (round = 0; round <= 1; ++round)
7729 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007730 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007731 {
7732 /* After checking that the value is valid: set defaults: space for
7733 * 'fillchars', NUL for 'listchars' */
7734 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007735 if (tab[i].cp != NULL)
7736 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007737 if (varp == &p_lcs)
7738 lcs_tab1 = NUL;
7739#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7740 else
7741 fill_diff = '-';
7742#endif
7743 }
7744 p = *varp;
7745 while (*p)
7746 {
7747 for (i = 0; i < entries; ++i)
7748 {
7749 len = (int)STRLEN(tab[i].name);
7750 if (STRNCMP(p, tab[i].name, len) == 0
7751 && p[len] == ':'
7752 && p[len + 1] != NUL)
7753 {
7754 s = p + len + 1;
7755#ifdef FEAT_MBYTE
7756 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007757 if (mb_char2cells(c1) > 1)
7758 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007759#else
7760 c1 = *s++;
7761#endif
7762 if (tab[i].cp == &lcs_tab2)
7763 {
7764 if (*s == NUL)
7765 continue;
7766#ifdef FEAT_MBYTE
7767 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007768 if (mb_char2cells(c2) > 1)
7769 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007770#else
7771 c2 = *s++;
7772#endif
7773 }
7774 if (*s == ',' || *s == NUL)
7775 {
7776 if (round)
7777 {
7778 if (tab[i].cp == &lcs_tab2)
7779 {
7780 lcs_tab1 = c1;
7781 lcs_tab2 = c2;
7782 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007783 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007784 *(tab[i].cp) = c1;
7785
7786 }
7787 p = s;
7788 break;
7789 }
7790 }
7791 }
7792
7793 if (i == entries)
7794 return e_invarg;
7795 if (*p == ',')
7796 ++p;
7797 }
7798 }
7799
7800 return NULL; /* no error */
7801}
7802
7803#ifdef FEAT_STL_OPT
7804/*
7805 * Check validity of options with the 'statusline' format.
7806 * Return error message or NULL.
7807 */
7808 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007809check_stl_option(char_u *s)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007810{
7811 int itemcnt = 0;
7812 int groupdepth = 0;
7813 static char_u errbuf[80];
7814
7815 while (*s && itemcnt < STL_MAX_ITEM)
7816 {
7817 /* Check for valid keys after % sequences */
7818 while (*s && *s != '%')
7819 s++;
7820 if (!*s)
7821 break;
7822 s++;
7823 if (*s != '%' && *s != ')')
7824 ++itemcnt;
7825 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7826 {
7827 s++;
7828 continue;
7829 }
7830 if (*s == ')')
7831 {
7832 s++;
7833 if (--groupdepth < 0)
7834 break;
7835 continue;
7836 }
7837 if (*s == '-')
7838 s++;
7839 while (VIM_ISDIGIT(*s))
7840 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007841 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007842 continue;
7843 if (*s == '.')
7844 {
7845 s++;
7846 while (*s && VIM_ISDIGIT(*s))
7847 s++;
7848 }
7849 if (*s == '(')
7850 {
7851 groupdepth++;
7852 continue;
7853 }
7854 if (vim_strchr(STL_ALL, *s) == NULL)
7855 {
7856 return illegal_char(errbuf, *s);
7857 }
7858 if (*s == '{')
7859 {
7860 s++;
7861 while (*s != '}' && *s)
7862 s++;
7863 if (*s != '}')
7864 return (char_u *)N_("E540: Unclosed expression sequence");
7865 }
7866 }
7867 if (itemcnt >= STL_MAX_ITEM)
7868 return (char_u *)N_("E541: too many items");
7869 if (groupdepth != 0)
7870 return (char_u *)N_("E542: unbalanced groups");
7871 return NULL;
7872}
7873#endif
7874
7875#ifdef FEAT_CLIPBOARD
7876/*
7877 * Extract the items in the 'clipboard' option and set global values.
7878 */
7879 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007880check_clipboard_option(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007881{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007882 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007883 int new_autoselect_star = FALSE;
7884 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007885 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007886 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007887 regprog_T *new_exclude_prog = NULL;
7888 char_u *errmsg = NULL;
7889 char_u *p;
7890
7891 for (p = p_cb; *p != NUL; )
7892 {
7893 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7894 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007895 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007896 p += 7;
7897 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007898 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007899 && (p[11] == ',' || p[11] == NUL))
7900 {
7901 new_unnamed |= CLIP_UNNAMED_PLUS;
7902 p += 11;
7903 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007904 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007905 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007906 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007907 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007908 p += 10;
7909 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007910 else if (STRNCMP(p, "autoselectplus", 14) == 0
7911 && (p[14] == ',' || p[14] == NUL))
7912 {
7913 new_autoselect_plus = TRUE;
7914 p += 14;
7915 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007916 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007917 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007918 {
7919 new_autoselectml = TRUE;
7920 p += 12;
7921 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007922 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7923 {
7924 new_html = TRUE;
7925 p += 4;
7926 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007927 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7928 {
7929 p += 8;
7930 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7931 if (new_exclude_prog == NULL)
7932 errmsg = e_invarg;
7933 break;
7934 }
7935 else
7936 {
7937 errmsg = e_invarg;
7938 break;
7939 }
7940 if (*p == ',')
7941 ++p;
7942 }
7943 if (errmsg == NULL)
7944 {
7945 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007946 clip_autoselect_star = new_autoselect_star;
7947 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007948 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007949 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02007950 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007951 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02007952#ifdef FEAT_GUI_GTK
7953 if (gui.in_use)
7954 {
7955 gui_gtk_set_selection_targets();
7956 gui_gtk_set_dnd_targets();
7957 }
7958#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007959 }
7960 else
Bram Moolenaar473de612013-06-08 18:19:48 +02007961 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007962
7963 return errmsg;
7964}
7965#endif
7966
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007967#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007968 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01007969did_set_spell_option(int is_spellfile)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007970{
7971 char_u *errmsg = NULL;
7972 win_T *wp;
7973 int l;
7974
7975 if (is_spellfile)
7976 {
7977 l = (int)STRLEN(curwin->w_s->b_p_spf);
7978 if (l > 0 && (l < 4
7979 || STRCMP(curwin->w_s->b_p_spf + l - 4, ".add") != 0))
7980 errmsg = e_invarg;
7981 }
7982
7983 if (errmsg == NULL)
7984 {
7985 FOR_ALL_WINDOWS(wp)
7986 if (wp->w_buffer == curbuf && wp->w_p_spell)
7987 {
7988 errmsg = did_set_spelllang(wp);
7989# ifdef FEAT_WINDOWS
7990 break;
7991# endif
7992 }
7993 }
7994 return errmsg;
7995}
7996
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007997/*
7998 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
7999 * Return error message when failed, NULL when OK.
8000 */
8001 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008002compile_cap_prog(synblock_T *synblock)
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008003{
Bram Moolenaar860cae12010-06-05 23:22:07 +02008004 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008005 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008006
Bram Moolenaar860cae12010-06-05 23:22:07 +02008007 if (*synblock->b_p_spc == NUL)
8008 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008009 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008010 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008011 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02008012 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008013 if (re != NULL)
8014 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008015 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02008016 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02008017 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008018 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008019 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008020 return e_invarg;
8021 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00008022 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008023 }
8024
Bram Moolenaar473de612013-06-08 18:19:48 +02008025 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00008026 return NULL;
8027}
8028#endif
8029
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008030#if defined(FEAT_EVAL) || defined(PROTO)
8031/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008032 * Set the scriptID for an option, taking care of setting the buffer- or
8033 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008034 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008035 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01008036set_option_scriptID_idx(int opt_idx, int opt_flags, int id)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008037{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008038 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
8039 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008040
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008041 /* Remember where the option was set. For local options need to do that
8042 * in the buffer or window structure. */
8043 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008044 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008045 if (both || (opt_flags & OPT_LOCAL))
8046 {
8047 if (indir & PV_BUF)
8048 curbuf->b_p_scriptID[indir & PV_MASK] = id;
8049 else if (indir & PV_WIN)
8050 curwin->w_p_scriptID[indir & PV_MASK] = id;
8051 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00008052}
8053#endif
8054
Bram Moolenaar071d4272004-06-13 20:20:40 +00008055/*
8056 * Set the value of a boolean option, and take care of side effects.
8057 * Returns NULL for success, or an error message for an error.
8058 */
8059 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008060set_bool_option(
8061 int opt_idx, /* index in options[] table */
8062 char_u *varp, /* pointer to the option variable */
8063 int value, /* new value */
8064 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008065{
8066 int old_value = *(int *)varp;
8067
Bram Moolenaar071d4272004-06-13 20:20:40 +00008068 /* Disallow changing some options from secure mode */
8069 if ((secure
8070#ifdef HAVE_SANDBOX
8071 || sandbox != 0
8072#endif
8073 ) && (options[opt_idx].flags & P_SECURE))
8074 return e_secure;
8075
8076 *(int *)varp = value; /* set the new value */
8077#ifdef FEAT_EVAL
8078 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008079 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008080#endif
8081
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008082#ifdef FEAT_GUI
8083 need_mouse_correct = TRUE;
8084#endif
8085
Bram Moolenaar071d4272004-06-13 20:20:40 +00008086 /* May set global value for local option. */
8087 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8088 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
8089
8090 /*
8091 * Handle side effects of changing a bool option.
8092 */
8093
8094 /* 'compatible' */
8095 if ((int *)varp == &p_cp)
8096 {
8097 compatible_set();
8098 }
8099
Bram Moolenaar920694c2016-08-21 17:45:02 +02008100#ifdef FEAT_LANGMAP
8101 if ((int *)varp == &p_lrm)
8102 /* 'langremap' -> !'langnoremap' */
8103 p_lnr = !p_lrm;
8104 else if ((int *)varp == &p_lnr)
8105 /* 'langnoremap' -> !'langremap' */
8106 p_lrm = !p_lnr;
8107#endif
8108
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008109#ifdef FEAT_PERSISTENT_UNDO
8110 /* 'undofile' */
8111 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
8112 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008113 /* Only take action when the option was set. When reset we do not
8114 * delete the undo file, the option may be set again without making
8115 * any changes in between. */
8116 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008117 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008118 char_u hash[UNDO_HASH_SIZE];
8119 buf_T *save_curbuf = curbuf;
8120
Bram Moolenaar29323592016-07-24 22:04:11 +02008121 FOR_ALL_BUFFERS(curbuf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008122 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008123 /* When 'undofile' is set globally: for every buffer, otherwise
8124 * only for the current buffer: Try to read in the undofile,
8125 * if one exists, the buffer wasn't changed and the buffer was
8126 * loaded */
8127 if ((curbuf == save_curbuf
8128 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
8129 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
8130 {
8131 u_compute_hash(hash);
8132 u_read_undo(NULL, hash, curbuf->b_fname);
8133 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008134 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02008135 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008136 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01008137 }
8138#endif
8139
Bram Moolenaar071d4272004-06-13 20:20:40 +00008140 else if ((int *)varp == &curbuf->b_p_ro)
8141 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00008142 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008143 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
8144 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00008145
8146 /* when 'readonly' is set may give W10 again */
8147 if (curbuf->b_p_ro)
8148 curbuf->b_did_warn = FALSE;
8149
Bram Moolenaar071d4272004-06-13 20:20:40 +00008150#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008151 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008152#endif
8153 }
8154
Bram Moolenaar9c449722010-07-20 18:44:27 +02008155#ifdef FEAT_GUI
8156 else if ((int *)varp == &p_mh)
8157 {
8158 if (!p_mh)
8159 gui_mch_mousehide(FALSE);
8160 }
8161#endif
8162
Bram Moolenaara539df02010-08-01 14:35:05 +02008163#ifdef FEAT_TITLE
8164 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008165 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008166 {
8167 redraw_titles();
8168 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008169 /* when 'endofline' is changed, redraw the window title */
8170 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008171 {
8172 redraw_titles();
8173 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02008174 /* when 'fixeol' is changed, redraw the window title */
8175 else if ((int *)varp == &curbuf->b_p_fixeol)
8176 {
8177 redraw_titles();
8178 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008179# ifdef FEAT_MBYTE
8180 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00008181 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008182 {
8183 redraw_titles();
8184 }
8185# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008186#endif
8187
8188 /* when 'bin' is set also set some other options */
8189 else if ((int *)varp == &curbuf->b_p_bin)
8190 {
8191 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
8192#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008193 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008194#endif
8195 }
8196
8197#ifdef FEAT_AUTOCMD
8198 /* when 'buflisted' changes, trigger autocommands */
8199 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
8200 {
8201 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
8202 NULL, NULL, TRUE, curbuf);
8203 }
8204#endif
8205
8206 /* when 'swf' is set, create swapfile, when reset remove swapfile */
8207 else if ((int *)varp == &curbuf->b_p_swf)
8208 {
8209 if (curbuf->b_p_swf && p_uc)
8210 ml_open_file(curbuf); /* create the swap file */
8211 else
Bram Moolenaard55de222007-05-06 13:38:48 +00008212 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
8213 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008214 mf_close_file(curbuf, TRUE); /* remove the swap file */
8215 }
8216
8217 /* when 'terse' is set change 'shortmess' */
8218 else if ((int *)varp == &p_terse)
8219 {
8220 char_u *p;
8221
8222 p = vim_strchr(p_shm, SHM_SEARCH);
8223
8224 /* insert 's' in p_shm */
8225 if (p_terse && p == NULL)
8226 {
8227 STRCPY(IObuff, p_shm);
8228 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008229 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008230 }
8231 /* remove 's' from p_shm */
8232 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00008233 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008234 }
8235
8236 /* when 'paste' is set or reset also change other options */
8237 else if ((int *)varp == &p_paste)
8238 {
8239 paste_option_changed();
8240 }
8241
8242 /* when 'insertmode' is set from an autocommand need to do work here */
8243 else if ((int *)varp == &p_im)
8244 {
8245 if (p_im)
8246 {
8247 if ((State & INSERT) == 0)
8248 need_start_insertmode = TRUE;
8249 stop_insert_mode = FALSE;
8250 }
Bram Moolenaar00672e12016-06-26 18:38:13 +02008251 /* only reset if it was set previously */
8252 else if (old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008253 {
8254 need_start_insertmode = FALSE;
8255 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00008256 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008257 clear_cmdline = TRUE; /* remove "(insert)" */
8258 restart_edit = 0;
8259 }
8260 }
8261
8262 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
8263 else if ((int *)varp == &p_ic && p_hls)
8264 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008265 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008266 }
8267
8268#ifdef FEAT_SEARCH_EXTRA
8269 /* when 'hlsearch' is set or reset: reset no_hlsearch */
8270 else if ((int *)varp == &p_hls)
8271 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01008272 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008273 }
8274#endif
8275
8276#ifdef FEAT_SCROLLBIND
8277 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
8278 * at the end of normal_cmd() */
8279 else if ((int *)varp == &curwin->w_p_scb)
8280 {
8281 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008282 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00008283 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008284 curwin->w_scbind_pos = curwin->w_topline;
8285 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008286 }
8287#endif
8288
8289#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
8290 /* There can be only one window with 'previewwindow' set. */
8291 else if ((int *)varp == &curwin->w_p_pvw)
8292 {
8293 if (curwin->w_p_pvw)
8294 {
8295 win_T *win;
8296
Bram Moolenaar29323592016-07-24 22:04:11 +02008297 FOR_ALL_WINDOWS(win)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008298 if (win->w_p_pvw && win != curwin)
8299 {
8300 curwin->w_p_pvw = FALSE;
8301 return (char_u *)N_("E590: A preview window already exists");
8302 }
8303 }
8304 }
8305#endif
8306
8307 /* when 'textmode' is set or reset also change 'fileformat' */
8308 else if ((int *)varp == &curbuf->b_p_tx)
8309 {
8310 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
8311 }
8312
8313 /* when 'textauto' is set or reset also change 'fileformats' */
8314 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008315 set_string_option_direct((char_u *)"ffs", -1,
8316 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008317 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008318
8319 /*
8320 * When 'lisp' option changes include/exclude '-' in
8321 * keyword characters.
8322 */
8323#ifdef FEAT_LISP
8324 else if (varp == (char_u *)&(curbuf->b_p_lisp))
8325 {
8326 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
8327 }
8328#endif
8329
8330#ifdef FEAT_TITLE
8331 /* when 'title' changed, may need to change the title; same for 'icon' */
8332 else if ((int *)varp == &p_title)
8333 {
8334 did_set_title(FALSE);
8335 }
8336
8337 else if ((int *)varp == &p_icon)
8338 {
8339 did_set_title(TRUE);
8340 }
8341#endif
8342
8343 else if ((int *)varp == &curbuf->b_changed)
8344 {
8345 if (!value)
8346 save_file_ff(curbuf); /* Buffer is unchanged */
8347#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008348 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008349#endif
8350#ifdef FEAT_AUTOCMD
8351 modified_was_set = value;
8352#endif
8353 }
8354
8355#ifdef BACKSLASH_IN_FILENAME
8356 else if ((int *)varp == &p_ssl)
8357 {
8358 if (p_ssl)
8359 {
8360 psepc = '/';
8361 psepcN = '\\';
8362 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008363 }
8364 else
8365 {
8366 psepc = '\\';
8367 psepcN = '/';
8368 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008369 }
8370
8371 /* need to adjust the file name arguments and buffer names. */
8372 buflist_slash_adjust();
8373 alist_slash_adjust();
8374# ifdef FEAT_EVAL
8375 scriptnames_slash_adjust();
8376# endif
8377 }
8378#endif
8379
8380 /* If 'wrap' is set, set w_leftcol to zero. */
8381 else if ((int *)varp == &curwin->w_p_wrap)
8382 {
8383 if (curwin->w_p_wrap)
8384 curwin->w_leftcol = 0;
8385 }
8386
8387#ifdef FEAT_WINDOWS
8388 else if ((int *)varp == &p_ea)
8389 {
8390 if (p_ea && !old_value)
8391 win_equal(curwin, FALSE, 0);
8392 }
8393#endif
8394
8395 else if ((int *)varp == &p_wiv)
8396 {
8397 /*
8398 * When 'weirdinvert' changed, set/reset 't_xs'.
8399 * Then set 'weirdinvert' according to value of 't_xs'.
8400 */
8401 if (p_wiv && !old_value)
8402 T_XS = (char_u *)"y";
8403 else if (!p_wiv && old_value)
8404 T_XS = empty_option;
8405 p_wiv = (*T_XS != NUL);
8406 }
8407
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00008408#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00008409 else if ((int *)varp == &p_beval)
8410 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008411 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008412 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008413 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008414 gui_mch_disable_beval_area(balloonEval);
8415 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008416#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008417
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008418#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008419 else if ((int *)varp == &p_acd)
8420 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008421 /* Change directories when the 'acd' option is set now. */
8422 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008423 }
8424#endif
8425
8426#ifdef FEAT_DIFF
8427 /* 'diff' */
8428 else if ((int *)varp == &curwin->w_p_diff)
8429 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008430 /* May add or remove the buffer from the list of diff buffers. */
8431 diff_buf_adjust(curwin);
8432# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008433 if (foldmethodIsDiff(curwin))
8434 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008435# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008436 }
8437#endif
8438
8439#ifdef USE_IM_CONTROL
8440 /* 'imdisable' */
8441 else if ((int *)varp == &p_imdisable)
8442 {
8443 /* Only de-activate it here, it will be enabled when changing mode. */
8444 if (p_imdisable)
8445 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008446 else if (State & INSERT)
8447 /* When the option is set from an autocommand, it may need to take
8448 * effect right away. */
8449 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008450 }
8451#endif
8452
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008453#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008454 /* 'spell' */
8455 else if ((int *)varp == &curwin->w_p_spell)
8456 {
8457 if (curwin->w_p_spell)
8458 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008459 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008460 if (errmsg != NULL)
8461 EMSG(_(errmsg));
8462 }
8463 }
8464#endif
8465
Bram Moolenaar071d4272004-06-13 20:20:40 +00008466#ifdef FEAT_FKMAP
8467 else if ((int *)varp == &p_altkeymap)
8468 {
8469 if (old_value != p_altkeymap)
8470 {
8471 if (!p_altkeymap)
8472 {
8473 p_hkmap = p_fkmap;
8474 p_fkmap = 0;
8475 }
8476 else
8477 {
8478 p_fkmap = p_hkmap;
8479 p_hkmap = 0;
8480 }
8481 (void)init_chartab();
8482 }
8483 }
8484
8485 /*
8486 * In case some second language keymapping options have changed, check
8487 * and correct the setting in a consistent way.
8488 */
8489
8490 /*
8491 * If hkmap or fkmap are set, reset Arabic keymapping.
8492 */
8493 if ((p_hkmap || p_fkmap) && p_altkeymap)
8494 {
8495 p_altkeymap = p_fkmap;
8496# ifdef FEAT_ARABIC
8497 curwin->w_p_arab = FALSE;
8498# endif
8499 (void)init_chartab();
8500 }
8501
8502 /*
8503 * If hkmap set, reset Farsi keymapping.
8504 */
8505 if (p_hkmap && p_altkeymap)
8506 {
8507 p_altkeymap = 0;
8508 p_fkmap = 0;
8509# ifdef FEAT_ARABIC
8510 curwin->w_p_arab = FALSE;
8511# endif
8512 (void)init_chartab();
8513 }
8514
8515 /*
8516 * If fkmap set, reset Hebrew keymapping.
8517 */
8518 if (p_fkmap && !p_altkeymap)
8519 {
8520 p_altkeymap = 1;
8521 p_hkmap = 0;
8522# ifdef FEAT_ARABIC
8523 curwin->w_p_arab = FALSE;
8524# endif
8525 (void)init_chartab();
8526 }
8527#endif
8528
8529#ifdef FEAT_ARABIC
8530 if ((int *)varp == &curwin->w_p_arab)
8531 {
8532 if (curwin->w_p_arab)
8533 {
8534 /*
8535 * 'arabic' is set, handle various sub-settings.
8536 */
8537 if (!p_tbidi)
8538 {
8539 /* set rightleft mode */
8540 if (!curwin->w_p_rl)
8541 {
8542 curwin->w_p_rl = TRUE;
8543 changed_window_setting();
8544 }
8545
8546 /* Enable Arabic shaping (major part of what Arabic requires) */
8547 if (!p_arshape)
8548 {
8549 p_arshape = TRUE;
8550 redraw_later_clear();
8551 }
8552 }
8553
8554 /* Arabic requires a utf-8 encoding, inform the user if its not
8555 * set. */
8556 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008557 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008558 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8559
Bram Moolenaar8820b482017-03-16 17:23:31 +01008560 msg_source(HL_ATTR(HLF_W));
8561 MSG_ATTR(_(w_arabic), HL_ATTR(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008562#ifdef FEAT_EVAL
8563 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8564#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008565 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008566
8567# ifdef FEAT_MBYTE
8568 /* set 'delcombine' */
8569 p_deco = TRUE;
8570# endif
8571
8572# ifdef FEAT_KEYMAP
8573 /* Force-set the necessary keymap for arabic */
8574 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8575 OPT_LOCAL);
8576# endif
8577# ifdef FEAT_FKMAP
8578 p_altkeymap = 0;
8579 p_hkmap = 0;
8580 p_fkmap = 0;
8581 (void)init_chartab();
8582# endif
8583 }
8584 else
8585 {
8586 /*
8587 * 'arabic' is reset, handle various sub-settings.
8588 */
8589 if (!p_tbidi)
8590 {
8591 /* reset rightleft mode */
8592 if (curwin->w_p_rl)
8593 {
8594 curwin->w_p_rl = FALSE;
8595 changed_window_setting();
8596 }
8597
8598 /* 'arabicshape' isn't reset, it is a global option and
8599 * another window may still need it "on". */
8600 }
8601
8602 /* 'delcombine' isn't reset, it is a global option and another
8603 * window may still want it "on". */
8604
8605# ifdef FEAT_KEYMAP
8606 /* Revert to the default keymap */
8607 curbuf->b_p_iminsert = B_IMODE_NONE;
8608 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8609# endif
8610 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008611 }
8612
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008613#endif
8614
Bram Moolenaar61be73b2016-04-29 22:59:22 +02008615#ifdef FEAT_TERMGUICOLORS
8616 /* 'termguicolors' */
8617 else if ((int *)varp == &p_tgc)
Bram Moolenaar8a633e32016-04-21 21:10:14 +02008618 {
8619# ifdef FEAT_GUI
8620 if (!gui.in_use && !gui.starting)
8621# endif
8622 highlight_gui_started();
8623 }
8624#endif
8625
Bram Moolenaar071d4272004-06-13 20:20:40 +00008626 /*
8627 * End of handling side effects for bool options.
8628 */
8629
Bram Moolenaar53744302015-07-17 17:38:22 +02008630 /* after handling side effects, call autocommand */
8631
Bram Moolenaar071d4272004-06-13 20:20:40 +00008632 options[opt_idx].flags |= P_WAS_SET;
8633
Bram Moolenaar53744302015-07-17 17:38:22 +02008634#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8635 if (!starting)
8636 {
8637 char_u buf_old[2], buf_new[2], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008638 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8639 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8640 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008641 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8642 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8643 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8644 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8645 reset_v_option_vars();
8646 }
8647#endif
8648
Bram Moolenaar071d4272004-06-13 20:20:40 +00008649 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008650 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008651 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008652 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008653 check_redraw(options[opt_idx].flags);
8654
8655 return NULL;
8656}
8657
8658/*
8659 * Set the value of a number option, and take care of side effects.
8660 * Returns NULL for success, or an error message for an error.
8661 */
8662 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01008663set_num_option(
8664 int opt_idx, /* index in options[] table */
8665 char_u *varp, /* pointer to the option variable */
8666 long value, /* new value */
8667 char_u *errbuf, /* buffer for error messages */
8668 size_t errbuflen, /* length of "errbuf" */
8669 int opt_flags) /* OPT_LOCAL, OPT_GLOBAL and
Bram Moolenaar071d4272004-06-13 20:20:40 +00008670 OPT_MODELINE */
8671{
8672 char_u *errmsg = NULL;
8673 long old_value = *(long *)varp;
8674 long old_Rows = Rows; /* remember old Rows */
8675 long old_Columns = Columns; /* remember old Columns */
8676 long *pp = (long *)varp;
8677
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008678 /* Disallow changing some options from secure mode. */
8679 if ((secure
8680#ifdef HAVE_SANDBOX
8681 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008682#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008683 ) && (options[opt_idx].flags & P_SECURE))
8684 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008685
8686 *pp = value;
8687#ifdef FEAT_EVAL
8688 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008689 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008690#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008691#ifdef FEAT_GUI
8692 need_mouse_correct = TRUE;
8693#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008694
Bram Moolenaar14f24742012-08-08 18:01:05 +02008695 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008696 {
8697 errmsg = e_positive;
8698 curbuf->b_p_sw = curbuf->b_p_ts;
8699 }
8700
8701 /*
8702 * Number options that need some action when changed
8703 */
8704#ifdef FEAT_WINDOWS
8705 if (pp == &p_wh || pp == &p_hh)
8706 {
8707 if (p_wh < 1)
8708 {
8709 errmsg = e_positive;
8710 p_wh = 1;
8711 }
8712 if (p_wmh > p_wh)
8713 {
8714 errmsg = e_winheight;
8715 p_wh = p_wmh;
8716 }
8717 if (p_hh < 0)
8718 {
8719 errmsg = e_positive;
8720 p_hh = 0;
8721 }
8722
8723 /* Change window height NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008724 if (!ONE_WINDOW)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008725 {
8726 if (pp == &p_wh && curwin->w_height < p_wh)
8727 win_setheight((int)p_wh);
8728 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8729 win_setheight((int)p_hh);
8730 }
8731 }
8732
8733 /* 'winminheight' */
8734 else if (pp == &p_wmh)
8735 {
8736 if (p_wmh < 0)
8737 {
8738 errmsg = e_positive;
8739 p_wmh = 0;
8740 }
8741 if (p_wmh > p_wh)
8742 {
8743 errmsg = e_winheight;
8744 p_wmh = p_wh;
8745 }
8746 win_setminheight();
8747 }
8748
Bram Moolenaar44a2f922016-03-19 22:11:51 +01008749# ifdef FEAT_WINDOWS
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008750 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008751 {
8752 if (p_wiw < 1)
8753 {
8754 errmsg = e_positive;
8755 p_wiw = 1;
8756 }
8757 if (p_wmw > p_wiw)
8758 {
8759 errmsg = e_winwidth;
8760 p_wiw = p_wmw;
8761 }
8762
8763 /* Change window width NOW */
Bram Moolenaar459ca562016-11-10 18:16:33 +01008764 if (!ONE_WINDOW && curwin->w_width < p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008765 win_setwidth((int)p_wiw);
8766 }
8767
8768 /* 'winminwidth' */
8769 else if (pp == &p_wmw)
8770 {
8771 if (p_wmw < 0)
8772 {
8773 errmsg = e_positive;
8774 p_wmw = 0;
8775 }
8776 if (p_wmw > p_wiw)
8777 {
8778 errmsg = e_winwidth;
8779 p_wmw = p_wiw;
8780 }
8781 win_setminheight();
8782 }
8783# endif
8784
8785#endif
8786
8787#ifdef FEAT_WINDOWS
8788 /* (re)set last window status line */
8789 else if (pp == &p_ls)
8790 {
8791 last_status(FALSE);
8792 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008793
8794 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008795 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008796 {
8797 shell_new_rows(); /* recompute window positions and heights */
8798 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008799#endif
8800
8801#ifdef FEAT_GUI
8802 else if (pp == &p_linespace)
8803 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008804 /* Recompute gui.char_height and resize the Vim window to keep the
8805 * same number of lines. */
8806 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008807 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008808 }
8809#endif
8810
8811#ifdef FEAT_FOLDING
8812 /* 'foldlevel' */
8813 else if (pp == &curwin->w_p_fdl)
8814 {
8815 if (curwin->w_p_fdl < 0)
8816 curwin->w_p_fdl = 0;
8817 newFoldLevel();
8818 }
8819
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008820 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008821 else if (pp == &curwin->w_p_fml)
8822 {
8823 foldUpdateAll(curwin);
8824 }
8825
8826 /* 'foldnestmax' */
8827 else if (pp == &curwin->w_p_fdn)
8828 {
8829 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8830 foldUpdateAll(curwin);
8831 }
8832
8833 /* 'foldcolumn' */
8834 else if (pp == &curwin->w_p_fdc)
8835 {
8836 if (curwin->w_p_fdc < 0)
8837 {
8838 errmsg = e_positive;
8839 curwin->w_p_fdc = 0;
8840 }
8841 else if (curwin->w_p_fdc > 12)
8842 {
8843 errmsg = e_invarg;
8844 curwin->w_p_fdc = 12;
8845 }
8846 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008847#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008848
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008849#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008850 /* 'shiftwidth' or 'tabstop' */
8851 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8852 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008853# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008854 if (foldmethodIsIndent(curwin))
8855 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008856# endif
8857# ifdef FEAT_CINDENT
8858 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8859 * parse 'cinoptions'. */
8860 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8861 parse_cino(curbuf);
8862# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008863 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008864#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008865
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008866#ifdef FEAT_MBYTE
8867 /* 'maxcombine' */
8868 else if (pp == &p_mco)
8869 {
8870 if (p_mco > MAX_MCO)
8871 p_mco = MAX_MCO;
8872 else if (p_mco < 0)
8873 p_mco = 0;
8874 screenclear(); /* will re-allocate the screen */
8875 }
8876#endif
8877
Bram Moolenaar071d4272004-06-13 20:20:40 +00008878 else if (pp == &curbuf->b_p_iminsert)
8879 {
8880 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8881 {
8882 errmsg = e_invarg;
8883 curbuf->b_p_iminsert = B_IMODE_NONE;
8884 }
8885 p_iminsert = curbuf->b_p_iminsert;
8886 if (termcap_active) /* don't do this in the alternate screen */
8887 showmode();
8888#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8889 /* Show/unshow value of 'keymap' in status lines. */
8890 status_redraw_curbuf();
8891#endif
8892 }
8893
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008894 else if (pp == &p_window)
8895 {
8896 if (p_window < 1)
8897 p_window = 1;
8898 else if (p_window >= Rows)
8899 p_window = Rows - 1;
8900 }
8901
Bram Moolenaar071d4272004-06-13 20:20:40 +00008902 else if (pp == &curbuf->b_p_imsearch)
8903 {
8904 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8905 {
8906 errmsg = e_invarg;
8907 curbuf->b_p_imsearch = B_IMODE_NONE;
8908 }
8909 p_imsearch = curbuf->b_p_imsearch;
8910 }
8911
8912#ifdef FEAT_TITLE
8913 /* if 'titlelen' has changed, redraw the title */
8914 else if (pp == &p_titlelen)
8915 {
8916 if (p_titlelen < 0)
8917 {
8918 errmsg = e_positive;
8919 p_titlelen = 85;
8920 }
8921 if (starting != NO_SCREEN && old_value != p_titlelen)
8922 need_maketitle = TRUE;
8923 }
8924#endif
8925
8926 /* if p_ch changed value, change the command line height */
8927 else if (pp == &p_ch)
8928 {
8929 if (p_ch < 1)
8930 {
8931 errmsg = e_positive;
8932 p_ch = 1;
8933 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008934 if (p_ch > Rows - min_rows() + 1)
8935 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008936
8937 /* Only compute the new window layout when startup has been
8938 * completed. Otherwise the frame sizes may be wrong. */
8939 if (p_ch != old_value && full_screen
8940#ifdef FEAT_GUI
8941 && !gui.starting
8942#endif
8943 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008944 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008945 }
8946
8947 /* when 'updatecount' changes from zero to non-zero, open swap files */
8948 else if (pp == &p_uc)
8949 {
8950 if (p_uc < 0)
8951 {
8952 errmsg = e_positive;
8953 p_uc = 100;
8954 }
8955 if (p_uc && !old_value)
8956 ml_open_files();
8957 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008958#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008959 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008960 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008961 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008962 {
8963 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008964 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008965 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008966 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008967 {
8968 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008969 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008970 }
8971 }
8972#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008973#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008974 else if (pp == &p_mzq)
8975 mzvim_reset_timer();
8976#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008977
Bram Moolenaarf42dd3c2017-01-28 16:06:38 +01008978#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
8979 /* 'pyxversion' */
8980 else if (pp == &p_pyx)
8981 {
8982 if (p_pyx != 0 && p_pyx != 2 && p_pyx != 3)
8983 errmsg = e_invarg;
8984 }
8985#endif
8986
Bram Moolenaar071d4272004-06-13 20:20:40 +00008987 /* sync undo before 'undolevels' changes */
8988 else if (pp == &p_ul)
8989 {
8990 /* use the old value, otherwise u_sync() may not work properly */
8991 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00008992 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008993 p_ul = value;
8994 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01008995 else if (pp == &curbuf->b_p_ul)
8996 {
8997 /* use the old value, otherwise u_sync() may not work properly */
8998 curbuf->b_p_ul = old_value;
8999 u_sync(TRUE);
9000 curbuf->b_p_ul = value;
9001 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009002
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009003#ifdef FEAT_LINEBREAK
9004 /* 'numberwidth' must be positive */
9005 else if (pp == &curwin->w_p_nuw)
9006 {
9007 if (curwin->w_p_nuw < 1)
9008 {
9009 errmsg = e_positive;
9010 curwin->w_p_nuw = 1;
9011 }
9012 if (curwin->w_p_nuw > 10)
9013 {
9014 errmsg = e_invarg;
9015 curwin->w_p_nuw = 10;
9016 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02009017 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009018 }
9019#endif
9020
Bram Moolenaar1a384422010-07-14 19:53:30 +02009021 else if (pp == &curbuf->b_p_tw)
9022 {
9023 if (curbuf->b_p_tw < 0)
9024 {
9025 errmsg = e_positive;
9026 curbuf->b_p_tw = 0;
9027 }
9028#ifdef FEAT_SYN_HL
9029# ifdef FEAT_WINDOWS
9030 {
9031 win_T *wp;
9032 tabpage_T *tp;
9033
9034 FOR_ALL_TAB_WINDOWS(tp, wp)
9035 check_colorcolumn(wp);
9036 }
9037# else
9038 check_colorcolumn(curwin);
9039# endif
9040#endif
9041 }
9042
Bram Moolenaar071d4272004-06-13 20:20:40 +00009043 /*
9044 * Check the bounds for numeric options here
9045 */
9046 if (Rows < min_rows() && full_screen)
9047 {
9048 if (errbuf != NULL)
9049 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00009050 vim_snprintf((char *)errbuf, errbuflen,
9051 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00009052 errmsg = errbuf;
9053 }
9054 Rows = min_rows();
9055 }
9056 if (Columns < MIN_COLUMNS && full_screen)
9057 {
9058 if (errbuf != NULL)
9059 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00009060 vim_snprintf((char *)errbuf, errbuflen,
9061 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009062 errmsg = errbuf;
9063 }
9064 Columns = MIN_COLUMNS;
9065 }
Bram Moolenaare057d402013-06-30 17:51:51 +02009066 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00009067
Bram Moolenaar071d4272004-06-13 20:20:40 +00009068 /*
9069 * If the screen (shell) height has been changed, assume it is the
9070 * physical screenheight.
9071 */
9072 if (old_Rows != Rows || old_Columns != Columns)
9073 {
9074 /* Changing the screen size is not allowed while updating the screen. */
9075 if (updating_screen)
9076 *pp = old_value;
9077 else if (full_screen
9078#ifdef FEAT_GUI
9079 && !gui.starting
9080#endif
9081 )
9082 set_shellsize((int)Columns, (int)Rows, TRUE);
9083 else
9084 {
9085 /* Postpone the resizing; check the size and cmdline position for
9086 * messages. */
9087 check_shellsize();
9088 if (cmdline_row > Rows - p_ch && Rows > p_ch)
9089 cmdline_row = Rows - p_ch;
9090 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00009091 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00009092 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009093 }
9094
Bram Moolenaar071d4272004-06-13 20:20:40 +00009095 if (curbuf->b_p_ts <= 0)
9096 {
9097 errmsg = e_positive;
9098 curbuf->b_p_ts = 8;
9099 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009100 if (p_tm < 0)
9101 {
9102 errmsg = e_positive;
9103 p_tm = 0;
9104 }
9105 if ((curwin->w_p_scr <= 0
9106 || (curwin->w_p_scr > curwin->w_height
9107 && curwin->w_height > 0))
9108 && full_screen)
9109 {
9110 if (pp == &(curwin->w_p_scr))
9111 {
9112 if (curwin->w_p_scr != 0)
9113 errmsg = e_scroll;
9114 win_comp_scroll(curwin);
9115 }
9116 /* If 'scroll' became invalid because of a side effect silently adjust
9117 * it. */
9118 else if (curwin->w_p_scr <= 0)
9119 curwin->w_p_scr = 1;
9120 else /* curwin->w_p_scr > curwin->w_height */
9121 curwin->w_p_scr = curwin->w_height;
9122 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00009123 if (p_hi < 0)
9124 {
9125 errmsg = e_positive;
9126 p_hi = 0;
9127 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02009128 else if (p_hi > 10000)
9129 {
9130 errmsg = e_invarg;
9131 p_hi = 10000;
9132 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02009133 if (p_re < 0 || p_re > 2)
9134 {
9135 errmsg = e_invarg;
9136 p_re = 0;
9137 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009138 if (p_report < 0)
9139 {
9140 errmsg = e_positive;
9141 p_report = 1;
9142 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00009143 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009144 {
9145 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
9146 p_sj = Rows / 2;
9147 else
9148 {
9149 errmsg = e_scroll;
9150 p_sj = 1;
9151 }
9152 }
9153 if (p_so < 0 && full_screen)
9154 {
9155 errmsg = e_scroll;
9156 p_so = 0;
9157 }
9158 if (p_siso < 0 && full_screen)
9159 {
9160 errmsg = e_positive;
9161 p_siso = 0;
9162 }
9163#ifdef FEAT_CMDWIN
9164 if (p_cwh < 1)
9165 {
9166 errmsg = e_positive;
9167 p_cwh = 1;
9168 }
9169#endif
9170 if (p_ut < 0)
9171 {
9172 errmsg = e_positive;
9173 p_ut = 2000;
9174 }
9175 if (p_ss < 0)
9176 {
9177 errmsg = e_positive;
9178 p_ss = 0;
9179 }
9180
9181 /* May set global value for local option. */
9182 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
9183 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
9184
9185 options[opt_idx].flags |= P_WAS_SET;
9186
Bram Moolenaar53744302015-07-17 17:38:22 +02009187#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
9188 if (!starting && errmsg == NULL)
9189 {
9190 char_u buf_old[11], buf_new[11], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02009191 vim_snprintf((char *)buf_old, 10, "%ld", old_value);
9192 vim_snprintf((char *)buf_new, 10, "%ld", value);
9193 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02009194 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
9195 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
9196 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
9197 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
9198 reset_v_option_vars();
9199 }
9200#endif
9201
Bram Moolenaar071d4272004-06-13 20:20:40 +00009202 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02009203 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01009204 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02009205 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009206 check_redraw(options[opt_idx].flags);
9207
9208 return errmsg;
9209}
9210
9211/*
9212 * Called after an option changed: check if something needs to be redrawn.
9213 */
9214 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009215check_redraw(long_u flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009216{
9217 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009218 int doclear = (flags & P_RCLR) == P_RCLR;
9219 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009220
9221#ifdef FEAT_WINDOWS
9222 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
9223 status_redraw_all();
9224#endif
9225
9226 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
9227 changed_window_setting();
9228 if (flags & P_RBUF)
9229 redraw_curbuf_later(NOT_VALID);
Bram Moolenaara2477fd2016-12-03 15:13:20 +01009230 if (flags & P_RWINONLY)
9231 redraw_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01009232 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009233 redraw_all_later(CLEAR);
9234 else if (all)
9235 redraw_all_later(NOT_VALID);
9236}
9237
9238/*
9239 * Find index for option 'arg'.
9240 * Return -1 if not found.
9241 */
9242 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009243findoption(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009244{
9245 int opt_idx;
9246 char *s, *p;
9247 static short quick_tab[27] = {0, 0}; /* quick access table */
9248 int is_term_opt;
9249
9250 /*
9251 * For first call: Initialize the quick-access table.
9252 * It contains the index for the first option that starts with a certain
9253 * letter. There are 26 letters, plus the first "t_" option.
9254 */
9255 if (quick_tab[1] == 0)
9256 {
9257 p = options[0].fullname;
9258 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9259 {
9260 if (s[0] != p[0])
9261 {
9262 if (s[0] == 't' && s[1] == '_')
9263 quick_tab[26] = opt_idx;
9264 else
9265 quick_tab[CharOrdLow(s[0])] = opt_idx;
9266 }
9267 p = s;
9268 }
9269 }
9270
9271 /*
9272 * Check for name starting with an illegal character.
9273 */
9274#ifdef EBCDIC
9275 if (!islower(arg[0]))
9276#else
9277 if (arg[0] < 'a' || arg[0] > 'z')
9278#endif
9279 return -1;
9280
9281 is_term_opt = (arg[0] == 't' && arg[1] == '_');
9282 if (is_term_opt)
9283 opt_idx = quick_tab[26];
9284 else
9285 opt_idx = quick_tab[CharOrdLow(arg[0])];
9286 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
9287 {
9288 if (STRCMP(arg, s) == 0) /* match full name */
9289 break;
9290 }
9291 if (s == NULL && !is_term_opt)
9292 {
9293 opt_idx = quick_tab[CharOrdLow(arg[0])];
9294 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
9295 {
9296 s = options[opt_idx].shortname;
9297 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
9298 break;
9299 s = NULL;
9300 }
9301 }
9302 if (s == NULL)
9303 opt_idx = -1;
9304 return opt_idx;
9305}
9306
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009307#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009308/*
9309 * Get the value for an option.
9310 *
9311 * Returns:
9312 * Number or Toggle option: 1, *numval gets value.
9313 * String option: 0, *stringval gets allocated string.
9314 * Hidden Number or Toggle option: -1.
9315 * hidden String option: -2.
9316 * unknown option: -3.
9317 */
9318 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009319get_option_value(
9320 char_u *name,
9321 long *numval,
9322 char_u **stringval, /* NULL when only checking existence */
9323 int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009324{
9325 int opt_idx;
9326 char_u *varp;
9327
9328 opt_idx = findoption(name);
9329 if (opt_idx < 0) /* unknown option */
Bram Moolenaare353c402017-02-04 19:49:16 +01009330 {
9331 int key;
9332
9333 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
9334 && (key = find_key_option(name)) != 0)
9335 {
9336 char_u key_name[2];
9337 char_u *p;
9338
9339 if (key < 0)
9340 {
9341 key_name[0] = KEY2TERMCAP0(key);
9342 key_name[1] = KEY2TERMCAP1(key);
9343 }
9344 else
9345 {
9346 key_name[0] = KS_KEY;
9347 key_name[1] = (key & 0xff);
9348 }
9349 p = find_termcode(key_name);
9350 if (p != NULL)
9351 {
9352 if (stringval != NULL)
9353 *stringval = vim_strsave(p);
9354 return 0;
9355 }
9356 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009357 return -3;
Bram Moolenaare353c402017-02-04 19:49:16 +01009358 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009359
9360 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
9361
9362 if (options[opt_idx].flags & P_STRING)
9363 {
9364 if (varp == NULL) /* hidden option */
9365 return -2;
9366 if (stringval != NULL)
9367 {
9368#ifdef FEAT_CRYPT
9369 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00009370 if ((char_u **)varp == &curbuf->b_p_key
9371 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009372 *stringval = vim_strsave((char_u *)"*****");
9373 else
9374#endif
9375 *stringval = vim_strsave(*(char_u **)(varp));
9376 }
9377 return 0;
9378 }
9379
9380 if (varp == NULL) /* hidden option */
9381 return -1;
9382 if (options[opt_idx].flags & P_NUM)
9383 *numval = *(long *)varp;
9384 else
9385 {
9386 /* Special case: 'modified' is b_changed, but we also want to consider
9387 * it set when 'ff' or 'fenc' changed. */
9388 if ((int *)varp == &curbuf->b_changed)
9389 *numval = curbufIsChanged();
9390 else
Bram Moolenaar2acfbed2016-07-01 23:14:02 +02009391 *numval = (long) *(int *)varp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009392 }
9393 return 1;
9394}
9395#endif
9396
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009397#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009398/*
9399 * Returns the option attributes and its value. Unlike the above function it
9400 * will return either global value or local value of the option depending on
9401 * what was requested, but it will never return global value if it was
9402 * requested to return local one and vice versa. Neither it will return
9403 * buffer-local value if it was requested to return window-local one.
9404 *
9405 * Pretends that option is absent if it is not present in the requested scope
9406 * (i.e. has no global, window-local or buffer-local value depending on
9407 * opt_type). Uses
9408 *
9409 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009410 * 0 hidden or unknown option, also option that does not have requested
9411 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009412 * see SOPT_* in vim.h for other flags
9413 *
9414 * Possible opt_type values: see SREQ_* in vim.h
9415 */
9416 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009417get_option_value_strict(
9418 char_u *name,
9419 long *numval,
9420 char_u **stringval, /* NULL when only obtaining attributes */
9421 int opt_type,
9422 void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009423{
9424 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009425 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009426 struct vimoption *p;
9427 int r = 0;
9428
9429 opt_idx = findoption(name);
9430 if (opt_idx < 0)
9431 return 0;
9432
9433 p = &(options[opt_idx]);
9434
9435 /* Hidden option */
9436 if (p->var == NULL)
9437 return 0;
9438
9439 if (p->flags & P_BOOL)
9440 r |= SOPT_BOOL;
9441 else if (p->flags & P_NUM)
9442 r |= SOPT_NUM;
9443 else if (p->flags & P_STRING)
9444 r |= SOPT_STRING;
9445
9446 if (p->indir == PV_NONE)
9447 {
9448 if (opt_type == SREQ_GLOBAL)
9449 r |= SOPT_GLOBAL;
9450 else
9451 return 0; /* Did not request global-only option */
9452 }
9453 else
9454 {
9455 if (p->indir & PV_BOTH)
9456 r |= SOPT_GLOBAL;
9457 else if (opt_type == SREQ_GLOBAL)
9458 return 0; /* Requested global option */
9459
9460 if (p->indir & PV_WIN)
9461 {
9462 if (opt_type == SREQ_BUF)
9463 return 0; /* Did not request window-local option */
9464 else
9465 r |= SOPT_WIN;
9466 }
9467 else if (p->indir & PV_BUF)
9468 {
9469 if (opt_type == SREQ_WIN)
9470 return 0; /* Did not request buffer-local option */
9471 else
9472 r |= SOPT_BUF;
9473 }
9474 }
9475
9476 if (stringval == NULL)
9477 return r;
9478
9479 if (opt_type == SREQ_GLOBAL)
9480 varp = p->var;
9481 else
9482 {
9483 if (opt_type == SREQ_BUF)
9484 {
9485 /* Special case: 'modified' is b_changed, but we also want to
9486 * consider it set when 'ff' or 'fenc' changed. */
9487 if (p->indir == PV_MOD)
9488 {
9489 *numval = bufIsChanged((buf_T *) from);
9490 varp = NULL;
9491 }
9492#ifdef FEAT_CRYPT
9493 else if (p->indir == PV_KEY)
9494 {
9495 /* never return the value of the crypt key */
9496 *stringval = NULL;
9497 varp = NULL;
9498 }
9499#endif
9500 else
9501 {
9502 aco_save_T aco;
9503 aucmd_prepbuf(&aco, (buf_T *) from);
9504 varp = get_varp(p);
9505 aucmd_restbuf(&aco);
9506 }
9507 }
9508 else if (opt_type == SREQ_WIN)
9509 {
9510 win_T *save_curwin;
9511 save_curwin = curwin;
9512 curwin = (win_T *) from;
9513 curbuf = curwin->w_buffer;
9514 varp = get_varp(p);
9515 curwin = save_curwin;
9516 curbuf = curwin->w_buffer;
9517 }
9518 if (varp == p->var)
9519 return (r | SOPT_UNSET);
9520 }
9521
9522 if (varp != NULL)
9523 {
9524 if (p->flags & P_STRING)
9525 *stringval = vim_strsave(*(char_u **)(varp));
9526 else if (p->flags & P_NUM)
9527 *numval = *(long *) varp;
9528 else
9529 *numval = *(int *)varp;
9530 }
9531
9532 return r;
9533}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009534
9535/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009536 * Iterate over options. First argument is a pointer to a pointer to a
9537 * structure inside options[] array, second is option type like in the above
9538 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009539 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009540 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009541 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009542 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009543 * first argument to NULL.
9544 *
9545 * Returns full option name for current option on each call.
9546 */
9547 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009548option_iter_next(void **option, int opt_type)
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009549{
9550 struct vimoption *ret = NULL;
9551 do
9552 {
9553 if (*option == NULL)
9554 *option = (void *) options;
9555 else if (((struct vimoption *) (*option))->fullname == NULL)
9556 {
9557 *option = NULL;
9558 return NULL;
9559 }
9560 else
9561 *option = (void *) (((struct vimoption *) (*option)) + 1);
9562
9563 ret = ((struct vimoption *) (*option));
9564
9565 /* Hidden option */
9566 if (ret->var == NULL)
9567 {
9568 ret = NULL;
9569 continue;
9570 }
9571
9572 switch (opt_type)
9573 {
9574 case SREQ_GLOBAL:
9575 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9576 ret = NULL;
9577 break;
9578 case SREQ_BUF:
9579 if (!(ret->indir & PV_BUF))
9580 ret = NULL;
9581 break;
9582 case SREQ_WIN:
9583 if (!(ret->indir & PV_WIN))
9584 ret = NULL;
9585 break;
9586 default:
Bram Moolenaar95f09602016-11-10 20:01:45 +01009587 internal_error("option_iter_next()");
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009588 return NULL;
9589 }
9590 }
9591 while (ret == NULL);
9592
9593 return (char_u *)ret->fullname;
9594}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009595#endif
9596
Bram Moolenaar071d4272004-06-13 20:20:40 +00009597/*
9598 * Set the value of option "name".
9599 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009600 *
9601 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009602 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009603 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009604set_option_value(
9605 char_u *name,
9606 long number,
9607 char_u *string,
9608 int opt_flags) /* OPT_LOCAL or 0 (both) */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009609{
9610 int opt_idx;
9611 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009612 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009613
9614 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009615 if (opt_idx < 0)
Bram Moolenaare353c402017-02-04 19:49:16 +01009616 {
9617 int key;
9618
9619 if (STRLEN(name) == 4 && name[0] == 't' && name[1] == '_'
9620 && (key = find_key_option(name)) != 0)
9621 {
9622 char_u key_name[2];
9623
9624 if (key < 0)
9625 {
9626 key_name[0] = KEY2TERMCAP0(key);
9627 key_name[1] = KEY2TERMCAP1(key);
9628 }
9629 else
9630 {
9631 key_name[0] = KS_KEY;
9632 key_name[1] = (key & 0xff);
9633 }
9634 add_termcode(key_name, string, FALSE);
9635 if (full_screen)
9636 ttest(FALSE);
9637 redraw_all_later(CLEAR);
9638 return NULL;
9639 }
9640
Bram Moolenaar071d4272004-06-13 20:20:40 +00009641 EMSG2(_("E355: Unknown option: %s"), name);
Bram Moolenaare353c402017-02-04 19:49:16 +01009642 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009643 else
9644 {
9645 flags = options[opt_idx].flags;
9646#ifdef HAVE_SANDBOX
9647 /* Disallow changing some options in the sandbox */
9648 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009649 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009650 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009651 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009652 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009653#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009654 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009655 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009656 else
9657 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009658 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009659 if (varp != NULL) /* hidden option is not changed */
9660 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009661 if (number == 0 && string != NULL)
9662 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009663 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009664
9665 /* Either we are given a string or we are setting option
9666 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009667 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009668 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009669 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009670 {
9671 /* There's another character after zeros or the string
9672 * is empty. In both cases, we are trying to set a
9673 * num option using a string. */
9674 EMSG3(_("E521: Number required: &%s = '%s'"),
9675 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009676 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009677
9678 }
9679 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009680 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009681 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009682 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009683 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009684 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009685 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009686 }
9687 }
9688 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009689 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009690}
9691
9692/*
9693 * Get the terminal code for a terminal option.
9694 * Returns NULL when not found.
9695 */
9696 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009697get_term_code(char_u *tname)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009698{
9699 int opt_idx;
9700 char_u *varp;
9701
9702 if (tname[0] != 't' || tname[1] != '_' ||
9703 tname[2] == NUL || tname[3] == NUL)
9704 return NULL;
9705 if ((opt_idx = findoption(tname)) >= 0)
9706 {
9707 varp = get_varp(&(options[opt_idx]));
9708 if (varp != NULL)
9709 varp = *(char_u **)(varp);
9710 return varp;
9711 }
9712 return find_termcode(tname + 2);
9713}
9714
9715 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009716get_highlight_default(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009717{
9718 int i;
9719
9720 i = findoption((char_u *)"hl");
9721 if (i >= 0)
9722 return options[i].def_val[VI_DEFAULT];
9723 return (char_u *)NULL;
9724}
9725
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009726#if defined(FEAT_MBYTE) || defined(PROTO)
9727 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +01009728get_encoding_default(void)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009729{
9730 int i;
9731
9732 i = findoption((char_u *)"enc");
9733 if (i >= 0)
9734 return options[i].def_val[VI_DEFAULT];
9735 return (char_u *)NULL;
9736}
9737#endif
9738
Bram Moolenaar071d4272004-06-13 20:20:40 +00009739/*
9740 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9741 */
9742 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009743find_key_option(char_u *arg)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009744{
9745 int key;
9746 int modifiers;
9747
9748 /*
9749 * Don't use get_special_key_code() for t_xx, we don't want it to call
9750 * add_termcap_entry().
9751 */
9752 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9753 key = TERMCAP2KEY(arg[2], arg[3]);
9754 else
9755 {
9756 --arg; /* put arg at the '<' */
9757 modifiers = 0;
Bram Moolenaar35a4cfa2016-08-14 16:07:48 +02009758 key = find_special_key(&arg, &modifiers, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009759 if (modifiers) /* can't handle modifiers here */
9760 key = 0;
9761 }
9762 return key;
9763}
9764
9765/*
9766 * if 'all' == 0: show changed options
9767 * if 'all' == 1: show all normal options
9768 * if 'all' == 2: show all terminal options
9769 */
9770 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009771showoptions(
9772 int all,
9773 int opt_flags) /* OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009774{
9775 struct vimoption *p;
9776 int col;
9777 int isterm;
9778 char_u *varp;
9779 struct vimoption **items;
9780 int item_count;
9781 int run;
9782 int row, rows;
9783 int cols;
9784 int i;
9785 int len;
9786
9787#define INC 20
9788#define GAP 3
9789
9790 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9791 PARAM_COUNT));
9792 if (items == NULL)
9793 return;
9794
9795 /* Highlight title */
9796 if (all == 2)
9797 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9798 else if (opt_flags & OPT_GLOBAL)
9799 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9800 else if (opt_flags & OPT_LOCAL)
9801 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9802 else
9803 MSG_PUTS_TITLE(_("\n--- Options ---"));
9804
9805 /*
9806 * do the loop two times:
9807 * 1. display the short items
9808 * 2. display the long items (only strings and numbers)
9809 */
9810 for (run = 1; run <= 2 && !got_int; ++run)
9811 {
9812 /*
9813 * collect the items in items[]
9814 */
9815 item_count = 0;
9816 for (p = &options[0]; p->fullname != NULL; p++)
9817 {
9818 varp = NULL;
9819 isterm = istermoption(p);
9820 if (opt_flags != 0)
9821 {
9822 if (p->indir != PV_NONE && !isterm)
9823 varp = get_varp_scope(p, opt_flags);
9824 }
9825 else
9826 varp = get_varp(p);
9827 if (varp != NULL
9828 && ((all == 2 && isterm)
9829 || (all == 1 && !isterm)
9830 || (all == 0 && !optval_default(p, varp))))
9831 {
9832 if (p->flags & P_BOOL)
9833 len = 1; /* a toggle option fits always */
9834 else
9835 {
9836 option_value2string(p, opt_flags);
9837 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9838 }
9839 if ((len <= INC - GAP && run == 1) ||
9840 (len > INC - GAP && run == 2))
9841 items[item_count++] = p;
9842 }
9843 }
9844
9845 /*
9846 * display the items
9847 */
9848 if (run == 1)
9849 {
9850 cols = (Columns + GAP - 3) / INC;
9851 if (cols == 0)
9852 cols = 1;
9853 rows = (item_count + cols - 1) / cols;
9854 }
9855 else /* run == 2 */
9856 rows = item_count;
9857 for (row = 0; row < rows && !got_int; ++row)
9858 {
9859 msg_putchar('\n'); /* go to next line */
9860 if (got_int) /* 'q' typed in more */
9861 break;
9862 col = 0;
9863 for (i = row; i < item_count; i += rows)
9864 {
9865 msg_col = col; /* make columns */
9866 showoneopt(items[i], opt_flags);
9867 col += INC;
9868 }
9869 out_flush();
9870 ui_breakcheck();
9871 }
9872 }
9873 vim_free(items);
9874}
9875
9876/*
9877 * Return TRUE if option "p" has its default value.
9878 */
9879 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009880optval_default(struct vimoption *p, char_u *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009881{
9882 int dvi;
9883
9884 if (varp == NULL)
9885 return TRUE; /* hidden option is always at default */
9886 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9887 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009888 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009889 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009890 /* the cast to long is required for Manx C, long_i is
9891 * needed for MSVC */
9892 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009893 /* P_STRING */
9894 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9895}
9896
9897/*
9898 * showoneopt: show the value of one option
9899 * must not be called with a hidden option!
9900 */
9901 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +01009902showoneopt(
9903 struct vimoption *p,
9904 int opt_flags) /* OPT_LOCAL or OPT_GLOBAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009905{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009906 char_u *varp;
9907 int save_silent = silent_mode;
9908
9909 silent_mode = FALSE;
9910 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009911
9912 varp = get_varp_scope(p, opt_flags);
9913
9914 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9915 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9916 ? !curbufIsChanged() : !*(int *)varp))
9917 MSG_PUTS("no");
9918 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9919 MSG_PUTS("--");
9920 else
9921 MSG_PUTS(" ");
9922 MSG_PUTS(p->fullname);
9923 if (!(p->flags & P_BOOL))
9924 {
9925 msg_putchar('=');
9926 /* put value string in NameBuff */
9927 option_value2string(p, opt_flags);
9928 msg_outtrans(NameBuff);
9929 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009930
9931 silent_mode = save_silent;
9932 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009933}
9934
9935/*
9936 * Write modified options as ":set" commands to a file.
9937 *
9938 * There are three values for "opt_flags":
9939 * OPT_GLOBAL: Write global option values and fresh values of
9940 * buffer-local options (used for start of a session
9941 * file).
9942 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
9943 * curwin (used for a vimrc file).
9944 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
9945 * and local values for window-local options of
9946 * curwin. Local values are also written when at the
9947 * default value, because a modeline or autocommand
9948 * may have set them when doing ":edit file" and the
9949 * user has set them back at the default or fresh
9950 * value.
9951 * When "local_only" is TRUE, don't write fresh
9952 * values, only local values (for ":mkview").
9953 * (fresh value = value used for a new buffer or window for a local option).
9954 *
9955 * Return FAIL on error, OK otherwise.
9956 */
9957 int
Bram Moolenaar9b578142016-01-30 19:39:49 +01009958makeset(FILE *fd, int opt_flags, int local_only)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009959{
9960 struct vimoption *p;
9961 char_u *varp; /* currently used value */
9962 char_u *varp_fresh; /* local value */
9963 char_u *varp_local = NULL; /* fresh value */
9964 char *cmd;
9965 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009966 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009967
9968 /*
9969 * The options that don't have a default (terminal name, columns, lines)
9970 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009971 * Do the loop over "options[]" twice: once for options with the
9972 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009973 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009974 for (pri = 1; pri >= 0; --pri)
9975 {
9976 for (p = &options[0]; !istermoption(p); p++)
9977 if (!(p->flags & P_NO_MKRC)
9978 && !istermoption(p)
9979 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009980 {
9981 /* skip global option when only doing locals */
9982 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
9983 continue;
9984
9985 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
9986 * file, they are always buffer-specific. */
9987 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
9988 continue;
9989
9990 /* Global values are only written when not at the default value. */
9991 varp = get_varp_scope(p, opt_flags);
9992 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
9993 continue;
9994
9995 round = 2;
9996 if (p->indir != PV_NONE)
9997 {
9998 if (p->var == VAR_WIN)
9999 {
10000 /* skip window-local option when only doing globals */
10001 if (!(opt_flags & OPT_LOCAL))
10002 continue;
10003 /* When fresh value of window-local option is not at the
10004 * default, need to write it too. */
10005 if (!(opt_flags & OPT_GLOBAL) && !local_only)
10006 {
10007 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
10008 if (!optval_default(p, varp_fresh))
10009 {
10010 round = 1;
10011 varp_local = varp;
10012 varp = varp_fresh;
10013 }
10014 }
10015 }
10016 }
10017
10018 /* Round 1: fresh value for window-local options.
10019 * Round 2: other values */
10020 for ( ; round <= 2; varp = varp_local, ++round)
10021 {
10022 if (round == 1 || (opt_flags & OPT_GLOBAL))
10023 cmd = "set";
10024 else
10025 cmd = "setlocal";
10026
10027 if (p->flags & P_BOOL)
10028 {
10029 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
10030 return FAIL;
10031 }
10032 else if (p->flags & P_NUM)
10033 {
10034 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
10035 return FAIL;
10036 }
10037 else /* P_STRING */
10038 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010039#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
10040 int do_endif = FALSE;
10041
Bram Moolenaar071d4272004-06-13 20:20:40 +000010042 /* Don't set 'syntax' and 'filetype' again if the value is
10043 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010044 if (
10045# if defined(FEAT_SYN_HL)
10046 p->indir == PV_SYN
10047# if defined(FEAT_AUTOCMD)
10048 ||
10049# endif
10050# endif
10051# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +000010052 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010053# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +000010054 )
Bram Moolenaar071d4272004-06-13 20:20:40 +000010055 {
10056 if (fprintf(fd, "if &%s != '%s'", p->fullname,
10057 *(char_u **)(varp)) < 0
10058 || put_eol(fd) < 0)
10059 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010060 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010061 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010062#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010063 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
10064 (p->flags & P_EXPAND) != 0) == FAIL)
10065 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010066#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
10067 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010068 {
10069 if (put_line(fd, "endif") == FAIL)
10070 return FAIL;
10071 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010072#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010073 }
10074 }
10075 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +000010076 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000010077 return OK;
10078}
10079
10080#if defined(FEAT_FOLDING) || defined(PROTO)
10081/*
10082 * Generate set commands for the local fold options only. Used when
10083 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
10084 */
10085 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010086makefoldset(FILE *fd)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010087{
10088 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
10089# ifdef FEAT_EVAL
10090 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
10091 == FAIL
10092# endif
10093 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
10094 == FAIL
10095 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
10096 == FAIL
10097 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
10098 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
10099 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
10100 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
10101 )
10102 return FAIL;
10103
10104 return OK;
10105}
10106#endif
10107
10108 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010109put_setstring(
10110 FILE *fd,
10111 char *cmd,
10112 char *name,
10113 char_u **valuep,
10114 int expand)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010115{
10116 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +020010117 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010118
10119 if (fprintf(fd, "%s %s=", cmd, name) < 0)
10120 return FAIL;
10121 if (*valuep != NULL)
10122 {
10123 /* Output 'pastetoggle' as key names. For other
10124 * options some characters have to be escaped with
10125 * CTRL-V or backslash */
10126 if (valuep == &p_pt)
10127 {
10128 s = *valuep;
10129 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +000010130 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010131 return FAIL;
10132 }
10133 else if (expand)
10134 {
Bram Moolenaarf8441472011-04-28 17:24:58 +020010135 buf = alloc(MAXPATHL);
10136 if (buf == NULL)
10137 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010138 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
10139 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +020010140 {
10141 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010142 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +020010143 }
10144 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010145 }
10146 else if (put_escstr(fd, *valuep, 2) == FAIL)
10147 return FAIL;
10148 }
10149 if (put_eol(fd) < 0)
10150 return FAIL;
10151 return OK;
10152}
10153
10154 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010155put_setnum(
10156 FILE *fd,
10157 char *cmd,
10158 char *name,
10159 long *valuep)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010160{
10161 long wc;
10162
10163 if (fprintf(fd, "%s %s=", cmd, name) < 0)
10164 return FAIL;
10165 if (wc_use_keyname((char_u *)valuep, &wc))
10166 {
10167 /* print 'wildchar' and 'wildcharm' as a key name */
10168 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
10169 return FAIL;
10170 }
10171 else if (fprintf(fd, "%ld", *valuep) < 0)
10172 return FAIL;
10173 if (put_eol(fd) < 0)
10174 return FAIL;
10175 return OK;
10176}
10177
10178 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010179put_setbool(
10180 FILE *fd,
10181 char *cmd,
10182 char *name,
10183 int value)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010184{
Bram Moolenaar893de922007-10-02 18:40:57 +000010185 if (value < 0) /* global/local option using global value */
10186 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010187 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
10188 || put_eol(fd) < 0)
10189 return FAIL;
10190 return OK;
10191}
10192
10193/*
10194 * Clear all the terminal options.
10195 * If the option has been allocated, free the memory.
10196 * Terminal options are never hidden or indirect.
10197 */
10198 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010199clear_termoptions(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010200{
Bram Moolenaar071d4272004-06-13 20:20:40 +000010201 /*
10202 * Reset a few things before clearing the old options. This may cause
10203 * outputting a few things that the terminal doesn't understand, but the
10204 * screen will be cleared later, so this is OK.
10205 */
10206#ifdef FEAT_MOUSE_TTY
10207 mch_setmouse(FALSE); /* switch mouse off */
10208#endif
10209#ifdef FEAT_TITLE
10210 mch_restore_title(3); /* restore window titles */
10211#endif
10212#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
10213 /* When starting the GUI close the display opened for the clipboard.
10214 * After restoring the title, because that will need the display. */
10215 if (gui.starting)
10216 clear_xterm_clip();
10217#endif
Bram Moolenaarcea912a2016-10-12 14:20:24 +020010218 stoptermcap(); /* stop termcap mode */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010219
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000010220 free_termoptions();
10221}
10222
10223 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010224free_termoptions(void)
Bram Moolenaarf461c8e2005-06-25 23:04:51 +000010225{
10226 struct vimoption *p;
10227
Bram Moolenaar071d4272004-06-13 20:20:40 +000010228 for (p = &options[0]; p->fullname != NULL; p++)
10229 if (istermoption(p))
10230 {
10231 if (p->flags & P_ALLOCED)
10232 free_string_option(*(char_u **)(p->var));
10233 if (p->flags & P_DEF_ALLOCED)
10234 free_string_option(p->def_val[VI_DEFAULT]);
10235 *(char_u **)(p->var) = empty_option;
10236 p->def_val[VI_DEFAULT] = empty_option;
10237 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
10238 }
10239 clear_termcodes();
10240}
10241
10242/*
Bram Moolenaar363cb672009-07-22 12:28:17 +000010243 * Free the string for one term option, if it was allocated.
10244 * Set the string to empty_option and clear allocated flag.
10245 * "var" points to the option value.
10246 */
10247 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010248free_one_termoption(char_u *var)
Bram Moolenaar363cb672009-07-22 12:28:17 +000010249{
10250 struct vimoption *p;
10251
10252 for (p = &options[0]; p->fullname != NULL; p++)
10253 if (p->var == var)
10254 {
10255 if (p->flags & P_ALLOCED)
10256 free_string_option(*(char_u **)(p->var));
10257 *(char_u **)(p->var) = empty_option;
10258 p->flags &= ~P_ALLOCED;
10259 break;
10260 }
10261}
10262
10263/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010264 * Set the terminal option defaults to the current value.
10265 * Used after setting the terminal name.
10266 */
10267 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010268set_term_defaults(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010269{
10270 struct vimoption *p;
10271
10272 for (p = &options[0]; p->fullname != NULL; p++)
10273 {
10274 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
10275 {
10276 if (p->flags & P_DEF_ALLOCED)
10277 {
10278 free_string_option(p->def_val[VI_DEFAULT]);
10279 p->flags &= ~P_DEF_ALLOCED;
10280 }
10281 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
10282 if (p->flags & P_ALLOCED)
10283 {
10284 p->flags |= P_DEF_ALLOCED;
10285 p->flags &= ~P_ALLOCED; /* don't free the value now */
10286 }
10287 }
10288 }
10289}
10290
10291/*
10292 * return TRUE if 'p' starts with 't_'
10293 */
10294 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010010295istermoption(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010296{
10297 return (p->fullname[0] == 't' && p->fullname[1] == '_');
10298}
10299
10300/*
10301 * Compute columns for ruler and shown command. 'sc_col' is also used to
10302 * decide what the maximum length of a message on the status line can be.
10303 * If there is a status line for the last window, 'sc_col' is independent
10304 * of 'ru_col'.
10305 */
10306
10307#define COL_RULER 17 /* columns needed by standard ruler */
10308
10309 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010310comp_col(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010311{
10312#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
Bram Moolenaar459ca562016-11-10 18:16:33 +010010313 int last_has_status = (p_ls == 2 || (p_ls == 1 && !ONE_WINDOW));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010314
10315 sc_col = 0;
10316 ru_col = 0;
10317 if (p_ru)
10318 {
10319#ifdef FEAT_STL_OPT
10320 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
10321#else
10322 ru_col = COL_RULER + 1;
10323#endif
10324 /* no last status line, adjust sc_col */
10325 if (!last_has_status)
10326 sc_col = ru_col;
10327 }
10328 if (p_sc)
10329 {
10330 sc_col += SHOWCMD_COLS;
10331 if (!p_ru || last_has_status) /* no need for separating space */
10332 ++sc_col;
10333 }
10334 sc_col = Columns - sc_col;
10335 ru_col = Columns - ru_col;
10336 if (sc_col <= 0) /* screen too narrow, will become a mess */
10337 sc_col = 1;
10338 if (ru_col <= 0)
10339 ru_col = 1;
10340#else
10341 sc_col = Columns;
10342 ru_col = Columns;
10343#endif
10344}
10345
10346/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010347 * Unset local option value, similar to ":set opt<".
10348 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010349 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010350unset_global_local_option(char_u *name, void *from)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010351{
10352 struct vimoption *p;
10353 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010354 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010355
10356 opt_idx = findoption(name);
Bram Moolenaarbd8539a2015-08-11 18:53:03 +020010357 if (opt_idx < 0)
10358 return;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010359 p = &(options[opt_idx]);
10360
10361 switch ((int)p->indir)
10362 {
10363 /* global option with local value: use local value if it's been set */
10364 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010365 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010366 break;
10367 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010368 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010369 break;
10370 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010371 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010372 break;
10373 case PV_AR:
10374 buf->b_p_ar = -1;
10375 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010376 case PV_BKC:
10377 clear_string_option(&buf->b_p_bkc);
10378 buf->b_bkc_flags = 0;
10379 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010380 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010381 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010382 break;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010383 case PV_TC:
10384 clear_string_option(&buf->b_p_tc);
10385 buf->b_tc_flags = 0;
10386 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010387#ifdef FEAT_FIND_ID
10388 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010389 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010390 break;
10391 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010392 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010393 break;
10394#endif
10395#ifdef FEAT_INS_EXPAND
10396 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010397 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010398 break;
10399 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010400 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010401 break;
10402#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010403 case PV_FP:
10404 clear_string_option(&buf->b_p_fp);
10405 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010406#ifdef FEAT_QUICKFIX
10407 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010408 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010409 break;
10410 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010411 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010412 break;
10413 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010414 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010415 break;
10416#endif
10417#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10418 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010419 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010420 break;
10421#endif
10422#if defined(FEAT_CRYPT)
10423 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010424 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010425 break;
10426#endif
10427#ifdef FEAT_STL_OPT
10428 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010429 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010430 break;
10431#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010432 case PV_UL:
10433 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10434 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010435#ifdef FEAT_LISP
10436 case PV_LW:
10437 clear_string_option(&buf->b_p_lw);
10438 break;
10439#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010440#ifdef FEAT_MBYTE
10441 case PV_MENC:
10442 clear_string_option(&buf->b_p_menc);
10443 break;
10444#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010445 }
10446}
10447
10448/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010449 * Get pointer to option variable, depending on local or global scope.
10450 */
10451 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010452get_varp_scope(struct vimoption *p, int opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010453{
10454 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10455 {
10456 if (p->var == VAR_WIN)
10457 return (char_u *)GLOBAL_WO(get_varp(p));
10458 return p->var;
10459 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010460 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010461 {
10462 switch ((int)p->indir)
10463 {
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010464 case PV_FP: return (char_u *)&(curbuf->b_p_fp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010465#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010466 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10467 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10468 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010469#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010470 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10471 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10472 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010473 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010474 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010475 case PV_TC: return (char_u *)&(curbuf->b_p_tc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010476#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010477 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10478 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010479#endif
10480#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010481 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10482 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010483#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010484#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10485 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10486#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010487#if defined(FEAT_CRYPT)
10488 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10489#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010490#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010491 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010492#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010493 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010494#ifdef FEAT_LISP
10495 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10496#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010497 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010498#ifdef FEAT_MBYTE
10499 case PV_MENC: return (char_u *)&(curbuf->b_p_menc);
10500#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010501 }
10502 return NULL; /* "cannot happen" */
10503 }
10504 return get_varp(p);
10505}
10506
10507/*
10508 * Get pointer to option variable.
10509 */
10510 static char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010511get_varp(struct vimoption *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010512{
10513 /* hidden option, always return NULL */
10514 if (p->var == NULL)
10515 return NULL;
10516
10517 switch ((int)p->indir)
10518 {
10519 case PV_NONE: return p->var;
10520
10521 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010522 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010523 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010524 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010525 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010526 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010527 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010528 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010529 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010530 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010531 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010010532 case PV_TC: return *curbuf->b_p_tc != NUL
10533 ? (char_u *)&(curbuf->b_p_tc) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010534 case PV_BKC: return *curbuf->b_p_bkc != NUL
10535 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010536#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010537 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010538 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010539 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010540 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10541#endif
10542#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010543 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010544 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010545 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010546 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10547#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010010548 case PV_FP: return *curbuf->b_p_fp != NUL
10549 ? (char_u *)&(curbuf->b_p_fp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010550#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010551 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010552 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010553 case PV_GP: return *curbuf->b_p_gp != NUL
10554 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10555 case PV_MP: return *curbuf->b_p_mp != NUL
10556 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010557#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010558#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10559 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10560 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10561#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010562#if defined(FEAT_CRYPT)
10563 case PV_CM: return *curbuf->b_p_cm != NUL
10564 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10565#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010566#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010567 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010568 ? (char_u *)&(curwin->w_p_stl) : p->var;
10569#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010570 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10571 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010572#ifdef FEAT_LISP
10573 case PV_LW: return *curbuf->b_p_lw != NUL
10574 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10575#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010010576#ifdef FEAT_MBYTE
10577 case PV_MENC: return *curbuf->b_p_menc != NUL
10578 ? (char_u *)&(curbuf->b_p_menc) : p->var;
10579#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010580
10581#ifdef FEAT_ARABIC
10582 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10583#endif
10584 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010585#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010586 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10587#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010588#ifdef FEAT_SYN_HL
10589 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10590 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010591 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010592#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010593#ifdef FEAT_DIFF
10594 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10595#endif
10596#ifdef FEAT_FOLDING
10597 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10598 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10599 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10600 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10601 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10602 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10603 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10604# ifdef FEAT_EVAL
10605 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10606 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10607# endif
10608 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10609#endif
10610 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010611 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010612#ifdef FEAT_LINEBREAK
10613 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10614#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010615#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010616 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010617 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10618#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010619#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10620 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10621#endif
10622#ifdef FEAT_RIGHTLEFT
10623 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10624 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10625#endif
10626 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10627 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10628#ifdef FEAT_LINEBREAK
10629 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010630 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10631 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010632#endif
10633#ifdef FEAT_SCROLLBIND
10634 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10635#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010636#ifdef FEAT_CURSORBIND
10637 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10638#endif
10639#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010640 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10641 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010642#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010643
10644 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10645 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10646#ifdef FEAT_MBYTE
10647 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10648#endif
10649#if defined(FEAT_QUICKFIX)
10650 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10651 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
10652#endif
10653 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10654 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10655#ifdef FEAT_CINDENT
10656 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10657 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10658 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10659#endif
10660#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10661 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10662#endif
10663#ifdef FEAT_COMMENTS
10664 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10665#endif
10666#ifdef FEAT_FOLDING
10667 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10668#endif
10669#ifdef FEAT_INS_EXPAND
10670 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10671#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010672#ifdef FEAT_COMPL_FUNC
10673 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010674 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010675#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010676 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010677 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010678 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10679#ifdef FEAT_MBYTE
10680 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10681#endif
10682 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10683#ifdef FEAT_AUTOCMD
10684 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10685#endif
10686 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010687 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010688 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10689 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10690 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10691 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10692#ifdef FEAT_FIND_ID
10693# ifdef FEAT_EVAL
10694 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10695# endif
10696#endif
10697#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10698 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10699 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10700#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010701#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010702 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10703#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010704#ifdef FEAT_CRYPT
10705 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10706#endif
10707#ifdef FEAT_LISP
10708 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10709#endif
10710 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10711 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10712 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10713 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10714 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010715 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010716#ifdef FEAT_TEXTOBJ
10717 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10718#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010719 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10720#ifdef FEAT_SMARTINDENT
10721 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10722#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010723 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010724 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10725#ifdef FEAT_SEARCHPATH
10726 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10727#endif
10728 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10729#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010730 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010731 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10732#endif
10733#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010734 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10735 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10736 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010737#endif
10738 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10739 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10740 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10741 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010742#ifdef FEAT_PERSISTENT_UNDO
10743 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10744#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010745 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10746#ifdef FEAT_KEYMAP
10747 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10748#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010749#ifdef FEAT_SIGNS
10750 case PV_SCL: return (char_u *)&(curwin->w_p_scl);
10751#endif
Bram Moolenaar95f09602016-11-10 20:01:45 +010010752 default: IEMSG(_("E356: get_varp ERROR"));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010753 }
10754 /* always return a valid pointer to avoid a crash! */
10755 return (char_u *)&(curbuf->b_p_wm);
10756}
10757
10758/*
10759 * Get the value of 'equalprg', either the buffer-local one or the global one.
10760 */
10761 char_u *
Bram Moolenaar9b578142016-01-30 19:39:49 +010010762get_equalprg(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010763{
10764 if (*curbuf->b_p_ep == NUL)
10765 return p_ep;
10766 return curbuf->b_p_ep;
10767}
10768
10769#if defined(FEAT_WINDOWS) || defined(PROTO)
10770/*
10771 * Copy options from one window to another.
10772 * Used when splitting a window.
10773 */
10774 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010775win_copy_options(win_T *wp_from, win_T *wp_to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010776{
10777 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10778 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10779# ifdef FEAT_RIGHTLEFT
10780# ifdef FEAT_FKMAP
10781 /* Is this right? */
10782 wp_to->w_farsi = wp_from->w_farsi;
10783# endif
10784# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020010785#if defined(FEAT_LINEBREAK)
10786 briopt_check(wp_to);
10787#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010788}
10789#endif
10790
10791/*
10792 * Copy the options from one winopt_T to another.
10793 * Doesn't free the old option values in "to", use clear_winopt() for that.
10794 * The 'scroll' option is not copied, because it depends on the window height.
10795 * The 'previewwindow' option is reset, there can be only one preview window.
10796 */
10797 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010798copy_winopt(winopt_T *from, winopt_T *to)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010799{
10800#ifdef FEAT_ARABIC
10801 to->wo_arab = from->wo_arab;
10802#endif
10803 to->wo_list = from->wo_list;
10804 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010805 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010806#ifdef FEAT_LINEBREAK
10807 to->wo_nuw = from->wo_nuw;
10808#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010809#ifdef FEAT_RIGHTLEFT
10810 to->wo_rl = from->wo_rl;
10811 to->wo_rlc = vim_strsave(from->wo_rlc);
10812#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010813#ifdef FEAT_STL_OPT
10814 to->wo_stl = vim_strsave(from->wo_stl);
10815#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010816 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010817#ifdef FEAT_DIFF
10818 to->wo_wrap_save = from->wo_wrap_save;
10819#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010820#ifdef FEAT_LINEBREAK
10821 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020010822 to->wo_bri = from->wo_bri;
10823 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010824#endif
10825#ifdef FEAT_SCROLLBIND
10826 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010827 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010828#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010829#ifdef FEAT_CURSORBIND
10830 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010831 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010832#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010833#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010834 to->wo_spell = from->wo_spell;
10835#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010836#ifdef FEAT_SYN_HL
10837 to->wo_cuc = from->wo_cuc;
10838 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010839 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010840#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010841#ifdef FEAT_DIFF
10842 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010843 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010844#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010845#ifdef FEAT_CONCEAL
10846 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010847 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010848#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010849#ifdef FEAT_FOLDING
10850 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010851 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010852 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010853 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010854 to->wo_fdi = vim_strsave(from->wo_fdi);
10855 to->wo_fml = from->wo_fml;
10856 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010857 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010858 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010859 to->wo_fdm_save = from->wo_diff_saved
10860 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010861 to->wo_fdn = from->wo_fdn;
10862# ifdef FEAT_EVAL
10863 to->wo_fde = vim_strsave(from->wo_fde);
10864 to->wo_fdt = vim_strsave(from->wo_fdt);
10865# endif
10866 to->wo_fmr = vim_strsave(from->wo_fmr);
10867#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010868#ifdef FEAT_SIGNS
10869 to->wo_scl = vim_strsave(from->wo_scl);
10870#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010871 check_winopt(to); /* don't want NULL pointers */
10872}
10873
10874/*
10875 * Check string options in a window for a NULL value.
10876 */
10877 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010878check_win_options(win_T *win)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010879{
10880 check_winopt(&win->w_onebuf_opt);
10881 check_winopt(&win->w_allbuf_opt);
10882}
10883
10884/*
10885 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10886 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020010887 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010888check_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010889{
10890#ifdef FEAT_FOLDING
10891 check_string_option(&wop->wo_fdi);
10892 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010893 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010894# ifdef FEAT_EVAL
10895 check_string_option(&wop->wo_fde);
10896 check_string_option(&wop->wo_fdt);
10897# endif
10898 check_string_option(&wop->wo_fmr);
10899#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010900#ifdef FEAT_SIGNS
10901 check_string_option(&wop->wo_scl);
10902#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010903#ifdef FEAT_RIGHTLEFT
10904 check_string_option(&wop->wo_rlc);
10905#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010906#ifdef FEAT_STL_OPT
10907 check_string_option(&wop->wo_stl);
10908#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010909#ifdef FEAT_SYN_HL
10910 check_string_option(&wop->wo_cc);
10911#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010912#ifdef FEAT_CONCEAL
10913 check_string_option(&wop->wo_cocu);
10914#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010915#ifdef FEAT_LINEBREAK
10916 check_string_option(&wop->wo_briopt);
10917#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010918}
10919
10920/*
10921 * Free the allocated memory inside a winopt_T.
10922 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010923 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010924clear_winopt(winopt_T *wop UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010925{
10926#ifdef FEAT_FOLDING
10927 clear_string_option(&wop->wo_fdi);
10928 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010929 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010930# ifdef FEAT_EVAL
10931 clear_string_option(&wop->wo_fde);
10932 clear_string_option(&wop->wo_fdt);
10933# endif
10934 clear_string_option(&wop->wo_fmr);
10935#endif
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020010936#ifdef FEAT_SIGNS
10937 clear_string_option(&wop->wo_scl);
10938#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010939#ifdef FEAT_LINEBREAK
10940 clear_string_option(&wop->wo_briopt);
10941#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010942#ifdef FEAT_RIGHTLEFT
10943 clear_string_option(&wop->wo_rlc);
10944#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010945#ifdef FEAT_STL_OPT
10946 clear_string_option(&wop->wo_stl);
10947#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010948#ifdef FEAT_SYN_HL
10949 clear_string_option(&wop->wo_cc);
10950#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010951#ifdef FEAT_CONCEAL
10952 clear_string_option(&wop->wo_cocu);
10953#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010954}
10955
10956/*
10957 * Copy global option values to local options for one buffer.
10958 * Used when creating a new buffer and sometimes when entering a buffer.
10959 * flags:
10960 * BCO_ENTER We will enter the buf buffer.
10961 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
10962 * appropriate.
10963 * BCO_NOHELP Don't copy the values to a help buffer.
10964 */
10965 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010010966buf_copy_options(buf_T *buf, int flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010967{
10968 int should_copy = TRUE;
10969 char_u *save_p_isk = NULL; /* init for GCC */
10970 int dont_do_help;
10971 int did_isk = FALSE;
10972
10973 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010974 * Skip this when the option defaults have not been set yet. Happens when
10975 * main() allocates the first buffer.
10976 */
10977 if (p_cpo != NULL)
10978 {
10979 /*
10980 * Always copy when entering and 'cpo' contains 'S'.
10981 * Don't copy when already initialized.
10982 * Don't copy when 'cpo' contains 's' and not entering.
10983 * 'S' BCO_ENTER initialized 's' should_copy
10984 * yes yes X X TRUE
10985 * yes no yes X FALSE
10986 * no X yes X FALSE
10987 * X no no yes FALSE
10988 * X no no no TRUE
10989 * no yes no X TRUE
10990 */
10991 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
10992 && (buf->b_p_initialized
10993 || (!(flags & BCO_ENTER)
10994 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
10995 should_copy = FALSE;
10996
10997 if (should_copy || (flags & BCO_ALWAYS))
10998 {
10999 /* Don't copy the options specific to a help buffer when
11000 * BCO_NOHELP is given or the options were initialized already
11001 * (jumping back to a help file with CTRL-T or CTRL-O) */
11002 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
11003 || buf->b_p_initialized;
11004 if (dont_do_help) /* don't free b_p_isk */
11005 {
11006 save_p_isk = buf->b_p_isk;
11007 buf->b_p_isk = NULL;
11008 }
11009 /*
11010 * Always free the allocated strings.
11011 * If not already initialized, set 'readonly' and copy 'fileformat'.
11012 */
11013 if (!buf->b_p_initialized)
11014 {
11015 free_buf_options(buf, TRUE);
11016 buf->b_p_ro = FALSE; /* don't copy readonly */
11017 buf->b_p_tx = p_tx;
11018#ifdef FEAT_MBYTE
11019 buf->b_p_fenc = vim_strsave(p_fenc);
11020#endif
Bram Moolenaare8ef3a02016-10-12 17:45:29 +020011021 switch (*p_ffs)
11022 {
11023 case 'm':
11024 buf->b_p_ff = vim_strsave((char_u *)FF_MAC); break;
11025 case 'd':
11026 buf->b_p_ff = vim_strsave((char_u *)FF_DOS); break;
11027 case 'u':
11028 buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); break;
11029 default:
11030 buf->b_p_ff = vim_strsave(p_ff);
11031 }
11032 if (buf->b_p_ff != NULL)
11033 buf->b_start_ffc = *buf->b_p_ff;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011034#if defined(FEAT_QUICKFIX)
11035 buf->b_p_bh = empty_option;
11036 buf->b_p_bt = empty_option;
11037#endif
11038 }
11039 else
11040 free_buf_options(buf, FALSE);
11041
11042 buf->b_p_ai = p_ai;
11043 buf->b_p_ai_nopaste = p_ai_nopaste;
11044 buf->b_p_sw = p_sw;
11045 buf->b_p_tw = p_tw;
11046 buf->b_p_tw_nopaste = p_tw_nopaste;
11047 buf->b_p_tw_nobin = p_tw_nobin;
11048 buf->b_p_wm = p_wm;
11049 buf->b_p_wm_nopaste = p_wm_nopaste;
11050 buf->b_p_wm_nobin = p_wm_nobin;
11051 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000011052#ifdef FEAT_MBYTE
11053 buf->b_p_bomb = p_bomb;
11054#endif
Bram Moolenaarb388be02015-07-22 22:19:38 +020011055 buf->b_p_fixeol = p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011056 buf->b_p_et = p_et;
11057 buf->b_p_et_nobin = p_et_nobin;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011058 buf->b_p_et_nopaste = p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011059 buf->b_p_ml = p_ml;
11060 buf->b_p_ml_nobin = p_ml_nobin;
11061 buf->b_p_inf = p_inf;
Bram Moolenaar3bab9392017-04-07 15:42:25 +020011062 buf->b_p_swf = cmdmod.noswapfile ? FALSE : p_swf;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011063#ifdef FEAT_INS_EXPAND
11064 buf->b_p_cpt = vim_strsave(p_cpt);
11065#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011066#ifdef FEAT_COMPL_FUNC
11067 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000011068 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011069#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011070 buf->b_p_sts = p_sts;
11071 buf->b_p_sts_nopaste = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011072 buf->b_p_sn = p_sn;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011073#ifdef FEAT_COMMENTS
11074 buf->b_p_com = vim_strsave(p_com);
11075#endif
11076#ifdef FEAT_FOLDING
11077 buf->b_p_cms = vim_strsave(p_cms);
11078#endif
11079 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000011080 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011081 buf->b_p_nf = vim_strsave(p_nf);
11082 buf->b_p_mps = vim_strsave(p_mps);
11083#ifdef FEAT_SMARTINDENT
11084 buf->b_p_si = p_si;
11085#endif
11086 buf->b_p_ci = p_ci;
11087#ifdef FEAT_CINDENT
11088 buf->b_p_cin = p_cin;
11089 buf->b_p_cink = vim_strsave(p_cink);
11090 buf->b_p_cino = vim_strsave(p_cino);
11091#endif
11092#ifdef FEAT_AUTOCMD
11093 /* Don't copy 'filetype', it must be detected */
11094 buf->b_p_ft = empty_option;
11095#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011096 buf->b_p_pi = p_pi;
11097#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
11098 buf->b_p_cinw = vim_strsave(p_cinw);
11099#endif
11100#ifdef FEAT_LISP
11101 buf->b_p_lisp = p_lisp;
11102#endif
11103#ifdef FEAT_SYN_HL
11104 /* Don't copy 'syntax', it must be set */
11105 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000011106 buf->b_p_smc = p_smc;
Bram Moolenaarb8060fe2016-01-19 22:29:28 +010011107 buf->b_s.b_syn_isk = empty_option;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011108#endif
11109#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020011110 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020011111 (void)compile_cap_prog(&buf->b_s);
11112 buf->b_s.b_p_spf = vim_strsave(p_spf);
11113 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011114#endif
11115#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
11116 buf->b_p_inde = vim_strsave(p_inde);
11117 buf->b_p_indk = vim_strsave(p_indk);
11118#endif
Bram Moolenaar9be7c042017-01-14 14:28:30 +010011119 buf->b_p_fp = empty_option;
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000011120#if defined(FEAT_EVAL)
11121 buf->b_p_fex = vim_strsave(p_fex);
11122#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011123#ifdef FEAT_CRYPT
11124 buf->b_p_key = vim_strsave(p_key);
11125#endif
11126#ifdef FEAT_SEARCHPATH
11127 buf->b_p_sua = vim_strsave(p_sua);
11128#endif
11129#ifdef FEAT_KEYMAP
11130 buf->b_p_keymap = vim_strsave(p_keymap);
11131 buf->b_kmap_state |= KEYMAP_INIT;
11132#endif
11133 /* This isn't really an option, but copying the langmap and IME
11134 * state from the current buffer is better than resetting it. */
11135 buf->b_p_iminsert = p_iminsert;
11136 buf->b_p_imsearch = p_imsearch;
11137
11138 /* options that are normally global but also have a local value
11139 * are not copied, start using the global value */
11140 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010011141 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020011142 buf->b_p_bkc = empty_option;
11143 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011144#ifdef FEAT_QUICKFIX
11145 buf->b_p_gp = empty_option;
11146 buf->b_p_mp = empty_option;
11147 buf->b_p_efm = empty_option;
11148#endif
11149 buf->b_p_ep = empty_option;
11150 buf->b_p_kp = empty_option;
11151 buf->b_p_path = empty_option;
11152 buf->b_p_tags = empty_option;
Bram Moolenaar0f6562e2015-11-24 18:48:14 +010011153 buf->b_p_tc = empty_option;
11154 buf->b_tc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011155#ifdef FEAT_FIND_ID
11156 buf->b_p_def = empty_option;
11157 buf->b_p_inc = empty_option;
11158# ifdef FEAT_EVAL
11159 buf->b_p_inex = vim_strsave(p_inex);
11160# endif
11161#endif
11162#ifdef FEAT_INS_EXPAND
11163 buf->b_p_dict = empty_option;
11164 buf->b_p_tsr = empty_option;
11165#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000011166#ifdef FEAT_TEXTOBJ
11167 buf->b_p_qe = vim_strsave(p_qe);
11168#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000011169#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
11170 buf->b_p_bexpr = empty_option;
11171#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020011172#if defined(FEAT_CRYPT)
11173 buf->b_p_cm = empty_option;
11174#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020011175#ifdef FEAT_PERSISTENT_UNDO
11176 buf->b_p_udf = p_udf;
11177#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010011178#ifdef FEAT_LISP
11179 buf->b_p_lw = empty_option;
11180#endif
Bram Moolenaar2c7292d2017-03-05 17:43:31 +010011181#ifdef FEAT_MBYTE
11182 buf->b_p_menc = empty_option;
11183#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011184
11185 /*
11186 * Don't copy the options set by ex_help(), use the saved values,
11187 * when going from a help buffer to a non-help buffer.
11188 * Don't touch these at all when BCO_NOHELP is used and going from
11189 * or to a help buffer.
11190 */
11191 if (dont_do_help)
11192 buf->b_p_isk = save_p_isk;
11193 else
11194 {
11195 buf->b_p_isk = vim_strsave(p_isk);
11196 did_isk = TRUE;
11197 buf->b_p_ts = p_ts;
11198 buf->b_help = FALSE;
11199#ifdef FEAT_QUICKFIX
11200 if (buf->b_p_bt[0] == 'h')
11201 clear_string_option(&buf->b_p_bt);
11202#endif
11203 buf->b_p_ma = p_ma;
11204 }
11205 }
11206
11207 /*
11208 * When the options should be copied (ignoring BCO_ALWAYS), set the
11209 * flag that indicates that the options have been initialized.
11210 */
11211 if (should_copy)
11212 buf->b_p_initialized = TRUE;
11213 }
11214
11215 check_buf_options(buf); /* make sure we don't have NULLs */
11216 if (did_isk)
11217 (void)buf_init_chartab(buf, FALSE);
11218}
11219
11220/*
11221 * Reset the 'modifiable' option and its default value.
11222 */
11223 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011224reset_modifiable(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011225{
11226 int opt_idx;
11227
11228 curbuf->b_p_ma = FALSE;
11229 p_ma = FALSE;
11230 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011231 if (opt_idx >= 0)
11232 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011233}
11234
11235/*
11236 * Set the global value for 'iminsert' to the local value.
11237 */
11238 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011239set_iminsert_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011240{
11241 p_iminsert = curbuf->b_p_iminsert;
11242}
11243
11244/*
11245 * Set the global value for 'imsearch' to the local value.
11246 */
11247 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011248set_imsearch_global(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011249{
11250 p_imsearch = curbuf->b_p_imsearch;
11251}
11252
11253#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
11254static int expand_option_idx = -1;
11255static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
11256static int expand_option_flags = 0;
11257
11258 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011259set_context_in_set_cmd(
11260 expand_T *xp,
11261 char_u *arg,
11262 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011263{
11264 int nextchar;
11265 long_u flags = 0; /* init for GCC */
11266 int opt_idx = 0; /* init for GCC */
11267 char_u *p;
11268 char_u *s;
11269 int is_term_option = FALSE;
11270 int key;
11271
11272 expand_option_flags = opt_flags;
11273
11274 xp->xp_context = EXPAND_SETTINGS;
11275 if (*arg == NUL)
11276 {
11277 xp->xp_pattern = arg;
11278 return;
11279 }
11280 p = arg + STRLEN(arg) - 1;
11281 if (*p == ' ' && *(p - 1) != '\\')
11282 {
11283 xp->xp_pattern = p + 1;
11284 return;
11285 }
11286 while (p > arg)
11287 {
11288 s = p;
11289 /* count number of backslashes before ' ' or ',' */
11290 if (*p == ' ' || *p == ',')
11291 {
11292 while (s > arg && *(s - 1) == '\\')
11293 --s;
11294 }
11295 /* break at a space with an even number of backslashes */
11296 if (*p == ' ' && ((p - s) & 1) == 0)
11297 {
11298 ++p;
11299 break;
11300 }
11301 --p;
11302 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000011303 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011304 {
11305 xp->xp_context = EXPAND_BOOL_SETTINGS;
11306 p += 2;
11307 }
11308 if (STRNCMP(p, "inv", 3) == 0)
11309 {
11310 xp->xp_context = EXPAND_BOOL_SETTINGS;
11311 p += 3;
11312 }
11313 xp->xp_pattern = arg = p;
11314 if (*arg == '<')
11315 {
11316 while (*p != '>')
11317 if (*p++ == NUL) /* expand terminal option name */
11318 return;
11319 key = get_special_key_code(arg + 1);
11320 if (key == 0) /* unknown name */
11321 {
11322 xp->xp_context = EXPAND_NOTHING;
11323 return;
11324 }
11325 nextchar = *++p;
11326 is_term_option = TRUE;
11327 expand_option_name[2] = KEY2TERMCAP0(key);
11328 expand_option_name[3] = KEY2TERMCAP1(key);
11329 }
11330 else
11331 {
11332 if (p[0] == 't' && p[1] == '_')
11333 {
11334 p += 2;
11335 if (*p != NUL)
11336 ++p;
11337 if (*p == NUL)
11338 return; /* expand option name */
11339 nextchar = *++p;
11340 is_term_option = TRUE;
11341 expand_option_name[2] = p[-2];
11342 expand_option_name[3] = p[-1];
11343 }
11344 else
11345 {
11346 /* Allow * wildcard */
11347 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
11348 p++;
11349 if (*p == NUL)
11350 return;
11351 nextchar = *p;
11352 *p = NUL;
11353 opt_idx = findoption(arg);
11354 *p = nextchar;
11355 if (opt_idx == -1 || options[opt_idx].var == NULL)
11356 {
11357 xp->xp_context = EXPAND_NOTHING;
11358 return;
11359 }
11360 flags = options[opt_idx].flags;
11361 if (flags & P_BOOL)
11362 {
11363 xp->xp_context = EXPAND_NOTHING;
11364 return;
11365 }
11366 }
11367 }
11368 /* handle "-=" and "+=" */
11369 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
11370 {
11371 ++p;
11372 nextchar = '=';
11373 }
11374 if ((nextchar != '=' && nextchar != ':')
11375 || xp->xp_context == EXPAND_BOOL_SETTINGS)
11376 {
11377 xp->xp_context = EXPAND_UNSUCCESSFUL;
11378 return;
11379 }
11380 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
11381 {
11382 xp->xp_context = EXPAND_OLD_SETTING;
11383 if (is_term_option)
11384 expand_option_idx = -1;
11385 else
11386 expand_option_idx = opt_idx;
11387 xp->xp_pattern = p + 1;
11388 return;
11389 }
11390 xp->xp_context = EXPAND_NOTHING;
11391 if (is_term_option || (flags & P_NUM))
11392 return;
11393
11394 xp->xp_pattern = p + 1;
11395
11396 if (flags & P_EXPAND)
11397 {
11398 p = options[opt_idx].var;
11399 if (p == (char_u *)&p_bdir
11400 || p == (char_u *)&p_dir
11401 || p == (char_u *)&p_path
Bram Moolenaarf6fee0e2016-02-21 23:02:49 +010011402 || p == (char_u *)&p_pp
Bram Moolenaar071d4272004-06-13 20:20:40 +000011403 || p == (char_u *)&p_rtp
11404#ifdef FEAT_SEARCHPATH
11405 || p == (char_u *)&p_cdpath
11406#endif
11407#ifdef FEAT_SESSION
11408 || p == (char_u *)&p_vdir
11409#endif
11410 )
11411 {
11412 xp->xp_context = EXPAND_DIRECTORIES;
11413 if (p == (char_u *)&p_path
11414#ifdef FEAT_SEARCHPATH
11415 || p == (char_u *)&p_cdpath
11416#endif
11417 )
11418 xp->xp_backslash = XP_BS_THREE;
11419 else
11420 xp->xp_backslash = XP_BS_ONE;
11421 }
11422 else
11423 {
11424 xp->xp_context = EXPAND_FILES;
11425 /* for 'tags' need three backslashes for a space */
11426 if (p == (char_u *)&p_tags)
11427 xp->xp_backslash = XP_BS_THREE;
11428 else
11429 xp->xp_backslash = XP_BS_ONE;
11430 }
11431 }
11432
11433 /* For an option that is a list of file names, find the start of the
11434 * last file name. */
11435 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11436 {
11437 /* count number of backslashes before ' ' or ',' */
11438 if (*p == ' ' || *p == ',')
11439 {
11440 s = p;
11441 while (s > xp->xp_pattern && *(s - 1) == '\\')
11442 --s;
11443 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11444 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11445 {
11446 xp->xp_pattern = p + 1;
11447 break;
11448 }
11449 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011450
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011451#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011452 /* for 'spellsuggest' start at "file:" */
11453 if (options[opt_idx].var == (char_u *)&p_sps
11454 && STRNCMP(p, "file:", 5) == 0)
11455 {
11456 xp->xp_pattern = p + 5;
11457 break;
11458 }
11459#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011460 }
11461
11462 return;
11463}
11464
11465 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011466ExpandSettings(
11467 expand_T *xp,
11468 regmatch_T *regmatch,
11469 int *num_file,
11470 char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011471{
11472 int num_normal = 0; /* Nr of matching non-term-code settings */
11473 int num_term = 0; /* Nr of matching terminal code settings */
11474 int opt_idx;
11475 int match;
11476 int count = 0;
11477 char_u *str;
11478 int loop;
11479 int is_term_opt;
11480 char_u name_buf[MAX_KEY_NAME_LEN];
11481 static char *(names[]) = {"all", "termcap"};
11482 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11483
11484 /* do this loop twice:
11485 * loop == 0: count the number of matching options
11486 * loop == 1: copy the matching options into allocated memory
11487 */
11488 for (loop = 0; loop <= 1; ++loop)
11489 {
11490 regmatch->rm_ic = ic;
11491 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11492 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011493 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11494 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011495 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11496 {
11497 if (loop == 0)
11498 num_normal++;
11499 else
11500 (*file)[count++] = vim_strsave((char_u *)names[match]);
11501 }
11502 }
11503 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11504 opt_idx++)
11505 {
11506 if (options[opt_idx].var == NULL)
11507 continue;
11508 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11509 && !(options[opt_idx].flags & P_BOOL))
11510 continue;
11511 is_term_opt = istermoption(&options[opt_idx]);
11512 if (is_term_opt && num_normal > 0)
11513 continue;
11514 match = FALSE;
11515 if (vim_regexec(regmatch, str, (colnr_T)0)
11516 || (options[opt_idx].shortname != NULL
11517 && vim_regexec(regmatch,
11518 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11519 match = TRUE;
11520 else if (is_term_opt)
11521 {
11522 name_buf[0] = '<';
11523 name_buf[1] = 't';
11524 name_buf[2] = '_';
11525 name_buf[3] = str[2];
11526 name_buf[4] = str[3];
11527 name_buf[5] = '>';
11528 name_buf[6] = NUL;
11529 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11530 {
11531 match = TRUE;
11532 str = name_buf;
11533 }
11534 }
11535 if (match)
11536 {
11537 if (loop == 0)
11538 {
11539 if (is_term_opt)
11540 num_term++;
11541 else
11542 num_normal++;
11543 }
11544 else
11545 (*file)[count++] = vim_strsave(str);
11546 }
11547 }
11548 /*
11549 * Check terminal key codes, these are not in the option table
11550 */
11551 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11552 {
11553 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11554 {
11555 if (!isprint(str[0]) || !isprint(str[1]))
11556 continue;
11557
11558 name_buf[0] = 't';
11559 name_buf[1] = '_';
11560 name_buf[2] = str[0];
11561 name_buf[3] = str[1];
11562 name_buf[4] = NUL;
11563
11564 match = FALSE;
11565 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11566 match = TRUE;
11567 else
11568 {
11569 name_buf[0] = '<';
11570 name_buf[1] = 't';
11571 name_buf[2] = '_';
11572 name_buf[3] = str[0];
11573 name_buf[4] = str[1];
11574 name_buf[5] = '>';
11575 name_buf[6] = NUL;
11576
11577 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11578 match = TRUE;
11579 }
11580 if (match)
11581 {
11582 if (loop == 0)
11583 num_term++;
11584 else
11585 (*file)[count++] = vim_strsave(name_buf);
11586 }
11587 }
11588
11589 /*
11590 * Check special key names.
11591 */
11592 regmatch->rm_ic = TRUE; /* ignore case here */
11593 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11594 {
11595 name_buf[0] = '<';
11596 STRCPY(name_buf + 1, str);
11597 STRCAT(name_buf, ">");
11598
11599 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11600 {
11601 if (loop == 0)
11602 num_term++;
11603 else
11604 (*file)[count++] = vim_strsave(name_buf);
11605 }
11606 }
11607 }
11608 if (loop == 0)
11609 {
11610 if (num_normal > 0)
11611 *num_file = num_normal;
11612 else if (num_term > 0)
11613 *num_file = num_term;
11614 else
11615 return OK;
11616 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11617 if (*file == NULL)
11618 {
11619 *file = (char_u **)"";
11620 return FAIL;
11621 }
11622 }
11623 }
11624 return OK;
11625}
11626
11627 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011628ExpandOldSetting(int *num_file, char_u ***file)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011629{
11630 char_u *var = NULL; /* init for GCC */
11631 char_u *buf;
11632
11633 *num_file = 0;
11634 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11635 if (*file == NULL)
11636 return FAIL;
11637
11638 /*
11639 * For a terminal key code expand_option_idx is < 0.
11640 */
11641 if (expand_option_idx < 0)
11642 {
11643 var = find_termcode(expand_option_name + 2);
11644 if (var == NULL)
11645 expand_option_idx = findoption(expand_option_name);
11646 }
11647
11648 if (expand_option_idx >= 0)
11649 {
11650 /* put string of option value in NameBuff */
11651 option_value2string(&options[expand_option_idx], expand_option_flags);
11652 var = NameBuff;
11653 }
11654 else if (var == NULL)
11655 var = (char_u *)"";
11656
11657 /* A backslash is required before some characters. This is the reverse of
11658 * what happens in do_set(). */
11659 buf = vim_strsave_escaped(var, escape_chars);
11660
11661 if (buf == NULL)
11662 {
11663 vim_free(*file);
11664 *file = NULL;
11665 return FAIL;
11666 }
11667
11668#ifdef BACKSLASH_IN_FILENAME
11669 /* For MS-Windows et al. we don't double backslashes at the start and
11670 * before a file name character. */
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011671 for (var = buf; *var != NUL; MB_PTR_ADV(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011672 if (var[0] == '\\' && var[1] == '\\'
11673 && expand_option_idx >= 0
11674 && (options[expand_option_idx].flags & P_EXPAND)
11675 && vim_isfilec(var[2])
11676 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011677 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011678#endif
11679
11680 *file[0] = buf;
11681 *num_file = 1;
11682 return OK;
11683}
11684#endif
11685
11686/*
11687 * Get the value for the numeric or string option *opp in a nice format into
11688 * NameBuff[]. Must not be called with a hidden option!
11689 */
11690 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011691option_value2string(
11692 struct vimoption *opp,
11693 int opt_flags) /* OPT_GLOBAL and/or OPT_LOCAL */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011694{
11695 char_u *varp;
11696
11697 varp = get_varp_scope(opp, opt_flags);
11698
11699 if (opp->flags & P_NUM)
11700 {
11701 long wc = 0;
11702
11703 if (wc_use_keyname(varp, &wc))
11704 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11705 else if (wc != 0)
11706 STRCPY(NameBuff, transchar((int)wc));
11707 else
11708 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11709 }
11710 else /* P_STRING */
11711 {
11712 varp = *(char_u **)(varp);
11713 if (varp == NULL) /* just in case */
11714 NameBuff[0] = NUL;
11715#ifdef FEAT_CRYPT
11716 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011717 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011718 STRCPY(NameBuff, "*****");
11719#endif
11720 else if (opp->flags & P_EXPAND)
11721 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11722 /* Translate 'pastetoggle' into special key names */
11723 else if ((char_u **)opp->var == &p_pt)
11724 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11725 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011726 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011727 }
11728}
11729
11730/*
11731 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11732 * printed as a keyname.
11733 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11734 */
11735 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011736wc_use_keyname(char_u *varp, long *wcp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011737{
11738 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11739 {
11740 *wcp = *(long *)varp;
11741 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11742 return TRUE;
11743 }
11744 return FALSE;
11745}
11746
Bram Moolenaar01615492015-02-03 13:00:38 +010011747#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011748/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011749 * Any character has an equivalent 'langmap' character. This is used for
11750 * keyboards that have a special language mode that sends characters above
11751 * 128 (although other characters can be translated too). The "to" field is a
11752 * Vim command character. This avoids having to switch the keyboard back to
11753 * ASCII mode when leaving Insert mode.
11754 *
11755 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11756 * commands.
11757 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11758 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11759 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011760 */
Bram Moolenaar01615492015-02-03 13:00:38 +010011761# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011762/*
11763 * With multi-byte support use growarray for 'langmap' chars >= 256
11764 */
11765typedef struct
11766{
11767 int from;
11768 int to;
11769} langmap_entry_T;
11770
11771static garray_T langmap_mapga;
Bram Moolenaarbaaa7e92016-01-29 22:47:03 +010011772static void langmap_set_entry(int from, int to);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011773
11774/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011775 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11776 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011777 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011778 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011779langmap_set_entry(int from, int to)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011780{
11781 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011782 int a = 0;
11783 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011784
11785 /* Do a binary search for an existing entry. */
11786 while (a != b)
11787 {
11788 int i = (a + b) / 2;
11789 int d = entries[i].from - from;
11790
11791 if (d == 0)
11792 {
11793 entries[i].to = to;
11794 return;
11795 }
11796 if (d < 0)
11797 a = i + 1;
11798 else
11799 b = i;
11800 }
11801
11802 if (ga_grow(&langmap_mapga, 1) != OK)
11803 return; /* out of memory */
11804
11805 /* insert new entry at position "a" */
11806 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11807 mch_memmove(entries + 1, entries,
11808 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11809 ++langmap_mapga.ga_len;
11810 entries[0].from = from;
11811 entries[0].to = to;
11812}
11813
11814/*
11815 * Apply 'langmap' to multi-byte character "c" and return the result.
11816 */
11817 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011818langmap_adjust_mb(int c)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011819{
11820 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11821 int a = 0;
11822 int b = langmap_mapga.ga_len;
11823
11824 while (a != b)
11825 {
11826 int i = (a + b) / 2;
11827 int d = entries[i].from - c;
11828
11829 if (d == 0)
11830 return entries[i].to; /* found matching entry */
11831 if (d < 0)
11832 a = i + 1;
11833 else
11834 b = i;
11835 }
11836 return c; /* no entry found, return "c" unmodified */
11837}
11838# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011839
11840 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011841langmap_init(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011842{
11843 int i;
11844
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011845 for (i = 0; i < 256; i++)
11846 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11847# ifdef FEAT_MBYTE
11848 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11849# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011850}
11851
11852/*
11853 * Called when langmap option is set; the language map can be
11854 * changed at any time!
11855 */
11856 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011857langmap_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011858{
11859 char_u *p;
11860 char_u *p2;
11861 int from, to;
11862
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011863#ifdef FEAT_MBYTE
11864 ga_clear(&langmap_mapga); /* clear the previous map first */
11865#endif
11866 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011867
11868 for (p = p_langmap; p[0] != NUL; )
11869 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011870 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011871 MB_PTR_ADV(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011872 {
11873 if (p2[0] == '\\' && p2[1] != NUL)
11874 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011875 }
11876 if (p2[0] == ';')
11877 ++p2; /* abcd;ABCD form, p2 points to A */
11878 else
11879 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11880 while (p[0])
11881 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011882 if (p[0] == ',')
11883 {
11884 ++p;
11885 break;
11886 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011887 if (p[0] == '\\' && p[1] != NUL)
11888 ++p;
11889#ifdef FEAT_MBYTE
11890 from = (*mb_ptr2char)(p);
11891#else
11892 from = p[0];
11893#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011894 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011895 if (p2 == NULL)
11896 {
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011897 MB_PTR_ADV(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011898 if (p[0] != ',')
11899 {
11900 if (p[0] == '\\')
11901 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011902#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011903 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011904#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011905 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011906#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011907 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011908 }
11909 else
11910 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011911 if (p2[0] != ',')
11912 {
11913 if (p2[0] == '\\')
11914 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011915#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011916 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011917#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011918 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011919#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011920 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011921 }
11922 if (to == NUL)
11923 {
11924 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
11925 transchar(from));
11926 return;
11927 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011928
11929#ifdef FEAT_MBYTE
11930 if (from >= 256)
11931 langmap_set_entry(from, to);
11932 else
11933#endif
11934 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011935
11936 /* Advance to next pair */
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011937 MB_PTR_ADV(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011938 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011939 {
Bram Moolenaar91acfff2017-03-12 19:22:36 +010011940 MB_PTR_ADV(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011941 if (*p == ';')
11942 {
11943 p = p2;
11944 if (p[0] != NUL)
11945 {
11946 if (p[0] != ',')
11947 {
11948 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
11949 return;
11950 }
11951 ++p;
11952 }
11953 break;
11954 }
11955 }
11956 }
11957 }
11958}
11959#endif
11960
11961/*
11962 * Return TRUE if format option 'x' is in effect.
11963 * Take care of no formatting when 'paste' is set.
11964 */
11965 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011966has_format_option(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011967{
11968 if (p_paste)
11969 return FALSE;
11970 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
11971}
11972
11973/*
11974 * Return TRUE if "x" is present in 'shortmess' option, or
11975 * 'shortmess' contains 'a' and "x" is present in SHM_A.
11976 */
11977 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010011978shortmess(int x)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011979{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010011980 return p_shm != NULL &&
11981 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000011982 || (vim_strchr(p_shm, 'a') != NULL
11983 && vim_strchr((char_u *)SHM_A, x) != NULL));
11984}
11985
11986/*
11987 * paste_option_changed() - Called after p_paste was set or reset.
11988 */
11989 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010011990paste_option_changed(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011991{
11992 static int old_p_paste = FALSE;
11993 static int save_sm = 0;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020011994 static int save_sta = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011995#ifdef FEAT_CMDL_INFO
11996 static int save_ru = 0;
11997#endif
11998#ifdef FEAT_RIGHTLEFT
11999 static int save_ri = 0;
12000 static int save_hkmap = 0;
12001#endif
12002 buf_T *buf;
12003
12004 if (p_paste)
12005 {
12006 /*
12007 * Paste switched from off to on.
12008 * Save the current values, so they can be restored later.
12009 */
12010 if (!old_p_paste)
12011 {
12012 /* save options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012013 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012014 {
12015 buf->b_p_tw_nopaste = buf->b_p_tw;
12016 buf->b_p_wm_nopaste = buf->b_p_wm;
12017 buf->b_p_sts_nopaste = buf->b_p_sts;
12018 buf->b_p_ai_nopaste = buf->b_p_ai;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012019 buf->b_p_et_nopaste = buf->b_p_et;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012020 }
12021
12022 /* save global options */
12023 save_sm = p_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012024 save_sta = p_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012025#ifdef FEAT_CMDL_INFO
12026 save_ru = p_ru;
12027#endif
12028#ifdef FEAT_RIGHTLEFT
12029 save_ri = p_ri;
12030 save_hkmap = p_hkmap;
12031#endif
12032 /* save global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012033 p_ai_nopaste = p_ai;
12034 p_et_nopaste = p_et;
12035 p_sts_nopaste = p_sts;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012036 p_tw_nopaste = p_tw;
12037 p_wm_nopaste = p_wm;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012038 }
12039
12040 /*
12041 * Always set the option values, also when 'paste' is set when it is
12042 * already on.
12043 */
12044 /* set options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012045 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012046 {
12047 buf->b_p_tw = 0; /* textwidth is 0 */
12048 buf->b_p_wm = 0; /* wrapmargin is 0 */
12049 buf->b_p_sts = 0; /* softtabstop is 0 */
12050 buf->b_p_ai = 0; /* no auto-indent */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012051 buf->b_p_et = 0; /* no expandtab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012052 }
12053
12054 /* set global options */
12055 p_sm = 0; /* no showmatch */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012056 p_sta = 0; /* no smarttab */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012057#ifdef FEAT_CMDL_INFO
12058# ifdef FEAT_WINDOWS
12059 if (p_ru)
12060 status_redraw_all(); /* redraw to remove the ruler */
12061# endif
12062 p_ru = 0; /* no ruler */
12063#endif
12064#ifdef FEAT_RIGHTLEFT
12065 p_ri = 0; /* no reverse insert */
12066 p_hkmap = 0; /* no Hebrew keyboard */
12067#endif
12068 /* set global values for local buffer options */
12069 p_tw = 0;
12070 p_wm = 0;
12071 p_sts = 0;
12072 p_ai = 0;
12073 }
12074
12075 /*
12076 * Paste switched from on to off: Restore saved values.
12077 */
12078 else if (old_p_paste)
12079 {
12080 /* restore options for each buffer */
Bram Moolenaar29323592016-07-24 22:04:11 +020012081 FOR_ALL_BUFFERS(buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012082 {
12083 buf->b_p_tw = buf->b_p_tw_nopaste;
12084 buf->b_p_wm = buf->b_p_wm_nopaste;
12085 buf->b_p_sts = buf->b_p_sts_nopaste;
12086 buf->b_p_ai = buf->b_p_ai_nopaste;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012087 buf->b_p_et = buf->b_p_et_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012088 }
12089
12090 /* restore global options */
12091 p_sm = save_sm;
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012092 p_sta = save_sta;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012093#ifdef FEAT_CMDL_INFO
12094# ifdef FEAT_WINDOWS
12095 if (p_ru != save_ru)
12096 status_redraw_all(); /* redraw to draw the ruler */
12097# endif
12098 p_ru = save_ru;
12099#endif
12100#ifdef FEAT_RIGHTLEFT
12101 p_ri = save_ri;
12102 p_hkmap = save_hkmap;
12103#endif
12104 /* set global values for local buffer options */
Bram Moolenaar54f018c2015-09-15 17:30:40 +020012105 p_ai = p_ai_nopaste;
12106 p_et = p_et_nopaste;
12107 p_sts = p_sts_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012108 p_tw = p_tw_nopaste;
12109 p_wm = p_wm_nopaste;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012110 }
12111
12112 old_p_paste = p_paste;
12113}
12114
12115/*
12116 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
12117 *
12118 * Reset 'compatible' and set the values for options that didn't get set yet
12119 * to the Vim defaults.
12120 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012121 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012122 */
12123 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012124vimrc_found(char_u *fname, char_u *envname)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012125{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012126 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000012127 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012128 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012129
12130 if (!option_was_set((char_u *)"cp"))
12131 {
12132 p_cp = FALSE;
12133 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12134 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
12135 set_option_default(opt_idx, OPT_FREE, FALSE);
12136 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020012137 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000012138 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000012139
12140 if (fname != NULL)
12141 {
12142 p = vim_getenv(envname, &dofree);
12143 if (p == NULL)
12144 {
12145 /* Set $MYVIMRC to the first vimrc file found. */
12146 p = FullName_save(fname, FALSE);
12147 if (p != NULL)
12148 {
12149 vim_setenv(envname, p);
12150 vim_free(p);
12151 }
12152 }
12153 else if (dofree)
12154 vim_free(p);
12155 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000012156}
12157
12158/*
12159 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
12160 */
12161 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012162change_compatible(int on)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012163{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000012164 int opt_idx;
12165
Bram Moolenaar071d4272004-06-13 20:20:40 +000012166 if (p_cp != on)
12167 {
12168 p_cp = on;
12169 compatible_set();
12170 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000012171 opt_idx = findoption((char_u *)"cp");
12172 if (opt_idx >= 0)
12173 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012174}
12175
12176/*
12177 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020012178 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012179 */
12180 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012181option_was_set(char_u *name)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012182{
12183 int idx;
12184
12185 idx = findoption(name);
12186 if (idx < 0) /* unknown option */
12187 return FALSE;
12188 if (options[idx].flags & P_WAS_SET)
12189 return TRUE;
12190 return FALSE;
12191}
12192
12193/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012194 * Reset the flag indicating option "name" was set.
12195 */
12196 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012197reset_option_was_set(char_u *name)
Bram Moolenaar15d55de2012-12-05 14:43:02 +010012198{
12199 int idx = findoption(name);
12200
12201 if (idx >= 0)
12202 options[idx].flags &= ~P_WAS_SET;
12203}
12204
12205/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000012206 * compatible_set() - Called when 'compatible' has been set or unset.
12207 *
12208 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
12209 * flag) to a Vi compatible value.
12210 * When 'compatible' is unset: Set all options that have a different default
12211 * for Vim (without the P_VI_DEF flag) to that default.
12212 */
12213 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012214compatible_set(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012215{
12216 int opt_idx;
12217
12218 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12219 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
12220 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
12221 set_option_default(opt_idx, OPT_FREE, p_cp);
12222 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020012223 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000012224}
12225
12226#ifdef FEAT_LINEBREAK
12227
12228# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
12229 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012230 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012231# endif
12232
12233/*
12234 * fill_breakat_flags() -- called when 'breakat' changes value.
12235 */
12236 static void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012237fill_breakat_flags(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012238{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000012239 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012240 int i;
12241
12242 for (i = 0; i < 256; i++)
12243 breakat_flags[i] = FALSE;
12244
12245 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000012246 for (p = p_breakat; *p; p++)
12247 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012248}
12249
12250# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000012251 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000012252# endif
12253
12254#endif
12255
12256/*
12257 * Check an option that can be a range of string values.
12258 *
12259 * Return OK for correct value, FAIL otherwise.
12260 * Empty is always OK.
12261 */
12262 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012263check_opt_strings(
12264 char_u *val,
12265 char **values,
12266 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012267{
12268 return opt_strings_flags(val, values, NULL, list);
12269}
12270
12271/*
12272 * Handle an option that can be a range of string values.
12273 * Set a flag in "*flagp" for each string present.
12274 *
12275 * Return OK for correct value, FAIL otherwise.
12276 * Empty is always OK.
12277 */
12278 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012279opt_strings_flags(
12280 char_u *val, /* new value */
12281 char **values, /* array of valid string values */
12282 unsigned *flagp,
12283 int list) /* when TRUE: accept a list of values */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012284{
12285 int i;
12286 int len;
12287 unsigned new_flags = 0;
12288
12289 while (*val)
12290 {
12291 for (i = 0; ; ++i)
12292 {
12293 if (values[i] == NULL) /* val not found in values[] */
12294 return FAIL;
12295
12296 len = (int)STRLEN(values[i]);
12297 if (STRNCMP(values[i], val, len) == 0
12298 && ((list && val[len] == ',') || val[len] == NUL))
12299 {
12300 val += len + (val[len] == ',');
12301 new_flags |= (1 << i);
12302 break; /* check next item in val list */
12303 }
12304 }
12305 }
12306 if (flagp != NULL)
12307 *flagp = new_flags;
12308
12309 return OK;
12310}
12311
12312/*
12313 * Read the 'wildmode' option, fill wim_flags[].
12314 */
12315 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012316check_opt_wim(void)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012317{
12318 char_u new_wim_flags[4];
12319 char_u *p;
12320 int i;
12321 int idx = 0;
12322
12323 for (i = 0; i < 4; ++i)
12324 new_wim_flags[i] = 0;
12325
12326 for (p = p_wim; *p; ++p)
12327 {
12328 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
12329 ;
12330 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
12331 return FAIL;
12332 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
12333 new_wim_flags[idx] |= WIM_LONGEST;
12334 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
12335 new_wim_flags[idx] |= WIM_FULL;
12336 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
12337 new_wim_flags[idx] |= WIM_LIST;
12338 else
12339 return FAIL;
12340 p += i;
12341 if (*p == NUL)
12342 break;
12343 if (*p == ',')
12344 {
12345 if (idx == 3)
12346 return FAIL;
12347 ++idx;
12348 }
12349 }
12350
12351 /* fill remaining entries with last flag */
12352 while (idx < 3)
12353 {
12354 new_wim_flags[idx + 1] = new_wim_flags[idx];
12355 ++idx;
12356 }
12357
12358 /* only when there are no errors, wim_flags[] is changed */
12359 for (i = 0; i < 4; ++i)
12360 wim_flags[i] = new_wim_flags[i];
12361 return OK;
12362}
12363
12364/*
12365 * Check if backspacing over something is allowed.
12366 */
12367 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012368can_bs(
12369 int what) /* BS_INDENT, BS_EOL or BS_START */
Bram Moolenaar071d4272004-06-13 20:20:40 +000012370{
12371 switch (*p_bs)
12372 {
12373 case '2': return TRUE;
12374 case '1': return (what != BS_START);
12375 case '0': return FALSE;
12376 }
12377 return vim_strchr(p_bs, what) != NULL;
12378}
12379
12380/*
12381 * Save the current values of 'fileformat' and 'fileencoding', so that we know
12382 * the file must be considered changed when the value is different.
12383 */
12384 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012385save_file_ff(buf_T *buf)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012386{
12387 buf->b_start_ffc = *buf->b_p_ff;
12388 buf->b_start_eol = buf->b_p_eol;
12389#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012390 buf->b_start_bomb = buf->b_p_bomb;
12391
Bram Moolenaar071d4272004-06-13 20:20:40 +000012392 /* Only use free/alloc when necessary, they take time. */
12393 if (buf->b_start_fenc == NULL
12394 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
12395 {
12396 vim_free(buf->b_start_fenc);
12397 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
12398 }
12399#endif
12400}
12401
12402/*
12403 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
12404 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012405 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
12406 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012407 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012408 * When "ignore_empty" is true don't consider a new, empty buffer to be
12409 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012410 */
12411 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012412file_ff_differs(buf_T *buf, int ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012413{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012414 /* In a buffer that was never loaded the options are not valid. */
12415 if (buf->b_flags & BF_NEVERLOADED)
12416 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012417 if (ignore_empty
12418 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012419 && buf->b_ml.ml_line_count == 1
12420 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12421 return FALSE;
12422 if (buf->b_start_ffc != *buf->b_p_ff)
12423 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012424 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012425 return TRUE;
12426#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012427 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12428 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012429 if (buf->b_start_fenc == NULL)
12430 return (*buf->b_p_fenc != NUL);
12431 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12432#else
12433 return FALSE;
12434#endif
12435}
12436
12437/*
12438 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12439 */
12440 int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012441check_ff_value(char_u *p)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012442{
12443 return check_opt_strings(p, p_ff_values, FALSE);
12444}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012445
12446/*
12447 * Return the effective shiftwidth value for current buffer, using the
12448 * 'tabstop' value when 'shiftwidth' is zero.
12449 */
12450 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012451get_sw_value(buf_T *buf)
Bram Moolenaar14f24742012-08-08 18:01:05 +020012452{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012453 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012454}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012455
12456/*
12457 * Return the effective softtabstop value for the current buffer, using the
12458 * 'tabstop' value when 'softtabstop' is negative.
12459 */
12460 long
Bram Moolenaar9b578142016-01-30 19:39:49 +010012461get_sts_value(void)
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012462{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012463 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012464}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012465
12466/*
12467 * Check matchpairs option for "*initc".
12468 * If there is a match set "*initc" to the matching character and "*findc" to
12469 * the opposite character. Set "*backwards" to the direction.
12470 * When "switchit" is TRUE swap the direction.
12471 */
12472 void
Bram Moolenaar9b578142016-01-30 19:39:49 +010012473find_mps_values(
12474 int *initc,
12475 int *findc,
12476 int *backwards,
12477 int switchit)
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012478{
12479 char_u *ptr;
12480
12481 ptr = curbuf->b_p_mps;
12482 while (*ptr != NUL)
12483 {
12484#ifdef FEAT_MBYTE
12485 if (has_mbyte)
12486 {
12487 char_u *prev;
12488
12489 if (mb_ptr2char(ptr) == *initc)
12490 {
12491 if (switchit)
12492 {
12493 *findc = *initc;
12494 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12495 *backwards = TRUE;
12496 }
12497 else
12498 {
12499 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12500 *backwards = FALSE;
12501 }
12502 return;
12503 }
12504 prev = ptr;
12505 ptr += mb_ptr2len(ptr) + 1;
12506 if (mb_ptr2char(ptr) == *initc)
12507 {
12508 if (switchit)
12509 {
12510 *findc = *initc;
12511 *initc = mb_ptr2char(prev);
12512 *backwards = FALSE;
12513 }
12514 else
12515 {
12516 *findc = mb_ptr2char(prev);
12517 *backwards = TRUE;
12518 }
12519 return;
12520 }
12521 ptr += mb_ptr2len(ptr);
12522 }
12523 else
12524#endif
12525 {
12526 if (*ptr == *initc)
12527 {
12528 if (switchit)
12529 {
12530 *backwards = TRUE;
12531 *findc = *initc;
12532 *initc = ptr[2];
12533 }
12534 else
12535 {
12536 *backwards = FALSE;
12537 *findc = ptr[2];
12538 }
12539 return;
12540 }
12541 ptr += 2;
12542 if (*ptr == *initc)
12543 {
12544 if (switchit)
12545 {
12546 *backwards = FALSE;
12547 *findc = *initc;
12548 *initc = ptr[-2];
12549 }
12550 else
12551 {
12552 *backwards = TRUE;
12553 *findc = ptr[-2];
12554 }
12555 return;
12556 }
12557 ++ptr;
12558 }
12559 if (*ptr == ',')
12560 ++ptr;
12561 }
12562}
Bram Moolenaar597a4222014-06-25 14:39:50 +020012563
12564#if defined(FEAT_LINEBREAK) || defined(PROTO)
12565/*
12566 * This is called when 'breakindentopt' is changed and when a window is
12567 * initialized.
12568 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012569 static int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012570briopt_check(win_T *wp)
Bram Moolenaar597a4222014-06-25 14:39:50 +020012571{
12572 char_u *p;
12573 int bri_shift = 0;
12574 long bri_min = 20;
12575 int bri_sbr = FALSE;
12576
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012577 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012578 while (*p != NUL)
12579 {
12580 if (STRNCMP(p, "shift:", 6) == 0
12581 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
12582 {
12583 p += 6;
12584 bri_shift = getdigits(&p);
12585 }
12586 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
12587 {
12588 p += 4;
12589 bri_min = getdigits(&p);
12590 }
12591 else if (STRNCMP(p, "sbr", 3) == 0)
12592 {
12593 p += 3;
12594 bri_sbr = TRUE;
12595 }
12596 if (*p != ',' && *p != NUL)
12597 return FAIL;
12598 if (*p == ',')
12599 ++p;
12600 }
12601
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012602 wp->w_p_brishift = bri_shift;
12603 wp->w_p_brimin = bri_min;
12604 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012605
12606 return OK;
12607}
12608#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012609
12610/*
12611 * Get the local or global value of 'backupcopy'.
12612 */
12613 unsigned int
Bram Moolenaar9b578142016-01-30 19:39:49 +010012614get_bkc_value(buf_T *buf)
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012615{
12616 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
12617}
Bram Moolenaar95ec9d62016-08-12 18:29:59 +020012618
12619#if defined(FEAT_SIGNS) || defined(PROTO)
12620/*
12621 * Return TRUE when window "wp" has a column to draw signs in.
12622 */
12623 int
12624signcolumn_on(win_T *wp)
12625{
12626 if (*wp->w_p_scl == 'n')
12627 return FALSE;
12628 if (*wp->w_p_scl == 'y')
12629 return TRUE;
12630 return (wp->w_buffer->b_signlist != NULL
12631# ifdef FEAT_NETBEANS_INTG
12632 || wp->w_buffer->b_has_sign_column
12633# endif
12634 );
12635}
12636#endif
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012637
12638#if defined(FEAT_EVAL) || defined(PROTO)
12639/*
12640 * Get window or buffer local options.
12641 */
12642 dict_T *
12643get_winbuf_options(int bufopt)
12644{
12645 dict_T *d;
12646 int opt_idx;
12647
12648 d = dict_alloc();
12649 if (d == NULL)
12650 return NULL;
12651
12652 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
12653 {
12654 struct vimoption *opt = &options[opt_idx];
12655
12656 if ((bufopt && (opt->indir & PV_BUF))
12657 || (!bufopt && (opt->indir & PV_WIN)))
12658 {
12659 char_u *varp = get_varp(opt);
12660
12661 if (varp != NULL)
12662 {
12663 if (opt->flags & P_STRING)
12664 dict_add_nr_str(d, opt->fullname, 0L, *(char_u **)varp);
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012665 else if (opt->flags & P_NUM)
12666 dict_add_nr_str(d, opt->fullname, *(long *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012667 else
Bram Moolenaar789a5c02016-09-12 19:51:11 +020012668 dict_add_nr_str(d, opt->fullname, *(int *)varp, NULL);
Bram Moolenaarb5ae48e2016-08-12 22:23:25 +020012669 }
12670 }
12671 }
12672
12673 return d;
12674}
12675#endif