blob: c51d082498d97bc40053f45e2584f2687088148a [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001/* vi:set ts=8 sts=4 sw=4:
2 *
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.
25 * - Add documentation! One line in doc/help.txt, full description in
26 * options.txt, and any other related places.
27 * - Add an entry in runtime/optwin.vim.
28 * When making changes:
29 * - Adjust the help for the option in doc/option.txt.
30 * - When an entry has the P_VIM flag, or is lacking the P_VI_DEF flag, add a
31 * comment at the help for the 'compatible' option.
32 */
33
34#define IN_OPTION_C
35#include "vim.h"
36
37/*
38 * The options that are local to a window or buffer have "indir" set to one of
39 * these values. Special values:
40 * PV_NONE: global option.
Bram Moolenaara23ccb82006-02-27 00:08:02 +000041 * PV_WIN is added: window-local option
42 * PV_BUF is added: buffer-local option
Bram Moolenaar071d4272004-06-13 20:20:40 +000043 * PV_BOTH is added: global option which also has a local value.
44 */
45#define PV_BOTH 0x1000
Bram Moolenaara23ccb82006-02-27 00:08:02 +000046#define PV_WIN 0x2000
47#define PV_BUF 0x4000
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000048#define PV_MASK 0x0fff
Bram Moolenaara23ccb82006-02-27 00:08:02 +000049#define OPT_WIN(x) (idopt_T)(PV_WIN + (int)(x))
50#define OPT_BUF(x) (idopt_T)(PV_BUF + (int)(x))
Bram Moolenaar071d4272004-06-13 20:20:40 +000051#define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x))
52
Bram Moolenaara23ccb82006-02-27 00:08:02 +000053/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000054 * Definition of the PV_ values for buffer-local options.
55 * The BV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +000056 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +000057#define PV_AI OPT_BUF(BV_AI)
58#define PV_AR OPT_BOTH(OPT_BUF(BV_AR))
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020059#define PV_BKC OPT_BOTH(OPT_BUF(BV_BKC))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000060#ifdef FEAT_QUICKFIX
Bram Moolenaara23ccb82006-02-27 00:08:02 +000061# define PV_BH OPT_BUF(BV_BH)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000062# define PV_BT OPT_BUF(BV_BT)
63# define PV_EFM OPT_BOTH(OPT_BUF(BV_EFM))
64# define PV_GP OPT_BOTH(OPT_BUF(BV_GP))
65# define PV_MP OPT_BOTH(OPT_BUF(BV_MP))
Bram Moolenaara23ccb82006-02-27 00:08:02 +000066#endif
67#define PV_BIN OPT_BUF(BV_BIN)
68#define PV_BL OPT_BUF(BV_BL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000069#ifdef FEAT_MBYTE
70# define PV_BOMB OPT_BUF(BV_BOMB)
71#endif
72#define PV_CI OPT_BUF(BV_CI)
73#ifdef FEAT_CINDENT
74# define PV_CIN OPT_BUF(BV_CIN)
75# define PV_CINK OPT_BUF(BV_CINK)
76# define PV_CINO OPT_BUF(BV_CINO)
77#endif
78#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
79# define PV_CINW OPT_BUF(BV_CINW)
80#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020081#define PV_CM OPT_BOTH(OPT_BUF(BV_CM))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000082#ifdef FEAT_FOLDING
83# define PV_CMS OPT_BUF(BV_CMS)
84#endif
85#ifdef FEAT_COMMENTS
86# define PV_COM OPT_BUF(BV_COM)
87#endif
88#ifdef FEAT_INS_EXPAND
89# define PV_CPT OPT_BUF(BV_CPT)
90# define PV_DICT OPT_BOTH(OPT_BUF(BV_DICT))
91# define PV_TSR OPT_BOTH(OPT_BUF(BV_TSR))
92#endif
93#ifdef FEAT_COMPL_FUNC
94# define PV_CFU OPT_BUF(BV_CFU)
95#endif
96#ifdef FEAT_FIND_ID
97# define PV_DEF OPT_BOTH(OPT_BUF(BV_DEF))
98# define PV_INC OPT_BOTH(OPT_BUF(BV_INC))
99#endif
100#define PV_EOL OPT_BUF(BV_EOL)
Bram Moolenaar34d72d42015-07-17 14:18:08 +0200101#define PV_FIXEOL OPT_BUF(BV_FIXEOL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000102#define PV_EP OPT_BOTH(OPT_BUF(BV_EP))
103#define PV_ET OPT_BUF(BV_ET)
104#ifdef FEAT_MBYTE
105# define PV_FENC OPT_BUF(BV_FENC)
106#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000107#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
108# define PV_BEXPR OPT_BOTH(OPT_BUF(BV_BEXPR))
109#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000110#ifdef FEAT_EVAL
111# define PV_FEX OPT_BUF(BV_FEX)
112#endif
113#define PV_FF OPT_BUF(BV_FF)
114#define PV_FLP OPT_BUF(BV_FLP)
115#define PV_FO OPT_BUF(BV_FO)
116#ifdef FEAT_AUTOCMD
117# define PV_FT OPT_BUF(BV_FT)
118#endif
119#define PV_IMI OPT_BUF(BV_IMI)
120#define PV_IMS OPT_BUF(BV_IMS)
121#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
122# define PV_INDE OPT_BUF(BV_INDE)
123# define PV_INDK OPT_BUF(BV_INDK)
124#endif
125#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
126# define PV_INEX OPT_BUF(BV_INEX)
127#endif
128#define PV_INF OPT_BUF(BV_INF)
129#define PV_ISK OPT_BUF(BV_ISK)
130#ifdef FEAT_CRYPT
131# define PV_KEY OPT_BUF(BV_KEY)
132#endif
133#ifdef FEAT_KEYMAP
134# define PV_KMAP OPT_BUF(BV_KMAP)
135#endif
136#define PV_KP OPT_BOTH(OPT_BUF(BV_KP))
137#ifdef FEAT_LISP
138# define PV_LISP OPT_BUF(BV_LISP)
Bram Moolenaaraf6c1312014-03-12 18:55:58 +0100139# define PV_LW OPT_BOTH(OPT_BUF(BV_LW))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000140#endif
141#define PV_MA OPT_BUF(BV_MA)
142#define PV_ML OPT_BUF(BV_ML)
143#define PV_MOD OPT_BUF(BV_MOD)
144#define PV_MPS OPT_BUF(BV_MPS)
145#define PV_NF OPT_BUF(BV_NF)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000146#ifdef FEAT_COMPL_FUNC
147# define PV_OFU OPT_BUF(BV_OFU)
148#endif
149#define PV_PATH OPT_BOTH(OPT_BUF(BV_PATH))
150#define PV_PI OPT_BUF(BV_PI)
151#ifdef FEAT_TEXTOBJ
152# define PV_QE OPT_BUF(BV_QE)
153#endif
154#define PV_RO OPT_BUF(BV_RO)
155#ifdef FEAT_SMARTINDENT
156# define PV_SI OPT_BUF(BV_SI)
157#endif
158#ifndef SHORT_FNAME
159# define PV_SN OPT_BUF(BV_SN)
160#endif
161#ifdef FEAT_SYN_HL
162# define PV_SMC OPT_BUF(BV_SMC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000163# define PV_SYN OPT_BUF(BV_SYN)
164#endif
165#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000166# define PV_SPC OPT_BUF(BV_SPC)
167# define PV_SPF OPT_BUF(BV_SPF)
168# define PV_SPL OPT_BUF(BV_SPL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000169#endif
170#define PV_STS OPT_BUF(BV_STS)
171#ifdef FEAT_SEARCHPATH
172# define PV_SUA OPT_BUF(BV_SUA)
173#endif
174#define PV_SW OPT_BUF(BV_SW)
175#define PV_SWF OPT_BUF(BV_SWF)
176#define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS))
177#define PV_TS OPT_BUF(BV_TS)
178#define PV_TW OPT_BUF(BV_TW)
179#define PV_TX OPT_BUF(BV_TX)
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200180#ifdef FEAT_PERSISTENT_UNDO
181# define PV_UDF OPT_BUF(BV_UDF)
182#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000183#define PV_WM OPT_BUF(BV_WM)
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000184
185/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000186 * Definition of the PV_ values for window-local options.
187 * The WV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000188 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000189#define PV_LIST OPT_WIN(WV_LIST)
190#ifdef FEAT_ARABIC
191# define PV_ARAB OPT_WIN(WV_ARAB)
192#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +0200193#ifdef FEAT_LINEBREAK
194# define PV_BRI OPT_WIN(WV_BRI)
195# define PV_BRIOPT OPT_WIN(WV_BRIOPT)
196#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000197#ifdef FEAT_DIFF
198# define PV_DIFF OPT_WIN(WV_DIFF)
199#endif
200#ifdef FEAT_FOLDING
201# define PV_FDC OPT_WIN(WV_FDC)
202# define PV_FEN OPT_WIN(WV_FEN)
203# define PV_FDI OPT_WIN(WV_FDI)
204# define PV_FDL OPT_WIN(WV_FDL)
205# define PV_FDM OPT_WIN(WV_FDM)
206# define PV_FML OPT_WIN(WV_FML)
207# define PV_FDN OPT_WIN(WV_FDN)
208# ifdef FEAT_EVAL
209# define PV_FDE OPT_WIN(WV_FDE)
210# define PV_FDT OPT_WIN(WV_FDT)
211# endif
212# define PV_FMR OPT_WIN(WV_FMR)
213#endif
214#ifdef FEAT_LINEBREAK
215# define PV_LBR OPT_WIN(WV_LBR)
216#endif
217#define PV_NU OPT_WIN(WV_NU)
Bram Moolenaar64486672010-05-16 15:46:46 +0200218#define PV_RNU OPT_WIN(WV_RNU)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000219#ifdef FEAT_LINEBREAK
220# define PV_NUW OPT_WIN(WV_NUW)
221#endif
222#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
223# define PV_PVW OPT_WIN(WV_PVW)
224#endif
225#ifdef FEAT_RIGHTLEFT
226# define PV_RL OPT_WIN(WV_RL)
227# define PV_RLC OPT_WIN(WV_RLC)
228#endif
229#ifdef FEAT_SCROLLBIND
230# define PV_SCBIND OPT_WIN(WV_SCBIND)
231#endif
232#define PV_SCROLL OPT_WIN(WV_SCROLL)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000233#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000234# define PV_SPELL OPT_WIN(WV_SPELL)
235#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000236#ifdef FEAT_SYN_HL
237# define PV_CUC OPT_WIN(WV_CUC)
238# define PV_CUL OPT_WIN(WV_CUL)
Bram Moolenaar1a384422010-07-14 19:53:30 +0200239# define PV_CC OPT_WIN(WV_CC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000240#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000241#ifdef FEAT_STL_OPT
242# define PV_STL OPT_BOTH(OPT_WIN(WV_STL))
243#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +0100244#define PV_UL OPT_BOTH(OPT_BUF(BV_UL))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000245#ifdef FEAT_WINDOWS
246# define PV_WFH OPT_WIN(WV_WFH)
247#endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +0000248#ifdef FEAT_VERTSPLIT
249# define PV_WFW OPT_WIN(WV_WFW)
250#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000251#define PV_WRAP OPT_WIN(WV_WRAP)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200252#ifdef FEAT_CURSORBIND
253# define PV_CRBIND OPT_WIN(WV_CRBIND)
254#endif
255#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200256# define PV_COCU OPT_WIN(WV_COCU)
257# define PV_COLE OPT_WIN(WV_COLE)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200258#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000259
260/* WV_ and BV_ values get typecasted to this for the "indir" field */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000261typedef enum
262{
Bram Moolenaar7d96acd2008-06-09 15:07:54 +0000263 PV_NONE = 0,
264 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000265} idopt_T;
266
267/*
268 * Options local to a window have a value local to a buffer and global to all
269 * buffers. Indicate this by setting "var" to VAR_WIN.
270 */
271#define VAR_WIN ((char_u *)-1)
272
273/*
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000274 * These are the global values for options which are also local to a buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000275 * Only to be used in option.c!
276 */
277static int p_ai;
278static int p_bin;
279#ifdef FEAT_MBYTE
280static int p_bomb;
281#endif
282#if defined(FEAT_QUICKFIX)
283static char_u *p_bh;
284static char_u *p_bt;
285#endif
286static int p_bl;
287static int p_ci;
288#ifdef FEAT_CINDENT
289static int p_cin;
290static char_u *p_cink;
291static char_u *p_cino;
292#endif
293#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
294static char_u *p_cinw;
295#endif
296#ifdef FEAT_COMMENTS
297static char_u *p_com;
298#endif
299#ifdef FEAT_FOLDING
300static char_u *p_cms;
301#endif
302#ifdef FEAT_INS_EXPAND
303static char_u *p_cpt;
304#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000305#ifdef FEAT_COMPL_FUNC
306static char_u *p_cfu;
Bram Moolenaare344bea2005-09-01 20:46:49 +0000307static char_u *p_ofu;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000308#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000309static int p_eol;
Bram Moolenaar34d72d42015-07-17 14:18:08 +0200310static int p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000311static int p_et;
312#ifdef FEAT_MBYTE
313static char_u *p_fenc;
314#endif
315static char_u *p_ff;
316static char_u *p_fo;
Bram Moolenaar86b68352004-12-27 21:59:20 +0000317static char_u *p_flp;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000318#ifdef FEAT_AUTOCMD
319static char_u *p_ft;
320#endif
321static long p_iminsert;
322static long p_imsearch;
323#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
324static char_u *p_inex;
325#endif
326#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
327static char_u *p_inde;
328static char_u *p_indk;
329#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +0000330#if defined(FEAT_EVAL)
331static char_u *p_fex;
332#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000333static int p_inf;
334static char_u *p_isk;
335#ifdef FEAT_CRYPT
336static char_u *p_key;
337#endif
338#ifdef FEAT_LISP
339static int p_lisp;
340#endif
341static int p_ml;
342static int p_ma;
343static int p_mod;
344static char_u *p_mps;
345static char_u *p_nf;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000346static int p_pi;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000347#ifdef FEAT_TEXTOBJ
348static char_u *p_qe;
349#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000350static int p_ro;
351#ifdef FEAT_SMARTINDENT
352static int p_si;
353#endif
354#ifndef SHORT_FNAME
355static int p_sn;
356#endif
357static long p_sts;
358#if defined(FEAT_SEARCHPATH)
359static char_u *p_sua;
360#endif
361static long p_sw;
362static int p_swf;
363#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +0000364static long p_smc;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000365static char_u *p_syn;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000366#endif
367#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000368static char_u *p_spc;
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000369static char_u *p_spf;
Bram Moolenaar217ad922005-03-20 22:37:15 +0000370static char_u *p_spl;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000371#endif
372static long p_ts;
373static long p_tw;
374static int p_tx;
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200375#ifdef FEAT_PERSISTENT_UNDO
376static int p_udf;
377#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000378static long p_wm;
379#ifdef FEAT_KEYMAP
380static char_u *p_keymap;
381#endif
382
383/* Saved values for when 'bin' is set. */
384static int p_et_nobin;
385static int p_ml_nobin;
386static long p_tw_nobin;
387static long p_wm_nobin;
388
389/* Saved values for when 'paste' is set */
390static long p_tw_nopaste;
391static long p_wm_nopaste;
392static long p_sts_nopaste;
393static int p_ai_nopaste;
394
395struct vimoption
396{
397 char *fullname; /* full option name */
398 char *shortname; /* permissible abbreviation */
399 long_u flags; /* see below */
400 char_u *var; /* global option: pointer to variable;
401 * window-local option: VAR_WIN;
402 * buffer-local option: global value */
403 idopt_T indir; /* global option: PV_NONE;
404 * local option: indirect option index */
405 char_u *def_val[2]; /* default values for variable (vi and vim) */
406#ifdef FEAT_EVAL
407 scid_T scriptID; /* script in which the option was last set */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000408# define SCRIPTID_INIT , 0
409#else
410# define SCRIPTID_INIT
Bram Moolenaar071d4272004-06-13 20:20:40 +0000411#endif
412};
413
414#define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */
415#define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */
416
417/*
418 * Flags
419 */
420#define P_BOOL 0x01 /* the option is boolean */
421#define P_NUM 0x02 /* the option is numeric */
422#define P_STRING 0x04 /* the option is a string */
423#define P_ALLOCED 0x08 /* the string option is in allocated memory,
Bram Moolenaar363cb672009-07-22 12:28:17 +0000424 must use free_string_option() when
425 assigning new value. Not set if default is
426 the same. */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000427#define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
428 never be used for local or hidden options! */
429#define P_NODEFAULT 0x40 /* don't set to default value */
430#define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must
431 use vim_free() when assigning new value */
432#define P_WAS_SET 0x100 /* option has been set/reset */
433#define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */
434#define P_VI_DEF 0x400 /* Use Vi default for Vim */
435#define P_VIM 0x800 /* Vim option, reset when 'cp' set */
436
437 /* when option changed, what to display: */
438#define P_RSTAT 0x1000 /* redraw status lines */
439#define P_RWIN 0x2000 /* redraw current window */
440#define P_RBUF 0x4000 /* redraw current buffer */
441#define P_RALL 0x6000 /* redraw all windows */
442#define P_RCLR 0x7000 /* clear and redraw all */
443
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200444#define P_COMMA 0x8000 /* comma separated list */
445#define P_ONECOMMA 0x18000L /* P_COMMA and cannot have two consecutive
446 * commas */
447#define P_NODUP 0x20000L /* don't allow duplicate strings */
448#define P_FLAGLIST 0x40000L /* list of single-char flags */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000449
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200450#define P_SECURE 0x80000L /* cannot change in modeline or secure mode */
451#define P_GETTEXT 0x100000L /* expand default value with _() */
452#define P_NOGLOB 0x200000L /* do not use local value for global vimrc */
453#define P_NFNAME 0x400000L /* only normal file name chars allowed */
454#define P_INSECURE 0x800000L /* option was set from a modeline */
455#define P_PRI_MKRC 0x1000000L /* priority for :mkvimrc (setting option has
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000456 side effects) */
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200457#define P_NO_ML 0x2000000L /* not allowed in modeline */
458#define P_CURSWANT 0x4000000L /* update curswant required; not needed when
Bram Moolenaar913077c2012-03-28 19:59:04 +0200459 * there is a redraw flag */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000460
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000461#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
462
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000463/* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used
464 * for the currency sign. */
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000465#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000466# define ISP_LATIN1 (char_u *)"@,~-255"
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000467#else
468# define ISP_LATIN1 (char_u *)"@,161-255"
469#endif
470
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000471/* The 16 bit MS-DOS version is low on space, make the string as short as
472 * possible when compiling with few features. */
473#if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
474 || defined(FEAT_VERTSPLIT) || defined(FEAT_CLIPBOARD) \
Bram Moolenaar860cae12010-06-05 23:22:07 +0200475 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) || defined(FEAT_CONCEAL)
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100476# 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,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 +0000477#else
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100478# 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 +0000479#endif
480
Bram Moolenaar071d4272004-06-13 20:20:40 +0000481/*
482 * options[] is initialized here.
483 * The order of the options MUST be alphabetic for ":set all" and findoption().
484 * All option names MUST start with a lowercase letter (for findoption()).
485 * Exception: "t_" options are at the end.
486 * The options with a NULL variable are 'hidden': a set command for them is
487 * ignored and they are not printed.
488 */
489static struct vimoption
490#ifdef FEAT_GUI_W16
491 _far
492#endif
493 options[] =
494{
Bram Moolenaar913077c2012-03-28 19:59:04 +0200495 {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000496#ifdef FEAT_RIGHTLEFT
497 (char_u *)&p_aleph, PV_NONE,
498#else
499 (char_u *)NULL, PV_NONE,
500#endif
501 {
502#if (defined(MSDOS) || defined(WIN3264) || defined(OS2)) && !defined(FEAT_GUI_W32)
503 (char_u *)128L,
504#else
505 (char_u *)224L,
506#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000507 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000508 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
509#if defined(FEAT_GUI) && defined(MACOS_X)
510 (char_u *)&p_antialias, PV_NONE,
511 {(char_u *)FALSE, (char_u *)FALSE}
512#else
513 (char_u *)NULL, PV_NONE,
514 {(char_u *)FALSE, (char_u *)FALSE}
515#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000516 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200517 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000518#ifdef FEAT_ARABIC
519 (char_u *)VAR_WIN, PV_ARAB,
520#else
521 (char_u *)NULL, PV_NONE,
522#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000523 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000524 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
525#ifdef FEAT_ARABIC
526 (char_u *)&p_arshape, PV_NONE,
527#else
528 (char_u *)NULL, PV_NONE,
529#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000530 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000531 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
532#ifdef FEAT_RIGHTLEFT
533 (char_u *)&p_ari, PV_NONE,
534#else
535 (char_u *)NULL, PV_NONE,
536#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000537 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000538 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
539#ifdef FEAT_FKMAP
540 (char_u *)&p_altkeymap, PV_NONE,
541#else
542 (char_u *)NULL, PV_NONE,
543#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000544 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000545 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
546#if defined(FEAT_MBYTE)
547 (char_u *)&p_ambw, PV_NONE,
548 {(char_u *)"single", (char_u *)0L}
549#else
550 (char_u *)NULL, PV_NONE,
551 {(char_u *)0L, (char_u *)0L}
552#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000553 SCRIPTID_INIT},
Bram Moolenaar8dff8182006-04-06 20:18:50 +0000554#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +0000555 {"autochdir", "acd", P_BOOL|P_VI_DEF,
556 (char_u *)&p_acd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000557 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000558#endif
559 {"autoindent", "ai", P_BOOL|P_VI_DEF,
560 (char_u *)&p_ai, PV_AI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000561 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000562 {"autoprint", "ap", P_BOOL|P_VI_DEF,
563 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000564 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000565 {"autoread", "ar", P_BOOL|P_VI_DEF,
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000566 (char_u *)&p_ar, PV_AR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000567 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000568 {"autowrite", "aw", P_BOOL|P_VI_DEF,
569 (char_u *)&p_aw, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000570 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000571 {"autowriteall","awa", P_BOOL|P_VI_DEF,
572 (char_u *)&p_awa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000573 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000574 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
575 (char_u *)&p_bg, PV_NONE,
576 {
577#if (defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI)
578 (char_u *)"dark",
579#else
580 (char_u *)"light",
581#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000582 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200583 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000584 (char_u *)&p_bs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000585 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000586 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
587 (char_u *)&p_bk, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000588 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200589 {"backupcopy", "bkc", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +0200590 (char_u *)&p_bkc, PV_BKC,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000591#ifdef UNIX
592 {(char_u *)"yes", (char_u *)"auto"}
593#else
594 {(char_u *)"auto", (char_u *)"auto"}
595#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000596 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200597 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
598 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000599 (char_u *)&p_bdir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000600 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000601 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000602 (char_u *)&p_bex, PV_NONE,
603 {
604#ifdef VMS
605 (char_u *)"_",
606#else
607 (char_u *)"~",
608#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000609 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200610 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000611#ifdef FEAT_WILDIGN
612 (char_u *)&p_bsk, PV_NONE,
613 {(char_u *)"", (char_u *)0L}
614#else
615 (char_u *)NULL, PV_NONE,
616 {(char_u *)0L, (char_u *)0L}
617#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000618 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000619#ifdef FEAT_BEVAL
620 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
621 (char_u *)&p_bdlay, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000622 {(char_u *)600L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000623 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
624 (char_u *)&p_beval, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000625 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000626# ifdef FEAT_EVAL
Bram Moolenaar39f05632006-03-19 22:15:26 +0000627 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000628 (char_u *)&p_bexpr, PV_BEXPR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000629 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000630# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000631#endif
632 {"beautify", "bf", P_BOOL|P_VI_DEF,
633 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000634 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000635 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
636 (char_u *)&p_bin, PV_BIN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000637 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000638 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
639#ifdef MSDOS
640 (char_u *)&p_biosk, PV_NONE,
641#else
642 (char_u *)NULL, PV_NONE,
643#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000644 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000645 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
646#ifdef FEAT_MBYTE
647 (char_u *)&p_bomb, PV_BOMB,
648#else
649 (char_u *)NULL, PV_NONE,
650#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000651 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000652 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
653#ifdef FEAT_LINEBREAK
654 (char_u *)&p_breakat, PV_NONE,
655 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
656#else
657 (char_u *)NULL, PV_NONE,
658 {(char_u *)0L, (char_u *)0L}
659#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000660 SCRIPTID_INIT},
Bram Moolenaar597a4222014-06-25 14:39:50 +0200661 {"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
662#ifdef FEAT_LINEBREAK
663 (char_u *)VAR_WIN, PV_BRI,
664 {(char_u *)FALSE, (char_u *)0L}
665#else
666 (char_u *)NULL, PV_NONE,
667 {(char_u *)0L, (char_u *)0L}
668#endif
669 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200670 {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF
671 |P_ONECOMMA|P_NODUP,
Bram Moolenaar597a4222014-06-25 14:39:50 +0200672#ifdef FEAT_LINEBREAK
673 (char_u *)VAR_WIN, PV_BRIOPT,
674 {(char_u *)"", (char_u *)NULL}
675#else
676 (char_u *)NULL, PV_NONE,
677 {(char_u *)"", (char_u *)NULL}
678#endif
679 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000680 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
681#ifdef FEAT_BROWSE
682 (char_u *)&p_bsdir, PV_NONE,
683 {(char_u *)"last", (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 Moolenaar071d4272004-06-13 20:20:40 +0000689 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
690#if defined(FEAT_QUICKFIX)
691 (char_u *)&p_bh, PV_BH,
692 {(char_u *)"", (char_u *)0L}
693#else
694 (char_u *)NULL, PV_NONE,
695 {(char_u *)0L, (char_u *)0L}
696#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000697 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000698 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
699 (char_u *)&p_bl, PV_BL,
700 {(char_u *)1L, (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000701 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000702 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
703#if defined(FEAT_QUICKFIX)
704 (char_u *)&p_bt, PV_BT,
705 {(char_u *)"", (char_u *)0L}
706#else
707 (char_u *)NULL, PV_NONE,
708 {(char_u *)0L, (char_u *)0L}
709#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000710 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200711 {"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000712#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000713 (char_u *)&p_cmp, PV_NONE,
714 {(char_u *)"internal,keepascii", (char_u *)0L}
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000715#else
716 (char_u *)NULL, PV_NONE,
717 {(char_u *)0L, (char_u *)0L}
718#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000719 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000720 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
721#ifdef FEAT_SEARCHPATH
722 (char_u *)&p_cdpath, PV_NONE,
723 {(char_u *)",,", (char_u *)0L}
724#else
725 (char_u *)NULL, PV_NONE,
726 {(char_u *)0L, (char_u *)0L}
727#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000728 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000729 {"cedit", NULL, P_STRING,
730#ifdef FEAT_CMDWIN
731 (char_u *)&p_cedit, PV_NONE,
732 {(char_u *)"", (char_u *)CTRL_F_STR}
733#else
734 (char_u *)NULL, PV_NONE,
735 {(char_u *)0L, (char_u *)0L}
736#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000737 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000738 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
739#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
740 (char_u *)&p_ccv, PV_NONE,
741 {(char_u *)"", (char_u *)0L}
742#else
743 (char_u *)NULL, PV_NONE,
744 {(char_u *)0L, (char_u *)0L}
745#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000746 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000747 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
748#ifdef FEAT_CINDENT
749 (char_u *)&p_cin, PV_CIN,
750#else
751 (char_u *)NULL, PV_NONE,
752#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000753 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200754 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000755#ifdef FEAT_CINDENT
756 (char_u *)&p_cink, PV_CINK,
757 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
758#else
759 (char_u *)NULL, PV_NONE,
760 {(char_u *)0L, (char_u *)0L}
761#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000762 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200763 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000764#ifdef FEAT_CINDENT
765 (char_u *)&p_cino, PV_CINO,
766#else
767 (char_u *)NULL, PV_NONE,
768#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000769 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200770 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000771#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
772 (char_u *)&p_cinw, PV_CINW,
773 {(char_u *)"if,else,while,do,for,switch",
774 (char_u *)0L}
775#else
776 (char_u *)NULL, PV_NONE,
777 {(char_u *)0L, (char_u *)0L}
778#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000779 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200780 {"clipboard", "cb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000781#ifdef FEAT_CLIPBOARD
782 (char_u *)&p_cb, PV_NONE,
783# ifdef FEAT_XCLIPBOARD
784 {(char_u *)"autoselect,exclude:cons\\|linux",
785 (char_u *)0L}
786# else
787 {(char_u *)"", (char_u *)0L}
788# endif
789#else
790 (char_u *)NULL, PV_NONE,
791 {(char_u *)"", (char_u *)0L}
792#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000793 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000794 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
795 (char_u *)&p_ch, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000796 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000797 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
798#ifdef FEAT_CMDWIN
799 (char_u *)&p_cwh, PV_NONE,
800#else
801 (char_u *)NULL, PV_NONE,
802#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000803 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200804 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar1a384422010-07-14 19:53:30 +0200805#ifdef FEAT_SYN_HL
806 (char_u *)VAR_WIN, PV_CC,
807#else
808 (char_u *)NULL, PV_NONE,
809#endif
810 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000811 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
812 (char_u *)&Columns, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000813 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200814 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
815 |P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000816#ifdef FEAT_COMMENTS
817 (char_u *)&p_com, PV_COM,
818 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
819 (char_u *)0L}
820#else
821 (char_u *)NULL, PV_NONE,
822 {(char_u *)0L, (char_u *)0L}
823#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000824 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200825 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000826#ifdef FEAT_FOLDING
827 (char_u *)&p_cms, PV_CMS,
828 {(char_u *)"/*%s*/", (char_u *)0L}
829#else
830 (char_u *)NULL, PV_NONE,
831 {(char_u *)0L, (char_u *)0L}
832#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000833 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000834 /* P_PRI_MKRC isn't needed here, optval_default()
835 * always returns TRUE for 'compatible' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000836 {"compatible", "cp", P_BOOL|P_RALL,
837 (char_u *)&p_cp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000838 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200839 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000840#ifdef FEAT_INS_EXPAND
841 (char_u *)&p_cpt, PV_CPT,
842 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
843#else
844 (char_u *)NULL, PV_NONE,
845 {(char_u *)0L, (char_u *)0L}
846#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000847 SCRIPTID_INIT},
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200848 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200849#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200850 (char_u *)VAR_WIN, PV_COCU,
851 {(char_u *)"", (char_u *)NULL}
852#else
853 (char_u *)NULL, PV_NONE,
854 {(char_u *)NULL, (char_u *)0L}
855#endif
856 SCRIPTID_INIT},
857 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
858#ifdef FEAT_CONCEAL
859 (char_u *)VAR_WIN, PV_COLE,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200860#else
861 (char_u *)NULL, PV_NONE,
862#endif
863 {(char_u *)0L, (char_u *)0L}
864 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000865 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
866#ifdef FEAT_COMPL_FUNC
867 (char_u *)&p_cfu, PV_CFU,
868 {(char_u *)"", (char_u *)0L}
869#else
870 (char_u *)NULL, PV_NONE,
871 {(char_u *)0L, (char_u *)0L}
872#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000873 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200874 {"completeopt", "cot", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000875#ifdef FEAT_INS_EXPAND
876 (char_u *)&p_cot, PV_NONE,
Bram Moolenaarc270d802006-03-11 21:29:41 +0000877 {(char_u *)"menu,preview", (char_u *)0L}
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000878#else
879 (char_u *)NULL, PV_NONE,
880 {(char_u *)0L, (char_u *)0L}
881#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000882 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000883 {"confirm", "cf", P_BOOL|P_VI_DEF,
884#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
885 (char_u *)&p_confirm, PV_NONE,
886#else
887 (char_u *)NULL, PV_NONE,
888#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000889 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000890 {"conskey", "consk",P_BOOL|P_VI_DEF,
891#ifdef MSDOS
892 (char_u *)&p_consk, PV_NONE,
893#else
894 (char_u *)NULL, PV_NONE,
895#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000896 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000897 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
898 (char_u *)&p_ci, PV_CI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000899 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000900 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
901 (char_u *)&p_cpo, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000902 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
903 SCRIPTID_INIT},
Bram Moolenaar49771f42010-07-20 17:32:38 +0200904 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200905#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200906 (char_u *)&p_cm, PV_CM,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200907 {(char_u *)"zip", (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200908#else
909 (char_u *)NULL, PV_NONE,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200910 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200911#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +0200912 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000913 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
914#ifdef FEAT_CSCOPE
915 (char_u *)&p_cspc, PV_NONE,
916#else
917 (char_u *)NULL, PV_NONE,
918#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000919 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000920 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
921#ifdef FEAT_CSCOPE
922 (char_u *)&p_csprg, PV_NONE,
923 {(char_u *)"cscope", (char_u *)0L}
924#else
925 (char_u *)NULL, PV_NONE,
926 {(char_u *)0L, (char_u *)0L}
927#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000928 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200929 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000930#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
931 (char_u *)&p_csqf, PV_NONE,
932 {(char_u *)"", (char_u *)0L}
933#else
934 (char_u *)NULL, PV_NONE,
935 {(char_u *)0L, (char_u *)0L}
936#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000937 SCRIPTID_INIT},
Bram Moolenaarf7befa92011-06-12 22:13:40 +0200938 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM,
939#ifdef FEAT_CSCOPE
940 (char_u *)&p_csre, PV_NONE,
941#else
942 (char_u *)NULL, PV_NONE,
943#endif
944 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000945 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
946#ifdef FEAT_CSCOPE
947 (char_u *)&p_cst, PV_NONE,
948#else
949 (char_u *)NULL, PV_NONE,
950#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000951 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000952 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
953#ifdef FEAT_CSCOPE
954 (char_u *)&p_csto, PV_NONE,
955#else
956 (char_u *)NULL, PV_NONE,
957#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000958 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000959 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
960#ifdef FEAT_CSCOPE
961 (char_u *)&p_csverbose, PV_NONE,
962#else
963 (char_u *)NULL, PV_NONE,
964#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000965 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200966 {"cursorbind", "crb", P_BOOL|P_VI_DEF,
967#ifdef FEAT_CURSORBIND
968 (char_u *)VAR_WIN, PV_CRBIND,
969#else
970 (char_u *)NULL, PV_NONE,
971#endif
972 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000973 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
974#ifdef FEAT_SYN_HL
975 (char_u *)VAR_WIN, PV_CUC,
976#else
977 (char_u *)NULL, PV_NONE,
978#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000979 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000980 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWIN,
981#ifdef FEAT_SYN_HL
982 (char_u *)VAR_WIN, PV_CUL,
983#else
984 (char_u *)NULL, PV_NONE,
985#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000986 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000987 {"debug", NULL, P_STRING|P_VI_DEF,
988 (char_u *)&p_debug, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000989 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200990 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000991#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000992 (char_u *)&p_def, PV_DEF,
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000993 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000994#else
995 (char_u *)NULL, PV_NONE,
996 {(char_u *)NULL, (char_u *)0L}
997#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000998 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000999 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
1000#ifdef FEAT_MBYTE
1001 (char_u *)&p_deco, PV_NONE,
1002#else
1003 (char_u *)NULL, PV_NONE,
1004#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001005 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001006 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001007#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001008 (char_u *)&p_dict, PV_DICT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001009#else
1010 (char_u *)NULL, PV_NONE,
1011#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001012 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001013 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
1014#ifdef FEAT_DIFF
1015 (char_u *)VAR_WIN, PV_DIFF,
1016#else
1017 (char_u *)NULL, PV_NONE,
1018#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001019 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001020 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001021#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1022 (char_u *)&p_dex, PV_NONE,
1023 {(char_u *)"", (char_u *)0L}
1024#else
1025 (char_u *)NULL, PV_NONE,
1026 {(char_u *)0L, (char_u *)0L}
1027#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001028 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001029 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_ONECOMMA
1030 |P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001031#ifdef FEAT_DIFF
1032 (char_u *)&p_dip, PV_NONE,
1033 {(char_u *)"filler", (char_u *)NULL}
1034#else
1035 (char_u *)NULL, PV_NONE,
1036 {(char_u *)"", (char_u *)NULL}
1037#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001038 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001039 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
1040#ifdef FEAT_DIGRAPHS
1041 (char_u *)&p_dg, PV_NONE,
1042#else
1043 (char_u *)NULL, PV_NONE,
1044#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001045 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001046 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
1047 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001048 (char_u *)&p_dir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001049 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001050 {"display", "dy", P_STRING|P_VI_DEF|P_ONECOMMA|P_RALL|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001051 (char_u *)&p_dy, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001052 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001053 {"eadirection", "ead", P_STRING|P_VI_DEF,
1054#ifdef FEAT_VERTSPLIT
1055 (char_u *)&p_ead, PV_NONE,
1056 {(char_u *)"both", (char_u *)0L}
1057#else
1058 (char_u *)NULL, PV_NONE,
1059 {(char_u *)NULL, (char_u *)0L}
1060#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001061 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001062 {"edcompatible","ed", P_BOOL|P_VI_DEF,
1063 (char_u *)&p_ed, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001064 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar865242e2010-07-14 21:12:05 +02001065 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001066#ifdef FEAT_MBYTE
1067 (char_u *)&p_enc, PV_NONE,
1068 {(char_u *)ENC_DFLT, (char_u *)0L}
1069#else
1070 (char_u *)NULL, PV_NONE,
1071 {(char_u *)0L, (char_u *)0L}
1072#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001073 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001074 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1075 (char_u *)&p_eol, PV_EOL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001076 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001077 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1078 (char_u *)&p_ea, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001079 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001080 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001081 (char_u *)&p_ep, PV_EP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001082 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001083 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1084 (char_u *)&p_eb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001085 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001086 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1087#ifdef FEAT_QUICKFIX
1088 (char_u *)&p_ef, PV_NONE,
1089 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1090#else
1091 (char_u *)NULL, PV_NONE,
1092 {(char_u *)NULL, (char_u *)0L}
1093#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001094 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001095 {"errorformat", "efm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001096#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001097 (char_u *)&p_efm, PV_EFM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001098 {(char_u *)DFLT_EFM, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001099#else
1100 (char_u *)NULL, PV_NONE,
1101 {(char_u *)NULL, (char_u *)0L}
1102#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001103 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001104 {"esckeys", "ek", P_BOOL|P_VIM,
1105 (char_u *)&p_ek, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001106 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001107 {"eventignore", "ei", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001108#ifdef FEAT_AUTOCMD
1109 (char_u *)&p_ei, PV_NONE,
1110#else
1111 (char_u *)NULL, PV_NONE,
1112#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001113 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001114 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1115 (char_u *)&p_et, PV_ET,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001116 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001117 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1118 (char_u *)&p_exrc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001119 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001120 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF
1121 |P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001122#ifdef FEAT_MBYTE
1123 (char_u *)&p_fenc, PV_FENC,
1124 {(char_u *)"", (char_u *)0L}
1125#else
1126 (char_u *)NULL, PV_NONE,
1127 {(char_u *)0L, (char_u *)0L}
1128#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001129 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001130 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001131#ifdef FEAT_MBYTE
1132 (char_u *)&p_fencs, PV_NONE,
1133 {(char_u *)"ucs-bom", (char_u *)0L}
1134#else
1135 (char_u *)NULL, PV_NONE,
1136 {(char_u *)0L, (char_u *)0L}
1137#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001138 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001139 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC
1140 |P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001141 (char_u *)&p_ff, PV_FF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001142 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001143 {"fileformats", "ffs", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001144 (char_u *)&p_ffs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001145 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1146 SCRIPTID_INIT},
Bram Moolenaar71afbfe2013-03-19 16:49:16 +01001147 {"fileignorecase", "fic", P_BOOL|P_VI_DEF,
1148 (char_u *)&p_fic, PV_NONE,
1149 {
1150#ifdef CASE_INSENSITIVE_FILENAME
1151 (char_u *)TRUE,
1152#else
1153 (char_u *)FALSE,
1154#endif
1155 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001156 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001157#ifdef FEAT_AUTOCMD
1158 (char_u *)&p_ft, PV_FT,
1159 {(char_u *)"", (char_u *)0L}
1160#else
1161 (char_u *)NULL, PV_NONE,
1162 {(char_u *)0L, (char_u *)0L}
1163#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001164 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001165 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001166#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1167 (char_u *)&p_fcs, PV_NONE,
1168 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1169#else
1170 (char_u *)NULL, PV_NONE,
1171 {(char_u *)"", (char_u *)0L}
1172#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001173 SCRIPTID_INIT},
Bram Moolenaar34d72d42015-07-17 14:18:08 +02001174 {"fixendofline", "fixeol", P_BOOL|P_VI_DEF|P_RSTAT,
1175 (char_u *)&p_fixeol, PV_FIXEOL,
1176 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001177 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1178#ifdef FEAT_FKMAP
1179 (char_u *)&p_fkmap, PV_NONE,
1180#else
1181 (char_u *)NULL, PV_NONE,
1182#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001183 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001184 {"flash", "fl", P_BOOL|P_VI_DEF,
1185 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001186 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001187#ifdef FEAT_FOLDING
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001188 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001189 (char_u *)&p_fcl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001190 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001191 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1192 (char_u *)VAR_WIN, PV_FDC,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001193 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001194 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1195 (char_u *)VAR_WIN, PV_FEN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001196 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001197 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1198# ifdef FEAT_EVAL
1199 (char_u *)VAR_WIN, PV_FDE,
1200 {(char_u *)"0", (char_u *)NULL}
1201# else
1202 (char_u *)NULL, PV_NONE,
1203 {(char_u *)NULL, (char_u *)0L}
1204# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001205 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001206 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1207 (char_u *)VAR_WIN, PV_FDI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001208 {(char_u *)"#", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001209 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
1210 (char_u *)VAR_WIN, PV_FDL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001211 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001212 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001213 (char_u *)&p_fdls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001214 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001215 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001216 P_RWIN|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001217 (char_u *)VAR_WIN, PV_FMR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001218 {(char_u *)"{{{,}}}", (char_u *)NULL}
1219 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001220 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1221 (char_u *)VAR_WIN, PV_FDM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001222 {(char_u *)"manual", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001223 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1224 (char_u *)VAR_WIN, PV_FML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001225 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001226 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1227 (char_u *)VAR_WIN, PV_FDN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001228 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001229 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001230 (char_u *)&p_fdo, PV_NONE,
1231 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001232 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001233 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1234# ifdef FEAT_EVAL
1235 (char_u *)VAR_WIN, PV_FDT,
1236 {(char_u *)"foldtext()", (char_u *)NULL}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001237# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001238 (char_u *)NULL, PV_NONE,
1239 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001240# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001241 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001242#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001243 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001244#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001245 (char_u *)&p_fex, PV_FEX,
1246 {(char_u *)"", (char_u *)0L}
1247#else
1248 (char_u *)NULL, PV_NONE,
1249 {(char_u *)0L, (char_u *)0L}
1250#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001251 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001252 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1253 (char_u *)&p_fo, PV_FO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001254 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1255 SCRIPTID_INIT},
Bram Moolenaar86b68352004-12-27 21:59:20 +00001256 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1257 (char_u *)&p_flp, PV_FLP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001258 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1259 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001260 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1261 (char_u *)&p_fp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001262 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001263 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1264#ifdef HAVE_FSYNC
1265 (char_u *)&p_fs, PV_NONE,
1266 {(char_u *)TRUE, (char_u *)0L}
1267#else
1268 (char_u *)NULL, PV_NONE,
1269 {(char_u *)FALSE, (char_u *)0L}
1270#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001271 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001272 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1273 (char_u *)&p_gd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001274 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001275 {"graphic", "gr", P_BOOL|P_VI_DEF,
1276 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001277 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001278 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001279#ifdef FEAT_QUICKFIX
1280 (char_u *)&p_gefm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001281 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001282#else
1283 (char_u *)NULL, PV_NONE,
1284 {(char_u *)NULL, (char_u *)0L}
1285#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001286 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001287 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1288#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001289 (char_u *)&p_gp, PV_GP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001290 {
1291# ifdef WIN3264
1292 /* may be changed to "grep -n" in os_win32.c */
1293 (char_u *)"findstr /n",
1294# else
1295# ifdef UNIX
1296 /* Add an extra file name so that grep will always
1297 * insert a file name in the match line. */
1298 (char_u *)"grep -n $* /dev/null",
1299# else
1300# ifdef VMS
1301 (char_u *)"SEARCH/NUMBERS ",
1302# else
1303 (char_u *)"grep -n ",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001304# endif
1305# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001306# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001307 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001308#else
1309 (char_u *)NULL, PV_NONE,
1310 {(char_u *)NULL, (char_u *)0L}
1311#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001312 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001313 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001314#ifdef CURSOR_SHAPE
1315 (char_u *)&p_guicursor, PV_NONE,
1316 {
1317# ifdef FEAT_GUI
1318 (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",
1319# else /* MSDOS or Win32 console */
1320 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1321# endif
1322 (char_u *)0L}
1323#else
1324 (char_u *)NULL, PV_NONE,
1325 {(char_u *)NULL, (char_u *)0L}
1326#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001327 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001328 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001329#ifdef FEAT_GUI
1330 (char_u *)&p_guifont, PV_NONE,
1331 {(char_u *)"", (char_u *)0L}
1332#else
1333 (char_u *)NULL, PV_NONE,
1334 {(char_u *)NULL, (char_u *)0L}
1335#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001336 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001337 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001338#if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1339 (char_u *)&p_guifontset, PV_NONE,
1340 {(char_u *)"", (char_u *)0L}
1341#else
1342 (char_u *)NULL, PV_NONE,
1343 {(char_u *)NULL, (char_u *)0L}
1344#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001345 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001346 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001347#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1348 (char_u *)&p_guifontwide, PV_NONE,
1349 {(char_u *)"", (char_u *)0L}
1350#else
1351 (char_u *)NULL, PV_NONE,
1352 {(char_u *)NULL, (char_u *)0L}
1353#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001354 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001355 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001356#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001357 (char_u *)&p_ghr, PV_NONE,
1358#else
1359 (char_u *)NULL, PV_NONE,
1360#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001361 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001362 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001363#if defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001364 (char_u *)&p_go, PV_NONE,
1365# if defined(UNIX) && !defined(MACOS)
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001366 {(char_u *)"aegimrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001367# else
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001368 {(char_u *)"egmrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001369# endif
1370#else
1371 (char_u *)NULL, PV_NONE,
1372 {(char_u *)NULL, (char_u *)0L}
1373#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001374 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001375 {"guipty", NULL, P_BOOL|P_VI_DEF,
1376#if defined(FEAT_GUI)
1377 (char_u *)&p_guipty, PV_NONE,
1378#else
1379 (char_u *)NULL, PV_NONE,
1380#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001381 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar18144c82006-04-12 21:52:12 +00001382 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00001383#if defined(FEAT_GUI_TABLINE)
1384 (char_u *)&p_gtl, PV_NONE,
1385 {(char_u *)"", (char_u *)0L}
1386#else
1387 (char_u *)NULL, PV_NONE,
1388 {(char_u *)NULL, (char_u *)0L}
1389#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001390 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001391 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar57657d82006-04-21 22:12:41 +00001392#if defined(FEAT_GUI_TABLINE)
1393 (char_u *)&p_gtt, PV_NONE,
1394 {(char_u *)"", (char_u *)0L}
1395#else
1396 (char_u *)NULL, PV_NONE,
1397 {(char_u *)NULL, (char_u *)0L}
1398#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001399 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001400 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1401 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001402 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001403 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1404 (char_u *)&p_hf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001405 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1406 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001407 {"helpheight", "hh", P_NUM|P_VI_DEF,
1408#ifdef FEAT_WINDOWS
1409 (char_u *)&p_hh, PV_NONE,
1410#else
1411 (char_u *)NULL, PV_NONE,
1412#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001413 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001414 {"helplang", "hlg", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001415#ifdef FEAT_MULTI_LANG
1416 (char_u *)&p_hlg, PV_NONE,
1417 {(char_u *)"", (char_u *)0L}
1418#else
1419 (char_u *)NULL, PV_NONE,
1420 {(char_u *)0L, (char_u *)0L}
1421#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001422 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001423 {"hidden", "hid", P_BOOL|P_VI_DEF,
1424 (char_u *)&p_hid, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001425 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001426 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001427 (char_u *)&p_hl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001428 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1429 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001430 {"history", "hi", P_NUM|P_VIM,
1431 (char_u *)&p_hi, PV_NONE,
Bram Moolenaar78159bb2014-06-25 11:48:54 +02001432 {(char_u *)0L, (char_u *)50L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001433 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1434#ifdef FEAT_RIGHTLEFT
1435 (char_u *)&p_hkmap, PV_NONE,
1436#else
1437 (char_u *)NULL, PV_NONE,
1438#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001439 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001440 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1441#ifdef FEAT_RIGHTLEFT
1442 (char_u *)&p_hkmapp, PV_NONE,
1443#else
1444 (char_u *)NULL, PV_NONE,
1445#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001446 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001447 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1448 (char_u *)&p_hls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001449 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001450 {"icon", NULL, P_BOOL|P_VI_DEF,
1451#ifdef FEAT_TITLE
1452 (char_u *)&p_icon, PV_NONE,
1453#else
1454 (char_u *)NULL, PV_NONE,
1455#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001456 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001457 {"iconstring", NULL, P_STRING|P_VI_DEF,
1458#ifdef FEAT_TITLE
1459 (char_u *)&p_iconstring, PV_NONE,
1460#else
1461 (char_u *)NULL, PV_NONE,
1462#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001463 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001464 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1465 (char_u *)&p_ic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001466 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001467 {"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
1468# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1469 (char_u *)&p_imaf, PV_NONE,
1470 {(char_u *)"", (char_u *)NULL}
1471# else
1472 (char_u *)NULL, PV_NONE,
1473 {(char_u *)NULL, (char_u *)0L}
1474# endif
1475 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001476 {"imactivatekey","imak",P_STRING|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001477#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001478 (char_u *)&p_imak, PV_NONE,
1479#else
1480 (char_u *)NULL, PV_NONE,
1481#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001482 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001483 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1484#ifdef USE_IM_CONTROL
1485 (char_u *)&p_imcmdline, PV_NONE,
1486#else
1487 (char_u *)NULL, PV_NONE,
1488#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001489 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001490 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1491#ifdef USE_IM_CONTROL
1492 (char_u *)&p_imdisable, PV_NONE,
1493#else
1494 (char_u *)NULL, PV_NONE,
1495#endif
1496#ifdef __sgi
1497 {(char_u *)TRUE, (char_u *)0L}
1498#else
1499 {(char_u *)FALSE, (char_u *)0L}
1500#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001501 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001502 {"iminsert", "imi", P_NUM|P_VI_DEF,
1503 (char_u *)&p_iminsert, PV_IMI,
1504#ifdef B_IMODE_IM
1505 {(char_u *)B_IMODE_IM, (char_u *)0L}
1506#else
1507 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1508#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001509 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001510 {"imsearch", "ims", P_NUM|P_VI_DEF,
1511 (char_u *)&p_imsearch, PV_IMS,
1512#ifdef B_IMODE_IM
1513 {(char_u *)B_IMODE_IM, (char_u *)0L}
1514#else
1515 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1516#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001517 SCRIPTID_INIT},
Bram Moolenaar4a460702013-06-29 14:42:26 +02001518 {"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001519# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1520 (char_u *)&p_imsf, PV_NONE,
1521 {(char_u *)"", (char_u *)NULL}
1522# else
1523 (char_u *)NULL, PV_NONE,
1524 {(char_u *)NULL, (char_u *)0L}
1525# endif
1526 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001527 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1528#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001529 (char_u *)&p_inc, PV_INC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001530 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1531#else
1532 (char_u *)NULL, PV_NONE,
1533 {(char_u *)0L, (char_u *)0L}
1534#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001535 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001536 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1537#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1538 (char_u *)&p_inex, PV_INEX,
1539 {(char_u *)"", (char_u *)0L}
1540#else
1541 (char_u *)NULL, PV_NONE,
1542 {(char_u *)0L, (char_u *)0L}
1543#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001544 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001545 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1546 (char_u *)&p_is, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001547 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001548 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1549#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1550 (char_u *)&p_inde, PV_INDE,
1551 {(char_u *)"", (char_u *)0L}
1552#else
1553 (char_u *)NULL, PV_NONE,
1554 {(char_u *)0L, (char_u *)0L}
1555#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001556 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001557 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001558#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1559 (char_u *)&p_indk, PV_INDK,
1560 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1561#else
1562 (char_u *)NULL, PV_NONE,
1563 {(char_u *)0L, (char_u *)0L}
1564#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001565 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001566 {"infercase", "inf", P_BOOL|P_VI_DEF,
1567 (char_u *)&p_inf, PV_INF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001568 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001569 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1570 (char_u *)&p_im, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001571 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001572 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1573 (char_u *)&p_isf, PV_NONE,
1574 {
1575#ifdef BACKSLASH_IN_FILENAME
1576 /* Excluded are: & and ^ are special in cmd.exe
1577 * ( and ) are used in text separating fnames */
1578 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1579#else
1580# ifdef AMIGA
1581 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1582# else
1583# ifdef VMS
1584 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1585# else /* UNIX et al. */
1586# ifdef EBCDIC
1587 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1588# else
1589 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1590# endif
1591# endif
1592# endif
1593#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001594 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001595 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1596 (char_u *)&p_isi, PV_NONE,
1597 {
1598#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1599 (char_u *)"@,48-57,_,128-167,224-235",
1600#else
1601# ifdef EBCDIC
1602 /* TODO: EBCDIC Check this! @ == isalpha()*/
1603 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1604 "112-120,128,140-142,156,158,172,"
1605 "174,186,191,203-207,219-225,235-239,"
1606 "251-254",
1607# else
1608 (char_u *)"@,48-57,_,192-255",
1609# endif
1610#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001611 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001612 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1613 (char_u *)&p_isk, PV_ISK,
1614 {
1615#ifdef EBCDIC
1616 (char_u *)"@,240-249,_",
1617 /* TODO: EBCDIC Check this! @ == isalpha()*/
1618 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1619 "112-120,128,140-142,156,158,172,"
1620 "174,186,191,203-207,219-225,235-239,"
1621 "251-254",
1622#else
1623 (char_u *)"@,48-57,_",
1624# if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1625 (char_u *)"@,48-57,_,128-167,224-235"
1626# else
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001627 ISK_LATIN1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001628# endif
1629#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001630 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001631 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1632 (char_u *)&p_isp, PV_NONE,
1633 {
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001634#if defined(MSDOS) || defined(MSWIN) || defined(OS2) \
1635 || (defined(MACOS) && !defined(MACOS_X)) \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001636 || defined(VMS)
1637 (char_u *)"@,~-255",
1638#else
1639# ifdef EBCDIC
1640 /* all chars above 63 are printable */
1641 (char_u *)"63-255",
1642# else
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00001643 ISP_LATIN1,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001644# endif
1645#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001646 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001647 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1648 (char_u *)&p_js, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001649 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001650 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1651#ifdef FEAT_CRYPT
1652 (char_u *)&p_key, PV_KEY,
1653 {(char_u *)"", (char_u *)0L}
1654#else
1655 (char_u *)NULL, PV_NONE,
1656 {(char_u *)0L, (char_u *)0L}
1657#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001658 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001659 {"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 +00001660#ifdef FEAT_KEYMAP
1661 (char_u *)&p_keymap, PV_KMAP,
1662 {(char_u *)"", (char_u *)0L}
1663#else
1664 (char_u *)NULL, PV_NONE,
1665 {(char_u *)"", (char_u *)0L}
1666#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001667 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001668 {"keymodel", "km", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001669 (char_u *)&p_km, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001670 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001671 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001672 (char_u *)&p_kp, PV_KP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001673 {
1674#if defined(MSDOS) || defined(MSWIN)
1675 (char_u *)":help",
1676#else
1677#ifdef VMS
1678 (char_u *)"help",
1679#else
1680# if defined(OS2)
1681 (char_u *)"view /",
1682# else
1683# ifdef USEMAN_S
1684 (char_u *)"man -s",
1685# else
1686 (char_u *)"man",
1687# endif
1688# endif
1689#endif
1690#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001691 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001692 {"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001693#ifdef FEAT_LANGMAP
1694 (char_u *)&p_langmap, PV_NONE,
1695 {(char_u *)"", /* unmatched } */
1696#else
1697 (char_u *)NULL, PV_NONE,
1698 {(char_u *)NULL,
1699#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001700 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001701 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001702#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1703 (char_u *)&p_lm, PV_NONE,
1704#else
1705 (char_u *)NULL, PV_NONE,
1706#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001707 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar4391cf92014-11-05 17:44:52 +01001708 {"langnoremap", "lnr", P_BOOL|P_VI_DEF,
1709#ifdef FEAT_LANGMAP
1710 (char_u *)&p_lnr, PV_NONE,
1711#else
1712 (char_u *)NULL, PV_NONE,
1713#endif
1714 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001715 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1716#ifdef FEAT_WINDOWS
1717 (char_u *)&p_ls, PV_NONE,
1718#else
1719 (char_u *)NULL, PV_NONE,
1720#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001721 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001722 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1723 (char_u *)&p_lz, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001724 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001725 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1726#ifdef FEAT_LINEBREAK
1727 (char_u *)VAR_WIN, PV_LBR,
1728#else
1729 (char_u *)NULL, PV_NONE,
1730#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001731 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001732 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1733 (char_u *)&Rows, PV_NONE,
1734 {
1735#if defined(MSDOS) || defined(WIN3264) || defined(OS2)
1736 (char_u *)25L,
1737#else
1738 (char_u *)24L,
1739#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001740 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001741 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1742#ifdef FEAT_GUI
1743 (char_u *)&p_linespace, PV_NONE,
1744#else
1745 (char_u *)NULL, PV_NONE,
1746#endif
1747#ifdef FEAT_GUI_W32
1748 {(char_u *)1L, (char_u *)0L}
1749#else
1750 {(char_u *)0L, (char_u *)0L}
1751#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001752 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001753 {"lisp", NULL, P_BOOL|P_VI_DEF,
1754#ifdef FEAT_LISP
1755 (char_u *)&p_lisp, PV_LISP,
1756#else
1757 (char_u *)NULL, PV_NONE,
1758#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001759 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001760 {"lispwords", "lw", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001761#ifdef FEAT_LISP
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01001762 (char_u *)&p_lispwords, PV_LW,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001763 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1764#else
1765 (char_u *)NULL, PV_NONE,
1766 {(char_u *)"", (char_u *)0L}
1767#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001768 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001769 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1770 (char_u *)VAR_WIN, PV_LIST,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001771 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001772 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001773 (char_u *)&p_lcs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001774 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001775 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1776 (char_u *)&p_lpl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001777 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001778#ifdef FEAT_GUI_MAC
1779 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
1780 (char_u *)&p_macatsui, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001781 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001782#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001783 {"magic", NULL, P_BOOL|P_VI_DEF,
1784 (char_u *)&p_magic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001785 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00001786 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001787#ifdef FEAT_QUICKFIX
1788 (char_u *)&p_mef, PV_NONE,
1789 {(char_u *)"", (char_u *)0L}
1790#else
1791 (char_u *)NULL, PV_NONE,
1792 {(char_u *)NULL, (char_u *)0L}
1793#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001794 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001795 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1796#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001797 (char_u *)&p_mp, PV_MP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001798# ifdef VMS
1799 {(char_u *)"MMS", (char_u *)0L}
1800# else
1801 {(char_u *)"make", (char_u *)0L}
1802# endif
1803#else
1804 (char_u *)NULL, PV_NONE,
1805 {(char_u *)NULL, (char_u *)0L}
1806#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001807 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001808 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001809 (char_u *)&p_mps, PV_MPS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001810 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1811 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001812 {"matchtime", "mat", P_NUM|P_VI_DEF,
1813 (char_u *)&p_mat, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001814 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001815 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001816#ifdef FEAT_MBYTE
1817 (char_u *)&p_mco, PV_NONE,
1818#else
1819 (char_u *)NULL, PV_NONE,
1820#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001821 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001822 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1823#ifdef FEAT_EVAL
1824 (char_u *)&p_mfd, PV_NONE,
1825#else
1826 (char_u *)NULL, PV_NONE,
1827#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001828 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001829 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1830 (char_u *)&p_mmd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001831 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001832 {"maxmem", "mm", P_NUM|P_VI_DEF,
1833 (char_u *)&p_mm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001834 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1835 SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00001836 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1837 (char_u *)&p_mmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001838 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001839 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1840 (char_u *)&p_mmt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001841 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1842 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001843 {"menuitems", "mis", P_NUM|P_VI_DEF,
1844#ifdef FEAT_MENU
1845 (char_u *)&p_mis, PV_NONE,
1846#else
1847 (char_u *)NULL, PV_NONE,
1848#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001849 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001850 {"mesg", NULL, P_BOOL|P_VI_DEF,
1851 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001852 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001853 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001854#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001855 (char_u *)&p_msm, PV_NONE,
1856 {(char_u *)"460000,2000,500", (char_u *)0L}
1857#else
1858 (char_u *)NULL, PV_NONE,
1859 {(char_u *)0L, (char_u *)0L}
1860#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001861 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001862 {"modeline", "ml", P_BOOL|P_VIM,
1863 (char_u *)&p_ml, PV_ML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001864 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001865 {"modelines", "mls", P_NUM|P_VI_DEF,
1866 (char_u *)&p_mls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001867 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001868 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1869 (char_u *)&p_ma, PV_MA,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001870 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001871 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1872 (char_u *)&p_mod, PV_MOD,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001873 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001874 {"more", NULL, P_BOOL|P_VIM,
1875 (char_u *)&p_more, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001876 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001877 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
1878 (char_u *)&p_mouse, PV_NONE,
1879 {
1880#if defined(MSDOS) || defined(WIN3264)
1881 (char_u *)"a",
1882#else
1883 (char_u *)"",
1884#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001885 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001886 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
1887#ifdef FEAT_GUI
1888 (char_u *)&p_mousef, PV_NONE,
1889#else
1890 (char_u *)NULL, PV_NONE,
1891#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001892 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001893 {"mousehide", "mh", P_BOOL|P_VI_DEF,
1894#ifdef FEAT_GUI
1895 (char_u *)&p_mh, PV_NONE,
1896#else
1897 (char_u *)NULL, PV_NONE,
1898#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001899 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001900 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
1901 (char_u *)&p_mousem, PV_NONE,
1902 {
1903#if defined(MSDOS) || defined(MSWIN)
1904 (char_u *)"popup",
1905#else
1906# if defined(MACOS)
1907 (char_u *)"popup_setpos",
1908# else
1909 (char_u *)"extend",
1910# endif
1911#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001912 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001913 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001914#ifdef FEAT_MOUSESHAPE
1915 (char_u *)&p_mouseshape, PV_NONE,
1916 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
1917#else
1918 (char_u *)NULL, PV_NONE,
1919 {(char_u *)NULL, (char_u *)0L}
1920#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001921 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001922 {"mousetime", "mouset", P_NUM|P_VI_DEF,
1923 (char_u *)&p_mouset, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001924 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001925 {"mzquantum", "mzq", P_NUM,
1926#ifdef FEAT_MZSCHEME
1927 (char_u *)&p_mzq, PV_NONE,
1928#else
1929 (char_u *)NULL, PV_NONE,
1930#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001931 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001932 {"novice", NULL, P_BOOL|P_VI_DEF,
1933 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001934 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001935 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001936 (char_u *)&p_nf, PV_NF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001937 {(char_u *)"octal,hex", (char_u *)0L}
1938 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001939 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
1940 (char_u *)VAR_WIN, PV_NU,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001941 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00001942 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
1943#ifdef FEAT_LINEBREAK
1944 (char_u *)VAR_WIN, PV_NUW,
1945#else
1946 (char_u *)NULL, PV_NONE,
1947#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001948 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
Bram Moolenaarf75a9632005-09-13 21:20:47 +00001949 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
Bram Moolenaare344bea2005-09-01 20:46:49 +00001950#ifdef FEAT_COMPL_FUNC
1951 (char_u *)&p_ofu, PV_OFU,
1952 {(char_u *)"", (char_u *)0L}
1953#else
1954 (char_u *)NULL, PV_NONE,
1955 {(char_u *)0L, (char_u *)0L}
1956#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001957 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001958 {"open", NULL, P_BOOL|P_VI_DEF,
1959 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001960 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar043545e2006-10-10 16:44:07 +00001961 {"opendevice", "odev", P_BOOL|P_VI_DEF,
1962#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1963 (char_u *)&p_odev, PV_NONE,
1964#else
1965 (char_u *)NULL, PV_NONE,
1966#endif
1967 {(char_u *)FALSE, (char_u *)FALSE}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001968 SCRIPTID_INIT},
Bram Moolenaar2c7a29c2005-12-12 22:02:31 +00001969 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
1970 (char_u *)&p_opfunc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001971 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001972 {"optimize", "opt", P_BOOL|P_VI_DEF,
1973 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001974 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001975 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001976 (char_u *)NULL, PV_NONE,
Bram Moolenaarb07269a2011-05-19 13:41:14 +02001977 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001978 {"paragraphs", "para", P_STRING|P_VI_DEF,
1979 (char_u *)&p_para, PV_NONE,
Bram Moolenaar57e48462008-03-12 16:38:55 +00001980 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001981 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001982 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001983 (char_u *)&p_paste, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001984 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001985 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
1986 (char_u *)&p_pt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001987 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001988 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
1989#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1990 (char_u *)&p_pex, PV_NONE,
1991 {(char_u *)"", (char_u *)0L}
1992#else
1993 (char_u *)NULL, PV_NONE,
1994 {(char_u *)0L, (char_u *)0L}
1995#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001996 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001997 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001998 (char_u *)&p_pm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001999 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002000 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002001 (char_u *)&p_path, PV_PATH,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002002 {
2003#if defined AMIGA || defined MSDOS || defined MSWIN
2004 (char_u *)".,,",
2005#else
2006# if defined(__EMX__)
2007 (char_u *)".,/emx/include,,",
2008# else /* Unix, probably */
2009 (char_u *)".,/usr/include,,",
2010# endif
2011#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002012 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002013 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
2014 (char_u *)&p_pi, PV_PI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002015 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002016 {"previewheight", "pvh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002017#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2018 (char_u *)&p_pvh, PV_NONE,
2019#else
2020 (char_u *)NULL, PV_NONE,
2021#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002022 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002023 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2024#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2025 (char_u *)VAR_WIN, PV_PVW,
2026#else
2027 (char_u *)NULL, PV_NONE,
2028#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002029 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002030 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002031#ifdef FEAT_PRINTER
2032 (char_u *)&p_pdev, PV_NONE,
2033 {(char_u *)"", (char_u *)0L}
2034#else
2035 (char_u *)NULL, PV_NONE,
2036 {(char_u *)NULL, (char_u *)0L}
2037#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002038 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002039 {"printencoding", "penc", P_STRING|P_VI_DEF,
2040#ifdef FEAT_POSTSCRIPT
2041 (char_u *)&p_penc, PV_NONE,
2042 {(char_u *)"", (char_u *)0L}
2043#else
2044 (char_u *)NULL, PV_NONE,
2045 {(char_u *)NULL, (char_u *)0L}
2046#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002047 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002048 {"printexpr", "pexpr", P_STRING|P_VI_DEF,
2049#ifdef FEAT_POSTSCRIPT
2050 (char_u *)&p_pexpr, PV_NONE,
2051 {(char_u *)"", (char_u *)0L}
2052#else
2053 (char_u *)NULL, PV_NONE,
2054 {(char_u *)NULL, (char_u *)0L}
2055#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002056 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002057 {"printfont", "pfn", P_STRING|P_VI_DEF,
2058#ifdef FEAT_PRINTER
2059 (char_u *)&p_pfn, PV_NONE,
2060 {
2061# ifdef MSWIN
2062 (char_u *)"Courier_New:h10",
2063# else
2064 (char_u *)"courier",
2065# endif
2066 (char_u *)0L}
2067#else
2068 (char_u *)NULL, PV_NONE,
2069 {(char_u *)NULL, (char_u *)0L}
2070#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002071 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002072 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
2073#ifdef FEAT_PRINTER
2074 (char_u *)&p_header, PV_NONE,
2075 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
2076#else
2077 (char_u *)NULL, PV_NONE,
2078 {(char_u *)NULL, (char_u *)0L}
2079#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002080 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002081 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
2082#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2083 (char_u *)&p_pmcs, PV_NONE,
2084 {(char_u *)"", (char_u *)0L}
2085#else
2086 (char_u *)NULL, PV_NONE,
2087 {(char_u *)NULL, (char_u *)0L}
2088#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002089 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002090 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2091#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2092 (char_u *)&p_pmfn, PV_NONE,
2093 {(char_u *)"", (char_u *)0L}
2094#else
2095 (char_u *)NULL, PV_NONE,
2096 {(char_u *)NULL, (char_u *)0L}
2097#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002098 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002099 {"printoptions", "popt", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002100#ifdef FEAT_PRINTER
2101 (char_u *)&p_popt, PV_NONE,
2102 {(char_u *)"", (char_u *)0L}
2103#else
2104 (char_u *)NULL, PV_NONE,
2105 {(char_u *)NULL, (char_u *)0L}
2106#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002107 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002108 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002109 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002110 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002111 {"pumheight", "ph", P_NUM|P_VI_DEF,
2112#ifdef FEAT_INS_EXPAND
2113 (char_u *)&p_ph, PV_NONE,
2114#else
2115 (char_u *)NULL, PV_NONE,
2116#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002117 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002118 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2119#ifdef FEAT_TEXTOBJ
2120 (char_u *)&p_qe, PV_QE,
2121 {(char_u *)"\\", (char_u *)0L}
2122#else
2123 (char_u *)NULL, PV_NONE,
2124 {(char_u *)NULL, (char_u *)0L}
2125#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002126 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002127 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2128 (char_u *)&p_ro, PV_RO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002129 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002130 {"redraw", NULL, P_BOOL|P_VI_DEF,
2131 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002132 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002133 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2134#ifdef FEAT_RELTIME
2135 (char_u *)&p_rdt, PV_NONE,
2136#else
2137 (char_u *)NULL, PV_NONE,
2138#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002139 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02002140 {"regexpengine", "re", P_NUM|P_VI_DEF,
2141 (char_u *)&p_re, PV_NONE,
2142 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002143 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2144 (char_u *)VAR_WIN, PV_RNU,
2145 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002146 {"remap", NULL, P_BOOL|P_VI_DEF,
2147 (char_u *)&p_remap, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002148 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002149 {"renderoptions", "rop", P_STRING|P_ONECOMMA|P_RCLR|P_VI_DEF,
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02002150#ifdef FEAT_RENDER_OPTIONS
2151 (char_u *)&p_rop, PV_NONE,
2152 {(char_u *)"", (char_u *)0L}
2153#else
2154 (char_u *)NULL, PV_NONE,
2155 {(char_u *)NULL, (char_u *)0L}
2156#endif
2157 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002158 {"report", NULL, P_NUM|P_VI_DEF,
2159 (char_u *)&p_report, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002160 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002161 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2162#ifdef WIN3264
2163 (char_u *)&p_rs, PV_NONE,
2164#else
2165 (char_u *)NULL, PV_NONE,
2166#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002167 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002168 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2169#ifdef FEAT_RIGHTLEFT
2170 (char_u *)&p_ri, PV_NONE,
2171#else
2172 (char_u *)NULL, PV_NONE,
2173#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002174 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002175 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2176#ifdef FEAT_RIGHTLEFT
2177 (char_u *)VAR_WIN, PV_RL,
2178#else
2179 (char_u *)NULL, PV_NONE,
2180#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002181 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002182 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2183#ifdef FEAT_RIGHTLEFT
2184 (char_u *)VAR_WIN, PV_RLC,
2185 {(char_u *)"search", (char_u *)NULL}
2186#else
2187 (char_u *)NULL, PV_NONE,
2188 {(char_u *)NULL, (char_u *)0L}
2189#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002190 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002191 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2192#ifdef FEAT_CMDL_INFO
2193 (char_u *)&p_ru, PV_NONE,
2194#else
2195 (char_u *)NULL, PV_NONE,
2196#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002197 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002198 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2199#ifdef FEAT_STL_OPT
2200 (char_u *)&p_ruf, PV_NONE,
2201#else
2202 (char_u *)NULL, PV_NONE,
2203#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002204 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002205 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2206 |P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002207 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002208 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2209 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002210 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2211 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002212 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002213 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2214#ifdef FEAT_SCROLLBIND
2215 (char_u *)VAR_WIN, PV_SCBIND,
2216#else
2217 (char_u *)NULL, PV_NONE,
2218#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002219 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002220 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2221 (char_u *)&p_sj, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002222 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002223 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2224 (char_u *)&p_so, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002225 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002226 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002227#ifdef FEAT_SCROLLBIND
2228 (char_u *)&p_sbo, PV_NONE,
2229 {(char_u *)"ver,jump", (char_u *)0L}
2230#else
2231 (char_u *)NULL, PV_NONE,
2232 {(char_u *)0L, (char_u *)0L}
2233#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002234 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002235 {"sections", "sect", P_STRING|P_VI_DEF,
2236 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002237 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2238 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002239 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2240 (char_u *)&p_secure, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002241 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002242 {"selection", "sel", P_STRING|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002243 (char_u *)&p_sel, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002244 {(char_u *)"inclusive", (char_u *)0L}
2245 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002246 {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002247 (char_u *)&p_slm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002248 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002249 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002250#ifdef FEAT_SESSION
2251 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002252 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002253 (char_u *)0L}
2254#else
2255 (char_u *)NULL, PV_NONE,
2256 {(char_u *)0L, (char_u *)0L}
2257#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002258 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002259 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2260 (char_u *)&p_sh, PV_NONE,
2261 {
2262#ifdef VMS
2263 (char_u *)"-",
2264#else
2265# if defined(MSDOS)
2266 (char_u *)"command",
2267# else
2268# if defined(WIN16)
2269 (char_u *)"command.com",
2270# else
2271# if defined(WIN3264)
2272 (char_u *)"", /* set in set_init_1() */
2273# else
2274# if defined(OS2)
2275 (char_u *)"cmd.exe",
2276# else
2277# if defined(ARCHIE)
2278 (char_u *)"gos",
2279# else
2280 (char_u *)"sh",
2281# endif
2282# endif
2283# endif
2284# endif
2285# endif
2286#endif /* VMS */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002287 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002288 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2289 (char_u *)&p_shcf, PV_NONE,
2290 {
2291#if defined(MSDOS) || defined(MSWIN)
2292 (char_u *)"/c",
2293#else
2294# if defined(OS2)
2295 (char_u *)"/c",
2296# else
2297 (char_u *)"-c",
2298# endif
2299#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002300 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002301 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2302#ifdef FEAT_QUICKFIX
2303 (char_u *)&p_sp, PV_NONE,
2304 {
2305#if defined(UNIX) || defined(OS2)
2306# ifdef ARCHIE
2307 (char_u *)"2>",
2308# else
2309 (char_u *)"| tee",
2310# endif
2311#else
2312 (char_u *)">",
2313#endif
2314 (char_u *)0L}
2315#else
2316 (char_u *)NULL, PV_NONE,
2317 {(char_u *)0L, (char_u *)0L}
2318#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002319 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002320 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2321 (char_u *)&p_shq, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002322 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002323 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2324 (char_u *)&p_srr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002325 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002326 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2327#ifdef BACKSLASH_IN_FILENAME
2328 (char_u *)&p_ssl, PV_NONE,
2329#else
2330 (char_u *)NULL, PV_NONE,
2331#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002332 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002333 {"shelltemp", "stmp", P_BOOL,
2334 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002335 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002336 {"shelltype", "st", P_NUM|P_VI_DEF,
2337#ifdef AMIGA
2338 (char_u *)&p_st, PV_NONE,
2339#else
2340 (char_u *)NULL, PV_NONE,
2341#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002342 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002343 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2344 (char_u *)&p_sxq, PV_NONE,
2345 {
2346#if defined(UNIX) && defined(USE_SYSTEM) && !defined(__EMX__)
2347 (char_u *)"\"",
2348#else
2349 (char_u *)"",
2350#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002351 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002352 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
2353 (char_u *)&p_sxe, PV_NONE,
2354 {
2355#if defined(MSDOS) || defined(WIN16) || defined(WIN3264)
2356 (char_u *)"\"&|<>()@^",
2357#else
2358 (char_u *)"",
2359#endif
2360 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002361 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2362 (char_u *)&p_sr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002363 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002364 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2365 (char_u *)&p_sw, PV_SW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002366 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002367 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2368 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002369 {(char_u *)"", (char_u *)"filnxtToO"}
2370 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002371 {"shortname", "sn", P_BOOL|P_VI_DEF,
2372#ifdef SHORT_FNAME
2373 (char_u *)NULL, PV_NONE,
2374#else
2375 (char_u *)&p_sn, PV_SN,
2376#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002377 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002378 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2379#ifdef FEAT_LINEBREAK
2380 (char_u *)&p_sbr, PV_NONE,
2381#else
2382 (char_u *)NULL, PV_NONE,
2383#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002384 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002385 {"showcmd", "sc", P_BOOL|P_VIM,
2386#ifdef FEAT_CMDL_INFO
2387 (char_u *)&p_sc, PV_NONE,
2388#else
2389 (char_u *)NULL, PV_NONE,
2390#endif
2391 {(char_u *)FALSE,
2392#ifdef UNIX
2393 (char_u *)FALSE
2394#else
2395 (char_u *)TRUE
2396#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002397 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002398 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2399 (char_u *)&p_sft, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002400 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002401 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2402 (char_u *)&p_sm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002403 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002404 {"showmode", "smd", P_BOOL|P_VIM,
2405 (char_u *)&p_smd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002406 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002407 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2408#ifdef FEAT_WINDOWS
2409 (char_u *)&p_stal, PV_NONE,
2410#else
2411 (char_u *)NULL, PV_NONE,
2412#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002413 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002414 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2415 (char_u *)&p_ss, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002416 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002417 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2418 (char_u *)&p_siso, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002419 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002420 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2421 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002422 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002423 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2424 (char_u *)&p_scs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002425 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002426 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2427#ifdef FEAT_SMARTINDENT
2428 (char_u *)&p_si, PV_SI,
2429#else
2430 (char_u *)NULL, PV_NONE,
2431#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002432 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002433 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2434 (char_u *)&p_sta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002435 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002436 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2437 (char_u *)&p_sts, PV_STS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002438 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002439 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2440 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002441 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002442 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002443#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002444 (char_u *)VAR_WIN, PV_SPELL,
2445#else
2446 (char_u *)NULL, PV_NONE,
2447#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002448 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002449 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002450#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002451 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002452 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002453#else
2454 (char_u *)NULL, PV_NONE,
2455 {(char_u *)0L, (char_u *)0L}
2456#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002457 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002458 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE
2459 |P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002460#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002461 (char_u *)&p_spf, PV_SPF,
2462 {(char_u *)"", (char_u *)0L}
2463#else
2464 (char_u *)NULL, PV_NONE,
2465 {(char_u *)0L, (char_u *)0L}
2466#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002467 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002468 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
2469 |P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002470#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002471 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002472 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002473#else
2474 (char_u *)NULL, PV_NONE,
2475 {(char_u *)0L, (char_u *)0L}
2476#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002477 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002478 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002479#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002480 (char_u *)&p_sps, PV_NONE,
2481 {(char_u *)"best", (char_u *)0L}
2482#else
2483 (char_u *)NULL, PV_NONE,
2484 {(char_u *)0L, (char_u *)0L}
2485#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002486 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002487 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2488#ifdef FEAT_WINDOWS
2489 (char_u *)&p_sb, PV_NONE,
2490#else
2491 (char_u *)NULL, PV_NONE,
2492#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002493 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002494 {"splitright", "spr", P_BOOL|P_VI_DEF,
2495#ifdef FEAT_VERTSPLIT
2496 (char_u *)&p_spr, PV_NONE,
2497#else
2498 (char_u *)NULL, PV_NONE,
2499#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002500 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002501 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2502 (char_u *)&p_sol, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002503 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002504 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2505#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002506 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002507#else
2508 (char_u *)NULL, PV_NONE,
2509#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002510 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002511 {"suffixes", "su", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002512 (char_u *)&p_su, PV_NONE,
2513 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002514 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002515 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002516#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002517 (char_u *)&p_sua, PV_SUA,
2518 {(char_u *)"", (char_u *)0L}
2519#else
2520 (char_u *)NULL, PV_NONE,
2521 {(char_u *)0L, (char_u *)0L}
2522#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002523 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002524 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2525 (char_u *)&p_swf, PV_SWF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002526 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002527 {"swapsync", "sws", P_STRING|P_VI_DEF,
2528 (char_u *)&p_sws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002529 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002530 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002531 (char_u *)&p_swb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002532 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002533 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2534#ifdef FEAT_SYN_HL
2535 (char_u *)&p_smc, PV_SMC,
2536 {(char_u *)3000L, (char_u *)0L}
2537#else
2538 (char_u *)NULL, PV_NONE,
2539 {(char_u *)0L, (char_u *)0L}
2540#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002541 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002542 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002543#ifdef FEAT_SYN_HL
2544 (char_u *)&p_syn, PV_SYN,
2545 {(char_u *)"", (char_u *)0L}
2546#else
2547 (char_u *)NULL, PV_NONE,
2548 {(char_u *)0L, (char_u *)0L}
2549#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002550 SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002551 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2552#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002553 (char_u *)&p_tal, PV_NONE,
2554#else
2555 (char_u *)NULL, PV_NONE,
2556#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002557 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002558 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2559#ifdef FEAT_WINDOWS
2560 (char_u *)&p_tpm, PV_NONE,
2561#else
2562 (char_u *)NULL, PV_NONE,
2563#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002564 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002565 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2566 (char_u *)&p_ts, PV_TS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002567 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002568 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2569 (char_u *)&p_tbs, PV_NONE,
2570#ifdef VMS /* binary searching doesn't appear to work on VMS */
2571 {(char_u *)0L, (char_u *)0L}
2572#else
2573 {(char_u *)TRUE, (char_u *)0L}
2574#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002575 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002576 {"taglength", "tl", P_NUM|P_VI_DEF,
2577 (char_u *)&p_tl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002578 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002579 {"tagrelative", "tr", P_BOOL|P_VIM,
2580 (char_u *)&p_tr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002581 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002582 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002583 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002584 {
2585#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2586 (char_u *)"./tags,./TAGS,tags,TAGS",
2587#else
2588 (char_u *)"./tags,tags",
2589#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002590 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002591 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2592 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002593 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002594 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2595 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002596 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002597 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2598#ifdef FEAT_ARABIC
2599 (char_u *)&p_tbidi, PV_NONE,
2600#else
2601 (char_u *)NULL, PV_NONE,
2602#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002603 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002604 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2605#ifdef FEAT_MBYTE
2606 (char_u *)&p_tenc, PV_NONE,
2607 {(char_u *)"", (char_u *)0L}
2608#else
2609 (char_u *)NULL, PV_NONE,
2610 {(char_u *)0L, (char_u *)0L}
2611#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002612 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002613 {"terse", NULL, P_BOOL|P_VI_DEF,
2614 (char_u *)&p_terse, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002615 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002616 {"textauto", "ta", P_BOOL|P_VIM,
2617 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002618 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2619 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002620 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2621 (char_u *)&p_tx, PV_TX,
2622 {
2623#ifdef USE_CRNL
2624 (char_u *)TRUE,
2625#else
2626 (char_u *)FALSE,
2627#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002628 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +02002629 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002630 (char_u *)&p_tw, PV_TW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002631 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002632 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002633#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002634 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002635#else
2636 (char_u *)NULL, PV_NONE,
2637#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002638 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002639 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2640 (char_u *)&p_to, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002641 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002642 {"timeout", "to", P_BOOL|P_VI_DEF,
2643 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002644 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002645 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2646 (char_u *)&p_tm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002647 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002648 {"title", NULL, P_BOOL|P_VI_DEF,
2649#ifdef FEAT_TITLE
2650 (char_u *)&p_title, PV_NONE,
2651#else
2652 (char_u *)NULL, PV_NONE,
2653#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002654 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002655 {"titlelen", NULL, P_NUM|P_VI_DEF,
2656#ifdef FEAT_TITLE
2657 (char_u *)&p_titlelen, PV_NONE,
2658#else
2659 (char_u *)NULL, PV_NONE,
2660#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002661 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002662 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002663#ifdef FEAT_TITLE
2664 (char_u *)&p_titleold, PV_NONE,
2665 {(char_u *)N_("Thanks for flying Vim"),
2666 (char_u *)0L}
2667#else
2668 (char_u *)NULL, PV_NONE,
2669 {(char_u *)0L, (char_u *)0L}
2670#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002671 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002672 {"titlestring", NULL, P_STRING|P_VI_DEF,
2673#ifdef FEAT_TITLE
2674 (char_u *)&p_titlestring, PV_NONE,
2675#else
2676 (char_u *)NULL, PV_NONE,
2677#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002678 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002679#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002680 {"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002681 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002682 {(char_u *)"icons,tooltips", (char_u *)0L}
2683 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002684#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002685#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002686 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
2687 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002688 {(char_u *)"small", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002689#endif
2690 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2691 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002692 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002693 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2694 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002695 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002696 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2697 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002698 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002699 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2700 (char_u *)&p_tf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002701 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002702 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2703#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2704 (char_u *)&p_ttym, PV_NONE,
2705#else
2706 (char_u *)NULL, PV_NONE,
2707#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002708 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002709 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2710 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002711 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002712 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2713 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002714 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002715 {"undodir", "udir", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP|P_SECURE
2716 |P_VI_DEF,
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002717#ifdef FEAT_PERSISTENT_UNDO
2718 (char_u *)&p_udir, PV_NONE,
2719 {(char_u *)".", (char_u *)0L}
2720#else
2721 (char_u *)NULL, PV_NONE,
2722 {(char_u *)0L, (char_u *)0L}
2723#endif
2724 SCRIPTID_INIT},
2725 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2726#ifdef FEAT_PERSISTENT_UNDO
2727 (char_u *)&p_udf, PV_UDF,
2728#else
2729 (char_u *)NULL, PV_NONE,
2730#endif
2731 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002732 {"undolevels", "ul", P_NUM|P_VI_DEF,
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01002733 (char_u *)&p_ul, PV_UL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002734 {
2735#if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS)
2736 (char_u *)1000L,
2737#else
2738 (char_u *)100L,
2739#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002740 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar59f931e2010-07-24 20:27:03 +02002741 {"undoreload", "ur", P_NUM|P_VI_DEF,
2742 (char_u *)&p_ur, PV_NONE,
2743 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002744 {"updatecount", "uc", P_NUM|P_VI_DEF,
2745 (char_u *)&p_uc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002746 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002747 {"updatetime", "ut", P_NUM|P_VI_DEF,
2748 (char_u *)&p_ut, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002749 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002750 {"verbose", "vbs", P_NUM|P_VI_DEF,
2751 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002752 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002753 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2754 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002755 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002756 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2757#ifdef FEAT_SESSION
2758 (char_u *)&p_vdir, PV_NONE,
2759 {(char_u *)DFLT_VDIR, (char_u *)0L}
2760#else
2761 (char_u *)NULL, PV_NONE,
2762 {(char_u *)0L, (char_u *)0L}
2763#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002764 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002765 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002766#ifdef FEAT_SESSION
2767 (char_u *)&p_vop, PV_NONE,
2768 {(char_u *)"folds,options,cursor", (char_u *)0L}
2769#else
2770 (char_u *)NULL, PV_NONE,
2771 {(char_u *)0L, (char_u *)0L}
2772#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002773 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002774 {"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002775#ifdef FEAT_VIMINFO
2776 (char_u *)&p_viminfo, PV_NONE,
2777#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
Bram Moolenaard812df62008-11-09 12:46:09 +00002778 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002779#else
2780# ifdef AMIGA
2781 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002782 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002783# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002784 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002785# endif
2786#endif
2787#else
2788 (char_u *)NULL, PV_NONE,
2789 {(char_u *)0L, (char_u *)0L}
2790#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002791 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002792 {"virtualedit", "ve", P_STRING|P_ONECOMMA|P_NODUP|P_VI_DEF
2793 |P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002794#ifdef FEAT_VIRTUALEDIT
2795 (char_u *)&p_ve, PV_NONE,
2796 {(char_u *)"", (char_u *)""}
2797#else
2798 (char_u *)NULL, PV_NONE,
2799 {(char_u *)0L, (char_u *)0L}
2800#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002801 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002802 {"visualbell", "vb", P_BOOL|P_VI_DEF,
2803 (char_u *)&p_vb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002804 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002805 {"w300", NULL, P_NUM|P_VI_DEF,
2806 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002807 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002808 {"w1200", NULL, P_NUM|P_VI_DEF,
2809 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002810 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002811 {"w9600", NULL, P_NUM|P_VI_DEF,
2812 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002813 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002814 {"warn", NULL, P_BOOL|P_VI_DEF,
2815 (char_u *)&p_warn, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002816 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002817 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
2818 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002819 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002820 {"whichwrap", "ww", P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002821 (char_u *)&p_ww, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002822 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002823 {"wildchar", "wc", P_NUM|P_VIM,
2824 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002825 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
2826 SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002827 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002828 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002829 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002830 {"wildignore", "wig", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002831#ifdef FEAT_WILDIGN
2832 (char_u *)&p_wig, PV_NONE,
2833#else
2834 (char_u *)NULL, PV_NONE,
2835#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002836 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002837 {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
2838 (char_u *)&p_wic, PV_NONE,
2839 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002840 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
2841#ifdef FEAT_WILDMENU
2842 (char_u *)&p_wmnu, PV_NONE,
2843#else
2844 (char_u *)NULL, PV_NONE,
2845#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002846 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002847 {"wildmode", "wim", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002848 (char_u *)&p_wim, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002849 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00002850 {"wildoptions", "wop", P_STRING|P_VI_DEF,
2851#ifdef FEAT_CMDL_COMPL
2852 (char_u *)&p_wop, PV_NONE,
2853 {(char_u *)"", (char_u *)0L}
2854#else
2855 (char_u *)NULL, PV_NONE,
2856 {(char_u *)NULL, (char_u *)0L}
2857#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002858 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002859 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
2860#ifdef FEAT_WAK
2861 (char_u *)&p_wak, PV_NONE,
2862 {(char_u *)"menu", (char_u *)0L}
2863#else
2864 (char_u *)NULL, PV_NONE,
2865 {(char_u *)NULL, (char_u *)0L}
2866#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002867 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002868 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00002869 (char_u *)&p_window, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002870 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002871 {"winheight", "wh", P_NUM|P_VI_DEF,
2872#ifdef FEAT_WINDOWS
2873 (char_u *)&p_wh, PV_NONE,
2874#else
2875 (char_u *)NULL, PV_NONE,
2876#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002877 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002878 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002879#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002880 (char_u *)VAR_WIN, PV_WFH,
2881#else
2882 (char_u *)NULL, PV_NONE,
2883#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002884 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002885 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
2886#ifdef FEAT_VERTSPLIT
2887 (char_u *)VAR_WIN, PV_WFW,
2888#else
2889 (char_u *)NULL, PV_NONE,
2890#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002891 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002892 {"winminheight", "wmh", P_NUM|P_VI_DEF,
2893#ifdef FEAT_WINDOWS
2894 (char_u *)&p_wmh, PV_NONE,
2895#else
2896 (char_u *)NULL, PV_NONE,
2897#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002898 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002899 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
2900#ifdef FEAT_VERTSPLIT
2901 (char_u *)&p_wmw, PV_NONE,
2902#else
2903 (char_u *)NULL, PV_NONE,
2904#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002905 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002906 {"winwidth", "wiw", P_NUM|P_VI_DEF,
2907#ifdef FEAT_VERTSPLIT
2908 (char_u *)&p_wiw, PV_NONE,
2909#else
2910 (char_u *)NULL, PV_NONE,
2911#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002912 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002913 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
2914 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002915 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002916 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
2917 (char_u *)&p_wm, PV_WM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002918 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002919 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
2920 (char_u *)&p_ws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002921 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002922 {"write", NULL, P_BOOL|P_VI_DEF,
2923 (char_u *)&p_write, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002924 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002925 {"writeany", "wa", P_BOOL|P_VI_DEF,
2926 (char_u *)&p_wa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002927 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002928 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
2929 (char_u *)&p_wb, PV_NONE,
2930 {
2931#ifdef FEAT_WRITEBACKUP
2932 (char_u *)TRUE,
2933#else
2934 (char_u *)FALSE,
2935#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002936 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002937 {"writedelay", "wd", P_NUM|P_VI_DEF,
2938 (char_u *)&p_wd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002939 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002940
2941/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002942#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00002943 (char_u *)&vvv, PV_NONE, \
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002944 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002945
2946 p_term("t_AB", T_CAB)
2947 p_term("t_AF", T_CAF)
2948 p_term("t_AL", T_CAL)
2949 p_term("t_al", T_AL)
2950 p_term("t_bc", T_BC)
2951 p_term("t_cd", T_CD)
2952 p_term("t_ce", T_CE)
2953 p_term("t_cl", T_CL)
2954 p_term("t_cm", T_CM)
2955 p_term("t_Co", T_CCO)
2956 p_term("t_CS", T_CCS)
2957 p_term("t_cs", T_CS)
2958#ifdef FEAT_VERTSPLIT
2959 p_term("t_CV", T_CSV)
2960#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002961 p_term("t_da", T_DA)
2962 p_term("t_db", T_DB)
2963 p_term("t_DL", T_CDL)
2964 p_term("t_dl", T_DL)
Bram Moolenaare5401222015-06-25 19:16:56 +02002965 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002966 p_term("t_fs", T_FS)
2967 p_term("t_IE", T_CIE)
2968 p_term("t_IS", T_CIS)
2969 p_term("t_ke", T_KE)
2970 p_term("t_ks", T_KS)
2971 p_term("t_le", T_LE)
2972 p_term("t_mb", T_MB)
2973 p_term("t_md", T_MD)
2974 p_term("t_me", T_ME)
2975 p_term("t_mr", T_MR)
2976 p_term("t_ms", T_MS)
2977 p_term("t_nd", T_ND)
2978 p_term("t_op", T_OP)
Bram Moolenaare5401222015-06-25 19:16:56 +02002979 p_term("t_RB", T_RBG)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002980 p_term("t_RI", T_CRI)
2981 p_term("t_RV", T_CRV)
2982 p_term("t_Sb", T_CSB)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002983 p_term("t_se", T_SE)
Bram Moolenaare5401222015-06-25 19:16:56 +02002984 p_term("t_Sf", T_CSF)
2985 p_term("t_SI", T_CSI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002986 p_term("t_so", T_SO)
Bram Moolenaare5401222015-06-25 19:16:56 +02002987 p_term("t_SR", T_CSR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002988 p_term("t_sr", T_SR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002989 p_term("t_te", T_TE)
2990 p_term("t_ti", T_TI)
Bram Moolenaare5401222015-06-25 19:16:56 +02002991 p_term("t_ts", T_TS)
2992 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002993 p_term("t_ue", T_UE)
2994 p_term("t_us", T_US)
Bram Moolenaare5401222015-06-25 19:16:56 +02002995 p_term("t_ut", T_UT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002996 p_term("t_vb", T_VB)
2997 p_term("t_ve", T_VE)
2998 p_term("t_vi", T_VI)
2999 p_term("t_vs", T_VS)
3000 p_term("t_WP", T_CWP)
3001 p_term("t_WS", T_CWS)
Bram Moolenaar494838a2015-02-10 19:20:37 +01003002 p_term("t_xn", T_XN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003003 p_term("t_xs", T_XS)
3004 p_term("t_ZH", T_CZH)
3005 p_term("t_ZR", T_CZR)
3006
3007/* terminal key codes are not in here */
3008
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003009 /* end marker */
3010 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00003011};
3012
3013#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
3014
3015#ifdef FEAT_MBYTE
3016static char *(p_ambw_values[]) = {"single", "double", NULL};
3017#endif
3018static char *(p_bg_values[]) = {"light", "dark", NULL};
3019static char *(p_nf_values[]) = {"octal", "hex", "alpha", NULL};
3020static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003021#ifdef FEAT_CRYPT
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02003022static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2", NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003023#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003024#ifdef FEAT_CMDL_COMPL
3025static char *(p_wop_values[]) = {"tagfile", NULL};
3026#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003027#ifdef FEAT_WAK
3028static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
3029#endif
3030static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003031static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
3032static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003033static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003034#ifdef FEAT_BROWSE
3035static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
3036#endif
3037#ifdef FEAT_SCROLLBIND
3038static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
3039#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00003040static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003041#ifdef FEAT_VERTSPLIT
3042static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
3043#endif
3044#if defined(FEAT_QUICKFIX)
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003045# ifdef FEAT_AUTOCMD
3046static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
3047# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003048static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003049# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003050static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
3051#endif
3052static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
3053#ifdef FEAT_FOLDING
3054static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003055# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00003056 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003057# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003058 NULL};
3059static char *(p_fcl_values[]) = {"all", NULL};
3060#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003061#ifdef FEAT_INS_EXPAND
Bram Moolenaarb6be1e22015-07-10 18:18:40 +02003062static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003063#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003064
3065static void set_option_default __ARGS((int, int opt_flags, int compatible));
3066static void set_options_default __ARGS((int opt_flags));
Bram Moolenaarf740b292006-02-16 22:11:02 +00003067static char_u *term_bg_default __ARGS((void));
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003068static void did_set_option __ARGS((int opt_idx, int opt_flags, int new_value));
Bram Moolenaar071d4272004-06-13 20:20:40 +00003069static char_u *illegal_char __ARGS((char_u *, int));
3070static int string_to_key __ARGS((char_u *arg));
3071#ifdef FEAT_CMDWIN
3072static char_u *check_cedit __ARGS((void));
3073#endif
3074#ifdef FEAT_TITLE
3075static void did_set_title __ARGS((int icon));
3076#endif
3077static char_u *option_expand __ARGS((int opt_idx, char_u *val));
3078static void didset_options __ARGS((void));
3079static void check_string_option __ARGS((char_u **pp));
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003080#if defined(FEAT_EVAL) || defined(PROTO)
3081static long_u *insecure_flag __ARGS((int opt_idx, int opt_flags));
3082#else
3083# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3084#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003085static void set_string_option_global __ARGS((int opt_idx, char_u **varp));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02003086static char_u *set_string_option __ARGS((int opt_idx, char_u *value, int opt_flags));
Bram Moolenaar071d4272004-06-13 20:20:40 +00003087static char_u *did_set_string_option __ARGS((int opt_idx, char_u **varp, int new_value_alloced, char_u *oldval, char_u *errbuf, int opt_flags));
3088static char_u *set_chars_option __ARGS((char_u **varp));
Bram Moolenaar1a384422010-07-14 19:53:30 +02003089#ifdef FEAT_SYN_HL
3090static int int_cmp __ARGS((const void *a, const void *b));
3091#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003092#ifdef FEAT_CLIPBOARD
3093static char_u *check_clipboard_option __ARGS((void));
3094#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003095#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02003096static char_u *compile_cap_prog __ARGS((synblock_T *synblock));
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003097#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003098#ifdef FEAT_EVAL
3099static void set_option_scriptID_idx __ARGS((int opt_idx, int opt_flags, int id));
3100#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003101static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value, int opt_flags));
Bram Moolenaar555b2802005-05-19 21:08:39 +00003102static char_u *set_num_option __ARGS((int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags));
Bram Moolenaar071d4272004-06-13 20:20:40 +00003103static void check_redraw __ARGS((long_u flags));
3104static int findoption __ARGS((char_u *));
3105static int find_key_option __ARGS((char_u *));
3106static void showoptions __ARGS((int all, int opt_flags));
3107static int optval_default __ARGS((struct vimoption *, char_u *varp));
3108static void showoneopt __ARGS((struct vimoption *, int opt_flags));
3109static int put_setstring __ARGS((FILE *fd, char *cmd, char *name, char_u **valuep, int expand));
3110static int put_setnum __ARGS((FILE *fd, char *cmd, char *name, long *valuep));
3111static int put_setbool __ARGS((FILE *fd, char *cmd, char *name, int value));
3112static int istermoption __ARGS((struct vimoption *));
3113static char_u *get_varp_scope __ARGS((struct vimoption *p, int opt_flags));
3114static char_u *get_varp __ARGS((struct vimoption *));
3115static void option_value2string __ARGS((struct vimoption *, int opt_flags));
Bram Moolenaar8dc907d2014-06-25 14:44:10 +02003116static void check_winopt __ARGS((winopt_T *wop));
Bram Moolenaar071d4272004-06-13 20:20:40 +00003117static int wc_use_keyname __ARGS((char_u *varp, long *wcp));
3118#ifdef FEAT_LANGMAP
3119static void langmap_init __ARGS((void));
3120static void langmap_set __ARGS((void));
3121#endif
3122static void paste_option_changed __ARGS((void));
3123static void compatible_set __ARGS((void));
3124#ifdef FEAT_LINEBREAK
3125static void fill_breakat_flags __ARGS((void));
3126#endif
3127static int opt_strings_flags __ARGS((char_u *val, char **values, unsigned *flagp, int list));
3128static int check_opt_strings __ARGS((char_u *val, char **values, int));
3129static int check_opt_wim __ARGS((void));
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003130#ifdef FEAT_LINEBREAK
3131static int briopt_check __ARGS((win_T *wp));
3132#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003133
3134/*
3135 * Initialize the options, first part.
3136 *
3137 * Called only once from main(), just after creating the first buffer.
3138 */
3139 void
3140set_init_1()
3141{
3142 char_u *p;
3143 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003144 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003145
3146#ifdef FEAT_LANGMAP
3147 langmap_init();
3148#endif
3149
3150 /* Be Vi compatible by default */
3151 p_cp = TRUE;
3152
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003153 /* Use POSIX compatibility when $VIM_POSIX is set. */
3154 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003155 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003156 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003157 set_string_default("shm", (char_u *)"A");
3158 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003159
Bram Moolenaar071d4272004-06-13 20:20:40 +00003160 /*
3161 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003162 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003163 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003164 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003165#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
3166# ifdef __EMX__
Bram Moolenaar7c626922005-02-07 22:01:03 +00003167 || ((p = mch_getenv((char_u *)"EMXSHELL")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003168# endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003169 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003170# ifdef WIN3264
Bram Moolenaar7c626922005-02-07 22:01:03 +00003171 || ((p = default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003172# endif
3173#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003174 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003175 set_string_default("sh", p);
3176
3177#ifdef FEAT_WILDIGN
3178 /*
3179 * Set the default for 'backupskip' to include environment variables for
3180 * temp files.
3181 */
3182 {
3183# ifdef UNIX
3184 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3185# else
3186 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3187# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003188 int len;
3189 garray_T ga;
3190 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003191
3192 ga_init2(&ga, 1, 100);
3193 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3194 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003195 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003196# ifdef UNIX
3197 if (*names[n] == NUL)
3198 p = (char_u *)"/tmp";
3199 else
3200# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003201 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003202 if (p != NULL && *p != NUL)
3203 {
3204 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003205 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003206 if (ga_grow(&ga, len) == OK)
3207 {
3208 if (ga.ga_len > 0)
3209 STRCAT(ga.ga_data, ",");
3210 STRCAT(ga.ga_data, p);
3211 add_pathsep(ga.ga_data);
3212 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003213 ga.ga_len += len;
3214 }
3215 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003216 if (mustfree)
3217 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003218 }
3219 if (ga.ga_data != NULL)
3220 {
3221 set_string_default("bsk", ga.ga_data);
3222 vim_free(ga.ga_data);
3223 }
3224 }
3225#endif
3226
3227 /*
3228 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3229 */
3230 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003231 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003232 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003233#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3234 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3235#endif
3236 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003237#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003238 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003239 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003240#else
3241# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003242 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003243 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003244# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003245 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003246# endif
3247#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003248 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003249 opt_idx = findoption((char_u *)"maxmem");
3250 if (opt_idx >= 0)
3251 {
3252#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
Bram Moolenaar427d51c2013-06-16 16:01:25 +02003253 if ((long)options[opt_idx].def_val[VI_DEFAULT] > (long)n
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003254 || (long)options[opt_idx].def_val[VI_DEFAULT] == 0L)
3255#endif
3256 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3257 }
3258 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003259 }
3260
3261#ifdef FEAT_GUI_W32
3262 /* force 'shortname' for Win32s */
3263 if (gui_is_win32s())
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003264 {
3265 opt_idx = findoption((char_u *)"shortname");
3266 if (opt_idx >= 0)
3267 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)TRUE;
3268 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003269#endif
3270
3271#ifdef FEAT_SEARCHPATH
3272 {
3273 char_u *cdpath;
3274 char_u *buf;
3275 int i;
3276 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003277 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003278
3279 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003280 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003281 if (cdpath != NULL)
3282 {
3283 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3284 if (buf != NULL)
3285 {
3286 buf[0] = ','; /* start with ",", current dir first */
3287 j = 1;
3288 for (i = 0; cdpath[i] != NUL; ++i)
3289 {
3290 if (vim_ispathlistsep(cdpath[i]))
3291 buf[j++] = ',';
3292 else
3293 {
3294 if (cdpath[i] == ' ' || cdpath[i] == ',')
3295 buf[j++] = '\\';
3296 buf[j++] = cdpath[i];
3297 }
3298 }
3299 buf[j] = NUL;
3300 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003301 if (opt_idx >= 0)
3302 {
3303 options[opt_idx].def_val[VI_DEFAULT] = buf;
3304 options[opt_idx].flags |= P_DEF_ALLOCED;
3305 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003306 else
3307 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003308 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003309 if (mustfree)
3310 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003311 }
3312 }
3313#endif
3314
3315#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(OS2) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
3316 /* Set print encoding on platforms that don't default to latin1 */
3317 set_string_default("penc",
3318# if defined(MSWIN) || defined(OS2)
3319 (char_u *)"cp1252"
3320# else
3321# ifdef VMS
3322 (char_u *)"dec-mcs"
3323# else
3324# ifdef EBCDIC
3325 (char_u *)"ebcdic-uk"
3326# else
3327# ifdef MAC
3328 (char_u *)"mac-roman"
3329# else /* HPUX */
3330 (char_u *)"hp-roman8"
3331# endif
3332# endif
3333# endif
3334# endif
3335 );
3336#endif
3337
3338#ifdef FEAT_POSTSCRIPT
3339 /* 'printexpr' must be allocated to be able to evaluate it. */
3340 set_string_default("pexpr",
Bram Moolenaared203462004-06-16 11:19:22 +00003341# if defined(MSWIN) || defined(MSDOS) || defined(OS2)
3342 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003343# else
3344# ifdef VMS
3345 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3346
3347# else
3348 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3349# endif
3350# endif
3351 );
3352#endif
3353
3354 /*
3355 * Set all the options (except the terminal options) to their default
3356 * value. Also set the global value for local options.
3357 */
3358 set_options_default(0);
3359
3360#ifdef FEAT_GUI
3361 if (found_reverse_arg)
3362 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3363#endif
3364
3365 curbuf->b_p_initialized = TRUE;
3366 curbuf->b_p_ar = -1; /* no local 'autoread' value */
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01003367 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003368 check_buf_options(curbuf);
3369 check_win_options(curwin);
3370 check_options();
3371
3372 /* Must be before option_expand(), because that one needs vim_isIDc() */
3373 didset_options();
3374
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003375#ifdef FEAT_SPELL
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003376 /* Use the current chartab for the generic chartab. */
3377 init_spell_chartab();
3378#endif
3379
Bram Moolenaar071d4272004-06-13 20:20:40 +00003380#ifdef FEAT_LINEBREAK
3381 /*
3382 * initialize the table for 'breakat'.
3383 */
3384 fill_breakat_flags();
3385#endif
3386
3387 /*
3388 * Expand environment variables and things like "~" for the defaults.
3389 * If option_expand() returns non-NULL the variable is expanded. This can
3390 * only happen for non-indirect options.
3391 * Also set the default to the expanded value, so ":set" does not list
3392 * them.
3393 * Don't set the P_ALLOCED flag, because we don't want to free the
3394 * default.
3395 */
3396 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3397 {
3398 if ((options[opt_idx].flags & P_GETTEXT)
3399 && options[opt_idx].var != NULL)
3400 p = (char_u *)_(*(char **)options[opt_idx].var);
3401 else
3402 p = option_expand(opt_idx, NULL);
3403 if (p != NULL && (p = vim_strsave(p)) != NULL)
3404 {
3405 *(char_u **)options[opt_idx].var = p;
3406 /* VIMEXP
3407 * Defaults for all expanded options are currently the same for Vi
3408 * and Vim. When this changes, add some code here! Also need to
3409 * split P_DEF_ALLOCED in two.
3410 */
3411 if (options[opt_idx].flags & P_DEF_ALLOCED)
3412 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3413 options[opt_idx].def_val[VI_DEFAULT] = p;
3414 options[opt_idx].flags |= P_DEF_ALLOCED;
3415 }
3416 }
3417
3418 /* Initialize the highlight_attr[] table. */
3419 highlight_changed();
3420
3421 save_file_ff(curbuf); /* Buffer is unchanged */
3422
3423 /* Parse default for 'wildmode' */
3424 check_opt_wim();
3425
3426#if defined(FEAT_ARABIC)
3427 /* Detect use of mlterm.
3428 * Mlterm is a terminal emulator akin to xterm that has some special
3429 * abilities (bidi namely).
3430 * NOTE: mlterm's author is being asked to 'set' a variable
3431 * instead of an environment variable due to inheritance.
3432 */
3433 if (mch_getenv((char_u *)"MLTERM") != NULL)
3434 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3435#endif
3436
3437#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
3438 /* Parse default for 'fillchars'. */
3439 (void)set_chars_option(&p_fcs);
3440#endif
3441
3442#ifdef FEAT_CLIPBOARD
3443 /* Parse default for 'clipboard' */
3444 (void)check_clipboard_option();
3445#endif
3446
3447#ifdef FEAT_MBYTE
3448# if defined(WIN3264) && defined(FEAT_GETTEXT)
3449 /*
3450 * If $LANG isn't set, try to get a good value for it. This makes the
3451 * right language be used automatically. Don't do this for English.
3452 */
3453 if (mch_getenv((char_u *)"LANG") == NULL)
3454 {
3455 char buf[20];
3456
3457 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3458 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3459 * only the first two. */
3460 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3461 (LPTSTR)buf, 20);
3462 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3463 {
3464 /* There are a few exceptions (probably more) */
3465 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3466 STRCPY(buf, "zh_TW");
3467 else if (STRNICMP(buf, "chs", 3) == 0
3468 || STRNICMP(buf, "zhc", 3) == 0)
3469 STRCPY(buf, "zh_CN");
3470 else if (STRNICMP(buf, "jp", 2) == 0)
3471 STRCPY(buf, "ja");
3472 else
3473 buf[2] = NUL; /* truncate to two-letter code */
3474 vim_setenv("LANG", buf);
3475 }
3476 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003477# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003478# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003479 /* Moved to os_mac_conv.c to avoid dependency problems. */
3480 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003481# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003482# endif
3483
3484 /* enc_locale() will try to find the encoding of the current locale. */
3485 p = enc_locale();
3486 if (p != NULL)
3487 {
3488 char_u *save_enc;
3489
3490 /* Try setting 'encoding' and check if the value is valid.
3491 * If not, go back to the default "latin1". */
3492 save_enc = p_enc;
3493 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003494 if (STRCMP(p_enc, "gb18030") == 0)
3495 {
3496 /* We don't support "gb18030", but "cp936" is a good substitute
3497 * for practical purposes, thus use that. It's not an alias to
3498 * still support conversion between gb18030 and utf-8. */
3499 p_enc = vim_strsave((char_u *)"cp936");
3500 vim_free(p);
3501 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003502 if (mb_init() == NULL)
3503 {
3504 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003505 if (opt_idx >= 0)
3506 {
3507 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3508 options[opt_idx].flags |= P_DEF_ALLOCED;
3509 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003510
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003511#if defined(MSDOS) || defined(MSWIN) || defined(OS2) || defined(MACOS) \
3512 || defined(VMS)
3513 if (STRCMP(p_enc, "latin1") == 0
3514# ifdef FEAT_MBYTE
3515 || enc_utf8
3516# endif
3517 )
3518 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003519 /* Adjust the default for 'isprint' and 'iskeyword' to match
3520 * latin1. Also set the defaults for when 'nocompatible' is
3521 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003522 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003523 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003524 set_string_option_direct((char_u *)"isk", -1,
3525 ISK_LATIN1, OPT_FREE, SID_NONE);
3526 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003527 if (opt_idx >= 0)
3528 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003529 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003530 if (opt_idx >= 0)
3531 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003532 (void)init_chartab();
3533 }
3534#endif
3535
Bram Moolenaar071d4272004-06-13 20:20:40 +00003536# if defined(WIN3264) && !defined(FEAT_GUI)
3537 /* Win32 console: When GetACP() returns a different value from
3538 * GetConsoleCP() set 'termencoding'. */
3539 if (GetACP() != GetConsoleCP())
3540 {
3541 char buf[50];
3542
3543 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3544 p_tenc = vim_strsave((char_u *)buf);
3545 if (p_tenc != NULL)
3546 {
3547 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003548 if (opt_idx >= 0)
3549 {
3550 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3551 options[opt_idx].flags |= P_DEF_ALLOCED;
3552 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003553 convert_setup(&input_conv, p_tenc, p_enc);
3554 convert_setup(&output_conv, p_enc, p_tenc);
3555 }
3556 else
3557 p_tenc = empty_option;
3558 }
3559# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003560# if defined(WIN3264) && defined(FEAT_MBYTE)
3561 /* $HOME may have characters in active code page. */
3562 init_homedir();
3563# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003564 }
3565 else
3566 {
3567 vim_free(p_enc);
3568 p_enc = save_enc;
3569 }
3570 }
3571#endif
3572
3573#ifdef FEAT_MULTI_LANG
3574 /* Set the default for 'helplang'. */
3575 set_helplang_default(get_mess_lang());
3576#endif
3577}
3578
3579/*
3580 * Set an option to its default value.
3581 * This does not take care of side effects!
3582 */
3583 static void
3584set_option_default(opt_idx, opt_flags, compatible)
3585 int opt_idx;
3586 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3587 int compatible; /* use Vi default value */
3588{
3589 char_u *varp; /* pointer to variable for current option */
3590 int dvi; /* index in def_val[] */
3591 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003592 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003593 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3594
3595 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3596 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003597 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003598 {
3599 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3600 if (flags & P_STRING)
3601 {
3602 /* Use set_string_option_direct() for local options to handle
3603 * freeing and allocating the value. */
3604 if (options[opt_idx].indir != PV_NONE)
3605 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003606 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003607 else
3608 {
3609 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3610 free_string_option(*(char_u **)(varp));
3611 *(char_u **)varp = options[opt_idx].def_val[dvi];
3612 options[opt_idx].flags &= ~P_ALLOCED;
3613 }
3614 }
3615 else if (flags & P_NUM)
3616 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003617 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003618 win_comp_scroll(curwin);
3619 else
3620 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003621 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003622 /* May also set global value for local option. */
3623 if (both)
3624 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3625 *(long *)varp;
3626 }
3627 }
3628 else /* P_BOOL */
3629 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003630 /* the cast to long is required for Manx C, long_i is needed for
3631 * MSVC */
3632 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003633#ifdef UNIX
3634 /* 'modeline' defaults to off for root */
3635 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3636 *(int *)varp = FALSE;
3637#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003638 /* May also set global value for local option. */
3639 if (both)
3640 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3641 *(int *)varp;
3642 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003643
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003644 /* The default value is not insecure. */
3645 flagsp = insecure_flag(opt_idx, opt_flags);
3646 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003647 }
3648
3649#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003650 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003651#endif
3652}
3653
3654/*
3655 * Set all options (except terminal options) to their default value.
3656 */
3657 static void
3658set_options_default(opt_flags)
3659 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3660{
3661 int i;
3662#ifdef FEAT_WINDOWS
3663 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003664 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003665#endif
3666
3667 for (i = 0; !istermoption(&options[i]); i++)
3668 if (!(options[i].flags & P_NODEFAULT))
3669 set_option_default(i, opt_flags, p_cp);
3670
3671#ifdef FEAT_WINDOWS
3672 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003673 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003674 win_comp_scroll(wp);
3675#else
3676 win_comp_scroll(curwin);
3677#endif
Bram Moolenaar5a4eceb2014-09-09 17:33:07 +02003678#ifdef FEAT_CINDENT
3679 parse_cino(curbuf);
3680#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003681}
3682
3683/*
3684 * Set the Vi-default value of a string option.
3685 * Used for 'sh', 'backupskip' and 'term'.
3686 */
3687 void
3688set_string_default(name, val)
3689 char *name;
3690 char_u *val;
3691{
3692 char_u *p;
3693 int opt_idx;
3694
3695 p = vim_strsave(val);
3696 if (p != NULL) /* we don't want a NULL */
3697 {
3698 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003699 if (opt_idx >= 0)
3700 {
3701 if (options[opt_idx].flags & P_DEF_ALLOCED)
3702 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3703 options[opt_idx].def_val[VI_DEFAULT] = p;
3704 options[opt_idx].flags |= P_DEF_ALLOCED;
3705 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003706 }
3707}
3708
3709/*
3710 * Set the Vi-default value of a number option.
3711 * Used for 'lines' and 'columns'.
3712 */
3713 void
3714set_number_default(name, val)
3715 char *name;
3716 long val;
3717{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003718 int opt_idx;
3719
3720 opt_idx = findoption((char_u *)name);
3721 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003722 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003723}
3724
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003725#if defined(EXITFREE) || defined(PROTO)
3726/*
3727 * Free all options.
3728 */
3729 void
3730free_all_options()
3731{
3732 int i;
3733
3734 for (i = 0; !istermoption(&options[i]); i++)
3735 {
3736 if (options[i].indir == PV_NONE)
3737 {
3738 /* global option: free value and default value. */
3739 if (options[i].flags & P_ALLOCED && options[i].var != NULL)
3740 free_string_option(*(char_u **)options[i].var);
3741 if (options[i].flags & P_DEF_ALLOCED)
3742 free_string_option(options[i].def_val[VI_DEFAULT]);
3743 }
3744 else if (options[i].var != VAR_WIN
3745 && (options[i].flags & P_STRING))
3746 /* buffer-local option: free global value */
3747 free_string_option(*(char_u **)options[i].var);
3748 }
3749}
3750#endif
3751
3752
Bram Moolenaar071d4272004-06-13 20:20:40 +00003753/*
3754 * Initialize the options, part two: After getting Rows and Columns and
3755 * setting 'term'.
3756 */
3757 void
3758set_init_2()
3759{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003760 int idx;
3761
Bram Moolenaar071d4272004-06-13 20:20:40 +00003762 /*
3763 * 'scroll' defaults to half the window height. Note that this default is
3764 * wrong when the window height changes.
3765 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003766 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003767 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003768 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003769 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003770 comp_col();
3771
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003772 /*
3773 * 'window' is only for backwards compatibility with Vi.
3774 * Default is Rows - 1.
3775 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003776 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003777 p_window = Rows - 1;
3778 set_number_default("window", Rows - 1);
3779
Bram Moolenaarf740b292006-02-16 22:11:02 +00003780 /* For DOS console the default is always black. */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003781#if !((defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003782 /*
3783 * If 'background' wasn't set by the user, try guessing the value,
3784 * depending on the terminal name. Only need to check for terminals
3785 * with a dark background, that can handle color.
3786 */
3787 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003788 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3789 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003790 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003791 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003792 /* don't mark it as set, when starting the GUI it may be
3793 * changed again */
3794 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003795 }
3796#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003797
3798#ifdef CURSOR_SHAPE
3799 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3800#endif
3801#ifdef FEAT_MOUSESHAPE
3802 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3803#endif
3804#ifdef FEAT_PRINTER
3805 (void)parse_printoptions(); /* parse 'printoptions' default value */
3806#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003807}
3808
3809/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00003810 * Return "dark" or "light" depending on the kind of terminal.
3811 * This is just guessing! Recognized are:
3812 * "linux" Linux console
3813 * "screen.linux" Linux console with screen
3814 * "cygwin" Cygwin shell
3815 * "putty" Putty program
3816 * We also check the COLORFGBG environment variable, which is set by
3817 * rxvt and derivatives. This variable contains either two or three
3818 * values separated by semicolons; we want the last value in either
3819 * case. If this value is 0-6 or 8, our background is dark.
3820 */
3821 static char_u *
3822term_bg_default()
3823{
Bram Moolenaarf740b292006-02-16 22:11:02 +00003824#if defined(MSDOS) || defined(OS2) || defined(WIN3264)
3825 /* DOS console nearly always black */
3826 return (char_u *)"dark";
3827#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00003828 char_u *p;
3829
Bram Moolenaarf740b292006-02-16 22:11:02 +00003830 if (STRCMP(T_NAME, "linux") == 0
3831 || STRCMP(T_NAME, "screen.linux") == 0
3832 || STRCMP(T_NAME, "cygwin") == 0
3833 || STRCMP(T_NAME, "putty") == 0
3834 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
3835 && (p = vim_strrchr(p, ';')) != NULL
3836 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
3837 && p[2] == NUL))
3838 return (char_u *)"dark";
3839 return (char_u *)"light";
3840#endif
3841}
3842
3843/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00003844 * Initialize the options, part three: After reading the .vimrc
3845 */
3846 void
3847set_init_3()
3848{
3849#if defined(UNIX) || defined(OS2) || defined(WIN3264)
3850/*
3851 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
3852 * This is done after other initializations, where 'shell' might have been
3853 * set, but only if they have not been set before.
3854 */
3855 char_u *p;
3856 int idx_srr;
3857 int do_srr;
3858#ifdef FEAT_QUICKFIX
3859 int idx_sp;
3860 int do_sp;
3861#endif
3862
3863 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003864 if (idx_srr < 0)
3865 do_srr = FALSE;
3866 else
3867 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003868#ifdef FEAT_QUICKFIX
3869 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003870 if (idx_sp < 0)
3871 do_sp = FALSE;
3872 else
3873 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003874#endif
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003875 p = get_isolated_shell_name();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003876 if (p != NULL)
3877 {
3878 /*
3879 * Default for p_sp is "| tee", for p_srr is ">".
3880 * For known shells it is changed here to include stderr.
3881 */
3882 if ( fnamecmp(p, "csh") == 0
3883 || fnamecmp(p, "tcsh") == 0
3884# if defined(OS2) || defined(WIN3264) /* also check with .exe extension */
3885 || fnamecmp(p, "csh.exe") == 0
3886 || fnamecmp(p, "tcsh.exe") == 0
3887# endif
3888 )
3889 {
3890#if defined(FEAT_QUICKFIX)
3891 if (do_sp)
3892 {
3893# ifdef WIN3264
3894 p_sp = (char_u *)">&";
3895# else
3896 p_sp = (char_u *)"|& tee";
3897# endif
3898 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3899 }
3900#endif
3901 if (do_srr)
3902 {
3903 p_srr = (char_u *)">&";
3904 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3905 }
3906 }
3907 else
3908# ifndef OS2 /* Always use bourne shell style redirection if we reach this */
3909 if ( fnamecmp(p, "sh") == 0
3910 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003911 || fnamecmp(p, "mksh") == 0
3912 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003913 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003914 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003915 || fnamecmp(p, "bash") == 0
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003916 || fnamecmp(p, "fish") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003917# ifdef WIN3264
3918 || fnamecmp(p, "cmd") == 0
3919 || fnamecmp(p, "sh.exe") == 0
3920 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003921 || fnamecmp(p, "mksh.exe") == 0
3922 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003923 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003924 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003925 || fnamecmp(p, "bash.exe") == 0
3926 || fnamecmp(p, "cmd.exe") == 0
3927# endif
3928 )
3929# endif
3930 {
3931#if defined(FEAT_QUICKFIX)
3932 if (do_sp)
3933 {
3934# ifdef WIN3264
3935 p_sp = (char_u *)">%s 2>&1";
3936# else
3937 p_sp = (char_u *)"2>&1| tee";
3938# endif
3939 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3940 }
3941#endif
3942 if (do_srr)
3943 {
3944 p_srr = (char_u *)">%s 2>&1";
3945 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3946 }
3947 }
3948 vim_free(p);
3949 }
3950#endif
3951
3952#if defined(MSDOS) || defined(WIN3264) || defined(OS2)
3953 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01003954 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
3955 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003956 * This is done after other initializations, where 'shell' might have been
3957 * set, but only if they have not been set before. Default for p_shcf is
3958 * "/c", for p_shq is "". For "sh" like shells it is changed here to
3959 * "-c" and "\"", but not for DJGPP, because it starts the shell without
3960 * command.com. And for Win32 we need to set p_sxq instead.
3961 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00003962 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003963 {
3964 int idx3;
3965
3966 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003967 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003968 {
3969 p_shcf = (char_u *)"-c";
3970 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3971 }
3972
3973# ifndef DJGPP
3974# ifdef WIN3264
3975 /* Somehow Win32 requires the quotes around the redirection too */
3976 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003977 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003978 {
3979 p_sxq = (char_u *)"\"";
3980 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3981 }
3982# else
3983 idx3 = findoption((char_u *)"shq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003984 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003985 {
3986 p_shq = (char_u *)"\"";
3987 options[idx3].def_val[VI_DEFAULT] = p_shq;
3988 }
3989# endif
3990# endif
3991 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01003992 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
3993 {
3994 int idx3;
3995
3996 /*
3997 * cmd.exe on Windows will strip the first and last double quote given
3998 * on the command line, e.g. most of the time things like:
3999 * cmd /c "my path/to/echo" "my args to echo"
4000 * become:
4001 * my path/to/echo" "my args to echo
4002 * when executed.
4003 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01004004 * To avoid this, set shellxquote to surround the command in
4005 * parenthesis. This appears to make most commands work, without
4006 * breaking commands that worked previously, such as
4007 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01004008 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01004009 idx3 = findoption((char_u *)"sxq");
4010 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4011 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004012 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004013 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4014 }
4015
Bram Moolenaara64ba222012-02-12 23:23:31 +01004016 idx3 = findoption((char_u *)"shcf");
4017 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4018 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004019 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004020 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4021 }
4022 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004023#endif
4024
4025#ifdef FEAT_TITLE
4026 set_title_defaults();
4027#endif
4028}
4029
4030#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4031/*
4032 * When 'helplang' is still at its default value, set it to "lang".
4033 * Only the first two characters of "lang" are used.
4034 */
4035 void
4036set_helplang_default(lang)
4037 char_u *lang;
4038{
4039 int idx;
4040
4041 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4042 return;
4043 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004044 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004045 {
4046 if (options[idx].flags & P_ALLOCED)
4047 free_string_option(p_hlg);
4048 p_hlg = vim_strsave(lang);
4049 if (p_hlg == NULL)
4050 p_hlg = empty_option;
4051 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004052 {
4053 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4054 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4055 {
4056 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4057 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4058 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004059 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004060 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004061 options[idx].flags |= P_ALLOCED;
4062 }
4063}
4064#endif
4065
4066#ifdef FEAT_GUI
4067static char_u *gui_bg_default __ARGS((void));
4068
4069 static char_u *
4070gui_bg_default()
4071{
4072 if (gui_get_lightness(gui.back_pixel) < 127)
4073 return (char_u *)"dark";
4074 return (char_u *)"light";
4075}
4076
4077/*
4078 * Option initializations that can only be done after opening the GUI window.
4079 */
4080 void
4081init_gui_options()
4082{
4083 /* Set the 'background' option according to the lightness of the
4084 * background color, unless the user has set it already. */
4085 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4086 {
4087 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4088 highlight_changed();
4089 }
4090}
4091#endif
4092
4093#ifdef FEAT_TITLE
4094/*
4095 * 'title' and 'icon' only default to true if they have not been set or reset
4096 * in .vimrc and we can read the old value.
4097 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4098 * they can be reset. This reduces startup time when using X on a remote
4099 * machine.
4100 */
4101 void
4102set_title_defaults()
4103{
4104 int idx1;
4105 long val;
4106
4107 /*
4108 * If GUI is (going to be) used, we can always set the window title and
4109 * icon name. Saves a bit of time, because the X11 display server does
4110 * not need to be contacted.
4111 */
4112 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004113 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004114 {
4115#ifdef FEAT_GUI
4116 if (gui.starting || gui.in_use)
4117 val = TRUE;
4118 else
4119#endif
4120 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004121 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004122 p_title = val;
4123 }
4124 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004125 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004126 {
4127#ifdef FEAT_GUI
4128 if (gui.starting || gui.in_use)
4129 val = TRUE;
4130 else
4131#endif
4132 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004133 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004134 p_icon = val;
4135 }
4136}
4137#endif
4138
4139/*
4140 * Parse 'arg' for option settings.
4141 *
4142 * 'arg' may be IObuff, but only when no errors can be present and option
4143 * does not need to be expanded with option_expand().
4144 * "opt_flags":
4145 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004146 * OPT_GLOBAL for ":setglobal"
4147 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004148 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004149 * OPT_WINONLY to only set window-local options
4150 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004151 *
4152 * returns FAIL if an error is detected, OK otherwise
4153 */
4154 int
4155do_set(arg, opt_flags)
4156 char_u *arg; /* option string (may be written to!) */
4157 int opt_flags;
4158{
4159 int opt_idx;
4160 char_u *errmsg;
4161 char_u errbuf[80];
4162 char_u *startarg;
4163 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4164 int nextchar; /* next non-white char after option name */
4165 int afterchar; /* character just after option name */
4166 int len;
4167 int i;
4168 long value;
4169 int key;
4170 long_u flags; /* flags for current option */
4171 char_u *varp = NULL; /* pointer to variable for current option */
4172 int did_show = FALSE; /* already showed one value */
4173 int adding; /* "opt+=arg" */
4174 int prepending; /* "opt^=arg" */
4175 int removing; /* "opt-=arg" */
4176 int cp_val = 0;
4177 char_u key_name[2];
4178
4179 if (*arg == NUL)
4180 {
4181 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004182 did_show = TRUE;
4183 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004184 }
4185
4186 while (*arg != NUL) /* loop to process all options */
4187 {
4188 errmsg = NULL;
4189 startarg = arg; /* remember for error message */
4190
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004191 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4192 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004193 {
4194 /*
4195 * ":set all" show all options.
4196 * ":set all&" set all options to their default value.
4197 */
4198 arg += 3;
4199 if (*arg == '&')
4200 {
4201 ++arg;
4202 /* Only for :set command set global value of local options. */
4203 set_options_default(OPT_FREE | opt_flags);
4204 }
4205 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004206 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004207 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004208 did_show = TRUE;
4209 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004210 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004211 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004212 {
4213 showoptions(2, opt_flags);
4214 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004215 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004216 arg += 7;
4217 }
4218 else
4219 {
4220 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004221 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004222 {
4223 prefix = 0;
4224 arg += 2;
4225 }
4226 else if (STRNCMP(arg, "inv", 3) == 0)
4227 {
4228 prefix = 2;
4229 arg += 3;
4230 }
4231
4232 /* find end of name */
4233 key = 0;
4234 if (*arg == '<')
4235 {
4236 nextchar = 0;
4237 opt_idx = -1;
4238 /* look out for <t_>;> */
4239 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4240 len = 5;
4241 else
4242 {
4243 len = 1;
4244 while (arg[len] != NUL && arg[len] != '>')
4245 ++len;
4246 }
4247 if (arg[len] != '>')
4248 {
4249 errmsg = e_invarg;
4250 goto skip;
4251 }
4252 arg[len] = NUL; /* put NUL after name */
4253 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4254 opt_idx = findoption(arg + 1);
4255 arg[len++] = '>'; /* restore '>' */
4256 if (opt_idx == -1)
4257 key = find_key_option(arg + 1);
4258 }
4259 else
4260 {
4261 len = 0;
4262 /*
4263 * The two characters after "t_" may not be alphanumeric.
4264 */
4265 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4266 len = 4;
4267 else
4268 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4269 ++len;
4270 nextchar = arg[len];
4271 arg[len] = NUL; /* put NUL after name */
4272 opt_idx = findoption(arg);
4273 arg[len] = nextchar; /* restore nextchar */
4274 if (opt_idx == -1)
4275 key = find_key_option(arg);
4276 }
4277
4278 /* remember character after option name */
4279 afterchar = arg[len];
4280
4281 /* skip white space, allow ":set ai ?" */
4282 while (vim_iswhite(arg[len]))
4283 ++len;
4284
4285 adding = FALSE;
4286 prepending = FALSE;
4287 removing = FALSE;
4288 if (arg[len] != NUL && arg[len + 1] == '=')
4289 {
4290 if (arg[len] == '+')
4291 {
4292 adding = TRUE; /* "+=" */
4293 ++len;
4294 }
4295 else if (arg[len] == '^')
4296 {
4297 prepending = TRUE; /* "^=" */
4298 ++len;
4299 }
4300 else if (arg[len] == '-')
4301 {
4302 removing = TRUE; /* "-=" */
4303 ++len;
4304 }
4305 }
4306 nextchar = arg[len];
4307
4308 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4309 {
4310 errmsg = (char_u *)N_("E518: Unknown option");
4311 goto skip;
4312 }
4313
4314 if (opt_idx >= 0)
4315 {
4316 if (options[opt_idx].var == NULL) /* hidden option: skip */
4317 {
4318 /* Only give an error message when requesting the value of
4319 * a hidden option, ignore setting it. */
4320 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4321 && (!(options[opt_idx].flags & P_BOOL)
4322 || nextchar == '?'))
4323 errmsg = (char_u *)N_("E519: Option not supported");
4324 goto skip;
4325 }
4326
4327 flags = options[opt_idx].flags;
4328 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4329 }
4330 else
4331 {
4332 flags = P_STRING;
4333 if (key < 0)
4334 {
4335 key_name[0] = KEY2TERMCAP0(key);
4336 key_name[1] = KEY2TERMCAP1(key);
4337 }
4338 else
4339 {
4340 key_name[0] = KS_KEY;
4341 key_name[1] = (key & 0xff);
4342 }
4343 }
4344
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004345 /* Skip all options that are not window-local (used when showing
4346 * an already loaded buffer in a window). */
4347 if ((opt_flags & OPT_WINONLY)
4348 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4349 goto skip;
4350
Bram Moolenaara3227e22006-03-08 21:32:40 +00004351 /* Skip all options that are window-local (used for :vimgrep). */
4352 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4353 && options[opt_idx].var == VAR_WIN)
4354 goto skip;
4355
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004356 /* Disallow changing some options from modelines. */
4357 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004358 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004359 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004360 {
4361 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4362 goto skip;
4363 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004364#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004365 /* In diff mode some options are overruled. This avoids that
4366 * 'foldmethod' becomes "marker" instead of "diff" and that
4367 * "wrap" gets set. */
4368 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004369 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004370 && (options[opt_idx].indir == PV_FDM
4371 || options[opt_idx].indir == PV_WRAP))
4372 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004373#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004374 }
4375
4376#ifdef HAVE_SANDBOX
4377 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004378 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004379 {
4380 errmsg = (char_u *)_(e_sandbox);
4381 goto skip;
4382 }
4383#endif
4384
4385 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4386 {
4387 arg += len;
4388 cp_val = p_cp;
4389 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4390 {
4391 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4392 {
4393 cp_val = FALSE;
4394 arg += 3;
4395 }
4396 else /* "opt&vi": set to Vi default */
4397 {
4398 cp_val = TRUE;
4399 arg += 2;
4400 }
4401 }
4402 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
4403 && arg[1] != NUL && !vim_iswhite(arg[1]))
4404 {
4405 errmsg = e_trailing;
4406 goto skip;
4407 }
4408 }
4409
4410 /*
4411 * allow '=' and ':' as MSDOS command.com allows only one
4412 * '=' character per "set" command line. grrr. (jw)
4413 */
4414 if (nextchar == '?'
4415 || (prefix == 1
4416 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4417 && !(flags & P_BOOL)))
4418 {
4419 /*
4420 * print value
4421 */
4422 if (did_show)
4423 msg_putchar('\n'); /* cursor below last one */
4424 else
4425 {
4426 gotocmdline(TRUE); /* cursor at status line */
4427 did_show = TRUE; /* remember that we did a line */
4428 }
4429 if (opt_idx >= 0)
4430 {
4431 showoneopt(&options[opt_idx], opt_flags);
4432#ifdef FEAT_EVAL
4433 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004434 {
4435 /* Mention where the option was last set. */
4436 if (varp == options[opt_idx].var)
4437 last_set_msg(options[opt_idx].scriptID);
4438 else if ((int)options[opt_idx].indir & PV_WIN)
4439 last_set_msg(curwin->w_p_scriptID[
4440 (int)options[opt_idx].indir & PV_MASK]);
4441 else if ((int)options[opt_idx].indir & PV_BUF)
4442 last_set_msg(curbuf->b_p_scriptID[
4443 (int)options[opt_idx].indir & PV_MASK]);
4444 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004445#endif
4446 }
4447 else
4448 {
4449 char_u *p;
4450
4451 p = find_termcode(key_name);
4452 if (p == NULL)
4453 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004454 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004455 goto skip;
4456 }
4457 else
4458 (void)show_one_termcode(key_name, p, TRUE);
4459 }
4460 if (nextchar != '?'
4461 && nextchar != NUL && !vim_iswhite(afterchar))
4462 errmsg = e_trailing;
4463 }
4464 else
4465 {
4466 if (flags & P_BOOL) /* boolean */
4467 {
4468 if (nextchar == '=' || nextchar == ':')
4469 {
4470 errmsg = e_invarg;
4471 goto skip;
4472 }
4473
4474 /*
4475 * ":set opt!": invert
4476 * ":set opt&": reset to default value
4477 * ":set opt<": reset to global value
4478 */
4479 if (nextchar == '!')
4480 value = *(int *)(varp) ^ 1;
4481 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004482 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004483 ((flags & P_VI_DEF) || cp_val)
4484 ? VI_DEFAULT : VIM_DEFAULT];
4485 else if (nextchar == '<')
4486 {
4487 /* For 'autoread' -1 means to use global value. */
4488 if ((int *)varp == &curbuf->b_p_ar
4489 && opt_flags == OPT_LOCAL)
4490 value = -1;
4491 else
4492 value = *(int *)get_varp_scope(&(options[opt_idx]),
4493 OPT_GLOBAL);
4494 }
4495 else
4496 {
4497 /*
4498 * ":set invopt": invert
4499 * ":set opt" or ":set noopt": set or reset
4500 */
4501 if (nextchar != NUL && !vim_iswhite(afterchar))
4502 {
4503 errmsg = e_trailing;
4504 goto skip;
4505 }
4506 if (prefix == 2) /* inv */
4507 value = *(int *)(varp) ^ 1;
4508 else
4509 value = prefix;
4510 }
4511
4512 errmsg = set_bool_option(opt_idx, varp, (int)value,
4513 opt_flags);
4514 }
4515 else /* numeric or string */
4516 {
4517 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4518 || prefix != 1)
4519 {
4520 errmsg = e_invarg;
4521 goto skip;
4522 }
4523
4524 if (flags & P_NUM) /* numeric */
4525 {
4526 /*
4527 * Different ways to set a number option:
4528 * & set to default value
4529 * < set to global value
4530 * <xx> accept special key codes for 'wildchar'
4531 * c accept any non-digit for 'wildchar'
4532 * [-]0-9 set number
4533 * other error
4534 */
4535 ++arg;
4536 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004537 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004538 ((flags & P_VI_DEF) || cp_val)
4539 ? VI_DEFAULT : VIM_DEFAULT];
4540 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004541 {
4542 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4543 * use the global value. */
4544 if ((long *)varp == &curbuf->b_p_ul
4545 && opt_flags == OPT_LOCAL)
4546 value = NO_LOCAL_UNDOLEVEL;
4547 else
4548 value = *(long *)get_varp_scope(
4549 &(options[opt_idx]), OPT_GLOBAL);
4550 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004551 else if (((long *)varp == &p_wc
4552 || (long *)varp == &p_wcm)
4553 && (*arg == '<'
4554 || *arg == '^'
4555 || ((!arg[1] || vim_iswhite(arg[1]))
4556 && !VIM_ISDIGIT(*arg))))
4557 {
4558 value = string_to_key(arg);
4559 if (value == 0 && (long *)varp != &p_wcm)
4560 {
4561 errmsg = e_invarg;
4562 goto skip;
4563 }
4564 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004565 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4566 {
Bram Moolenaar18400e62015-01-27 15:58:40 +01004567 /* Allow negative (for 'undolevels'), octal and
4568 * hex numbers. */
Bram Moolenaar5d1bc782015-07-17 13:03:48 +02004569 vim_str2nr(arg, NULL, &i, TRUE, TRUE, &value, NULL, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004570 if (arg[i] != NUL && !vim_iswhite(arg[i]))
4571 {
4572 errmsg = e_invarg;
4573 goto skip;
4574 }
4575 }
4576 else
4577 {
4578 errmsg = (char_u *)N_("E521: Number required after =");
4579 goto skip;
4580 }
4581
4582 if (adding)
4583 value = *(long *)varp + value;
4584 if (prepending)
4585 value = *(long *)varp * value;
4586 if (removing)
4587 value = *(long *)varp - value;
4588 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004589 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004590 }
4591 else if (opt_idx >= 0) /* string */
4592 {
4593 char_u *save_arg = NULL;
4594 char_u *s = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004595 char_u *oldval = NULL; /* previous value if *varp */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004596 char_u *newval;
Bram Moolenaar53744302015-07-17 17:38:22 +02004597 char_u *origval = NULL;
4598#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4599 char_u *saved_origval = NULL;
4600#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004601 unsigned newlen;
4602 int comma;
4603 int bs;
4604 int new_value_alloced; /* new string option
4605 was allocated */
4606
4607 /* When using ":set opt=val" for a global option
4608 * with a local value the local value will be
4609 * reset, use the global value here. */
4610 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004611 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004612 varp = options[opt_idx].var;
4613
4614 /* The old value is kept until we are sure that the
4615 * new value is valid. */
4616 oldval = *(char_u **)varp;
4617 if (nextchar == '&') /* set to default val */
4618 {
4619 newval = options[opt_idx].def_val[
4620 ((flags & P_VI_DEF) || cp_val)
4621 ? VI_DEFAULT : VIM_DEFAULT];
4622 if ((char_u **)varp == &p_bg)
4623 {
4624 /* guess the value of 'background' */
4625#ifdef FEAT_GUI
4626 if (gui.in_use)
4627 newval = gui_bg_default();
4628 else
4629#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004630 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004631 }
4632
4633 /* expand environment variables and ~ (since the
4634 * default value was already expanded, only
4635 * required when an environment variable was set
4636 * later */
4637 if (newval == NULL)
4638 newval = empty_option;
4639 else
4640 {
4641 s = option_expand(opt_idx, newval);
4642 if (s == NULL)
4643 s = newval;
4644 newval = vim_strsave(s);
4645 }
4646 new_value_alloced = TRUE;
4647 }
4648 else if (nextchar == '<') /* set to global val */
4649 {
4650 newval = vim_strsave(*(char_u **)get_varp_scope(
4651 &(options[opt_idx]), OPT_GLOBAL));
4652 new_value_alloced = TRUE;
4653 }
4654 else
4655 {
4656 ++arg; /* jump to after the '=' or ':' */
4657
4658 /*
4659 * Set 'keywordprg' to ":help" if an empty
4660 * value was passed to :set by the user.
4661 * Misuse errbuf[] for the resulting string.
4662 */
4663 if (varp == (char_u *)&p_kp
4664 && (*arg == NUL || *arg == ' '))
4665 {
4666 STRCPY(errbuf, ":help");
4667 save_arg = arg;
4668 arg = errbuf;
4669 }
4670 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004671 * Convert 'backspace' number to string, for
4672 * adding, prepending and removing string.
4673 */
4674 else if (varp == (char_u *)&p_bs
4675 && VIM_ISDIGIT(**(char_u **)varp))
4676 {
4677 i = getdigits((char_u **)varp);
4678 switch (i)
4679 {
4680 case 0:
4681 *(char_u **)varp = empty_option;
4682 break;
4683 case 1:
4684 *(char_u **)varp = vim_strsave(
4685 (char_u *)"indent,eol");
4686 break;
4687 case 2:
4688 *(char_u **)varp = vim_strsave(
4689 (char_u *)"indent,eol,start");
4690 break;
4691 }
4692 vim_free(oldval);
4693 oldval = *(char_u **)varp;
4694 }
4695 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004696 * Convert 'whichwrap' number to string, for
4697 * backwards compatibility with Vim 3.0.
4698 * Misuse errbuf[] for the resulting string.
4699 */
4700 else if (varp == (char_u *)&p_ww
4701 && VIM_ISDIGIT(*arg))
4702 {
4703 *errbuf = NUL;
4704 i = getdigits(&arg);
4705 if (i & 1)
4706 STRCAT(errbuf, "b,");
4707 if (i & 2)
4708 STRCAT(errbuf, "s,");
4709 if (i & 4)
4710 STRCAT(errbuf, "h,l,");
4711 if (i & 8)
4712 STRCAT(errbuf, "<,>,");
4713 if (i & 16)
4714 STRCAT(errbuf, "[,],");
4715 if (*errbuf != NUL) /* remove trailing , */
4716 errbuf[STRLEN(errbuf) - 1] = NUL;
4717 save_arg = arg;
4718 arg = errbuf;
4719 }
4720 /*
4721 * Remove '>' before 'dir' and 'bdir', for
4722 * backwards compatibility with version 3.0
4723 */
4724 else if ( *arg == '>'
4725 && (varp == (char_u *)&p_dir
4726 || varp == (char_u *)&p_bdir))
4727 {
4728 ++arg;
4729 }
4730
4731 /* When setting the local value of a global
4732 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004733 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004734 && (opt_flags & OPT_LOCAL))
4735 origval = *(char_u **)get_varp(
4736 &options[opt_idx]);
4737 else
4738 origval = oldval;
4739
4740 /*
4741 * Copy the new string into allocated memory.
4742 * Can't use set_string_option_direct(), because
4743 * we need to remove the backslashes.
4744 */
4745 /* get a bit too much */
4746 newlen = (unsigned)STRLEN(arg) + 1;
4747 if (adding || prepending || removing)
4748 newlen += (unsigned)STRLEN(origval) + 1;
4749 newval = alloc(newlen);
4750 if (newval == NULL) /* out of mem, don't change */
4751 break;
4752 s = newval;
4753
4754 /*
4755 * Copy the string, skip over escaped chars.
4756 * For MS-DOS and WIN32 backslashes before normal
4757 * file name characters are not removed, and keep
4758 * backslash at start, for "\\machine\path", but
4759 * do remove it for "\\\\machine\\path".
4760 * The reverse is found in ExpandOldSetting().
4761 */
4762 while (*arg && !vim_iswhite(*arg))
4763 {
4764 if (*arg == '\\' && arg[1] != NUL
4765#ifdef BACKSLASH_IN_FILENAME
4766 && !((flags & P_EXPAND)
4767 && vim_isfilec(arg[1])
4768 && (arg[1] != '\\'
4769 || (s == newval
4770 && arg[2] != '\\')))
4771#endif
4772 )
4773 ++arg; /* remove backslash */
4774#ifdef FEAT_MBYTE
4775 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00004776 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004777 {
4778 /* copy multibyte char */
4779 mch_memmove(s, arg, (size_t)i);
4780 arg += i;
4781 s += i;
4782 }
4783 else
4784#endif
4785 *s++ = *arg++;
4786 }
4787 *s = NUL;
4788
4789 /*
4790 * Expand environment variables and ~.
4791 * Don't do it when adding without inserting a
4792 * comma.
4793 */
4794 if (!(adding || prepending || removing)
4795 || (flags & P_COMMA))
4796 {
4797 s = option_expand(opt_idx, newval);
4798 if (s != NULL)
4799 {
4800 vim_free(newval);
4801 newlen = (unsigned)STRLEN(s) + 1;
4802 if (adding || prepending || removing)
4803 newlen += (unsigned)STRLEN(origval) + 1;
4804 newval = alloc(newlen);
4805 if (newval == NULL)
4806 break;
4807 STRCPY(newval, s);
4808 }
4809 }
4810
4811 /* locate newval[] in origval[] when removing it
4812 * and when adding to avoid duplicates */
4813 i = 0; /* init for GCC */
4814 if (removing || (flags & P_NODUP))
4815 {
4816 i = (int)STRLEN(newval);
4817 bs = 0;
4818 for (s = origval; *s; ++s)
4819 {
4820 if ((!(flags & P_COMMA)
4821 || s == origval
4822 || (s[-1] == ',' && !(bs & 1)))
4823 && STRNCMP(s, newval, i) == 0
4824 && (!(flags & P_COMMA)
4825 || s[i] == ','
4826 || s[i] == NUL))
4827 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004828 /* Count backslashes. Only a comma with an
4829 * even number of backslashes before it is
Bram Moolenaar071d4272004-06-13 20:20:40 +00004830 * recognized as a separator */
4831 if (s > origval && s[-1] == '\\')
4832 ++bs;
4833 else
4834 bs = 0;
4835 }
4836
4837 /* do not add if already there */
4838 if ((adding || prepending) && *s)
4839 {
4840 prepending = FALSE;
4841 adding = FALSE;
4842 STRCPY(newval, origval);
4843 }
4844 }
4845
4846 /* concatenate the two strings; add a ',' if
4847 * needed */
4848 if (adding || prepending)
4849 {
4850 comma = ((flags & P_COMMA) && *origval != NUL
4851 && *newval != NUL);
4852 if (adding)
4853 {
4854 i = (int)STRLEN(origval);
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004855 /* strip a trailing comma, would get 2 */
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02004856 if (comma && (flags & P_ONECOMMA) && i > 1
4857 && origval[i - 1] == ','
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004858 && origval[i - 2] != '\\')
4859 i--;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004860 mch_memmove(newval + i + comma, newval,
4861 STRLEN(newval) + 1);
4862 mch_memmove(newval, origval, (size_t)i);
4863 }
4864 else
4865 {
4866 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004867 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004868 }
4869 if (comma)
4870 newval[i] = ',';
4871 }
4872
4873 /* Remove newval[] from origval[]. (Note: "i" has
4874 * been set above and is used here). */
4875 if (removing)
4876 {
4877 STRCPY(newval, origval);
4878 if (*s)
4879 {
4880 /* may need to remove a comma */
4881 if (flags & P_COMMA)
4882 {
4883 if (s == origval)
4884 {
4885 /* include comma after string */
4886 if (s[i] == ',')
4887 ++i;
4888 }
4889 else
4890 {
4891 /* include comma before string */
4892 --s;
4893 ++i;
4894 }
4895 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004896 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004897 }
4898 }
4899
4900 if (flags & P_FLAGLIST)
4901 {
4902 /* Remove flags that appear twice. */
4903 for (s = newval; *s; ++s)
4904 if ((!(flags & P_COMMA) || *s != ',')
4905 && vim_strchr(s + 1, *s) != NULL)
4906 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004907 STRMOVE(s, s + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004908 --s;
4909 }
4910 }
4911
4912 if (save_arg != NULL) /* number for 'whichwrap' */
4913 arg = save_arg;
4914 new_value_alloced = TRUE;
4915 }
4916
4917 /* Set the new value. */
4918 *(char_u **)(varp) = newval;
4919
Bram Moolenaar53744302015-07-17 17:38:22 +02004920#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4921 if (!starting && options[opt_idx].indir != PV_KEY
4922 && origval != NULL)
4923 /* origval may be freed by
4924 * did_set_string_option(), make a copy. */
4925 saved_origval = vim_strsave(origval);
4926#endif
4927
Bram Moolenaar071d4272004-06-13 20:20:40 +00004928 /* Handle side effects, and set the global value for
4929 * ":set" on local options. */
4930 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
4931 new_value_alloced, oldval, errbuf, opt_flags);
4932
4933 /* If error detected, print the error message. */
4934 if (errmsg != NULL)
4935 goto skip;
Bram Moolenaar53744302015-07-17 17:38:22 +02004936#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4937 if (saved_origval != NULL)
4938 {
4939 char_u buf_type[7];
4940
4941 sprintf((char *)buf_type, "%s",
4942 (opt_flags & OPT_LOCAL) ? "local" : "global");
4943 set_vim_var_string(VV_OPTION_NEW, newval, -1);
4944 set_vim_var_string(VV_OPTION_OLD, saved_origval, -1);
4945 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
4946 apply_autocmds(EVENT_OPTIONSET,
4947 (char_u *)options[opt_idx].fullname,
4948 NULL, FALSE, NULL);
4949 reset_v_option_vars();
4950 vim_free(saved_origval);
4951 }
4952#endif
4953
Bram Moolenaar071d4272004-06-13 20:20:40 +00004954 }
4955 else /* key code option */
4956 {
4957 char_u *p;
4958
4959 if (nextchar == '&')
4960 {
4961 if (add_termcap_entry(key_name, TRUE) == FAIL)
4962 errmsg = (char_u *)N_("E522: Not found in termcap");
4963 }
4964 else
4965 {
4966 ++arg; /* jump to after the '=' or ':' */
4967 for (p = arg; *p && !vim_iswhite(*p); ++p)
4968 if (*p == '\\' && p[1] != NUL)
4969 ++p;
4970 nextchar = *p;
4971 *p = NUL;
4972 add_termcode(key_name, arg, FALSE);
4973 *p = nextchar;
4974 }
4975 if (full_screen)
4976 ttest(FALSE);
4977 redraw_all_later(CLEAR);
4978 }
4979 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004980
Bram Moolenaar071d4272004-06-13 20:20:40 +00004981 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004982 did_set_option(opt_idx, opt_flags,
4983 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004984 }
4985
4986skip:
4987 /*
4988 * Advance to next argument.
4989 * - skip until a blank found, taking care of backslashes
4990 * - skip blanks
4991 * - skip one "=val" argument (for hidden options ":set gfn =xx")
4992 */
4993 for (i = 0; i < 2 ; ++i)
4994 {
4995 while (*arg != NUL && !vim_iswhite(*arg))
4996 if (*arg++ == '\\' && *arg != NUL)
4997 ++arg;
4998 arg = skipwhite(arg);
4999 if (*arg != '=')
5000 break;
5001 }
5002 }
5003
5004 if (errmsg != NULL)
5005 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005006 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005007 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005008 if (i + (arg - startarg) < IOSIZE)
5009 {
5010 /* append the argument with the error */
5011 STRCAT(IObuff, ": ");
5012 mch_memmove(IObuff + i, startarg, (arg - startarg));
5013 IObuff[i + (arg - startarg)] = NUL;
5014 }
5015 /* make sure all characters are printable */
5016 trans_characters(IObuff, IOSIZE);
5017
5018 ++no_wait_return; /* wait_return done later */
5019 emsg(IObuff); /* show error highlighted */
5020 --no_wait_return;
5021
5022 return FAIL;
5023 }
5024
5025 arg = skipwhite(arg);
5026 }
5027
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005028theend:
5029 if (silent_mode && did_show)
5030 {
5031 /* After displaying option values in silent mode. */
5032 silent_mode = FALSE;
5033 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5034 msg_putchar('\n');
5035 cursor_on(); /* msg_start() switches it off */
5036 out_flush();
5037 silent_mode = TRUE;
5038 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5039 }
5040
Bram Moolenaar071d4272004-06-13 20:20:40 +00005041 return OK;
5042}
5043
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005044/*
5045 * Call this when an option has been given a new value through a user command.
5046 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5047 */
5048 static void
5049did_set_option(opt_idx, opt_flags, new_value)
5050 int opt_idx;
5051 int opt_flags; /* possibly with OPT_MODELINE */
5052 int new_value; /* value was replaced completely */
5053{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005054 long_u *p;
5055
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005056 options[opt_idx].flags |= P_WAS_SET;
5057
5058 /* When an option is set in the sandbox, from a modeline or in secure mode
5059 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005060 * flag. */
5061 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005062 if (secure
5063#ifdef HAVE_SANDBOX
5064 || sandbox != 0
5065#endif
5066 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005067 *p = *p | P_INSECURE;
5068 else if (new_value)
5069 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005070}
5071
Bram Moolenaar071d4272004-06-13 20:20:40 +00005072 static char_u *
5073illegal_char(errbuf, c)
5074 char_u *errbuf;
5075 int c;
5076{
5077 if (errbuf == NULL)
5078 return (char_u *)"";
5079 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005080 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005081 return errbuf;
5082}
5083
5084/*
5085 * Convert a key name or string into a key value.
5086 * Used for 'wildchar' and 'cedit' options.
5087 */
5088 static int
5089string_to_key(arg)
5090 char_u *arg;
5091{
5092 if (*arg == '<')
5093 return find_key_option(arg + 1);
5094 if (*arg == '^')
5095 return Ctrl_chr(arg[1]);
5096 return *arg;
5097}
5098
5099#ifdef FEAT_CMDWIN
5100/*
5101 * Check value of 'cedit' and set cedit_key.
5102 * Returns NULL if value is OK, error message otherwise.
5103 */
5104 static char_u *
5105check_cedit()
5106{
5107 int n;
5108
5109 if (*p_cedit == NUL)
5110 cedit_key = -1;
5111 else
5112 {
5113 n = string_to_key(p_cedit);
5114 if (vim_isprintc(n))
5115 return e_invarg;
5116 cedit_key = n;
5117 }
5118 return NULL;
5119}
5120#endif
5121
5122#ifdef FEAT_TITLE
5123/*
5124 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5125 * maketitle() to create and display it.
5126 * When switching the title or icon off, call mch_restore_title() to get
5127 * the old value back.
5128 */
5129 static void
5130did_set_title(icon)
5131 int icon; /* Did set icon instead of title */
5132{
5133 if (starting != NO_SCREEN
5134#ifdef FEAT_GUI
5135 && !gui.starting
5136#endif
5137 )
5138 {
5139 maketitle();
5140 if (icon)
5141 {
5142 if (!p_icon)
5143 mch_restore_title(2);
5144 }
5145 else
5146 {
5147 if (!p_title)
5148 mch_restore_title(1);
5149 }
5150 }
5151}
5152#endif
5153
5154/*
5155 * set_options_bin - called when 'bin' changes value.
5156 */
5157 void
5158set_options_bin(oldval, newval, opt_flags)
5159 int oldval;
5160 int newval;
5161 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5162{
5163 /*
5164 * The option values that are changed when 'bin' changes are
5165 * copied when 'bin is set and restored when 'bin' is reset.
5166 */
5167 if (newval)
5168 {
5169 if (!oldval) /* switched on */
5170 {
5171 if (!(opt_flags & OPT_GLOBAL))
5172 {
5173 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5174 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5175 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5176 curbuf->b_p_et_nobin = curbuf->b_p_et;
5177 }
5178 if (!(opt_flags & OPT_LOCAL))
5179 {
5180 p_tw_nobin = p_tw;
5181 p_wm_nobin = p_wm;
5182 p_ml_nobin = p_ml;
5183 p_et_nobin = p_et;
5184 }
5185 }
5186
5187 if (!(opt_flags & OPT_GLOBAL))
5188 {
5189 curbuf->b_p_tw = 0; /* no automatic line wrap */
5190 curbuf->b_p_wm = 0; /* no automatic line wrap */
5191 curbuf->b_p_ml = 0; /* no modelines */
5192 curbuf->b_p_et = 0; /* no expandtab */
5193 }
5194 if (!(opt_flags & OPT_LOCAL))
5195 {
5196 p_tw = 0;
5197 p_wm = 0;
5198 p_ml = FALSE;
5199 p_et = FALSE;
5200 p_bin = TRUE; /* needed when called for the "-b" argument */
5201 }
5202 }
5203 else if (oldval) /* switched off */
5204 {
5205 if (!(opt_flags & OPT_GLOBAL))
5206 {
5207 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5208 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5209 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5210 curbuf->b_p_et = curbuf->b_p_et_nobin;
5211 }
5212 if (!(opt_flags & OPT_LOCAL))
5213 {
5214 p_tw = p_tw_nobin;
5215 p_wm = p_wm_nobin;
5216 p_ml = p_ml_nobin;
5217 p_et = p_et_nobin;
5218 }
5219 }
5220}
5221
5222#ifdef FEAT_VIMINFO
5223/*
5224 * Find the parameter represented by the given character (eg ', :, ", or /),
5225 * and return its associated value in the 'viminfo' string.
5226 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005227 * If the parameter is not specified in the string or there is no following
5228 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005229 */
5230 int
5231get_viminfo_parameter(type)
5232 int type;
5233{
5234 char_u *p;
5235
5236 p = find_viminfo_parameter(type);
5237 if (p != NULL && VIM_ISDIGIT(*p))
5238 return atoi((char *)p);
5239 return -1;
5240}
5241
5242/*
5243 * Find the parameter represented by the given character (eg ''', ':', '"', or
5244 * '/') in the 'viminfo' option and return a pointer to the string after it.
5245 * Return NULL if the parameter is not specified in the string.
5246 */
5247 char_u *
5248find_viminfo_parameter(type)
5249 int type;
5250{
5251 char_u *p;
5252
5253 for (p = p_viminfo; *p; ++p)
5254 {
5255 if (*p == type)
5256 return p + 1;
5257 if (*p == 'n') /* 'n' is always the last one */
5258 break;
5259 p = vim_strchr(p, ','); /* skip until next ',' */
5260 if (p == NULL) /* hit the end without finding parameter */
5261 break;
5262 }
5263 return NULL;
5264}
5265#endif
5266
5267/*
5268 * Expand environment variables for some string options.
5269 * These string options cannot be indirect!
5270 * If "val" is NULL expand the current value of the option.
5271 * Return pointer to NameBuff, or NULL when not expanded.
5272 */
5273 static char_u *
5274option_expand(opt_idx, val)
5275 int opt_idx;
5276 char_u *val;
5277{
5278 /* if option doesn't need expansion nothing to do */
5279 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5280 return NULL;
5281
5282 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5283 * expand_env() would truncate the string. */
5284 if (val != NULL && STRLEN(val) > MAXPATHL)
5285 return NULL;
5286
5287 if (val == NULL)
5288 val = *(char_u **)options[opt_idx].var;
5289
5290 /*
5291 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5292 * Escape spaces when expanding 'tags', they are used to separate file
5293 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005294 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005295 */
5296 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005297 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005298#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005299 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5300#endif
5301 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005302 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5303 return NULL;
5304
5305 return NameBuff;
5306}
5307
5308/*
5309 * After setting various option values: recompute variables that depend on
5310 * option values.
5311 */
5312 static void
5313didset_options()
5314{
5315 /* initialize the table for 'iskeyword' et.al. */
5316 (void)init_chartab();
5317
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005318#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005319 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005320#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005321 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
5322#ifdef FEAT_SESSION
5323 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5324 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5325#endif
5326#ifdef FEAT_FOLDING
5327 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5328#endif
5329 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
5330#ifdef FEAT_VIRTUALEDIT
5331 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5332#endif
5333#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5334 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5335#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005336#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005337 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005338 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005339 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005340#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005341#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5342 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5343#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005344#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005345 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5346#endif
5347#ifdef FEAT_CMDWIN
5348 /* set cedit_key */
5349 (void)check_cedit();
5350#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005351#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005352 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005353#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005354}
5355
5356/*
5357 * Check for string options that are NULL (normally only termcap options).
5358 */
5359 void
5360check_options()
5361{
5362 int opt_idx;
5363
5364 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5365 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5366 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5367}
5368
5369/*
5370 * Check string options in a buffer for NULL value.
5371 */
5372 void
5373check_buf_options(buf)
5374 buf_T *buf;
5375{
5376#if defined(FEAT_QUICKFIX)
5377 check_string_option(&buf->b_p_bh);
5378 check_string_option(&buf->b_p_bt);
5379#endif
5380#ifdef FEAT_MBYTE
5381 check_string_option(&buf->b_p_fenc);
5382#endif
5383 check_string_option(&buf->b_p_ff);
5384#ifdef FEAT_FIND_ID
5385 check_string_option(&buf->b_p_def);
5386 check_string_option(&buf->b_p_inc);
5387# ifdef FEAT_EVAL
5388 check_string_option(&buf->b_p_inex);
5389# endif
5390#endif
5391#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5392 check_string_option(&buf->b_p_inde);
5393 check_string_option(&buf->b_p_indk);
5394#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005395#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5396 check_string_option(&buf->b_p_bexpr);
5397#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005398#if defined(FEAT_CRYPT)
5399 check_string_option(&buf->b_p_cm);
5400#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005401#if defined(FEAT_EVAL)
5402 check_string_option(&buf->b_p_fex);
5403#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005404#ifdef FEAT_CRYPT
5405 check_string_option(&buf->b_p_key);
5406#endif
5407 check_string_option(&buf->b_p_kp);
5408 check_string_option(&buf->b_p_mps);
5409 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005410 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005411 check_string_option(&buf->b_p_isk);
5412#ifdef FEAT_COMMENTS
5413 check_string_option(&buf->b_p_com);
5414#endif
5415#ifdef FEAT_FOLDING
5416 check_string_option(&buf->b_p_cms);
5417#endif
5418 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005419#ifdef FEAT_TEXTOBJ
5420 check_string_option(&buf->b_p_qe);
5421#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005422#ifdef FEAT_SYN_HL
5423 check_string_option(&buf->b_p_syn);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005424#endif
5425#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005426 check_string_option(&buf->b_s.b_p_spc);
5427 check_string_option(&buf->b_s.b_p_spf);
5428 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005429#endif
5430#ifdef FEAT_SEARCHPATH
5431 check_string_option(&buf->b_p_sua);
5432#endif
5433#ifdef FEAT_CINDENT
5434 check_string_option(&buf->b_p_cink);
5435 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005436 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005437#endif
5438#ifdef FEAT_AUTOCMD
5439 check_string_option(&buf->b_p_ft);
5440#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005441#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5442 check_string_option(&buf->b_p_cinw);
5443#endif
5444#ifdef FEAT_INS_EXPAND
5445 check_string_option(&buf->b_p_cpt);
5446#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005447#ifdef FEAT_COMPL_FUNC
5448 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005449 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005450#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005451#ifdef FEAT_KEYMAP
5452 check_string_option(&buf->b_p_keymap);
5453#endif
5454#ifdef FEAT_QUICKFIX
5455 check_string_option(&buf->b_p_gp);
5456 check_string_option(&buf->b_p_mp);
5457 check_string_option(&buf->b_p_efm);
5458#endif
5459 check_string_option(&buf->b_p_ep);
5460 check_string_option(&buf->b_p_path);
5461 check_string_option(&buf->b_p_tags);
5462#ifdef FEAT_INS_EXPAND
5463 check_string_option(&buf->b_p_dict);
5464 check_string_option(&buf->b_p_tsr);
5465#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005466#ifdef FEAT_LISP
5467 check_string_option(&buf->b_p_lw);
5468#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005469 check_string_option(&buf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005470}
5471
5472/*
5473 * Free the string allocated for an option.
5474 * Checks for the string being empty_option. This may happen if we're out of
5475 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5476 * check_options().
5477 * Does NOT check for P_ALLOCED flag!
5478 */
5479 void
5480free_string_option(p)
5481 char_u *p;
5482{
5483 if (p != empty_option)
5484 vim_free(p);
5485}
5486
5487 void
5488clear_string_option(pp)
5489 char_u **pp;
5490{
5491 if (*pp != empty_option)
5492 vim_free(*pp);
5493 *pp = empty_option;
5494}
5495
5496 static void
5497check_string_option(pp)
5498 char_u **pp;
5499{
5500 if (*pp == NULL)
5501 *pp = empty_option;
5502}
5503
5504/*
5505 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5506 */
5507 void
5508set_term_option_alloced(p)
5509 char_u **p;
5510{
5511 int opt_idx;
5512
5513 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5514 if (options[opt_idx].var == (char_u *)p)
5515 {
5516 options[opt_idx].flags |= P_ALLOCED;
5517 return;
5518 }
5519 return; /* cannot happen: didn't find it! */
5520}
5521
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005522#if defined(FEAT_EVAL) || defined(PROTO)
5523/*
5524 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5525 * Return FALSE when it wasn't.
5526 * Return -1 for an unknown option.
5527 */
5528 int
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005529was_set_insecurely(opt, opt_flags)
5530 char_u *opt;
5531 int opt_flags;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005532{
5533 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005534 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005535
5536 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005537 {
5538 flagp = insecure_flag(idx, opt_flags);
5539 return (*flagp & P_INSECURE) != 0;
5540 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005541 EMSG2(_(e_intern2), "was_set_insecurely()");
5542 return -1;
5543}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005544
5545/*
5546 * Get a pointer to the flags used for the P_INSECURE flag of option
5547 * "opt_idx". For some local options a local flags field is used.
5548 */
5549 static long_u *
5550insecure_flag(opt_idx, opt_flags)
5551 int opt_idx;
5552 int opt_flags;
5553{
5554 if (opt_flags & OPT_LOCAL)
5555 switch ((int)options[opt_idx].indir)
5556 {
5557#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005558 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005559#endif
5560#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005561# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005562 case PV_FDE: return &curwin->w_p_fde_flags;
5563 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005564# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005565# ifdef FEAT_BEVAL
5566 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5567# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005568# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005569 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005570# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005571 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005572# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005573 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005574# endif
5575#endif
5576 }
5577
5578 /* Nothing special, return global flags field. */
5579 return &options[opt_idx].flags;
5580}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005581#endif
5582
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005583#ifdef FEAT_TITLE
5584static void redraw_titles __ARGS((void));
5585
5586/*
5587 * Redraw the window title and/or tab page text later.
5588 */
5589static void redraw_titles()
5590{
5591 need_maketitle = TRUE;
5592# ifdef FEAT_WINDOWS
5593 redraw_tabline = TRUE;
5594# endif
5595}
5596#endif
5597
Bram Moolenaar071d4272004-06-13 20:20:40 +00005598/*
5599 * Set a string option to a new value (without checking the effect).
5600 * The string is copied into allocated memory.
5601 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005602 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005603 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005604 */
5605 void
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005606set_string_option_direct(name, opt_idx, val, opt_flags, set_sid)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005607 char_u *name;
5608 int opt_idx;
5609 char_u *val;
5610 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar78a15312009-05-15 19:33:18 +00005611 int set_sid UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005612{
5613 char_u *s;
5614 char_u **varp;
5615 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005616 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005617
Bram Moolenaar89d40322006-08-29 15:30:07 +00005618 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005619 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005620 idx = findoption(name);
5621 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005622 {
5623 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar0b105412014-11-30 13:34:23 +01005624 EMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005625 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005626 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005627 }
5628
Bram Moolenaar89d40322006-08-29 15:30:07 +00005629 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005630 return;
5631
5632 s = vim_strsave(val);
5633 if (s != NULL)
5634 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005635 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005636 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005637 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005638 free_string_option(*varp);
5639 *varp = s;
5640
5641 /* For buffer/window local option may also set the global value. */
5642 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005643 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005644
Bram Moolenaar89d40322006-08-29 15:30:07 +00005645 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005646
5647 /* When setting both values of a global option with a local value,
5648 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005649 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005650 {
5651 free_string_option(*varp);
5652 *varp = empty_option;
5653 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005654# ifdef FEAT_EVAL
5655 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005656 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005657 set_sid == 0 ? current_SID : set_sid);
5658# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005659 }
5660}
5661
5662/*
5663 * Set global value for string option when it's a local option.
5664 */
5665 static void
5666set_string_option_global(opt_idx, varp)
5667 int opt_idx; /* option index */
5668 char_u **varp; /* pointer to option variable */
5669{
5670 char_u **p, *s;
5671
5672 /* the global value is always allocated */
5673 if (options[opt_idx].var == VAR_WIN)
5674 p = (char_u **)GLOBAL_WO(varp);
5675 else
5676 p = (char_u **)options[opt_idx].var;
5677 if (options[opt_idx].indir != PV_NONE
5678 && p != varp
5679 && (s = vim_strsave(*varp)) != NULL)
5680 {
5681 free_string_option(*p);
5682 *p = s;
5683 }
5684}
5685
5686/*
5687 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005688 *
5689 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005690 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005691 static char_u *
Bram Moolenaar071d4272004-06-13 20:20:40 +00005692set_string_option(opt_idx, value, opt_flags)
5693 int opt_idx;
5694 char_u *value;
5695 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5696{
5697 char_u *s;
5698 char_u **varp;
5699 char_u *oldval;
Bram Moolenaar53744302015-07-17 17:38:22 +02005700#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5701 char_u *saved_oldval = NULL;
5702#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005703 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005704
5705 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005706 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005707
5708 s = vim_strsave(value);
5709 if (s != NULL)
5710 {
5711 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5712 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005713 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005714 ? OPT_GLOBAL : OPT_LOCAL)
5715 : opt_flags);
5716 oldval = *varp;
5717 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02005718
5719#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5720 if (!starting && options[opt_idx].indir != PV_KEY)
5721 saved_oldval = vim_strsave(oldval);
5722#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005723 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5724 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005725 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02005726
5727 /* call autocomamnd after handling side effects */
5728#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5729 if (saved_oldval != NULL)
5730 {
5731 char_u buf_type[7];
5732 sprintf((char *)buf_type, "%s",
5733 (opt_flags & OPT_LOCAL) ? "local" : "global");
5734 set_vim_var_string(VV_OPTION_NEW, s, -1);
5735 set_vim_var_string(VV_OPTION_OLD, oldval, -1);
5736 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
5737 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
5738 reset_v_option_vars();
5739 vim_free(saved_oldval);
5740 }
5741#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005742 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005743 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005744}
5745
5746/*
5747 * Handle string options that need some action to perform when changed.
5748 * Returns NULL for success, or an error message for an error.
5749 */
5750 static char_u *
5751did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
5752 opt_flags)
5753 int opt_idx; /* index in options[] table */
5754 char_u **varp; /* pointer to the option variable */
5755 int new_value_alloced; /* new value was allocated */
5756 char_u *oldval; /* previous value of the option */
5757 char_u *errbuf; /* buffer for errors, or NULL */
5758 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5759{
5760 char_u *errmsg = NULL;
5761 char_u *s, *p;
5762 int did_chartab = FALSE;
5763 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005764 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00005765#ifdef FEAT_GUI
5766 /* set when changing an option that only requires a redraw in the GUI */
5767 int redraw_gui_only = FALSE;
5768#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005769
5770 /* Get the global option to compare with, otherwise we would have to check
5771 * two values for all local options. */
5772 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
5773
5774 /* Disallow changing some options from secure mode */
5775 if ((secure
5776#ifdef HAVE_SANDBOX
5777 || sandbox != 0
5778#endif
5779 ) && (options[opt_idx].flags & P_SECURE))
5780 {
5781 errmsg = e_secure;
5782 }
5783
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005784 /* Check for a "normal" file name in some options. Disallow a path
5785 * separator (slash and/or backslash), wildcards and characters that are
5786 * often illegal in a file name. */
5787 else if ((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005788 && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL)
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005789 {
5790 errmsg = e_invarg;
5791 }
5792
Bram Moolenaar071d4272004-06-13 20:20:40 +00005793 /* 'term' */
5794 else if (varp == &T_NAME)
5795 {
5796 if (T_NAME[0] == NUL)
5797 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
5798#ifdef FEAT_GUI
5799 if (gui.in_use)
5800 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
5801 else if (term_is_gui(T_NAME))
5802 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
5803#endif
5804 else if (set_termname(T_NAME) == FAIL)
5805 errmsg = (char_u *)N_("E522: Not found in termcap");
5806 else
5807 /* Screen colors may have changed. */
5808 redraw_later_clear();
5809 }
5810
5811 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005812 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005813 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005814 char_u *bkc = p_bkc;
5815 unsigned int *flags = &bkc_flags;
5816
5817 if (opt_flags & OPT_LOCAL)
5818 {
5819 bkc = curbuf->b_p_bkc;
5820 flags = &curbuf->b_bkc_flags;
5821 }
5822
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005823 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
5824 /* make the local value empty: use the global value */
5825 *flags = 0;
5826 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00005827 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005828 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
5829 errmsg = e_invarg;
5830 if ((((int)*flags & BKC_AUTO) != 0)
5831 + (((int)*flags & BKC_YES) != 0)
5832 + (((int)*flags & BKC_NO) != 0) != 1)
5833 {
5834 /* Must have exactly one of "auto", "yes" and "no". */
5835 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
5836 errmsg = e_invarg;
5837 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005838 }
5839 }
5840
5841 /* 'backupext' and 'patchmode' */
5842 else if (varp == &p_bex || varp == &p_pm)
5843 {
5844 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
5845 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
5846 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
5847 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02005848#ifdef FEAT_LINEBREAK
5849 /* 'breakindentopt' */
5850 else if (varp == &curwin->w_p_briopt)
5851 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005852 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02005853 errmsg = e_invarg;
5854 }
5855#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005856
5857 /*
5858 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[]
5859 * If the new option is invalid, use old value. 'lisp' option: refill
5860 * chartab[] for '-' char
5861 */
5862 else if ( varp == &p_isi
5863 || varp == &(curbuf->b_p_isk)
5864 || varp == &p_isp
5865 || varp == &p_isf)
5866 {
5867 if (init_chartab() == FAIL)
5868 {
5869 did_chartab = TRUE; /* need to restore it below */
5870 errmsg = e_invarg; /* error in value */
5871 }
5872 }
5873
5874 /* 'helpfile' */
5875 else if (varp == &p_hf)
5876 {
5877 /* May compute new values for $VIM and $VIMRUNTIME */
5878 if (didset_vim)
5879 {
5880 vim_setenv((char_u *)"VIM", (char_u *)"");
5881 didset_vim = FALSE;
5882 }
5883 if (didset_vimruntime)
5884 {
5885 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
5886 didset_vimruntime = FALSE;
5887 }
5888 }
5889
Bram Moolenaar1a384422010-07-14 19:53:30 +02005890#ifdef FEAT_SYN_HL
5891 /* 'colorcolumn' */
5892 else if (varp == &curwin->w_p_cc)
5893 errmsg = check_colorcolumn(curwin);
5894#endif
5895
Bram Moolenaar071d4272004-06-13 20:20:40 +00005896#ifdef FEAT_MULTI_LANG
5897 /* 'helplang' */
5898 else if (varp == &p_hlg)
5899 {
5900 /* Check for "", "ab", "ab,cd", etc. */
5901 for (s = p_hlg; *s != NUL; s += 3)
5902 {
5903 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
5904 {
5905 errmsg = e_invarg;
5906 break;
5907 }
5908 if (s[2] == NUL)
5909 break;
5910 }
5911 }
5912#endif
5913
5914 /* 'highlight' */
5915 else if (varp == &p_hl)
5916 {
5917 if (highlight_changed() == FAIL)
5918 errmsg = e_invarg; /* invalid flags */
5919 }
5920
5921 /* 'nrformats' */
5922 else if (gvarp == &p_nf)
5923 {
5924 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
5925 errmsg = e_invarg;
5926 }
5927
5928#ifdef FEAT_SESSION
5929 /* 'sessionoptions' */
5930 else if (varp == &p_ssop)
5931 {
5932 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
5933 errmsg = e_invarg;
5934 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
5935 {
5936 /* Don't allow both "sesdir" and "curdir". */
5937 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
5938 errmsg = e_invarg;
5939 }
5940 }
5941 /* 'viewoptions' */
5942 else if (varp == &p_vop)
5943 {
5944 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
5945 errmsg = e_invarg;
5946 }
5947#endif
5948
5949 /* 'scrollopt' */
5950#ifdef FEAT_SCROLLBIND
5951 else if (varp == &p_sbo)
5952 {
5953 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
5954 errmsg = e_invarg;
5955 }
5956#endif
5957
5958 /* 'ambiwidth' */
5959#ifdef FEAT_MBYTE
5960 else if (varp == &p_ambw)
5961 {
5962 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
5963 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02005964 else if (set_chars_option(&p_lcs) != NULL)
5965 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
5966# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5967 else if (set_chars_option(&p_fcs) != NULL)
5968 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
5969# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005970 }
5971#endif
5972
5973 /* 'background' */
5974 else if (varp == &p_bg)
5975 {
5976 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
5977 {
5978#ifdef FEAT_EVAL
5979 int dark = (*p_bg == 'd');
5980#endif
5981
5982 init_highlight(FALSE, FALSE);
5983
5984#ifdef FEAT_EVAL
5985 if (dark != (*p_bg == 'd')
5986 && get_var_value((char_u *)"g:colors_name") != NULL)
5987 {
5988 /* The color scheme must have set 'background' back to another
5989 * value, that's not what we want here. Disable the color
5990 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00005991 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005992 free_string_option(p_bg);
5993 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
5994 check_string_option(&p_bg);
5995 init_highlight(FALSE, FALSE);
5996 }
5997#endif
5998 }
5999 else
6000 errmsg = e_invarg;
6001 }
6002
6003 /* 'wildmode' */
6004 else if (varp == &p_wim)
6005 {
6006 if (check_opt_wim() == FAIL)
6007 errmsg = e_invarg;
6008 }
6009
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006010#ifdef FEAT_CMDL_COMPL
6011 /* 'wildoptions' */
6012 else if (varp == &p_wop)
6013 {
6014 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6015 errmsg = e_invarg;
6016 }
6017#endif
6018
Bram Moolenaar071d4272004-06-13 20:20:40 +00006019#ifdef FEAT_WAK
6020 /* 'winaltkeys' */
6021 else if (varp == &p_wak)
6022 {
6023 if (*p_wak == NUL
6024 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6025 errmsg = e_invarg;
6026# ifdef FEAT_MENU
6027# ifdef FEAT_GUI_MOTIF
6028 else if (gui.in_use)
6029 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6030# else
6031# ifdef FEAT_GUI_GTK
6032 else if (gui.in_use)
6033 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6034# endif
6035# endif
6036# endif
6037 }
6038#endif
6039
6040#ifdef FEAT_AUTOCMD
6041 /* 'eventignore' */
6042 else if (varp == &p_ei)
6043 {
6044 if (check_ei() == FAIL)
6045 errmsg = e_invarg;
6046 }
6047#endif
6048
6049#ifdef FEAT_MBYTE
6050 /* 'encoding' and 'fileencoding' */
6051 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc)
6052 {
6053 if (gvarp == &p_fenc)
6054 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006055 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006056 errmsg = e_modifiable;
6057 else if (vim_strchr(*varp, ',') != NULL)
6058 /* No comma allowed in 'fileencoding'; catches confusing it
6059 * with 'fileencodings'. */
6060 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006061 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006062 {
6063# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006064 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006065 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006066# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006067 /* Add 'fileencoding' to the swap file. */
6068 ml_setflags(curbuf);
6069 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006070 }
6071 if (errmsg == NULL)
6072 {
6073 /* canonize the value, so that STRCMP() can be used on it */
6074 p = enc_canonize(*varp);
6075 if (p != NULL)
6076 {
6077 vim_free(*varp);
6078 *varp = p;
6079 }
6080 if (varp == &p_enc)
6081 {
6082 errmsg = mb_init();
6083# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006084 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006085# endif
6086 }
6087 }
6088
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006089# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006090 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6091 {
6092 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6093 if (STRCMP(p_tenc, "utf-8") != 0)
6094 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6095 }
6096# endif
6097
6098 if (errmsg == NULL)
6099 {
6100# ifdef FEAT_KEYMAP
6101 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6102 * (with another encoding). */
6103 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6104 (void)keymap_init();
6105# endif
6106
6107 /* When 'termencoding' is not empty and 'encoding' changes or when
6108 * 'termencoding' changes, need to setup for keyboard input and
6109 * display output conversion. */
6110 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6111 {
6112 convert_setup(&input_conv, p_tenc, p_enc);
6113 convert_setup(&output_conv, p_enc, p_tenc);
6114 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006115
6116# if defined(WIN3264) && defined(FEAT_MBYTE)
6117 /* $HOME may have characters in active code page. */
6118 if (varp == &p_enc)
6119 init_homedir();
6120# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006121 }
6122 }
6123#endif
6124
6125#if defined(FEAT_POSTSCRIPT)
6126 else if (varp == &p_penc)
6127 {
6128 /* Canonize printencoding if VIM standard one */
6129 p = enc_canonize(p_penc);
6130 if (p != NULL)
6131 {
6132 vim_free(p_penc);
6133 p_penc = p;
6134 }
6135 else
6136 {
6137 /* Ensure lower case and '-' for '_' */
6138 for (s = p_penc; *s != NUL; s++)
6139 {
6140 if (*s == '_')
6141 *s = '-';
6142 else
6143 *s = TOLOWER_ASC(*s);
6144 }
6145 }
6146 }
6147#endif
6148
Bram Moolenaar9372a112005-12-06 19:59:18 +00006149#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006150 else if (varp == &p_imak)
6151 {
6152 if (gui.in_use && !im_xim_isvalid_imactivate())
6153 errmsg = e_invarg;
6154 }
6155#endif
6156
6157#ifdef FEAT_KEYMAP
6158 else if (varp == &curbuf->b_p_keymap)
6159 {
6160 /* load or unload key mapping tables */
6161 errmsg = keymap_init();
6162
Bram Moolenaarfab06232009-03-04 03:13:35 +00006163 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006164 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006165 if (*curbuf->b_p_keymap != NUL)
6166 {
6167 /* Installed a new keymap, switch on using it. */
6168 curbuf->b_p_iminsert = B_IMODE_LMAP;
6169 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6170 curbuf->b_p_imsearch = B_IMODE_LMAP;
6171 }
6172 else
6173 {
6174 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6175 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6176 curbuf->b_p_iminsert = B_IMODE_NONE;
6177 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6178 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6179 }
6180 if ((opt_flags & OPT_LOCAL) == 0)
6181 {
6182 set_iminsert_global();
6183 set_imsearch_global();
6184 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006185# ifdef FEAT_WINDOWS
6186 status_redraw_curbuf();
6187# endif
6188 }
6189 }
6190#endif
6191
6192 /* 'fileformat' */
6193 else if (gvarp == &p_ff)
6194 {
6195 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6196 errmsg = e_modifiable;
6197 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6198 errmsg = e_invarg;
6199 else
6200 {
6201 /* may also change 'textmode' */
6202 if (get_fileformat(curbuf) == EOL_DOS)
6203 curbuf->b_p_tx = TRUE;
6204 else
6205 curbuf->b_p_tx = FALSE;
6206#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006207 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006208#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006209 /* update flag in swap file */
6210 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006211 /* Redraw needed when switching to/from "mac": a CR in the text
6212 * will be displayed differently. */
6213 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6214 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006215 }
6216 }
6217
6218 /* 'fileformats' */
6219 else if (varp == &p_ffs)
6220 {
6221 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6222 errmsg = e_invarg;
6223 else
6224 {
6225 /* also change 'textauto' */
6226 if (*p_ffs == NUL)
6227 p_ta = FALSE;
6228 else
6229 p_ta = TRUE;
6230 }
6231 }
6232
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006233#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006234 /* 'cryptkey' */
6235 else if (gvarp == &p_key)
6236 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006237# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006238 /* Make sure the ":set" command doesn't show the new value in the
6239 * history. */
6240 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006241# endif
6242 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6243 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006244 ml_set_crypt_key(curbuf, oldval,
6245 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006246 }
6247
6248 else if (gvarp == &p_cm)
6249 {
6250 if (opt_flags & OPT_LOCAL)
6251 p = curbuf->b_p_cm;
6252 else
6253 p = p_cm;
6254 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6255 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006256 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006257 errmsg = e_invarg;
6258 else
6259 {
6260 /* When setting the global value to empty, make it "zip". */
6261 if (*p_cm == NUL)
6262 {
6263 if (new_value_alloced)
6264 free_string_option(p_cm);
6265 p_cm = vim_strsave((char_u *)"zip");
6266 new_value_alloced = TRUE;
6267 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006268 /* When using ":set cm=name" the local value is going to be empty.
6269 * Do that here, otherwise the crypt functions will still use the
6270 * local value. */
6271 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6272 {
6273 free_string_option(curbuf->b_p_cm);
6274 curbuf->b_p_cm = empty_option;
6275 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006276
6277 /* Need to update the swapfile when the effective method changed.
6278 * Set "s" to the effective old value, "p" to the effective new
6279 * method and compare. */
6280 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6281 s = p_cm; /* was previously using the global value */
6282 else
6283 s = oldval;
6284 if (*curbuf->b_p_cm == NUL)
6285 p = p_cm; /* is now using the global value */
6286 else
6287 p = curbuf->b_p_cm;
6288 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006289 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006290
6291 /* If the global value changes need to update the swapfile for all
6292 * buffers using that value. */
6293 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6294 {
6295 buf_T *buf;
6296
6297 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
6298 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006299 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006300 }
6301 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006302 }
6303#endif
6304
6305 /* 'matchpairs' */
6306 else if (gvarp == &p_mps)
6307 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006308#ifdef FEAT_MBYTE
6309 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006310 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006311 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006312 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006313 int x2 = -1;
6314 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006315
6316 if (*p != NUL)
6317 p += mb_ptr2len(p);
6318 if (*p != NUL)
6319 x2 = *p++;
6320 if (*p != NUL)
6321 {
6322 x3 = mb_ptr2char(p);
6323 p += mb_ptr2len(p);
6324 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006325 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006326 {
6327 errmsg = e_invarg;
6328 break;
6329 }
6330 if (*p == NUL)
6331 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006332 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006333 }
6334 else
6335#endif
6336 {
6337 /* Check for "x:y,x:y" */
6338 for (p = *varp; *p != NUL; p += 4)
6339 {
6340 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6341 {
6342 errmsg = e_invarg;
6343 break;
6344 }
6345 if (p[3] == NUL)
6346 break;
6347 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006348 }
6349 }
6350
6351#ifdef FEAT_COMMENTS
6352 /* 'comments' */
6353 else if (gvarp == &p_com)
6354 {
6355 for (s = *varp; *s; )
6356 {
6357 while (*s && *s != ':')
6358 {
6359 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6360 && !VIM_ISDIGIT(*s) && *s != '-')
6361 {
6362 errmsg = illegal_char(errbuf, *s);
6363 break;
6364 }
6365 ++s;
6366 }
6367 if (*s++ == NUL)
6368 errmsg = (char_u *)N_("E524: Missing colon");
6369 else if (*s == ',' || *s == NUL)
6370 errmsg = (char_u *)N_("E525: Zero length string");
6371 if (errmsg != NULL)
6372 break;
6373 while (*s && *s != ',')
6374 {
6375 if (*s == '\\' && s[1] != NUL)
6376 ++s;
6377 ++s;
6378 }
6379 s = skip_to_option_part(s);
6380 }
6381 }
6382#endif
6383
6384 /* 'listchars' */
6385 else if (varp == &p_lcs)
6386 {
6387 errmsg = set_chars_option(varp);
6388 }
6389
6390#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6391 /* 'fillchars' */
6392 else if (varp == &p_fcs)
6393 {
6394 errmsg = set_chars_option(varp);
6395 }
6396#endif
6397
6398#ifdef FEAT_CMDWIN
6399 /* 'cedit' */
6400 else if (varp == &p_cedit)
6401 {
6402 errmsg = check_cedit();
6403 }
6404#endif
6405
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006406 /* 'verbosefile' */
6407 else if (varp == &p_vfile)
6408 {
6409 verbose_stop();
6410 if (*p_vfile != NUL && verbose_open() == FAIL)
6411 errmsg = e_invarg;
6412 }
6413
Bram Moolenaar071d4272004-06-13 20:20:40 +00006414#ifdef FEAT_VIMINFO
6415 /* 'viminfo' */
6416 else if (varp == &p_viminfo)
6417 {
6418 for (s = p_viminfo; *s;)
6419 {
6420 /* Check it's a valid character */
6421 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6422 {
6423 errmsg = illegal_char(errbuf, *s);
6424 break;
6425 }
6426 if (*s == 'n') /* name is always last one */
6427 {
6428 break;
6429 }
6430 else if (*s == 'r') /* skip until next ',' */
6431 {
6432 while (*++s && *s != ',')
6433 ;
6434 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006435 else if (*s == '%')
6436 {
6437 /* optional number */
6438 while (vim_isdigit(*++s))
6439 ;
6440 }
6441 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006442 ++s; /* no extra chars */
6443 else /* must have a number */
6444 {
6445 while (vim_isdigit(*++s))
6446 ;
6447
6448 if (!VIM_ISDIGIT(*(s - 1)))
6449 {
6450 if (errbuf != NULL)
6451 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006452 sprintf((char *)errbuf,
6453 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006454 transchar_byte(*(s - 1)));
6455 errmsg = errbuf;
6456 }
6457 else
6458 errmsg = (char_u *)"";
6459 break;
6460 }
6461 }
6462 if (*s == ',')
6463 ++s;
6464 else if (*s)
6465 {
6466 if (errbuf != NULL)
6467 errmsg = (char_u *)N_("E527: Missing comma");
6468 else
6469 errmsg = (char_u *)"";
6470 break;
6471 }
6472 }
6473 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6474 errmsg = (char_u *)N_("E528: Must specify a ' value");
6475 }
6476#endif /* FEAT_VIMINFO */
6477
6478 /* terminal options */
6479 else if (istermoption(&options[opt_idx]) && full_screen)
6480 {
6481 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6482 if (varp == &T_CCO)
6483 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006484 int colors = atoi((char *)T_CCO);
6485
6486 /* Only reinitialize colors if t_Co value has really changed to
6487 * avoid expensive reload of colorscheme if t_Co is set to the
6488 * same value multiple times. */
6489 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006490 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006491 t_colors = colors;
6492 if (t_colors <= 1)
6493 {
6494 if (new_value_alloced)
6495 vim_free(T_CCO);
6496 T_CCO = empty_option;
6497 }
6498 /* We now have a different color setup, initialize it again. */
6499 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006500 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006501 }
6502 ttest(FALSE);
6503 if (varp == &T_ME)
6504 {
6505 out_str(T_ME);
6506 redraw_later(CLEAR);
6507#if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32))
6508 /* Since t_me has been set, this probably means that the user
6509 * wants to use this as default colors. Need to reset default
6510 * background/foreground colors. */
6511 mch_set_normal_colors();
6512#endif
6513 }
6514 }
6515
6516#ifdef FEAT_LINEBREAK
6517 /* 'showbreak' */
6518 else if (varp == &p_sbr)
6519 {
6520 for (s = p_sbr; *s; )
6521 {
6522 if (ptr2cells(s) != 1)
6523 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006524 mb_ptr_adv(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006525 }
6526 }
6527#endif
6528
6529#ifdef FEAT_GUI
6530 /* 'guifont' */
6531 else if (varp == &p_guifont)
6532 {
6533 if (gui.in_use)
6534 {
6535 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006536# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006537 /*
6538 * Put up a font dialog and let the user select a new value.
6539 * If this is cancelled go back to the old value but don't
6540 * give an error message.
6541 */
6542 if (STRCMP(p, "*") == 0)
6543 {
6544 p = gui_mch_font_dialog(oldval);
6545
6546 if (new_value_alloced)
6547 free_string_option(p_guifont);
6548
6549 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6550 new_value_alloced = TRUE;
6551 }
6552# endif
6553 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6554 {
6555# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6556 if (STRCMP(p_guifont, "*") == 0)
6557 {
6558 /* Dialog was cancelled: Keep the old value without giving
6559 * an error message. */
6560 if (new_value_alloced)
6561 free_string_option(p_guifont);
6562 p_guifont = vim_strsave(oldval);
6563 new_value_alloced = TRUE;
6564 }
6565 else
6566# endif
6567 errmsg = (char_u *)N_("E596: Invalid font(s)");
6568 }
6569 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006570 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006571 }
6572# ifdef FEAT_XFONTSET
6573 else if (varp == &p_guifontset)
6574 {
6575 if (STRCMP(p_guifontset, "*") == 0)
6576 errmsg = (char_u *)N_("E597: can't select fontset");
6577 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6578 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006579 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006580 }
6581# endif
6582# ifdef FEAT_MBYTE
6583 else if (varp == &p_guifontwide)
6584 {
6585 if (STRCMP(p_guifontwide, "*") == 0)
6586 errmsg = (char_u *)N_("E533: can't select wide font");
6587 else if (gui_get_wide_font() == FAIL)
6588 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006589 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006590 }
6591# endif
6592#endif
6593
6594#ifdef CURSOR_SHAPE
6595 /* 'guicursor' */
6596 else if (varp == &p_guicursor)
6597 errmsg = parse_shape_opt(SHAPE_CURSOR);
6598#endif
6599
6600#ifdef FEAT_MOUSESHAPE
6601 /* 'mouseshape' */
6602 else if (varp == &p_mouseshape)
6603 {
6604 errmsg = parse_shape_opt(SHAPE_MOUSE);
6605 update_mouseshape(-1);
6606 }
6607#endif
6608
6609#ifdef FEAT_PRINTER
6610 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006611 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006612# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006613 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006614 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006615# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006616#endif
6617
6618#ifdef FEAT_LANGMAP
6619 /* 'langmap' */
6620 else if (varp == &p_langmap)
6621 langmap_set();
6622#endif
6623
6624#ifdef FEAT_LINEBREAK
6625 /* 'breakat' */
6626 else if (varp == &p_breakat)
6627 fill_breakat_flags();
6628#endif
6629
6630#ifdef FEAT_TITLE
6631 /* 'titlestring' and 'iconstring' */
6632 else if (varp == &p_titlestring || varp == &p_iconstring)
6633 {
6634# ifdef FEAT_STL_OPT
6635 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6636
6637 /* NULL => statusline syntax */
6638 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6639 stl_syntax |= flagval;
6640 else
6641 stl_syntax &= ~flagval;
6642# endif
6643 did_set_title(varp == &p_iconstring);
6644
6645 }
6646#endif
6647
6648#ifdef FEAT_GUI
6649 /* 'guioptions' */
6650 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006651 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006652 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006653 redraw_gui_only = TRUE;
6654 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006655#endif
6656
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006657#if defined(FEAT_GUI_TABLINE)
6658 /* 'guitablabel' */
6659 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006660 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006661 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006662 redraw_gui_only = TRUE;
6663 }
6664 /* 'guitabtooltip' */
6665 else if (varp == &p_gtt)
6666 {
6667 redraw_gui_only = TRUE;
6668 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006669#endif
6670
Bram Moolenaar071d4272004-06-13 20:20:40 +00006671#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6672 /* 'ttymouse' */
6673 else if (varp == &p_ttym)
6674 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006675 /* Switch the mouse off before changing the escape sequences used for
6676 * that. */
6677 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006678 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6679 errmsg = e_invarg;
6680 else
6681 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006682 if (termcap_active)
6683 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006684 }
6685#endif
6686
Bram Moolenaar071d4272004-06-13 20:20:40 +00006687 /* 'selection' */
6688 else if (varp == &p_sel)
6689 {
6690 if (*p_sel == NUL
6691 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6692 errmsg = e_invarg;
6693 }
6694
6695 /* 'selectmode' */
6696 else if (varp == &p_slm)
6697 {
6698 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6699 errmsg = e_invarg;
6700 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006701
6702#ifdef FEAT_BROWSE
6703 /* 'browsedir' */
6704 else if (varp == &p_bsdir)
6705 {
6706 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
6707 && !mch_isdir(p_bsdir))
6708 errmsg = e_invarg;
6709 }
6710#endif
6711
Bram Moolenaar071d4272004-06-13 20:20:40 +00006712 /* 'keymodel' */
6713 else if (varp == &p_km)
6714 {
6715 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
6716 errmsg = e_invarg;
6717 else
6718 {
6719 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
6720 km_startsel = (vim_strchr(p_km, 'a') != NULL);
6721 }
6722 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006723
6724 /* 'mousemodel' */
6725 else if (varp == &p_mousem)
6726 {
6727 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
6728 errmsg = e_invarg;
6729#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
6730 else if (*p_mousem != *oldval)
6731 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
6732 * to create or delete the popup menus. */
6733 gui_motif_update_mousemodel(root_menu);
6734#endif
6735 }
6736
6737 /* 'switchbuf' */
6738 else if (varp == &p_swb)
6739 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00006740 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006741 errmsg = e_invarg;
6742 }
6743
6744 /* 'debug' */
6745 else if (varp == &p_debug)
6746 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00006747 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006748 errmsg = e_invarg;
6749 }
6750
6751 /* 'display' */
6752 else if (varp == &p_dy)
6753 {
6754 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
6755 errmsg = e_invarg;
6756 else
6757 (void)init_chartab();
6758
6759 }
6760
6761#ifdef FEAT_VERTSPLIT
6762 /* 'eadirection' */
6763 else if (varp == &p_ead)
6764 {
6765 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
6766 errmsg = e_invarg;
6767 }
6768#endif
6769
6770#ifdef FEAT_CLIPBOARD
6771 /* 'clipboard' */
6772 else if (varp == &p_cb)
6773 errmsg = check_clipboard_option();
6774#endif
6775
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00006776#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006777 /* When 'spelllang' or 'spellfile' is set and there is a window for this
6778 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006779 else if (varp == &(curwin->w_s->b_p_spl)
6780 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00006781 {
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006782 win_T *wp;
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006783 int l;
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006784
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006785 if (varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006786 {
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006787 l = (int)STRLEN(curwin->w_s->b_p_spf);
6788 if (l > 0 && (l < 4 || STRCMP(curwin->w_s->b_p_spf + l - 4,
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006789 ".add") != 0))
6790 errmsg = e_invarg;
6791 }
6792
6793 if (errmsg == NULL)
6794 {
6795 FOR_ALL_WINDOWS(wp)
6796 if (wp->w_buffer == curbuf && wp->w_p_spell)
6797 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006798 errmsg = did_set_spelllang(wp);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006799# ifdef FEAT_WINDOWS
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006800 break;
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006801# endif
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006802 }
6803 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006804 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006805 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006806 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006807 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006808 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006809 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006810 /* 'spellsuggest' */
6811 else if (varp == &p_sps)
6812 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00006813 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006814 errmsg = e_invarg;
6815 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00006816 /* 'mkspellmem' */
6817 else if (varp == &p_msm)
6818 {
6819 if (spell_check_msm() != OK)
6820 errmsg = e_invarg;
6821 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006822#endif
6823
Bram Moolenaar071d4272004-06-13 20:20:40 +00006824#ifdef FEAT_QUICKFIX
6825 /* When 'bufhidden' is set, check for valid value. */
6826 else if (gvarp == &p_bh)
6827 {
6828 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
6829 errmsg = e_invarg;
6830 }
6831
6832 /* When 'buftype' is set, check for valid value. */
6833 else if (gvarp == &p_bt)
6834 {
6835 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
6836 errmsg = e_invarg;
6837 else
6838 {
6839# ifdef FEAT_WINDOWS
6840 if (curwin->w_status_height)
6841 {
6842 curwin->w_redr_status = TRUE;
6843 redraw_later(VALID);
6844 }
6845# endif
6846 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar5075aad2010-01-27 15:58:13 +01006847# ifdef FEAT_TITLE
6848 redraw_titles();
6849# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006850 }
6851 }
6852#endif
6853
6854#ifdef FEAT_STL_OPT
6855 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006856 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006857 {
6858 int wid;
6859
6860 if (varp == &p_ruf) /* reset ru_wid first */
6861 ru_wid = 0;
6862 s = *varp;
6863 if (varp == &p_ruf && *s == '%')
6864 {
6865 /* set ru_wid if 'ruf' starts with "%99(" */
6866 if (*++s == '-') /* ignore a '-' */
6867 s++;
6868 wid = getdigits(&s);
6869 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
6870 ru_wid = wid;
6871 else
6872 errmsg = check_stl_option(p_ruf);
6873 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00006874 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00006875 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006876 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006877 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006878 comp_col();
6879 }
6880#endif
6881
6882#ifdef FEAT_INS_EXPAND
6883 /* check if it is a valid value for 'complete' -- Acevedo */
6884 else if (gvarp == &p_cpt)
6885 {
6886 for (s = *varp; *s;)
6887 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02006888 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006889 s++;
6890 if (!*s)
6891 break;
6892 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
6893 {
6894 errmsg = illegal_char(errbuf, *s);
6895 break;
6896 }
6897 if (*++s != NUL && *s != ',' && *s != ' ')
6898 {
6899 if (s[-1] == 'k' || s[-1] == 's')
6900 {
6901 /* skip optional filename after 'k' and 's' */
6902 while (*s && *s != ',' && *s != ' ')
6903 {
6904 if (*s == '\\')
6905 ++s;
6906 ++s;
6907 }
6908 }
6909 else
6910 {
6911 if (errbuf != NULL)
6912 {
6913 sprintf((char *)errbuf,
6914 _("E535: Illegal character after <%c>"),
6915 *--s);
6916 errmsg = errbuf;
6917 }
6918 else
6919 errmsg = (char_u *)"";
6920 break;
6921 }
6922 }
6923 }
6924 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00006925
6926 /* 'completeopt' */
6927 else if (varp == &p_cot)
6928 {
6929 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
6930 errmsg = e_invarg;
6931 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006932#endif /* FEAT_INS_EXPAND */
6933
6934
6935#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
6936 else if (varp == &p_toolbar)
6937 {
6938 if (opt_strings_flags(p_toolbar, p_toolbar_values,
6939 &toolbar_flags, TRUE) != OK)
6940 errmsg = e_invarg;
6941 else
6942 {
6943 out_flush();
6944 gui_mch_show_toolbar((toolbar_flags &
6945 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6946 }
6947 }
6948#endif
6949
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006950#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006951 /* 'toolbariconsize': GTK+ 2 only */
6952 else if (varp == &p_tbis)
6953 {
6954 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
6955 errmsg = e_invarg;
6956 else
6957 {
6958 out_flush();
6959 gui_mch_show_toolbar((toolbar_flags &
6960 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6961 }
6962 }
6963#endif
6964
6965 /* 'pastetoggle': translate key codes like in a mapping */
6966 else if (varp == &p_pt)
6967 {
6968 if (*p_pt)
6969 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00006970 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006971 if (p != NULL)
6972 {
6973 if (new_value_alloced)
6974 free_string_option(p_pt);
6975 p_pt = p;
6976 new_value_alloced = TRUE;
6977 }
6978 }
6979 }
6980
6981 /* 'backspace' */
6982 else if (varp == &p_bs)
6983 {
6984 if (VIM_ISDIGIT(*p_bs))
6985 {
6986 if (*p_bs >'2' || p_bs[1] != NUL)
6987 errmsg = e_invarg;
6988 }
6989 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
6990 errmsg = e_invarg;
6991 }
6992
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00006993#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006994 /* 'casemap' */
6995 else if (varp == &p_cmp)
6996 {
6997 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
6998 errmsg = e_invarg;
6999 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007000#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007001
7002#ifdef FEAT_DIFF
7003 /* 'diffopt' */
7004 else if (varp == &p_dip)
7005 {
7006 if (diffopt_changed() == FAIL)
7007 errmsg = e_invarg;
7008 }
7009#endif
7010
7011#ifdef FEAT_FOLDING
7012 /* 'foldmethod' */
7013 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7014 {
7015 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7016 || *curwin->w_p_fdm == NUL)
7017 errmsg = e_invarg;
7018 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007019 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007020 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007021 if (foldmethodIsDiff(curwin))
7022 newFoldLevel();
7023 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007024 }
7025# ifdef FEAT_EVAL
7026 /* 'foldexpr' */
7027 else if (varp == &curwin->w_p_fde)
7028 {
7029 if (foldmethodIsExpr(curwin))
7030 foldUpdateAll(curwin);
7031 }
7032# endif
7033 /* 'foldmarker' */
7034 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7035 {
7036 p = vim_strchr(*varp, ',');
7037 if (p == NULL)
7038 errmsg = (char_u *)N_("E536: comma required");
7039 else if (p == *varp || p[1] == NUL)
7040 errmsg = e_invarg;
7041 else if (foldmethodIsMarker(curwin))
7042 foldUpdateAll(curwin);
7043 }
7044 /* 'commentstring' */
7045 else if (gvarp == &p_cms)
7046 {
7047 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7048 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7049 }
7050 /* 'foldopen' */
7051 else if (varp == &p_fdo)
7052 {
7053 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7054 errmsg = e_invarg;
7055 }
7056 /* 'foldclose' */
7057 else if (varp == &p_fcl)
7058 {
7059 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7060 errmsg = e_invarg;
7061 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007062 /* 'foldignore' */
7063 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7064 {
7065 if (foldmethodIsIndent(curwin))
7066 foldUpdateAll(curwin);
7067 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007068#endif
7069
7070#ifdef FEAT_VIRTUALEDIT
7071 /* 'virtualedit' */
7072 else if (varp == &p_ve)
7073 {
7074 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7075 errmsg = e_invarg;
7076 else if (STRCMP(p_ve, oldval) != 0)
7077 {
7078 /* Recompute cursor position in case the new 've' setting
7079 * changes something. */
7080 validate_virtcol();
7081 coladvance(curwin->w_virtcol);
7082 }
7083 }
7084#endif
7085
7086#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7087 else if (varp == &p_csqf)
7088 {
7089 if (p_csqf != NULL)
7090 {
7091 p = p_csqf;
7092 while (*p != NUL)
7093 {
7094 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7095 || p[1] == NUL
7096 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7097 || (p[2] != NUL && p[2] != ','))
7098 {
7099 errmsg = e_invarg;
7100 break;
7101 }
7102 else if (p[2] == NUL)
7103 break;
7104 else
7105 p += 3;
7106 }
7107 }
7108 }
7109#endif
7110
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007111#ifdef FEAT_CINDENT
7112 /* 'cinoptions' */
7113 else if (gvarp == &p_cino)
7114 {
7115 /* TODO: recognize errors */
7116 parse_cino(curbuf);
7117 }
7118#endif
7119
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007120#if defined(FEAT_RENDER_OPTIONS)
7121 else if (varp == &p_rop && gui.in_use)
7122 {
7123 if (!gui_mch_set_rendering_options(p_rop))
7124 errmsg = e_invarg;
7125 }
7126#endif
7127
Bram Moolenaar071d4272004-06-13 20:20:40 +00007128 /* Options that are a list of flags. */
7129 else
7130 {
7131 p = NULL;
7132 if (varp == &p_ww)
7133 p = (char_u *)WW_ALL;
7134 if (varp == &p_shm)
7135 p = (char_u *)SHM_ALL;
7136 else if (varp == &(p_cpo))
7137 p = (char_u *)CPO_ALL;
7138 else if (varp == &(curbuf->b_p_fo))
7139 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007140#ifdef FEAT_CONCEAL
7141 else if (varp == &curwin->w_p_cocu)
7142 p = (char_u *)COCU_ALL;
7143#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007144 else if (varp == &p_mouse)
7145 {
7146#ifdef FEAT_MOUSE
7147 p = (char_u *)MOUSE_ALL;
7148#else
7149 if (*p_mouse != NUL)
7150 errmsg = (char_u *)N_("E538: No mouse support");
7151#endif
7152 }
7153#if defined(FEAT_GUI)
7154 else if (varp == &p_go)
7155 p = (char_u *)GO_ALL;
7156#endif
7157 if (p != NULL)
7158 {
7159 for (s = *varp; *s; ++s)
7160 if (vim_strchr(p, *s) == NULL)
7161 {
7162 errmsg = illegal_char(errbuf, *s);
7163 break;
7164 }
7165 }
7166 }
7167
7168 /*
7169 * If error detected, restore the previous value.
7170 */
7171 if (errmsg != NULL)
7172 {
7173 if (new_value_alloced)
7174 free_string_option(*varp);
7175 *varp = oldval;
7176 /*
7177 * When resetting some values, need to act on it.
7178 */
7179 if (did_chartab)
7180 (void)init_chartab();
7181 if (varp == &p_hl)
7182 (void)highlight_changed();
7183 }
7184 else
7185 {
7186#ifdef FEAT_EVAL
7187 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007188 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007189#endif
7190 /*
7191 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007192 * Use "free_oldval", because recursiveness may change the flags under
7193 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007194 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007195 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007196 free_string_option(oldval);
7197 if (new_value_alloced)
7198 options[opt_idx].flags |= P_ALLOCED;
7199 else
7200 options[opt_idx].flags &= ~P_ALLOCED;
7201
7202 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007203 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007204 {
7205 /* global option with local value set to use global value; free
7206 * the local value and make it empty */
7207 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7208 free_string_option(*(char_u **)p);
7209 *(char_u **)p = empty_option;
7210 }
7211
7212 /* May set global value for local option. */
7213 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7214 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007215
7216#ifdef FEAT_AUTOCMD
7217 /*
7218 * Trigger the autocommand only after setting the flags.
7219 */
7220# ifdef FEAT_SYN_HL
7221 /* When 'syntax' is set, load the syntax of that name */
7222 if (varp == &(curbuf->b_p_syn))
7223 {
7224 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7225 curbuf->b_fname, TRUE, curbuf);
7226 }
7227# endif
7228 else if (varp == &(curbuf->b_p_ft))
7229 {
7230 /* 'filetype' is set, trigger the FileType autocommand */
7231 did_filetype = TRUE;
7232 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
7233 curbuf->b_fname, TRUE, curbuf);
7234 }
7235#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007236#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007237 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007238 {
7239 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007240 char_u *q = curwin->w_s->b_p_spl;
7241
7242 /* Skip the first name if it is "cjk". */
7243 if (STRNCMP(q, "cjk,", 4) == 0)
7244 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007245
7246 /*
7247 * Source the spell/LANG.vim in 'runtimepath'.
7248 * They could set 'spellcapcheck' depending on the language.
7249 * Use the first name in 'spelllang' up to '_region' or
7250 * '.encoding'.
7251 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007252 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007253 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7254 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007255 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007256 source_runtime(fname, TRUE);
7257 }
7258#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007259 }
7260
7261#ifdef FEAT_MOUSE
7262 if (varp == &p_mouse)
7263 {
7264# ifdef FEAT_MOUSE_TTY
7265 if (*p_mouse == NUL)
7266 mch_setmouse(FALSE); /* switch mouse off */
7267 else
7268# endif
7269 setmouse(); /* in case 'mouse' changed */
7270 }
7271#endif
7272
Bram Moolenaar913077c2012-03-28 19:59:04 +02007273 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007274 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007275 curwin->w_set_curswant = TRUE;
7276
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007277#ifdef FEAT_GUI
7278 /* check redraw when it's not a GUI option or the GUI is active. */
7279 if (!redraw_gui_only || gui.in_use)
7280#endif
7281 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007282
7283 return errmsg;
7284}
7285
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007286#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007287/*
7288 * Simple int comparison function for use with qsort()
7289 */
7290 static int
7291int_cmp(a, b)
7292 const void *a;
7293 const void *b;
7294{
7295 return *(const int *)a - *(const int *)b;
7296}
7297
7298/*
7299 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7300 * Returns error message, NULL if it's OK.
7301 */
7302 char_u *
7303check_colorcolumn(wp)
7304 win_T *wp;
7305{
7306 char_u *s;
7307 int col;
7308 int count = 0;
7309 int color_cols[256];
7310 int i;
7311 int j = 0;
7312
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007313 if (wp->w_buffer == NULL)
7314 return NULL; /* buffer was closed */
7315
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007316 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007317 {
7318 if (*s == '-' || *s == '+')
7319 {
7320 /* -N and +N: add to 'textwidth' */
7321 col = (*s == '-') ? -1 : 1;
7322 ++s;
7323 if (!VIM_ISDIGIT(*s))
7324 return e_invarg;
7325 col = col * getdigits(&s);
7326 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007327 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007328 col += wp->w_buffer->b_p_tw;
7329 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007330 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007331 }
7332 else if (VIM_ISDIGIT(*s))
7333 col = getdigits(&s);
7334 else
7335 return e_invarg;
7336 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007337skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007338 if (*s == NUL)
7339 break;
7340 if (*s != ',')
7341 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007342 if (*++s == NUL)
7343 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007344 }
7345
7346 vim_free(wp->w_p_cc_cols);
7347 if (count == 0)
7348 wp->w_p_cc_cols = NULL;
7349 else
7350 {
7351 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7352 if (wp->w_p_cc_cols != NULL)
7353 {
7354 /* sort the columns for faster usage on screen redraw inside
7355 * win_line() */
7356 qsort(color_cols, count, sizeof(int), int_cmp);
7357
7358 for (i = 0; i < count; ++i)
7359 /* skip duplicates */
7360 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7361 wp->w_p_cc_cols[j++] = color_cols[i];
7362 wp->w_p_cc_cols[j] = -1; /* end marker */
7363 }
7364 }
7365
7366 return NULL; /* no error */
7367}
7368#endif
7369
Bram Moolenaar071d4272004-06-13 20:20:40 +00007370/*
7371 * Handle setting 'listchars' or 'fillchars'.
7372 * Returns error message, NULL if it's OK.
7373 */
7374 static char_u *
7375set_chars_option(varp)
7376 char_u **varp;
7377{
7378 int round, i, len, entries;
7379 char_u *p, *s;
7380 int c1, c2 = 0;
7381 struct charstab
7382 {
7383 int *cp;
7384 char *name;
7385 };
7386#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7387 static struct charstab filltab[] =
7388 {
7389 {&fill_stl, "stl"},
7390 {&fill_stlnc, "stlnc"},
7391 {&fill_vert, "vert"},
7392 {&fill_fold, "fold"},
7393 {&fill_diff, "diff"},
7394 };
7395#endif
7396 static struct charstab lcstab[] =
7397 {
7398 {&lcs_eol, "eol"},
7399 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007400 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007401 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007402 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007403 {&lcs_tab2, "tab"},
7404 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007405#ifdef FEAT_CONCEAL
7406 {&lcs_conceal, "conceal"},
7407#else
7408 {NULL, "conceal"},
7409#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007410 };
7411 struct charstab *tab;
7412
7413#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7414 if (varp == &p_lcs)
7415#endif
7416 {
7417 tab = lcstab;
7418 entries = sizeof(lcstab) / sizeof(struct charstab);
7419 }
7420#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7421 else
7422 {
7423 tab = filltab;
7424 entries = sizeof(filltab) / sizeof(struct charstab);
7425 }
7426#endif
7427
7428 /* first round: check for valid value, second round: assign values */
7429 for (round = 0; round <= 1; ++round)
7430 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007431 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007432 {
7433 /* After checking that the value is valid: set defaults: space for
7434 * 'fillchars', NUL for 'listchars' */
7435 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007436 if (tab[i].cp != NULL)
7437 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007438 if (varp == &p_lcs)
7439 lcs_tab1 = NUL;
7440#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7441 else
7442 fill_diff = '-';
7443#endif
7444 }
7445 p = *varp;
7446 while (*p)
7447 {
7448 for (i = 0; i < entries; ++i)
7449 {
7450 len = (int)STRLEN(tab[i].name);
7451 if (STRNCMP(p, tab[i].name, len) == 0
7452 && p[len] == ':'
7453 && p[len + 1] != NUL)
7454 {
7455 s = p + len + 1;
7456#ifdef FEAT_MBYTE
7457 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007458 if (mb_char2cells(c1) > 1)
7459 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007460#else
7461 c1 = *s++;
7462#endif
7463 if (tab[i].cp == &lcs_tab2)
7464 {
7465 if (*s == NUL)
7466 continue;
7467#ifdef FEAT_MBYTE
7468 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007469 if (mb_char2cells(c2) > 1)
7470 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007471#else
7472 c2 = *s++;
7473#endif
7474 }
7475 if (*s == ',' || *s == NUL)
7476 {
7477 if (round)
7478 {
7479 if (tab[i].cp == &lcs_tab2)
7480 {
7481 lcs_tab1 = c1;
7482 lcs_tab2 = c2;
7483 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007484 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007485 *(tab[i].cp) = c1;
7486
7487 }
7488 p = s;
7489 break;
7490 }
7491 }
7492 }
7493
7494 if (i == entries)
7495 return e_invarg;
7496 if (*p == ',')
7497 ++p;
7498 }
7499 }
7500
7501 return NULL; /* no error */
7502}
7503
7504#ifdef FEAT_STL_OPT
7505/*
7506 * Check validity of options with the 'statusline' format.
7507 * Return error message or NULL.
7508 */
7509 char_u *
7510check_stl_option(s)
7511 char_u *s;
7512{
7513 int itemcnt = 0;
7514 int groupdepth = 0;
7515 static char_u errbuf[80];
7516
7517 while (*s && itemcnt < STL_MAX_ITEM)
7518 {
7519 /* Check for valid keys after % sequences */
7520 while (*s && *s != '%')
7521 s++;
7522 if (!*s)
7523 break;
7524 s++;
7525 if (*s != '%' && *s != ')')
7526 ++itemcnt;
7527 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7528 {
7529 s++;
7530 continue;
7531 }
7532 if (*s == ')')
7533 {
7534 s++;
7535 if (--groupdepth < 0)
7536 break;
7537 continue;
7538 }
7539 if (*s == '-')
7540 s++;
7541 while (VIM_ISDIGIT(*s))
7542 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007543 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007544 continue;
7545 if (*s == '.')
7546 {
7547 s++;
7548 while (*s && VIM_ISDIGIT(*s))
7549 s++;
7550 }
7551 if (*s == '(')
7552 {
7553 groupdepth++;
7554 continue;
7555 }
7556 if (vim_strchr(STL_ALL, *s) == NULL)
7557 {
7558 return illegal_char(errbuf, *s);
7559 }
7560 if (*s == '{')
7561 {
7562 s++;
7563 while (*s != '}' && *s)
7564 s++;
7565 if (*s != '}')
7566 return (char_u *)N_("E540: Unclosed expression sequence");
7567 }
7568 }
7569 if (itemcnt >= STL_MAX_ITEM)
7570 return (char_u *)N_("E541: too many items");
7571 if (groupdepth != 0)
7572 return (char_u *)N_("E542: unbalanced groups");
7573 return NULL;
7574}
7575#endif
7576
7577#ifdef FEAT_CLIPBOARD
7578/*
7579 * Extract the items in the 'clipboard' option and set global values.
7580 */
7581 static char_u *
7582check_clipboard_option()
7583{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007584 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007585 int new_autoselect_star = FALSE;
7586 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007587 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007588 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007589 regprog_T *new_exclude_prog = NULL;
7590 char_u *errmsg = NULL;
7591 char_u *p;
7592
7593 for (p = p_cb; *p != NUL; )
7594 {
7595 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7596 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007597 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007598 p += 7;
7599 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007600 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007601 && (p[11] == ',' || p[11] == NUL))
7602 {
7603 new_unnamed |= CLIP_UNNAMED_PLUS;
7604 p += 11;
7605 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007606 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007607 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007608 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007609 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007610 p += 10;
7611 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007612 else if (STRNCMP(p, "autoselectplus", 14) == 0
7613 && (p[14] == ',' || p[14] == NUL))
7614 {
7615 new_autoselect_plus = TRUE;
7616 p += 14;
7617 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007618 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007619 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007620 {
7621 new_autoselectml = TRUE;
7622 p += 12;
7623 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007624 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7625 {
7626 new_html = TRUE;
7627 p += 4;
7628 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007629 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7630 {
7631 p += 8;
7632 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7633 if (new_exclude_prog == NULL)
7634 errmsg = e_invarg;
7635 break;
7636 }
7637 else
7638 {
7639 errmsg = e_invarg;
7640 break;
7641 }
7642 if (*p == ',')
7643 ++p;
7644 }
7645 if (errmsg == NULL)
7646 {
7647 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007648 clip_autoselect_star = new_autoselect_star;
7649 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007650 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007651 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02007652 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007653 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02007654#ifdef FEAT_GUI_GTK
7655 if (gui.in_use)
7656 {
7657 gui_gtk_set_selection_targets();
7658 gui_gtk_set_dnd_targets();
7659 }
7660#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007661 }
7662 else
Bram Moolenaar473de612013-06-08 18:19:48 +02007663 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007664
7665 return errmsg;
7666}
7667#endif
7668
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007669#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007670/*
7671 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
7672 * Return error message when failed, NULL when OK.
7673 */
7674 static char_u *
Bram Moolenaar860cae12010-06-05 23:22:07 +02007675compile_cap_prog(synblock)
7676 synblock_T *synblock;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007677{
Bram Moolenaar860cae12010-06-05 23:22:07 +02007678 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007679 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007680
Bram Moolenaar860cae12010-06-05 23:22:07 +02007681 if (*synblock->b_p_spc == NUL)
7682 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007683 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007684 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007685 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007686 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007687 if (re != NULL)
7688 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007689 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02007690 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02007691 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007692 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007693 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007694 return e_invarg;
7695 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007696 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007697 }
7698
Bram Moolenaar473de612013-06-08 18:19:48 +02007699 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007700 return NULL;
7701}
7702#endif
7703
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007704#if defined(FEAT_EVAL) || defined(PROTO)
7705/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007706 * Set the scriptID for an option, taking care of setting the buffer- or
7707 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007708 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007709 static void
7710set_option_scriptID_idx(opt_idx, opt_flags, id)
7711 int opt_idx;
7712 int opt_flags;
7713 int id;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007714{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007715 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
7716 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007717
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007718 /* Remember where the option was set. For local options need to do that
7719 * in the buffer or window structure. */
7720 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007721 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007722 if (both || (opt_flags & OPT_LOCAL))
7723 {
7724 if (indir & PV_BUF)
7725 curbuf->b_p_scriptID[indir & PV_MASK] = id;
7726 else if (indir & PV_WIN)
7727 curwin->w_p_scriptID[indir & PV_MASK] = id;
7728 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007729}
7730#endif
7731
Bram Moolenaar071d4272004-06-13 20:20:40 +00007732/*
7733 * Set the value of a boolean option, and take care of side effects.
7734 * Returns NULL for success, or an error message for an error.
7735 */
7736 static char_u *
7737set_bool_option(opt_idx, varp, value, opt_flags)
7738 int opt_idx; /* index in options[] table */
7739 char_u *varp; /* pointer to the option variable */
7740 int value; /* new value */
7741 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
7742{
7743 int old_value = *(int *)varp;
7744
Bram Moolenaar071d4272004-06-13 20:20:40 +00007745 /* Disallow changing some options from secure mode */
7746 if ((secure
7747#ifdef HAVE_SANDBOX
7748 || sandbox != 0
7749#endif
7750 ) && (options[opt_idx].flags & P_SECURE))
7751 return e_secure;
7752
7753 *(int *)varp = value; /* set the new value */
7754#ifdef FEAT_EVAL
7755 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007756 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007757#endif
7758
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00007759#ifdef FEAT_GUI
7760 need_mouse_correct = TRUE;
7761#endif
7762
Bram Moolenaar071d4272004-06-13 20:20:40 +00007763 /* May set global value for local option. */
7764 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
7765 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
7766
7767 /*
7768 * Handle side effects of changing a bool option.
7769 */
7770
7771 /* 'compatible' */
7772 if ((int *)varp == &p_cp)
7773 {
7774 compatible_set();
7775 }
7776
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007777#ifdef FEAT_PERSISTENT_UNDO
7778 /* 'undofile' */
7779 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
7780 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007781 /* Only take action when the option was set. When reset we do not
7782 * delete the undo file, the option may be set again without making
7783 * any changes in between. */
7784 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007785 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007786 char_u hash[UNDO_HASH_SIZE];
7787 buf_T *save_curbuf = curbuf;
7788
7789 for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007790 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007791 /* When 'undofile' is set globally: for every buffer, otherwise
7792 * only for the current buffer: Try to read in the undofile,
7793 * if one exists, the buffer wasn't changed and the buffer was
7794 * loaded */
7795 if ((curbuf == save_curbuf
7796 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
7797 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
7798 {
7799 u_compute_hash(hash);
7800 u_read_undo(NULL, hash, curbuf->b_fname);
7801 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007802 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007803 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007804 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007805 }
7806#endif
7807
Bram Moolenaar071d4272004-06-13 20:20:40 +00007808 else if ((int *)varp == &curbuf->b_p_ro)
7809 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007810 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007811 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
7812 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007813
7814 /* when 'readonly' is set may give W10 again */
7815 if (curbuf->b_p_ro)
7816 curbuf->b_did_warn = FALSE;
7817
Bram Moolenaar071d4272004-06-13 20:20:40 +00007818#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007819 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007820#endif
7821 }
7822
Bram Moolenaar9c449722010-07-20 18:44:27 +02007823#ifdef FEAT_GUI
7824 else if ((int *)varp == &p_mh)
7825 {
7826 if (!p_mh)
7827 gui_mch_mousehide(FALSE);
7828 }
7829#endif
7830
Bram Moolenaara539df02010-08-01 14:35:05 +02007831#ifdef FEAT_TITLE
7832 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007833 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007834 {
7835 redraw_titles();
7836 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007837 /* when 'endofline' is changed, redraw the window title */
7838 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007839 {
7840 redraw_titles();
7841 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02007842 /* when 'fixeol' is changed, redraw the window title */
7843 else if ((int *)varp == &curbuf->b_p_fixeol)
7844 {
7845 redraw_titles();
7846 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007847# ifdef FEAT_MBYTE
7848 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00007849 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007850 {
7851 redraw_titles();
7852 }
7853# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007854#endif
7855
7856 /* when 'bin' is set also set some other options */
7857 else if ((int *)varp == &curbuf->b_p_bin)
7858 {
7859 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
7860#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007861 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007862#endif
7863 }
7864
7865#ifdef FEAT_AUTOCMD
7866 /* when 'buflisted' changes, trigger autocommands */
7867 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
7868 {
7869 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
7870 NULL, NULL, TRUE, curbuf);
7871 }
7872#endif
7873
7874 /* when 'swf' is set, create swapfile, when reset remove swapfile */
7875 else if ((int *)varp == &curbuf->b_p_swf)
7876 {
7877 if (curbuf->b_p_swf && p_uc)
7878 ml_open_file(curbuf); /* create the swap file */
7879 else
Bram Moolenaard55de222007-05-06 13:38:48 +00007880 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
7881 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007882 mf_close_file(curbuf, TRUE); /* remove the swap file */
7883 }
7884
7885 /* when 'terse' is set change 'shortmess' */
7886 else if ((int *)varp == &p_terse)
7887 {
7888 char_u *p;
7889
7890 p = vim_strchr(p_shm, SHM_SEARCH);
7891
7892 /* insert 's' in p_shm */
7893 if (p_terse && p == NULL)
7894 {
7895 STRCPY(IObuff, p_shm);
7896 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007897 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007898 }
7899 /* remove 's' from p_shm */
7900 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007901 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007902 }
7903
7904 /* when 'paste' is set or reset also change other options */
7905 else if ((int *)varp == &p_paste)
7906 {
7907 paste_option_changed();
7908 }
7909
7910 /* when 'insertmode' is set from an autocommand need to do work here */
7911 else if ((int *)varp == &p_im)
7912 {
7913 if (p_im)
7914 {
7915 if ((State & INSERT) == 0)
7916 need_start_insertmode = TRUE;
7917 stop_insert_mode = FALSE;
7918 }
7919 else
7920 {
7921 need_start_insertmode = FALSE;
7922 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00007923 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007924 clear_cmdline = TRUE; /* remove "(insert)" */
7925 restart_edit = 0;
7926 }
7927 }
7928
7929 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
7930 else if ((int *)varp == &p_ic && p_hls)
7931 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007932 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007933 }
7934
7935#ifdef FEAT_SEARCH_EXTRA
7936 /* when 'hlsearch' is set or reset: reset no_hlsearch */
7937 else if ((int *)varp == &p_hls)
7938 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01007939 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007940 }
7941#endif
7942
7943#ifdef FEAT_SCROLLBIND
7944 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
7945 * at the end of normal_cmd() */
7946 else if ((int *)varp == &curwin->w_p_scb)
7947 {
7948 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02007949 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007950 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02007951 curwin->w_scbind_pos = curwin->w_topline;
7952 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007953 }
7954#endif
7955
7956#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
7957 /* There can be only one window with 'previewwindow' set. */
7958 else if ((int *)varp == &curwin->w_p_pvw)
7959 {
7960 if (curwin->w_p_pvw)
7961 {
7962 win_T *win;
7963
7964 for (win = firstwin; win != NULL; win = win->w_next)
7965 if (win->w_p_pvw && win != curwin)
7966 {
7967 curwin->w_p_pvw = FALSE;
7968 return (char_u *)N_("E590: A preview window already exists");
7969 }
7970 }
7971 }
7972#endif
7973
7974 /* when 'textmode' is set or reset also change 'fileformat' */
7975 else if ((int *)varp == &curbuf->b_p_tx)
7976 {
7977 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
7978 }
7979
7980 /* when 'textauto' is set or reset also change 'fileformats' */
7981 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007982 set_string_option_direct((char_u *)"ffs", -1,
7983 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007984 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007985
7986 /*
7987 * When 'lisp' option changes include/exclude '-' in
7988 * keyword characters.
7989 */
7990#ifdef FEAT_LISP
7991 else if (varp == (char_u *)&(curbuf->b_p_lisp))
7992 {
7993 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
7994 }
7995#endif
7996
7997#ifdef FEAT_TITLE
7998 /* when 'title' changed, may need to change the title; same for 'icon' */
7999 else if ((int *)varp == &p_title)
8000 {
8001 did_set_title(FALSE);
8002 }
8003
8004 else if ((int *)varp == &p_icon)
8005 {
8006 did_set_title(TRUE);
8007 }
8008#endif
8009
8010 else if ((int *)varp == &curbuf->b_changed)
8011 {
8012 if (!value)
8013 save_file_ff(curbuf); /* Buffer is unchanged */
8014#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008015 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008016#endif
8017#ifdef FEAT_AUTOCMD
8018 modified_was_set = value;
8019#endif
8020 }
8021
8022#ifdef BACKSLASH_IN_FILENAME
8023 else if ((int *)varp == &p_ssl)
8024 {
8025 if (p_ssl)
8026 {
8027 psepc = '/';
8028 psepcN = '\\';
8029 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008030 }
8031 else
8032 {
8033 psepc = '\\';
8034 psepcN = '/';
8035 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008036 }
8037
8038 /* need to adjust the file name arguments and buffer names. */
8039 buflist_slash_adjust();
8040 alist_slash_adjust();
8041# ifdef FEAT_EVAL
8042 scriptnames_slash_adjust();
8043# endif
8044 }
8045#endif
8046
8047 /* If 'wrap' is set, set w_leftcol to zero. */
8048 else if ((int *)varp == &curwin->w_p_wrap)
8049 {
8050 if (curwin->w_p_wrap)
8051 curwin->w_leftcol = 0;
8052 }
8053
8054#ifdef FEAT_WINDOWS
8055 else if ((int *)varp == &p_ea)
8056 {
8057 if (p_ea && !old_value)
8058 win_equal(curwin, FALSE, 0);
8059 }
8060#endif
8061
8062 else if ((int *)varp == &p_wiv)
8063 {
8064 /*
8065 * When 'weirdinvert' changed, set/reset 't_xs'.
8066 * Then set 'weirdinvert' according to value of 't_xs'.
8067 */
8068 if (p_wiv && !old_value)
8069 T_XS = (char_u *)"y";
8070 else if (!p_wiv && old_value)
8071 T_XS = empty_option;
8072 p_wiv = (*T_XS != NUL);
8073 }
8074
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00008075#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00008076 else if ((int *)varp == &p_beval)
8077 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008078 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008079 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008080 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008081 gui_mch_disable_beval_area(balloonEval);
8082 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008083#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008084
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008085#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008086 else if ((int *)varp == &p_acd)
8087 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008088 /* Change directories when the 'acd' option is set now. */
8089 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008090 }
8091#endif
8092
8093#ifdef FEAT_DIFF
8094 /* 'diff' */
8095 else if ((int *)varp == &curwin->w_p_diff)
8096 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008097 /* May add or remove the buffer from the list of diff buffers. */
8098 diff_buf_adjust(curwin);
8099# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008100 if (foldmethodIsDiff(curwin))
8101 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008102# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008103 }
8104#endif
8105
8106#ifdef USE_IM_CONTROL
8107 /* 'imdisable' */
8108 else if ((int *)varp == &p_imdisable)
8109 {
8110 /* Only de-activate it here, it will be enabled when changing mode. */
8111 if (p_imdisable)
8112 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008113 else if (State & INSERT)
8114 /* When the option is set from an autocommand, it may need to take
8115 * effect right away. */
8116 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008117 }
8118#endif
8119
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008120#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008121 /* 'spell' */
8122 else if ((int *)varp == &curwin->w_p_spell)
8123 {
8124 if (curwin->w_p_spell)
8125 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008126 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008127 if (errmsg != NULL)
8128 EMSG(_(errmsg));
8129 }
8130 }
8131#endif
8132
Bram Moolenaar071d4272004-06-13 20:20:40 +00008133#ifdef FEAT_FKMAP
8134 else if ((int *)varp == &p_altkeymap)
8135 {
8136 if (old_value != p_altkeymap)
8137 {
8138 if (!p_altkeymap)
8139 {
8140 p_hkmap = p_fkmap;
8141 p_fkmap = 0;
8142 }
8143 else
8144 {
8145 p_fkmap = p_hkmap;
8146 p_hkmap = 0;
8147 }
8148 (void)init_chartab();
8149 }
8150 }
8151
8152 /*
8153 * In case some second language keymapping options have changed, check
8154 * and correct the setting in a consistent way.
8155 */
8156
8157 /*
8158 * If hkmap or fkmap are set, reset Arabic keymapping.
8159 */
8160 if ((p_hkmap || p_fkmap) && p_altkeymap)
8161 {
8162 p_altkeymap = p_fkmap;
8163# ifdef FEAT_ARABIC
8164 curwin->w_p_arab = FALSE;
8165# endif
8166 (void)init_chartab();
8167 }
8168
8169 /*
8170 * If hkmap set, reset Farsi keymapping.
8171 */
8172 if (p_hkmap && p_altkeymap)
8173 {
8174 p_altkeymap = 0;
8175 p_fkmap = 0;
8176# ifdef FEAT_ARABIC
8177 curwin->w_p_arab = FALSE;
8178# endif
8179 (void)init_chartab();
8180 }
8181
8182 /*
8183 * If fkmap set, reset Hebrew keymapping.
8184 */
8185 if (p_fkmap && !p_altkeymap)
8186 {
8187 p_altkeymap = 1;
8188 p_hkmap = 0;
8189# ifdef FEAT_ARABIC
8190 curwin->w_p_arab = FALSE;
8191# endif
8192 (void)init_chartab();
8193 }
8194#endif
8195
8196#ifdef FEAT_ARABIC
8197 if ((int *)varp == &curwin->w_p_arab)
8198 {
8199 if (curwin->w_p_arab)
8200 {
8201 /*
8202 * 'arabic' is set, handle various sub-settings.
8203 */
8204 if (!p_tbidi)
8205 {
8206 /* set rightleft mode */
8207 if (!curwin->w_p_rl)
8208 {
8209 curwin->w_p_rl = TRUE;
8210 changed_window_setting();
8211 }
8212
8213 /* Enable Arabic shaping (major part of what Arabic requires) */
8214 if (!p_arshape)
8215 {
8216 p_arshape = TRUE;
8217 redraw_later_clear();
8218 }
8219 }
8220
8221 /* Arabic requires a utf-8 encoding, inform the user if its not
8222 * set. */
8223 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008224 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008225 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8226
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008227 msg_source(hl_attr(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008228 MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
8229#ifdef FEAT_EVAL
8230 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8231#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008232 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008233
8234# ifdef FEAT_MBYTE
8235 /* set 'delcombine' */
8236 p_deco = TRUE;
8237# endif
8238
8239# ifdef FEAT_KEYMAP
8240 /* Force-set the necessary keymap for arabic */
8241 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8242 OPT_LOCAL);
8243# endif
8244# ifdef FEAT_FKMAP
8245 p_altkeymap = 0;
8246 p_hkmap = 0;
8247 p_fkmap = 0;
8248 (void)init_chartab();
8249# endif
8250 }
8251 else
8252 {
8253 /*
8254 * 'arabic' is reset, handle various sub-settings.
8255 */
8256 if (!p_tbidi)
8257 {
8258 /* reset rightleft mode */
8259 if (curwin->w_p_rl)
8260 {
8261 curwin->w_p_rl = FALSE;
8262 changed_window_setting();
8263 }
8264
8265 /* 'arabicshape' isn't reset, it is a global option and
8266 * another window may still need it "on". */
8267 }
8268
8269 /* 'delcombine' isn't reset, it is a global option and another
8270 * window may still want it "on". */
8271
8272# ifdef FEAT_KEYMAP
8273 /* Revert to the default keymap */
8274 curbuf->b_p_iminsert = B_IMODE_NONE;
8275 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8276# endif
8277 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008278 }
8279
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008280#endif
8281
Bram Moolenaar071d4272004-06-13 20:20:40 +00008282 /*
8283 * End of handling side effects for bool options.
8284 */
8285
Bram Moolenaar53744302015-07-17 17:38:22 +02008286 /* after handling side effects, call autocommand */
8287
Bram Moolenaar071d4272004-06-13 20:20:40 +00008288 options[opt_idx].flags |= P_WAS_SET;
8289
Bram Moolenaar53744302015-07-17 17:38:22 +02008290#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8291 if (!starting)
8292 {
8293 char_u buf_old[2], buf_new[2], buf_type[7];
8294 snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8295 snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8296 sprintf((char *)buf_type, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
8297 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8298 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8299 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8300 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8301 reset_v_option_vars();
8302 }
8303#endif
8304
Bram Moolenaar071d4272004-06-13 20:20:40 +00008305 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008306 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008307 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008308 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008309 check_redraw(options[opt_idx].flags);
8310
8311 return NULL;
8312}
8313
8314/*
8315 * Set the value of a number option, and take care of side effects.
8316 * Returns NULL for success, or an error message for an error.
8317 */
8318 static char_u *
Bram Moolenaar555b2802005-05-19 21:08:39 +00008319set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008320 int opt_idx; /* index in options[] table */
8321 char_u *varp; /* pointer to the option variable */
8322 long value; /* new value */
8323 char_u *errbuf; /* buffer for error messages */
Bram Moolenaar555b2802005-05-19 21:08:39 +00008324 size_t errbuflen; /* length of "errbuf" */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008325 int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and
8326 OPT_MODELINE */
8327{
8328 char_u *errmsg = NULL;
8329 long old_value = *(long *)varp;
8330 long old_Rows = Rows; /* remember old Rows */
8331 long old_Columns = Columns; /* remember old Columns */
8332 long *pp = (long *)varp;
8333
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008334 /* Disallow changing some options from secure mode. */
8335 if ((secure
8336#ifdef HAVE_SANDBOX
8337 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008338#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008339 ) && (options[opt_idx].flags & P_SECURE))
8340 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008341
8342 *pp = value;
8343#ifdef FEAT_EVAL
8344 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008345 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008346#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008347#ifdef FEAT_GUI
8348 need_mouse_correct = TRUE;
8349#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008350
Bram Moolenaar14f24742012-08-08 18:01:05 +02008351 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008352 {
8353 errmsg = e_positive;
8354 curbuf->b_p_sw = curbuf->b_p_ts;
8355 }
8356
8357 /*
8358 * Number options that need some action when changed
8359 */
8360#ifdef FEAT_WINDOWS
8361 if (pp == &p_wh || pp == &p_hh)
8362 {
8363 if (p_wh < 1)
8364 {
8365 errmsg = e_positive;
8366 p_wh = 1;
8367 }
8368 if (p_wmh > p_wh)
8369 {
8370 errmsg = e_winheight;
8371 p_wh = p_wmh;
8372 }
8373 if (p_hh < 0)
8374 {
8375 errmsg = e_positive;
8376 p_hh = 0;
8377 }
8378
8379 /* Change window height NOW */
8380 if (lastwin != firstwin)
8381 {
8382 if (pp == &p_wh && curwin->w_height < p_wh)
8383 win_setheight((int)p_wh);
8384 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8385 win_setheight((int)p_hh);
8386 }
8387 }
8388
8389 /* 'winminheight' */
8390 else if (pp == &p_wmh)
8391 {
8392 if (p_wmh < 0)
8393 {
8394 errmsg = e_positive;
8395 p_wmh = 0;
8396 }
8397 if (p_wmh > p_wh)
8398 {
8399 errmsg = e_winheight;
8400 p_wmh = p_wh;
8401 }
8402 win_setminheight();
8403 }
8404
8405# ifdef FEAT_VERTSPLIT
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008406 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008407 {
8408 if (p_wiw < 1)
8409 {
8410 errmsg = e_positive;
8411 p_wiw = 1;
8412 }
8413 if (p_wmw > p_wiw)
8414 {
8415 errmsg = e_winwidth;
8416 p_wiw = p_wmw;
8417 }
8418
8419 /* Change window width NOW */
8420 if (lastwin != firstwin && curwin->w_width < p_wiw)
8421 win_setwidth((int)p_wiw);
8422 }
8423
8424 /* 'winminwidth' */
8425 else if (pp == &p_wmw)
8426 {
8427 if (p_wmw < 0)
8428 {
8429 errmsg = e_positive;
8430 p_wmw = 0;
8431 }
8432 if (p_wmw > p_wiw)
8433 {
8434 errmsg = e_winwidth;
8435 p_wmw = p_wiw;
8436 }
8437 win_setminheight();
8438 }
8439# endif
8440
8441#endif
8442
8443#ifdef FEAT_WINDOWS
8444 /* (re)set last window status line */
8445 else if (pp == &p_ls)
8446 {
8447 last_status(FALSE);
8448 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008449
8450 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008451 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008452 {
8453 shell_new_rows(); /* recompute window positions and heights */
8454 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008455#endif
8456
8457#ifdef FEAT_GUI
8458 else if (pp == &p_linespace)
8459 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008460 /* Recompute gui.char_height and resize the Vim window to keep the
8461 * same number of lines. */
8462 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008463 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008464 }
8465#endif
8466
8467#ifdef FEAT_FOLDING
8468 /* 'foldlevel' */
8469 else if (pp == &curwin->w_p_fdl)
8470 {
8471 if (curwin->w_p_fdl < 0)
8472 curwin->w_p_fdl = 0;
8473 newFoldLevel();
8474 }
8475
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008476 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008477 else if (pp == &curwin->w_p_fml)
8478 {
8479 foldUpdateAll(curwin);
8480 }
8481
8482 /* 'foldnestmax' */
8483 else if (pp == &curwin->w_p_fdn)
8484 {
8485 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8486 foldUpdateAll(curwin);
8487 }
8488
8489 /* 'foldcolumn' */
8490 else if (pp == &curwin->w_p_fdc)
8491 {
8492 if (curwin->w_p_fdc < 0)
8493 {
8494 errmsg = e_positive;
8495 curwin->w_p_fdc = 0;
8496 }
8497 else if (curwin->w_p_fdc > 12)
8498 {
8499 errmsg = e_invarg;
8500 curwin->w_p_fdc = 12;
8501 }
8502 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008503#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008504
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008505#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008506 /* 'shiftwidth' or 'tabstop' */
8507 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8508 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008509# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008510 if (foldmethodIsIndent(curwin))
8511 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008512# endif
8513# ifdef FEAT_CINDENT
8514 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8515 * parse 'cinoptions'. */
8516 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8517 parse_cino(curbuf);
8518# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008519 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008520#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008521
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008522#ifdef FEAT_MBYTE
8523 /* 'maxcombine' */
8524 else if (pp == &p_mco)
8525 {
8526 if (p_mco > MAX_MCO)
8527 p_mco = MAX_MCO;
8528 else if (p_mco < 0)
8529 p_mco = 0;
8530 screenclear(); /* will re-allocate the screen */
8531 }
8532#endif
8533
Bram Moolenaar071d4272004-06-13 20:20:40 +00008534 else if (pp == &curbuf->b_p_iminsert)
8535 {
8536 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8537 {
8538 errmsg = e_invarg;
8539 curbuf->b_p_iminsert = B_IMODE_NONE;
8540 }
8541 p_iminsert = curbuf->b_p_iminsert;
8542 if (termcap_active) /* don't do this in the alternate screen */
8543 showmode();
8544#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8545 /* Show/unshow value of 'keymap' in status lines. */
8546 status_redraw_curbuf();
8547#endif
8548 }
8549
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008550 else if (pp == &p_window)
8551 {
8552 if (p_window < 1)
8553 p_window = 1;
8554 else if (p_window >= Rows)
8555 p_window = Rows - 1;
8556 }
8557
Bram Moolenaar071d4272004-06-13 20:20:40 +00008558 else if (pp == &curbuf->b_p_imsearch)
8559 {
8560 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8561 {
8562 errmsg = e_invarg;
8563 curbuf->b_p_imsearch = B_IMODE_NONE;
8564 }
8565 p_imsearch = curbuf->b_p_imsearch;
8566 }
8567
8568#ifdef FEAT_TITLE
8569 /* if 'titlelen' has changed, redraw the title */
8570 else if (pp == &p_titlelen)
8571 {
8572 if (p_titlelen < 0)
8573 {
8574 errmsg = e_positive;
8575 p_titlelen = 85;
8576 }
8577 if (starting != NO_SCREEN && old_value != p_titlelen)
8578 need_maketitle = TRUE;
8579 }
8580#endif
8581
8582 /* if p_ch changed value, change the command line height */
8583 else if (pp == &p_ch)
8584 {
8585 if (p_ch < 1)
8586 {
8587 errmsg = e_positive;
8588 p_ch = 1;
8589 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008590 if (p_ch > Rows - min_rows() + 1)
8591 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008592
8593 /* Only compute the new window layout when startup has been
8594 * completed. Otherwise the frame sizes may be wrong. */
8595 if (p_ch != old_value && full_screen
8596#ifdef FEAT_GUI
8597 && !gui.starting
8598#endif
8599 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008600 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008601 }
8602
8603 /* when 'updatecount' changes from zero to non-zero, open swap files */
8604 else if (pp == &p_uc)
8605 {
8606 if (p_uc < 0)
8607 {
8608 errmsg = e_positive;
8609 p_uc = 100;
8610 }
8611 if (p_uc && !old_value)
8612 ml_open_files();
8613 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008614#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008615 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008616 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008617 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008618 {
8619 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008620 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008621 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008622 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008623 {
8624 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008625 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008626 }
8627 }
8628#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008629#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008630 else if (pp == &p_mzq)
8631 mzvim_reset_timer();
8632#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008633
8634 /* sync undo before 'undolevels' changes */
8635 else if (pp == &p_ul)
8636 {
8637 /* use the old value, otherwise u_sync() may not work properly */
8638 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00008639 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008640 p_ul = value;
8641 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01008642 else if (pp == &curbuf->b_p_ul)
8643 {
8644 /* use the old value, otherwise u_sync() may not work properly */
8645 curbuf->b_p_ul = old_value;
8646 u_sync(TRUE);
8647 curbuf->b_p_ul = value;
8648 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008649
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008650#ifdef FEAT_LINEBREAK
8651 /* 'numberwidth' must be positive */
8652 else if (pp == &curwin->w_p_nuw)
8653 {
8654 if (curwin->w_p_nuw < 1)
8655 {
8656 errmsg = e_positive;
8657 curwin->w_p_nuw = 1;
8658 }
8659 if (curwin->w_p_nuw > 10)
8660 {
8661 errmsg = e_invarg;
8662 curwin->w_p_nuw = 10;
8663 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02008664 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008665 }
8666#endif
8667
Bram Moolenaar1a384422010-07-14 19:53:30 +02008668 else if (pp == &curbuf->b_p_tw)
8669 {
8670 if (curbuf->b_p_tw < 0)
8671 {
8672 errmsg = e_positive;
8673 curbuf->b_p_tw = 0;
8674 }
8675#ifdef FEAT_SYN_HL
8676# ifdef FEAT_WINDOWS
8677 {
8678 win_T *wp;
8679 tabpage_T *tp;
8680
8681 FOR_ALL_TAB_WINDOWS(tp, wp)
8682 check_colorcolumn(wp);
8683 }
8684# else
8685 check_colorcolumn(curwin);
8686# endif
8687#endif
8688 }
8689
Bram Moolenaar071d4272004-06-13 20:20:40 +00008690 /*
8691 * Check the bounds for numeric options here
8692 */
8693 if (Rows < min_rows() && full_screen)
8694 {
8695 if (errbuf != NULL)
8696 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008697 vim_snprintf((char *)errbuf, errbuflen,
8698 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00008699 errmsg = errbuf;
8700 }
8701 Rows = min_rows();
8702 }
8703 if (Columns < MIN_COLUMNS && full_screen)
8704 {
8705 if (errbuf != NULL)
8706 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008707 vim_snprintf((char *)errbuf, errbuflen,
8708 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008709 errmsg = errbuf;
8710 }
8711 Columns = MIN_COLUMNS;
8712 }
Bram Moolenaare057d402013-06-30 17:51:51 +02008713 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008714
8715#ifdef DJGPP
8716 /* avoid a crash by checking for a too large value of 'columns' */
8717 if (old_Columns != Columns && full_screen && term_console)
8718 mch_check_columns();
8719#endif
8720
8721 /*
8722 * If the screen (shell) height has been changed, assume it is the
8723 * physical screenheight.
8724 */
8725 if (old_Rows != Rows || old_Columns != Columns)
8726 {
8727 /* Changing the screen size is not allowed while updating the screen. */
8728 if (updating_screen)
8729 *pp = old_value;
8730 else if (full_screen
8731#ifdef FEAT_GUI
8732 && !gui.starting
8733#endif
8734 )
8735 set_shellsize((int)Columns, (int)Rows, TRUE);
8736 else
8737 {
8738 /* Postpone the resizing; check the size and cmdline position for
8739 * messages. */
8740 check_shellsize();
8741 if (cmdline_row > Rows - p_ch && Rows > p_ch)
8742 cmdline_row = Rows - p_ch;
8743 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00008744 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008745 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008746 }
8747
Bram Moolenaar071d4272004-06-13 20:20:40 +00008748 if (curbuf->b_p_ts <= 0)
8749 {
8750 errmsg = e_positive;
8751 curbuf->b_p_ts = 8;
8752 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008753 if (p_tm < 0)
8754 {
8755 errmsg = e_positive;
8756 p_tm = 0;
8757 }
8758 if ((curwin->w_p_scr <= 0
8759 || (curwin->w_p_scr > curwin->w_height
8760 && curwin->w_height > 0))
8761 && full_screen)
8762 {
8763 if (pp == &(curwin->w_p_scr))
8764 {
8765 if (curwin->w_p_scr != 0)
8766 errmsg = e_scroll;
8767 win_comp_scroll(curwin);
8768 }
8769 /* If 'scroll' became invalid because of a side effect silently adjust
8770 * it. */
8771 else if (curwin->w_p_scr <= 0)
8772 curwin->w_p_scr = 1;
8773 else /* curwin->w_p_scr > curwin->w_height */
8774 curwin->w_p_scr = curwin->w_height;
8775 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00008776 if (p_hi < 0)
8777 {
8778 errmsg = e_positive;
8779 p_hi = 0;
8780 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02008781 else if (p_hi > 10000)
8782 {
8783 errmsg = e_invarg;
8784 p_hi = 10000;
8785 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02008786 if (p_re < 0 || p_re > 2)
8787 {
8788 errmsg = e_invarg;
8789 p_re = 0;
8790 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008791 if (p_report < 0)
8792 {
8793 errmsg = e_positive;
8794 p_report = 1;
8795 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00008796 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008797 {
8798 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
8799 p_sj = Rows / 2;
8800 else
8801 {
8802 errmsg = e_scroll;
8803 p_sj = 1;
8804 }
8805 }
8806 if (p_so < 0 && full_screen)
8807 {
8808 errmsg = e_scroll;
8809 p_so = 0;
8810 }
8811 if (p_siso < 0 && full_screen)
8812 {
8813 errmsg = e_positive;
8814 p_siso = 0;
8815 }
8816#ifdef FEAT_CMDWIN
8817 if (p_cwh < 1)
8818 {
8819 errmsg = e_positive;
8820 p_cwh = 1;
8821 }
8822#endif
8823 if (p_ut < 0)
8824 {
8825 errmsg = e_positive;
8826 p_ut = 2000;
8827 }
8828 if (p_ss < 0)
8829 {
8830 errmsg = e_positive;
8831 p_ss = 0;
8832 }
8833
8834 /* May set global value for local option. */
8835 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8836 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
8837
8838 options[opt_idx].flags |= P_WAS_SET;
8839
Bram Moolenaar53744302015-07-17 17:38:22 +02008840#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8841 if (!starting && errmsg == NULL)
8842 {
8843 char_u buf_old[11], buf_new[11], buf_type[7];
8844 snprintf((char *)buf_old, 10, "%ld", old_value);
8845 snprintf((char *)buf_new, 10, "%ld", value);
8846 snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
8847 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8848 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8849 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8850 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8851 reset_v_option_vars();
8852 }
8853#endif
8854
Bram Moolenaar071d4272004-06-13 20:20:40 +00008855 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008856 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008857 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008858 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008859 check_redraw(options[opt_idx].flags);
8860
8861 return errmsg;
8862}
8863
8864/*
8865 * Called after an option changed: check if something needs to be redrawn.
8866 */
8867 static void
8868check_redraw(flags)
8869 long_u flags;
8870{
8871 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008872 int doclear = (flags & P_RCLR) == P_RCLR;
8873 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008874
8875#ifdef FEAT_WINDOWS
8876 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
8877 status_redraw_all();
8878#endif
8879
8880 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
8881 changed_window_setting();
8882 if (flags & P_RBUF)
8883 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008884 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008885 redraw_all_later(CLEAR);
8886 else if (all)
8887 redraw_all_later(NOT_VALID);
8888}
8889
8890/*
8891 * Find index for option 'arg'.
8892 * Return -1 if not found.
8893 */
8894 static int
8895findoption(arg)
8896 char_u *arg;
8897{
8898 int opt_idx;
8899 char *s, *p;
8900 static short quick_tab[27] = {0, 0}; /* quick access table */
8901 int is_term_opt;
8902
8903 /*
8904 * For first call: Initialize the quick-access table.
8905 * It contains the index for the first option that starts with a certain
8906 * letter. There are 26 letters, plus the first "t_" option.
8907 */
8908 if (quick_tab[1] == 0)
8909 {
8910 p = options[0].fullname;
8911 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8912 {
8913 if (s[0] != p[0])
8914 {
8915 if (s[0] == 't' && s[1] == '_')
8916 quick_tab[26] = opt_idx;
8917 else
8918 quick_tab[CharOrdLow(s[0])] = opt_idx;
8919 }
8920 p = s;
8921 }
8922 }
8923
8924 /*
8925 * Check for name starting with an illegal character.
8926 */
8927#ifdef EBCDIC
8928 if (!islower(arg[0]))
8929#else
8930 if (arg[0] < 'a' || arg[0] > 'z')
8931#endif
8932 return -1;
8933
8934 is_term_opt = (arg[0] == 't' && arg[1] == '_');
8935 if (is_term_opt)
8936 opt_idx = quick_tab[26];
8937 else
8938 opt_idx = quick_tab[CharOrdLow(arg[0])];
8939 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8940 {
8941 if (STRCMP(arg, s) == 0) /* match full name */
8942 break;
8943 }
8944 if (s == NULL && !is_term_opt)
8945 {
8946 opt_idx = quick_tab[CharOrdLow(arg[0])];
8947 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
8948 {
8949 s = options[opt_idx].shortname;
8950 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
8951 break;
8952 s = NULL;
8953 }
8954 }
8955 if (s == NULL)
8956 opt_idx = -1;
8957 return opt_idx;
8958}
8959
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008960#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008961/*
8962 * Get the value for an option.
8963 *
8964 * Returns:
8965 * Number or Toggle option: 1, *numval gets value.
8966 * String option: 0, *stringval gets allocated string.
8967 * Hidden Number or Toggle option: -1.
8968 * hidden String option: -2.
8969 * unknown option: -3.
8970 */
8971 int
8972get_option_value(name, numval, stringval, opt_flags)
8973 char_u *name;
8974 long *numval;
Bram Moolenaar370df582010-06-22 05:16:38 +02008975 char_u **stringval; /* NULL when only checking existence */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008976 int opt_flags;
8977{
8978 int opt_idx;
8979 char_u *varp;
8980
8981 opt_idx = findoption(name);
8982 if (opt_idx < 0) /* unknown option */
8983 return -3;
8984
8985 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
8986
8987 if (options[opt_idx].flags & P_STRING)
8988 {
8989 if (varp == NULL) /* hidden option */
8990 return -2;
8991 if (stringval != NULL)
8992 {
8993#ifdef FEAT_CRYPT
8994 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00008995 if ((char_u **)varp == &curbuf->b_p_key
8996 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008997 *stringval = vim_strsave((char_u *)"*****");
8998 else
8999#endif
9000 *stringval = vim_strsave(*(char_u **)(varp));
9001 }
9002 return 0;
9003 }
9004
9005 if (varp == NULL) /* hidden option */
9006 return -1;
9007 if (options[opt_idx].flags & P_NUM)
9008 *numval = *(long *)varp;
9009 else
9010 {
9011 /* Special case: 'modified' is b_changed, but we also want to consider
9012 * it set when 'ff' or 'fenc' changed. */
9013 if ((int *)varp == &curbuf->b_changed)
9014 *numval = curbufIsChanged();
9015 else
9016 *numval = *(int *)varp;
9017 }
9018 return 1;
9019}
9020#endif
9021
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009022#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009023/*
9024 * Returns the option attributes and its value. Unlike the above function it
9025 * will return either global value or local value of the option depending on
9026 * what was requested, but it will never return global value if it was
9027 * requested to return local one and vice versa. Neither it will return
9028 * buffer-local value if it was requested to return window-local one.
9029 *
9030 * Pretends that option is absent if it is not present in the requested scope
9031 * (i.e. has no global, window-local or buffer-local value depending on
9032 * opt_type). Uses
9033 *
9034 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009035 * 0 hidden or unknown option, also option that does not have requested
9036 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009037 * see SOPT_* in vim.h for other flags
9038 *
9039 * Possible opt_type values: see SREQ_* in vim.h
9040 */
9041 int
9042get_option_value_strict(name, numval, stringval, opt_type, from)
9043 char_u *name;
9044 long *numval;
9045 char_u **stringval; /* NULL when only obtaining attributes */
9046 int opt_type;
9047 void *from;
9048{
9049 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009050 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009051 struct vimoption *p;
9052 int r = 0;
9053
9054 opt_idx = findoption(name);
9055 if (opt_idx < 0)
9056 return 0;
9057
9058 p = &(options[opt_idx]);
9059
9060 /* Hidden option */
9061 if (p->var == NULL)
9062 return 0;
9063
9064 if (p->flags & P_BOOL)
9065 r |= SOPT_BOOL;
9066 else if (p->flags & P_NUM)
9067 r |= SOPT_NUM;
9068 else if (p->flags & P_STRING)
9069 r |= SOPT_STRING;
9070
9071 if (p->indir == PV_NONE)
9072 {
9073 if (opt_type == SREQ_GLOBAL)
9074 r |= SOPT_GLOBAL;
9075 else
9076 return 0; /* Did not request global-only option */
9077 }
9078 else
9079 {
9080 if (p->indir & PV_BOTH)
9081 r |= SOPT_GLOBAL;
9082 else if (opt_type == SREQ_GLOBAL)
9083 return 0; /* Requested global option */
9084
9085 if (p->indir & PV_WIN)
9086 {
9087 if (opt_type == SREQ_BUF)
9088 return 0; /* Did not request window-local option */
9089 else
9090 r |= SOPT_WIN;
9091 }
9092 else if (p->indir & PV_BUF)
9093 {
9094 if (opt_type == SREQ_WIN)
9095 return 0; /* Did not request buffer-local option */
9096 else
9097 r |= SOPT_BUF;
9098 }
9099 }
9100
9101 if (stringval == NULL)
9102 return r;
9103
9104 if (opt_type == SREQ_GLOBAL)
9105 varp = p->var;
9106 else
9107 {
9108 if (opt_type == SREQ_BUF)
9109 {
9110 /* Special case: 'modified' is b_changed, but we also want to
9111 * consider it set when 'ff' or 'fenc' changed. */
9112 if (p->indir == PV_MOD)
9113 {
9114 *numval = bufIsChanged((buf_T *) from);
9115 varp = NULL;
9116 }
9117#ifdef FEAT_CRYPT
9118 else if (p->indir == PV_KEY)
9119 {
9120 /* never return the value of the crypt key */
9121 *stringval = NULL;
9122 varp = NULL;
9123 }
9124#endif
9125 else
9126 {
9127 aco_save_T aco;
9128 aucmd_prepbuf(&aco, (buf_T *) from);
9129 varp = get_varp(p);
9130 aucmd_restbuf(&aco);
9131 }
9132 }
9133 else if (opt_type == SREQ_WIN)
9134 {
9135 win_T *save_curwin;
9136 save_curwin = curwin;
9137 curwin = (win_T *) from;
9138 curbuf = curwin->w_buffer;
9139 varp = get_varp(p);
9140 curwin = save_curwin;
9141 curbuf = curwin->w_buffer;
9142 }
9143 if (varp == p->var)
9144 return (r | SOPT_UNSET);
9145 }
9146
9147 if (varp != NULL)
9148 {
9149 if (p->flags & P_STRING)
9150 *stringval = vim_strsave(*(char_u **)(varp));
9151 else if (p->flags & P_NUM)
9152 *numval = *(long *) varp;
9153 else
9154 *numval = *(int *)varp;
9155 }
9156
9157 return r;
9158}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009159
9160/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009161 * Iterate over options. First argument is a pointer to a pointer to a
9162 * structure inside options[] array, second is option type like in the above
9163 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009164 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009165 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009166 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009167 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009168 * first argument to NULL.
9169 *
9170 * Returns full option name for current option on each call.
9171 */
9172 char_u *
9173option_iter_next(option, opt_type)
9174 void **option;
9175 int opt_type;
9176{
9177 struct vimoption *ret = NULL;
9178 do
9179 {
9180 if (*option == NULL)
9181 *option = (void *) options;
9182 else if (((struct vimoption *) (*option))->fullname == NULL)
9183 {
9184 *option = NULL;
9185 return NULL;
9186 }
9187 else
9188 *option = (void *) (((struct vimoption *) (*option)) + 1);
9189
9190 ret = ((struct vimoption *) (*option));
9191
9192 /* Hidden option */
9193 if (ret->var == NULL)
9194 {
9195 ret = NULL;
9196 continue;
9197 }
9198
9199 switch (opt_type)
9200 {
9201 case SREQ_GLOBAL:
9202 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9203 ret = NULL;
9204 break;
9205 case SREQ_BUF:
9206 if (!(ret->indir & PV_BUF))
9207 ret = NULL;
9208 break;
9209 case SREQ_WIN:
9210 if (!(ret->indir & PV_WIN))
9211 ret = NULL;
9212 break;
9213 default:
9214 EMSG2(_(e_intern2), "option_iter_next()");
9215 return NULL;
9216 }
9217 }
9218 while (ret == NULL);
9219
9220 return (char_u *)ret->fullname;
9221}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009222#endif
9223
Bram Moolenaar071d4272004-06-13 20:20:40 +00009224/*
9225 * Set the value of option "name".
9226 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009227 *
9228 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009229 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009230 char_u *
Bram Moolenaar071d4272004-06-13 20:20:40 +00009231set_option_value(name, number, string, opt_flags)
9232 char_u *name;
9233 long number;
9234 char_u *string;
9235 int opt_flags; /* OPT_LOCAL or 0 (both) */
9236{
9237 int opt_idx;
9238 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009239 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009240
9241 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009242 if (opt_idx < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009243 EMSG2(_("E355: Unknown option: %s"), name);
9244 else
9245 {
9246 flags = options[opt_idx].flags;
9247#ifdef HAVE_SANDBOX
9248 /* Disallow changing some options in the sandbox */
9249 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009250 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009251 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009252 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009253 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009254#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009255 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009256 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009257 else
9258 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009259 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009260 if (varp != NULL) /* hidden option is not changed */
9261 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009262 if (number == 0 && string != NULL)
9263 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009264 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009265
9266 /* Either we are given a string or we are setting option
9267 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009268 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009269 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009270 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009271 {
9272 /* There's another character after zeros or the string
9273 * is empty. In both cases, we are trying to set a
9274 * num option using a string. */
9275 EMSG3(_("E521: Number required: &%s = '%s'"),
9276 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009277 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009278
9279 }
9280 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009281 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009282 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009283 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009284 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009285 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009286 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009287 }
9288 }
9289 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009290 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009291}
9292
9293/*
9294 * Get the terminal code for a terminal option.
9295 * Returns NULL when not found.
9296 */
9297 char_u *
9298get_term_code(tname)
9299 char_u *tname;
9300{
9301 int opt_idx;
9302 char_u *varp;
9303
9304 if (tname[0] != 't' || tname[1] != '_' ||
9305 tname[2] == NUL || tname[3] == NUL)
9306 return NULL;
9307 if ((opt_idx = findoption(tname)) >= 0)
9308 {
9309 varp = get_varp(&(options[opt_idx]));
9310 if (varp != NULL)
9311 varp = *(char_u **)(varp);
9312 return varp;
9313 }
9314 return find_termcode(tname + 2);
9315}
9316
9317 char_u *
9318get_highlight_default()
9319{
9320 int i;
9321
9322 i = findoption((char_u *)"hl");
9323 if (i >= 0)
9324 return options[i].def_val[VI_DEFAULT];
9325 return (char_u *)NULL;
9326}
9327
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009328#if defined(FEAT_MBYTE) || defined(PROTO)
9329 char_u *
9330get_encoding_default()
9331{
9332 int i;
9333
9334 i = findoption((char_u *)"enc");
9335 if (i >= 0)
9336 return options[i].def_val[VI_DEFAULT];
9337 return (char_u *)NULL;
9338}
9339#endif
9340
Bram Moolenaar071d4272004-06-13 20:20:40 +00009341/*
9342 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9343 */
9344 static int
9345find_key_option(arg)
9346 char_u *arg;
9347{
9348 int key;
9349 int modifiers;
9350
9351 /*
9352 * Don't use get_special_key_code() for t_xx, we don't want it to call
9353 * add_termcap_entry().
9354 */
9355 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9356 key = TERMCAP2KEY(arg[2], arg[3]);
9357 else
9358 {
9359 --arg; /* put arg at the '<' */
9360 modifiers = 0;
Bram Moolenaar2a8ced02008-12-24 11:54:31 +00009361 key = find_special_key(&arg, &modifiers, TRUE, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009362 if (modifiers) /* can't handle modifiers here */
9363 key = 0;
9364 }
9365 return key;
9366}
9367
9368/*
9369 * if 'all' == 0: show changed options
9370 * if 'all' == 1: show all normal options
9371 * if 'all' == 2: show all terminal options
9372 */
9373 static void
9374showoptions(all, opt_flags)
9375 int all;
9376 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
9377{
9378 struct vimoption *p;
9379 int col;
9380 int isterm;
9381 char_u *varp;
9382 struct vimoption **items;
9383 int item_count;
9384 int run;
9385 int row, rows;
9386 int cols;
9387 int i;
9388 int len;
9389
9390#define INC 20
9391#define GAP 3
9392
9393 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9394 PARAM_COUNT));
9395 if (items == NULL)
9396 return;
9397
9398 /* Highlight title */
9399 if (all == 2)
9400 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9401 else if (opt_flags & OPT_GLOBAL)
9402 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9403 else if (opt_flags & OPT_LOCAL)
9404 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9405 else
9406 MSG_PUTS_TITLE(_("\n--- Options ---"));
9407
9408 /*
9409 * do the loop two times:
9410 * 1. display the short items
9411 * 2. display the long items (only strings and numbers)
9412 */
9413 for (run = 1; run <= 2 && !got_int; ++run)
9414 {
9415 /*
9416 * collect the items in items[]
9417 */
9418 item_count = 0;
9419 for (p = &options[0]; p->fullname != NULL; p++)
9420 {
9421 varp = NULL;
9422 isterm = istermoption(p);
9423 if (opt_flags != 0)
9424 {
9425 if (p->indir != PV_NONE && !isterm)
9426 varp = get_varp_scope(p, opt_flags);
9427 }
9428 else
9429 varp = get_varp(p);
9430 if (varp != NULL
9431 && ((all == 2 && isterm)
9432 || (all == 1 && !isterm)
9433 || (all == 0 && !optval_default(p, varp))))
9434 {
9435 if (p->flags & P_BOOL)
9436 len = 1; /* a toggle option fits always */
9437 else
9438 {
9439 option_value2string(p, opt_flags);
9440 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9441 }
9442 if ((len <= INC - GAP && run == 1) ||
9443 (len > INC - GAP && run == 2))
9444 items[item_count++] = p;
9445 }
9446 }
9447
9448 /*
9449 * display the items
9450 */
9451 if (run == 1)
9452 {
9453 cols = (Columns + GAP - 3) / INC;
9454 if (cols == 0)
9455 cols = 1;
9456 rows = (item_count + cols - 1) / cols;
9457 }
9458 else /* run == 2 */
9459 rows = item_count;
9460 for (row = 0; row < rows && !got_int; ++row)
9461 {
9462 msg_putchar('\n'); /* go to next line */
9463 if (got_int) /* 'q' typed in more */
9464 break;
9465 col = 0;
9466 for (i = row; i < item_count; i += rows)
9467 {
9468 msg_col = col; /* make columns */
9469 showoneopt(items[i], opt_flags);
9470 col += INC;
9471 }
9472 out_flush();
9473 ui_breakcheck();
9474 }
9475 }
9476 vim_free(items);
9477}
9478
9479/*
9480 * Return TRUE if option "p" has its default value.
9481 */
9482 static int
9483optval_default(p, varp)
9484 struct vimoption *p;
9485 char_u *varp;
9486{
9487 int dvi;
9488
9489 if (varp == NULL)
9490 return TRUE; /* hidden option is always at default */
9491 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9492 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009493 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009494 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009495 /* the cast to long is required for Manx C, long_i is
9496 * needed for MSVC */
9497 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009498 /* P_STRING */
9499 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9500}
9501
9502/*
9503 * showoneopt: show the value of one option
9504 * must not be called with a hidden option!
9505 */
9506 static void
9507showoneopt(p, opt_flags)
9508 struct vimoption *p;
9509 int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */
9510{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009511 char_u *varp;
9512 int save_silent = silent_mode;
9513
9514 silent_mode = FALSE;
9515 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009516
9517 varp = get_varp_scope(p, opt_flags);
9518
9519 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9520 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9521 ? !curbufIsChanged() : !*(int *)varp))
9522 MSG_PUTS("no");
9523 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9524 MSG_PUTS("--");
9525 else
9526 MSG_PUTS(" ");
9527 MSG_PUTS(p->fullname);
9528 if (!(p->flags & P_BOOL))
9529 {
9530 msg_putchar('=');
9531 /* put value string in NameBuff */
9532 option_value2string(p, opt_flags);
9533 msg_outtrans(NameBuff);
9534 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009535
9536 silent_mode = save_silent;
9537 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009538}
9539
9540/*
9541 * Write modified options as ":set" commands to a file.
9542 *
9543 * There are three values for "opt_flags":
9544 * OPT_GLOBAL: Write global option values and fresh values of
9545 * buffer-local options (used for start of a session
9546 * file).
9547 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
9548 * curwin (used for a vimrc file).
9549 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
9550 * and local values for window-local options of
9551 * curwin. Local values are also written when at the
9552 * default value, because a modeline or autocommand
9553 * may have set them when doing ":edit file" and the
9554 * user has set them back at the default or fresh
9555 * value.
9556 * When "local_only" is TRUE, don't write fresh
9557 * values, only local values (for ":mkview").
9558 * (fresh value = value used for a new buffer or window for a local option).
9559 *
9560 * Return FAIL on error, OK otherwise.
9561 */
9562 int
9563makeset(fd, opt_flags, local_only)
9564 FILE *fd;
9565 int opt_flags;
9566 int local_only;
9567{
9568 struct vimoption *p;
9569 char_u *varp; /* currently used value */
9570 char_u *varp_fresh; /* local value */
9571 char_u *varp_local = NULL; /* fresh value */
9572 char *cmd;
9573 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009574 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009575
9576 /*
9577 * The options that don't have a default (terminal name, columns, lines)
9578 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009579 * Do the loop over "options[]" twice: once for options with the
9580 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009581 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009582 for (pri = 1; pri >= 0; --pri)
9583 {
9584 for (p = &options[0]; !istermoption(p); p++)
9585 if (!(p->flags & P_NO_MKRC)
9586 && !istermoption(p)
9587 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009588 {
9589 /* skip global option when only doing locals */
9590 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
9591 continue;
9592
9593 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
9594 * file, they are always buffer-specific. */
9595 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
9596 continue;
9597
9598 /* Global values are only written when not at the default value. */
9599 varp = get_varp_scope(p, opt_flags);
9600 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
9601 continue;
9602
9603 round = 2;
9604 if (p->indir != PV_NONE)
9605 {
9606 if (p->var == VAR_WIN)
9607 {
9608 /* skip window-local option when only doing globals */
9609 if (!(opt_flags & OPT_LOCAL))
9610 continue;
9611 /* When fresh value of window-local option is not at the
9612 * default, need to write it too. */
9613 if (!(opt_flags & OPT_GLOBAL) && !local_only)
9614 {
9615 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
9616 if (!optval_default(p, varp_fresh))
9617 {
9618 round = 1;
9619 varp_local = varp;
9620 varp = varp_fresh;
9621 }
9622 }
9623 }
9624 }
9625
9626 /* Round 1: fresh value for window-local options.
9627 * Round 2: other values */
9628 for ( ; round <= 2; varp = varp_local, ++round)
9629 {
9630 if (round == 1 || (opt_flags & OPT_GLOBAL))
9631 cmd = "set";
9632 else
9633 cmd = "setlocal";
9634
9635 if (p->flags & P_BOOL)
9636 {
9637 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
9638 return FAIL;
9639 }
9640 else if (p->flags & P_NUM)
9641 {
9642 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
9643 return FAIL;
9644 }
9645 else /* P_STRING */
9646 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009647#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9648 int do_endif = FALSE;
9649
Bram Moolenaar071d4272004-06-13 20:20:40 +00009650 /* Don't set 'syntax' and 'filetype' again if the value is
9651 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009652 if (
9653# if defined(FEAT_SYN_HL)
9654 p->indir == PV_SYN
9655# if defined(FEAT_AUTOCMD)
9656 ||
9657# endif
9658# endif
9659# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009660 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009661# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009662 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00009663 {
9664 if (fprintf(fd, "if &%s != '%s'", p->fullname,
9665 *(char_u **)(varp)) < 0
9666 || put_eol(fd) < 0)
9667 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009668 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009669 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009670#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009671 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
9672 (p->flags & P_EXPAND) != 0) == FAIL)
9673 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009674#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9675 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009676 {
9677 if (put_line(fd, "endif") == FAIL)
9678 return FAIL;
9679 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009680#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009681 }
9682 }
9683 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009684 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009685 return OK;
9686}
9687
9688#if defined(FEAT_FOLDING) || defined(PROTO)
9689/*
9690 * Generate set commands for the local fold options only. Used when
9691 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
9692 */
9693 int
9694makefoldset(fd)
9695 FILE *fd;
9696{
9697 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
9698# ifdef FEAT_EVAL
9699 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
9700 == FAIL
9701# endif
9702 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
9703 == FAIL
9704 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
9705 == FAIL
9706 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
9707 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
9708 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
9709 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
9710 )
9711 return FAIL;
9712
9713 return OK;
9714}
9715#endif
9716
9717 static int
9718put_setstring(fd, cmd, name, valuep, expand)
9719 FILE *fd;
9720 char *cmd;
9721 char *name;
9722 char_u **valuep;
9723 int expand;
9724{
9725 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009726 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009727
9728 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9729 return FAIL;
9730 if (*valuep != NULL)
9731 {
9732 /* Output 'pastetoggle' as key names. For other
9733 * options some characters have to be escaped with
9734 * CTRL-V or backslash */
9735 if (valuep == &p_pt)
9736 {
9737 s = *valuep;
9738 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +00009739 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009740 return FAIL;
9741 }
9742 else if (expand)
9743 {
Bram Moolenaarf8441472011-04-28 17:24:58 +02009744 buf = alloc(MAXPATHL);
9745 if (buf == NULL)
9746 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009747 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
9748 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +02009749 {
9750 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009751 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009752 }
9753 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009754 }
9755 else if (put_escstr(fd, *valuep, 2) == FAIL)
9756 return FAIL;
9757 }
9758 if (put_eol(fd) < 0)
9759 return FAIL;
9760 return OK;
9761}
9762
9763 static int
9764put_setnum(fd, cmd, name, valuep)
9765 FILE *fd;
9766 char *cmd;
9767 char *name;
9768 long *valuep;
9769{
9770 long wc;
9771
9772 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9773 return FAIL;
9774 if (wc_use_keyname((char_u *)valuep, &wc))
9775 {
9776 /* print 'wildchar' and 'wildcharm' as a key name */
9777 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
9778 return FAIL;
9779 }
9780 else if (fprintf(fd, "%ld", *valuep) < 0)
9781 return FAIL;
9782 if (put_eol(fd) < 0)
9783 return FAIL;
9784 return OK;
9785}
9786
9787 static int
9788put_setbool(fd, cmd, name, value)
9789 FILE *fd;
9790 char *cmd;
9791 char *name;
9792 int value;
9793{
Bram Moolenaar893de922007-10-02 18:40:57 +00009794 if (value < 0) /* global/local option using global value */
9795 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009796 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
9797 || put_eol(fd) < 0)
9798 return FAIL;
9799 return OK;
9800}
9801
9802/*
9803 * Clear all the terminal options.
9804 * If the option has been allocated, free the memory.
9805 * Terminal options are never hidden or indirect.
9806 */
9807 void
9808clear_termoptions()
9809{
Bram Moolenaar071d4272004-06-13 20:20:40 +00009810 /*
9811 * Reset a few things before clearing the old options. This may cause
9812 * outputting a few things that the terminal doesn't understand, but the
9813 * screen will be cleared later, so this is OK.
9814 */
9815#ifdef FEAT_MOUSE_TTY
9816 mch_setmouse(FALSE); /* switch mouse off */
9817#endif
9818#ifdef FEAT_TITLE
9819 mch_restore_title(3); /* restore window titles */
9820#endif
9821#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
9822 /* When starting the GUI close the display opened for the clipboard.
9823 * After restoring the title, because that will need the display. */
9824 if (gui.starting)
9825 clear_xterm_clip();
9826#endif
9827#ifdef WIN3264
9828 /*
9829 * Check if this is allowed now.
9830 */
9831 if (can_end_termcap_mode(FALSE) == TRUE)
9832#endif
9833 stoptermcap(); /* stop termcap mode */
9834
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00009835 free_termoptions();
9836}
9837
9838 void
9839free_termoptions()
9840{
9841 struct vimoption *p;
9842
Bram Moolenaar071d4272004-06-13 20:20:40 +00009843 for (p = &options[0]; p->fullname != NULL; p++)
9844 if (istermoption(p))
9845 {
9846 if (p->flags & P_ALLOCED)
9847 free_string_option(*(char_u **)(p->var));
9848 if (p->flags & P_DEF_ALLOCED)
9849 free_string_option(p->def_val[VI_DEFAULT]);
9850 *(char_u **)(p->var) = empty_option;
9851 p->def_val[VI_DEFAULT] = empty_option;
9852 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
9853 }
9854 clear_termcodes();
9855}
9856
9857/*
Bram Moolenaar363cb672009-07-22 12:28:17 +00009858 * Free the string for one term option, if it was allocated.
9859 * Set the string to empty_option and clear allocated flag.
9860 * "var" points to the option value.
9861 */
9862 void
9863free_one_termoption(var)
9864 char_u *var;
9865{
9866 struct vimoption *p;
9867
9868 for (p = &options[0]; p->fullname != NULL; p++)
9869 if (p->var == var)
9870 {
9871 if (p->flags & P_ALLOCED)
9872 free_string_option(*(char_u **)(p->var));
9873 *(char_u **)(p->var) = empty_option;
9874 p->flags &= ~P_ALLOCED;
9875 break;
9876 }
9877}
9878
9879/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00009880 * Set the terminal option defaults to the current value.
9881 * Used after setting the terminal name.
9882 */
9883 void
9884set_term_defaults()
9885{
9886 struct vimoption *p;
9887
9888 for (p = &options[0]; p->fullname != NULL; p++)
9889 {
9890 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
9891 {
9892 if (p->flags & P_DEF_ALLOCED)
9893 {
9894 free_string_option(p->def_val[VI_DEFAULT]);
9895 p->flags &= ~P_DEF_ALLOCED;
9896 }
9897 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
9898 if (p->flags & P_ALLOCED)
9899 {
9900 p->flags |= P_DEF_ALLOCED;
9901 p->flags &= ~P_ALLOCED; /* don't free the value now */
9902 }
9903 }
9904 }
9905}
9906
9907/*
9908 * return TRUE if 'p' starts with 't_'
9909 */
9910 static int
9911istermoption(p)
9912 struct vimoption *p;
9913{
9914 return (p->fullname[0] == 't' && p->fullname[1] == '_');
9915}
9916
9917/*
9918 * Compute columns for ruler and shown command. 'sc_col' is also used to
9919 * decide what the maximum length of a message on the status line can be.
9920 * If there is a status line for the last window, 'sc_col' is independent
9921 * of 'ru_col'.
9922 */
9923
9924#define COL_RULER 17 /* columns needed by standard ruler */
9925
9926 void
9927comp_col()
9928{
9929#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
9930 int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin));
9931
9932 sc_col = 0;
9933 ru_col = 0;
9934 if (p_ru)
9935 {
9936#ifdef FEAT_STL_OPT
9937 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
9938#else
9939 ru_col = COL_RULER + 1;
9940#endif
9941 /* no last status line, adjust sc_col */
9942 if (!last_has_status)
9943 sc_col = ru_col;
9944 }
9945 if (p_sc)
9946 {
9947 sc_col += SHOWCMD_COLS;
9948 if (!p_ru || last_has_status) /* no need for separating space */
9949 ++sc_col;
9950 }
9951 sc_col = Columns - sc_col;
9952 ru_col = Columns - ru_col;
9953 if (sc_col <= 0) /* screen too narrow, will become a mess */
9954 sc_col = 1;
9955 if (ru_col <= 0)
9956 ru_col = 1;
9957#else
9958 sc_col = Columns;
9959 ru_col = Columns;
9960#endif
9961}
9962
9963/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009964 * Unset local option value, similar to ":set opt<".
9965 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009966 void
9967unset_global_local_option(name, from)
9968 char_u *name;
9969 void *from;
9970{
9971 struct vimoption *p;
9972 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009973 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009974
9975 opt_idx = findoption(name);
9976 p = &(options[opt_idx]);
9977
9978 switch ((int)p->indir)
9979 {
9980 /* global option with local value: use local value if it's been set */
9981 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009982 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009983 break;
9984 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009985 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009986 break;
9987 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009988 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009989 break;
9990 case PV_AR:
9991 buf->b_p_ar = -1;
9992 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009993 case PV_BKC:
9994 clear_string_option(&buf->b_p_bkc);
9995 buf->b_bkc_flags = 0;
9996 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009997 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009998 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009999 break;
10000#ifdef FEAT_FIND_ID
10001 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010002 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010003 break;
10004 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010005 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010006 break;
10007#endif
10008#ifdef FEAT_INS_EXPAND
10009 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010010 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010011 break;
10012 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010013 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010014 break;
10015#endif
10016#ifdef FEAT_QUICKFIX
10017 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010018 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010019 break;
10020 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010021 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010022 break;
10023 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010024 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010025 break;
10026#endif
10027#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10028 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010029 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010030 break;
10031#endif
10032#if defined(FEAT_CRYPT)
10033 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010034 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010035 break;
10036#endif
10037#ifdef FEAT_STL_OPT
10038 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010039 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010040 break;
10041#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010042 case PV_UL:
10043 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10044 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010045#ifdef FEAT_LISP
10046 case PV_LW:
10047 clear_string_option(&buf->b_p_lw);
10048 break;
10049#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010050 }
10051}
10052
10053/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010054 * Get pointer to option variable, depending on local or global scope.
10055 */
10056 static char_u *
10057get_varp_scope(p, opt_flags)
10058 struct vimoption *p;
10059 int opt_flags;
10060{
10061 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10062 {
10063 if (p->var == VAR_WIN)
10064 return (char_u *)GLOBAL_WO(get_varp(p));
10065 return p->var;
10066 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010067 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010068 {
10069 switch ((int)p->indir)
10070 {
10071#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010072 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10073 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10074 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010075#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010076 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10077 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10078 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010079 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010080 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010081#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010082 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10083 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010084#endif
10085#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010086 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10087 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010088#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010089#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10090 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10091#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010092#if defined(FEAT_CRYPT)
10093 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10094#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010095#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010096 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010097#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010098 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010099#ifdef FEAT_LISP
10100 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10101#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010102 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010103 }
10104 return NULL; /* "cannot happen" */
10105 }
10106 return get_varp(p);
10107}
10108
10109/*
10110 * Get pointer to option variable.
10111 */
10112 static char_u *
10113get_varp(p)
10114 struct vimoption *p;
10115{
10116 /* hidden option, always return NULL */
10117 if (p->var == NULL)
10118 return NULL;
10119
10120 switch ((int)p->indir)
10121 {
10122 case PV_NONE: return p->var;
10123
10124 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010125 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010126 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010127 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010128 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010129 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010130 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010131 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010132 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010133 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010134 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010135 case PV_BKC: return *curbuf->b_p_bkc != NUL
10136 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010137#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010138 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010139 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010140 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010141 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10142#endif
10143#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010144 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010145 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010146 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010147 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10148#endif
10149#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010150 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010151 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010152 case PV_GP: return *curbuf->b_p_gp != NUL
10153 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10154 case PV_MP: return *curbuf->b_p_mp != NUL
10155 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010156#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010157#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10158 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10159 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10160#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010161#if defined(FEAT_CRYPT)
10162 case PV_CM: return *curbuf->b_p_cm != NUL
10163 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10164#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010165#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010166 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010167 ? (char_u *)&(curwin->w_p_stl) : p->var;
10168#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010169 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10170 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010171#ifdef FEAT_LISP
10172 case PV_LW: return *curbuf->b_p_lw != NUL
10173 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10174#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010175
10176#ifdef FEAT_ARABIC
10177 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10178#endif
10179 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010180#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010181 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10182#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010183#ifdef FEAT_SYN_HL
10184 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10185 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010186 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010187#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010188#ifdef FEAT_DIFF
10189 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10190#endif
10191#ifdef FEAT_FOLDING
10192 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10193 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10194 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10195 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10196 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10197 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10198 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10199# ifdef FEAT_EVAL
10200 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10201 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10202# endif
10203 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10204#endif
10205 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010206 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010207#ifdef FEAT_LINEBREAK
10208 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10209#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010210#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010211 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
10212#endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010213#ifdef FEAT_VERTSPLIT
10214 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10215#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010216#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10217 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10218#endif
10219#ifdef FEAT_RIGHTLEFT
10220 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10221 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10222#endif
10223 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10224 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10225#ifdef FEAT_LINEBREAK
10226 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010227 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10228 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010229#endif
10230#ifdef FEAT_SCROLLBIND
10231 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10232#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010233#ifdef FEAT_CURSORBIND
10234 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10235#endif
10236#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010237 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10238 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010239#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010240
10241 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10242 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10243#ifdef FEAT_MBYTE
10244 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10245#endif
10246#if defined(FEAT_QUICKFIX)
10247 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10248 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
10249#endif
10250 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10251 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10252#ifdef FEAT_CINDENT
10253 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10254 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10255 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10256#endif
10257#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10258 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10259#endif
10260#ifdef FEAT_COMMENTS
10261 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10262#endif
10263#ifdef FEAT_FOLDING
10264 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10265#endif
10266#ifdef FEAT_INS_EXPAND
10267 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10268#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010269#ifdef FEAT_COMPL_FUNC
10270 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010271 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010272#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010273 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010274 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010275 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10276#ifdef FEAT_MBYTE
10277 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10278#endif
10279 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10280#ifdef FEAT_AUTOCMD
10281 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10282#endif
10283 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010284 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010285 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10286 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10287 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10288 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10289#ifdef FEAT_FIND_ID
10290# ifdef FEAT_EVAL
10291 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10292# endif
10293#endif
10294#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10295 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10296 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10297#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010298#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010299 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10300#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010301#ifdef FEAT_CRYPT
10302 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10303#endif
10304#ifdef FEAT_LISP
10305 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10306#endif
10307 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10308 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10309 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10310 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10311 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010312 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010313#ifdef FEAT_TEXTOBJ
10314 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10315#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010316 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10317#ifdef FEAT_SMARTINDENT
10318 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10319#endif
10320#ifndef SHORT_FNAME
10321 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
10322#endif
10323 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10324#ifdef FEAT_SEARCHPATH
10325 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10326#endif
10327 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10328#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010329 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010330 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10331#endif
10332#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010333 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10334 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10335 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010336#endif
10337 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10338 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10339 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10340 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010341#ifdef FEAT_PERSISTENT_UNDO
10342 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10343#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010344 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10345#ifdef FEAT_KEYMAP
10346 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10347#endif
10348 default: EMSG(_("E356: get_varp ERROR"));
10349 }
10350 /* always return a valid pointer to avoid a crash! */
10351 return (char_u *)&(curbuf->b_p_wm);
10352}
10353
10354/*
10355 * Get the value of 'equalprg', either the buffer-local one or the global one.
10356 */
10357 char_u *
10358get_equalprg()
10359{
10360 if (*curbuf->b_p_ep == NUL)
10361 return p_ep;
10362 return curbuf->b_p_ep;
10363}
10364
10365#if defined(FEAT_WINDOWS) || defined(PROTO)
10366/*
10367 * Copy options from one window to another.
10368 * Used when splitting a window.
10369 */
10370 void
10371win_copy_options(wp_from, wp_to)
10372 win_T *wp_from;
10373 win_T *wp_to;
10374{
10375 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10376 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10377# ifdef FEAT_RIGHTLEFT
10378# ifdef FEAT_FKMAP
10379 /* Is this right? */
10380 wp_to->w_farsi = wp_from->w_farsi;
10381# endif
10382# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020010383#if defined(FEAT_LINEBREAK)
10384 briopt_check(wp_to);
10385#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010386}
10387#endif
10388
10389/*
10390 * Copy the options from one winopt_T to another.
10391 * Doesn't free the old option values in "to", use clear_winopt() for that.
10392 * The 'scroll' option is not copied, because it depends on the window height.
10393 * The 'previewwindow' option is reset, there can be only one preview window.
10394 */
10395 void
10396copy_winopt(from, to)
10397 winopt_T *from;
10398 winopt_T *to;
10399{
10400#ifdef FEAT_ARABIC
10401 to->wo_arab = from->wo_arab;
10402#endif
10403 to->wo_list = from->wo_list;
10404 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010405 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010406#ifdef FEAT_LINEBREAK
10407 to->wo_nuw = from->wo_nuw;
10408#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010409#ifdef FEAT_RIGHTLEFT
10410 to->wo_rl = from->wo_rl;
10411 to->wo_rlc = vim_strsave(from->wo_rlc);
10412#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010413#ifdef FEAT_STL_OPT
10414 to->wo_stl = vim_strsave(from->wo_stl);
10415#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010416 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010417#ifdef FEAT_DIFF
10418 to->wo_wrap_save = from->wo_wrap_save;
10419#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010420#ifdef FEAT_LINEBREAK
10421 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020010422 to->wo_bri = from->wo_bri;
10423 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010424#endif
10425#ifdef FEAT_SCROLLBIND
10426 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010427 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010428#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010429#ifdef FEAT_CURSORBIND
10430 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010431 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010432#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010433#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010434 to->wo_spell = from->wo_spell;
10435#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010436#ifdef FEAT_SYN_HL
10437 to->wo_cuc = from->wo_cuc;
10438 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010439 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010440#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010441#ifdef FEAT_DIFF
10442 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010443 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010444#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010445#ifdef FEAT_CONCEAL
10446 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010447 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010448#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010449#ifdef FEAT_FOLDING
10450 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010451 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010452 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010453 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010454 to->wo_fdi = vim_strsave(from->wo_fdi);
10455 to->wo_fml = from->wo_fml;
10456 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010457 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010458 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010459 to->wo_fdm_save = from->wo_diff_saved
10460 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010461 to->wo_fdn = from->wo_fdn;
10462# ifdef FEAT_EVAL
10463 to->wo_fde = vim_strsave(from->wo_fde);
10464 to->wo_fdt = vim_strsave(from->wo_fdt);
10465# endif
10466 to->wo_fmr = vim_strsave(from->wo_fmr);
10467#endif
10468 check_winopt(to); /* don't want NULL pointers */
10469}
10470
10471/*
10472 * Check string options in a window for a NULL value.
10473 */
10474 void
10475check_win_options(win)
10476 win_T *win;
10477{
10478 check_winopt(&win->w_onebuf_opt);
10479 check_winopt(&win->w_allbuf_opt);
10480}
10481
10482/*
10483 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10484 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020010485 static void
Bram Moolenaar071d4272004-06-13 20:20:40 +000010486check_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010487 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010488{
10489#ifdef FEAT_FOLDING
10490 check_string_option(&wop->wo_fdi);
10491 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010492 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010493# ifdef FEAT_EVAL
10494 check_string_option(&wop->wo_fde);
10495 check_string_option(&wop->wo_fdt);
10496# endif
10497 check_string_option(&wop->wo_fmr);
10498#endif
10499#ifdef FEAT_RIGHTLEFT
10500 check_string_option(&wop->wo_rlc);
10501#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010502#ifdef FEAT_STL_OPT
10503 check_string_option(&wop->wo_stl);
10504#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010505#ifdef FEAT_SYN_HL
10506 check_string_option(&wop->wo_cc);
10507#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010508#ifdef FEAT_CONCEAL
10509 check_string_option(&wop->wo_cocu);
10510#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010511#ifdef FEAT_LINEBREAK
10512 check_string_option(&wop->wo_briopt);
10513#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010514}
10515
10516/*
10517 * Free the allocated memory inside a winopt_T.
10518 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010519 void
10520clear_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010521 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010522{
10523#ifdef FEAT_FOLDING
10524 clear_string_option(&wop->wo_fdi);
10525 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010526 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010527# ifdef FEAT_EVAL
10528 clear_string_option(&wop->wo_fde);
10529 clear_string_option(&wop->wo_fdt);
10530# endif
10531 clear_string_option(&wop->wo_fmr);
10532#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010533#ifdef FEAT_LINEBREAK
10534 clear_string_option(&wop->wo_briopt);
10535#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010536#ifdef FEAT_RIGHTLEFT
10537 clear_string_option(&wop->wo_rlc);
10538#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010539#ifdef FEAT_STL_OPT
10540 clear_string_option(&wop->wo_stl);
10541#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010542#ifdef FEAT_SYN_HL
10543 clear_string_option(&wop->wo_cc);
10544#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010545#ifdef FEAT_CONCEAL
10546 clear_string_option(&wop->wo_cocu);
10547#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010548}
10549
10550/*
10551 * Copy global option values to local options for one buffer.
10552 * Used when creating a new buffer and sometimes when entering a buffer.
10553 * flags:
10554 * BCO_ENTER We will enter the buf buffer.
10555 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
10556 * appropriate.
10557 * BCO_NOHELP Don't copy the values to a help buffer.
10558 */
10559 void
10560buf_copy_options(buf, flags)
10561 buf_T *buf;
10562 int flags;
10563{
10564 int should_copy = TRUE;
10565 char_u *save_p_isk = NULL; /* init for GCC */
10566 int dont_do_help;
10567 int did_isk = FALSE;
10568
10569 /*
Bram Moolenaar1a384422010-07-14 19:53:30 +020010570 * Don't do anything if the buffer is invalid.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010571 */
10572 if (buf == NULL || !buf_valid(buf))
10573 return;
10574
10575 /*
10576 * Skip this when the option defaults have not been set yet. Happens when
10577 * main() allocates the first buffer.
10578 */
10579 if (p_cpo != NULL)
10580 {
10581 /*
10582 * Always copy when entering and 'cpo' contains 'S'.
10583 * Don't copy when already initialized.
10584 * Don't copy when 'cpo' contains 's' and not entering.
10585 * 'S' BCO_ENTER initialized 's' should_copy
10586 * yes yes X X TRUE
10587 * yes no yes X FALSE
10588 * no X yes X FALSE
10589 * X no no yes FALSE
10590 * X no no no TRUE
10591 * no yes no X TRUE
10592 */
10593 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
10594 && (buf->b_p_initialized
10595 || (!(flags & BCO_ENTER)
10596 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
10597 should_copy = FALSE;
10598
10599 if (should_copy || (flags & BCO_ALWAYS))
10600 {
10601 /* Don't copy the options specific to a help buffer when
10602 * BCO_NOHELP is given or the options were initialized already
10603 * (jumping back to a help file with CTRL-T or CTRL-O) */
10604 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
10605 || buf->b_p_initialized;
10606 if (dont_do_help) /* don't free b_p_isk */
10607 {
10608 save_p_isk = buf->b_p_isk;
10609 buf->b_p_isk = NULL;
10610 }
10611 /*
10612 * Always free the allocated strings.
10613 * If not already initialized, set 'readonly' and copy 'fileformat'.
10614 */
10615 if (!buf->b_p_initialized)
10616 {
10617 free_buf_options(buf, TRUE);
10618 buf->b_p_ro = FALSE; /* don't copy readonly */
10619 buf->b_p_tx = p_tx;
10620#ifdef FEAT_MBYTE
10621 buf->b_p_fenc = vim_strsave(p_fenc);
10622#endif
10623 buf->b_p_ff = vim_strsave(p_ff);
10624#if defined(FEAT_QUICKFIX)
10625 buf->b_p_bh = empty_option;
10626 buf->b_p_bt = empty_option;
10627#endif
10628 }
10629 else
10630 free_buf_options(buf, FALSE);
10631
10632 buf->b_p_ai = p_ai;
10633 buf->b_p_ai_nopaste = p_ai_nopaste;
10634 buf->b_p_sw = p_sw;
10635 buf->b_p_tw = p_tw;
10636 buf->b_p_tw_nopaste = p_tw_nopaste;
10637 buf->b_p_tw_nobin = p_tw_nobin;
10638 buf->b_p_wm = p_wm;
10639 buf->b_p_wm_nopaste = p_wm_nopaste;
10640 buf->b_p_wm_nobin = p_wm_nobin;
10641 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000010642#ifdef FEAT_MBYTE
10643 buf->b_p_bomb = p_bomb;
10644#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010645 buf->b_p_et = p_et;
10646 buf->b_p_et_nobin = p_et_nobin;
10647 buf->b_p_ml = p_ml;
10648 buf->b_p_ml_nobin = p_ml_nobin;
10649 buf->b_p_inf = p_inf;
10650 buf->b_p_swf = p_swf;
10651#ifdef FEAT_INS_EXPAND
10652 buf->b_p_cpt = vim_strsave(p_cpt);
10653#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010654#ifdef FEAT_COMPL_FUNC
10655 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010656 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010657#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010658 buf->b_p_sts = p_sts;
10659 buf->b_p_sts_nopaste = p_sts_nopaste;
10660#ifndef SHORT_FNAME
10661 buf->b_p_sn = p_sn;
10662#endif
10663#ifdef FEAT_COMMENTS
10664 buf->b_p_com = vim_strsave(p_com);
10665#endif
10666#ifdef FEAT_FOLDING
10667 buf->b_p_cms = vim_strsave(p_cms);
10668#endif
10669 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010670 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010671 buf->b_p_nf = vim_strsave(p_nf);
10672 buf->b_p_mps = vim_strsave(p_mps);
10673#ifdef FEAT_SMARTINDENT
10674 buf->b_p_si = p_si;
10675#endif
10676 buf->b_p_ci = p_ci;
10677#ifdef FEAT_CINDENT
10678 buf->b_p_cin = p_cin;
10679 buf->b_p_cink = vim_strsave(p_cink);
10680 buf->b_p_cino = vim_strsave(p_cino);
10681#endif
10682#ifdef FEAT_AUTOCMD
10683 /* Don't copy 'filetype', it must be detected */
10684 buf->b_p_ft = empty_option;
10685#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010686 buf->b_p_pi = p_pi;
10687#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10688 buf->b_p_cinw = vim_strsave(p_cinw);
10689#endif
10690#ifdef FEAT_LISP
10691 buf->b_p_lisp = p_lisp;
10692#endif
10693#ifdef FEAT_SYN_HL
10694 /* Don't copy 'syntax', it must be set */
10695 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010696 buf->b_p_smc = p_smc;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010697#endif
10698#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020010699 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010700 (void)compile_cap_prog(&buf->b_s);
10701 buf->b_s.b_p_spf = vim_strsave(p_spf);
10702 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010703#endif
10704#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10705 buf->b_p_inde = vim_strsave(p_inde);
10706 buf->b_p_indk = vim_strsave(p_indk);
10707#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010708#if defined(FEAT_EVAL)
10709 buf->b_p_fex = vim_strsave(p_fex);
10710#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010711#ifdef FEAT_CRYPT
10712 buf->b_p_key = vim_strsave(p_key);
10713#endif
10714#ifdef FEAT_SEARCHPATH
10715 buf->b_p_sua = vim_strsave(p_sua);
10716#endif
10717#ifdef FEAT_KEYMAP
10718 buf->b_p_keymap = vim_strsave(p_keymap);
10719 buf->b_kmap_state |= KEYMAP_INIT;
10720#endif
10721 /* This isn't really an option, but copying the langmap and IME
10722 * state from the current buffer is better than resetting it. */
10723 buf->b_p_iminsert = p_iminsert;
10724 buf->b_p_imsearch = p_imsearch;
10725
10726 /* options that are normally global but also have a local value
10727 * are not copied, start using the global value */
10728 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010729 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010730 buf->b_p_bkc = empty_option;
10731 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010732#ifdef FEAT_QUICKFIX
10733 buf->b_p_gp = empty_option;
10734 buf->b_p_mp = empty_option;
10735 buf->b_p_efm = empty_option;
10736#endif
10737 buf->b_p_ep = empty_option;
10738 buf->b_p_kp = empty_option;
10739 buf->b_p_path = empty_option;
10740 buf->b_p_tags = empty_option;
10741#ifdef FEAT_FIND_ID
10742 buf->b_p_def = empty_option;
10743 buf->b_p_inc = empty_option;
10744# ifdef FEAT_EVAL
10745 buf->b_p_inex = vim_strsave(p_inex);
10746# endif
10747#endif
10748#ifdef FEAT_INS_EXPAND
10749 buf->b_p_dict = empty_option;
10750 buf->b_p_tsr = empty_option;
10751#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010752#ifdef FEAT_TEXTOBJ
10753 buf->b_p_qe = vim_strsave(p_qe);
10754#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010755#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10756 buf->b_p_bexpr = empty_option;
10757#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010758#if defined(FEAT_CRYPT)
10759 buf->b_p_cm = empty_option;
10760#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010761#ifdef FEAT_PERSISTENT_UNDO
10762 buf->b_p_udf = p_udf;
10763#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010764#ifdef FEAT_LISP
10765 buf->b_p_lw = empty_option;
10766#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010767
10768 /*
10769 * Don't copy the options set by ex_help(), use the saved values,
10770 * when going from a help buffer to a non-help buffer.
10771 * Don't touch these at all when BCO_NOHELP is used and going from
10772 * or to a help buffer.
10773 */
10774 if (dont_do_help)
10775 buf->b_p_isk = save_p_isk;
10776 else
10777 {
10778 buf->b_p_isk = vim_strsave(p_isk);
10779 did_isk = TRUE;
10780 buf->b_p_ts = p_ts;
10781 buf->b_help = FALSE;
10782#ifdef FEAT_QUICKFIX
10783 if (buf->b_p_bt[0] == 'h')
10784 clear_string_option(&buf->b_p_bt);
10785#endif
10786 buf->b_p_ma = p_ma;
10787 }
10788 }
10789
10790 /*
10791 * When the options should be copied (ignoring BCO_ALWAYS), set the
10792 * flag that indicates that the options have been initialized.
10793 */
10794 if (should_copy)
10795 buf->b_p_initialized = TRUE;
10796 }
10797
10798 check_buf_options(buf); /* make sure we don't have NULLs */
10799 if (did_isk)
10800 (void)buf_init_chartab(buf, FALSE);
10801}
10802
10803/*
10804 * Reset the 'modifiable' option and its default value.
10805 */
10806 void
10807reset_modifiable()
10808{
10809 int opt_idx;
10810
10811 curbuf->b_p_ma = FALSE;
10812 p_ma = FALSE;
10813 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000010814 if (opt_idx >= 0)
10815 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010816}
10817
10818/*
10819 * Set the global value for 'iminsert' to the local value.
10820 */
10821 void
10822set_iminsert_global()
10823{
10824 p_iminsert = curbuf->b_p_iminsert;
10825}
10826
10827/*
10828 * Set the global value for 'imsearch' to the local value.
10829 */
10830 void
10831set_imsearch_global()
10832{
10833 p_imsearch = curbuf->b_p_imsearch;
10834}
10835
10836#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
10837static int expand_option_idx = -1;
10838static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
10839static int expand_option_flags = 0;
10840
10841 void
10842set_context_in_set_cmd(xp, arg, opt_flags)
10843 expand_T *xp;
10844 char_u *arg;
10845 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
10846{
10847 int nextchar;
10848 long_u flags = 0; /* init for GCC */
10849 int opt_idx = 0; /* init for GCC */
10850 char_u *p;
10851 char_u *s;
10852 int is_term_option = FALSE;
10853 int key;
10854
10855 expand_option_flags = opt_flags;
10856
10857 xp->xp_context = EXPAND_SETTINGS;
10858 if (*arg == NUL)
10859 {
10860 xp->xp_pattern = arg;
10861 return;
10862 }
10863 p = arg + STRLEN(arg) - 1;
10864 if (*p == ' ' && *(p - 1) != '\\')
10865 {
10866 xp->xp_pattern = p + 1;
10867 return;
10868 }
10869 while (p > arg)
10870 {
10871 s = p;
10872 /* count number of backslashes before ' ' or ',' */
10873 if (*p == ' ' || *p == ',')
10874 {
10875 while (s > arg && *(s - 1) == '\\')
10876 --s;
10877 }
10878 /* break at a space with an even number of backslashes */
10879 if (*p == ' ' && ((p - s) & 1) == 0)
10880 {
10881 ++p;
10882 break;
10883 }
10884 --p;
10885 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000010886 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010887 {
10888 xp->xp_context = EXPAND_BOOL_SETTINGS;
10889 p += 2;
10890 }
10891 if (STRNCMP(p, "inv", 3) == 0)
10892 {
10893 xp->xp_context = EXPAND_BOOL_SETTINGS;
10894 p += 3;
10895 }
10896 xp->xp_pattern = arg = p;
10897 if (*arg == '<')
10898 {
10899 while (*p != '>')
10900 if (*p++ == NUL) /* expand terminal option name */
10901 return;
10902 key = get_special_key_code(arg + 1);
10903 if (key == 0) /* unknown name */
10904 {
10905 xp->xp_context = EXPAND_NOTHING;
10906 return;
10907 }
10908 nextchar = *++p;
10909 is_term_option = TRUE;
10910 expand_option_name[2] = KEY2TERMCAP0(key);
10911 expand_option_name[3] = KEY2TERMCAP1(key);
10912 }
10913 else
10914 {
10915 if (p[0] == 't' && p[1] == '_')
10916 {
10917 p += 2;
10918 if (*p != NUL)
10919 ++p;
10920 if (*p == NUL)
10921 return; /* expand option name */
10922 nextchar = *++p;
10923 is_term_option = TRUE;
10924 expand_option_name[2] = p[-2];
10925 expand_option_name[3] = p[-1];
10926 }
10927 else
10928 {
10929 /* Allow * wildcard */
10930 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
10931 p++;
10932 if (*p == NUL)
10933 return;
10934 nextchar = *p;
10935 *p = NUL;
10936 opt_idx = findoption(arg);
10937 *p = nextchar;
10938 if (opt_idx == -1 || options[opt_idx].var == NULL)
10939 {
10940 xp->xp_context = EXPAND_NOTHING;
10941 return;
10942 }
10943 flags = options[opt_idx].flags;
10944 if (flags & P_BOOL)
10945 {
10946 xp->xp_context = EXPAND_NOTHING;
10947 return;
10948 }
10949 }
10950 }
10951 /* handle "-=" and "+=" */
10952 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
10953 {
10954 ++p;
10955 nextchar = '=';
10956 }
10957 if ((nextchar != '=' && nextchar != ':')
10958 || xp->xp_context == EXPAND_BOOL_SETTINGS)
10959 {
10960 xp->xp_context = EXPAND_UNSUCCESSFUL;
10961 return;
10962 }
10963 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
10964 {
10965 xp->xp_context = EXPAND_OLD_SETTING;
10966 if (is_term_option)
10967 expand_option_idx = -1;
10968 else
10969 expand_option_idx = opt_idx;
10970 xp->xp_pattern = p + 1;
10971 return;
10972 }
10973 xp->xp_context = EXPAND_NOTHING;
10974 if (is_term_option || (flags & P_NUM))
10975 return;
10976
10977 xp->xp_pattern = p + 1;
10978
10979 if (flags & P_EXPAND)
10980 {
10981 p = options[opt_idx].var;
10982 if (p == (char_u *)&p_bdir
10983 || p == (char_u *)&p_dir
10984 || p == (char_u *)&p_path
10985 || p == (char_u *)&p_rtp
10986#ifdef FEAT_SEARCHPATH
10987 || p == (char_u *)&p_cdpath
10988#endif
10989#ifdef FEAT_SESSION
10990 || p == (char_u *)&p_vdir
10991#endif
10992 )
10993 {
10994 xp->xp_context = EXPAND_DIRECTORIES;
10995 if (p == (char_u *)&p_path
10996#ifdef FEAT_SEARCHPATH
10997 || p == (char_u *)&p_cdpath
10998#endif
10999 )
11000 xp->xp_backslash = XP_BS_THREE;
11001 else
11002 xp->xp_backslash = XP_BS_ONE;
11003 }
11004 else
11005 {
11006 xp->xp_context = EXPAND_FILES;
11007 /* for 'tags' need three backslashes for a space */
11008 if (p == (char_u *)&p_tags)
11009 xp->xp_backslash = XP_BS_THREE;
11010 else
11011 xp->xp_backslash = XP_BS_ONE;
11012 }
11013 }
11014
11015 /* For an option that is a list of file names, find the start of the
11016 * last file name. */
11017 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11018 {
11019 /* count number of backslashes before ' ' or ',' */
11020 if (*p == ' ' || *p == ',')
11021 {
11022 s = p;
11023 while (s > xp->xp_pattern && *(s - 1) == '\\')
11024 --s;
11025 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11026 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11027 {
11028 xp->xp_pattern = p + 1;
11029 break;
11030 }
11031 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011032
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011033#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011034 /* for 'spellsuggest' start at "file:" */
11035 if (options[opt_idx].var == (char_u *)&p_sps
11036 && STRNCMP(p, "file:", 5) == 0)
11037 {
11038 xp->xp_pattern = p + 5;
11039 break;
11040 }
11041#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011042 }
11043
11044 return;
11045}
11046
11047 int
11048ExpandSettings(xp, regmatch, num_file, file)
11049 expand_T *xp;
11050 regmatch_T *regmatch;
11051 int *num_file;
11052 char_u ***file;
11053{
11054 int num_normal = 0; /* Nr of matching non-term-code settings */
11055 int num_term = 0; /* Nr of matching terminal code settings */
11056 int opt_idx;
11057 int match;
11058 int count = 0;
11059 char_u *str;
11060 int loop;
11061 int is_term_opt;
11062 char_u name_buf[MAX_KEY_NAME_LEN];
11063 static char *(names[]) = {"all", "termcap"};
11064 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11065
11066 /* do this loop twice:
11067 * loop == 0: count the number of matching options
11068 * loop == 1: copy the matching options into allocated memory
11069 */
11070 for (loop = 0; loop <= 1; ++loop)
11071 {
11072 regmatch->rm_ic = ic;
11073 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11074 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011075 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11076 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011077 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11078 {
11079 if (loop == 0)
11080 num_normal++;
11081 else
11082 (*file)[count++] = vim_strsave((char_u *)names[match]);
11083 }
11084 }
11085 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11086 opt_idx++)
11087 {
11088 if (options[opt_idx].var == NULL)
11089 continue;
11090 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11091 && !(options[opt_idx].flags & P_BOOL))
11092 continue;
11093 is_term_opt = istermoption(&options[opt_idx]);
11094 if (is_term_opt && num_normal > 0)
11095 continue;
11096 match = FALSE;
11097 if (vim_regexec(regmatch, str, (colnr_T)0)
11098 || (options[opt_idx].shortname != NULL
11099 && vim_regexec(regmatch,
11100 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11101 match = TRUE;
11102 else if (is_term_opt)
11103 {
11104 name_buf[0] = '<';
11105 name_buf[1] = 't';
11106 name_buf[2] = '_';
11107 name_buf[3] = str[2];
11108 name_buf[4] = str[3];
11109 name_buf[5] = '>';
11110 name_buf[6] = NUL;
11111 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11112 {
11113 match = TRUE;
11114 str = name_buf;
11115 }
11116 }
11117 if (match)
11118 {
11119 if (loop == 0)
11120 {
11121 if (is_term_opt)
11122 num_term++;
11123 else
11124 num_normal++;
11125 }
11126 else
11127 (*file)[count++] = vim_strsave(str);
11128 }
11129 }
11130 /*
11131 * Check terminal key codes, these are not in the option table
11132 */
11133 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11134 {
11135 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11136 {
11137 if (!isprint(str[0]) || !isprint(str[1]))
11138 continue;
11139
11140 name_buf[0] = 't';
11141 name_buf[1] = '_';
11142 name_buf[2] = str[0];
11143 name_buf[3] = str[1];
11144 name_buf[4] = NUL;
11145
11146 match = FALSE;
11147 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11148 match = TRUE;
11149 else
11150 {
11151 name_buf[0] = '<';
11152 name_buf[1] = 't';
11153 name_buf[2] = '_';
11154 name_buf[3] = str[0];
11155 name_buf[4] = str[1];
11156 name_buf[5] = '>';
11157 name_buf[6] = NUL;
11158
11159 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11160 match = TRUE;
11161 }
11162 if (match)
11163 {
11164 if (loop == 0)
11165 num_term++;
11166 else
11167 (*file)[count++] = vim_strsave(name_buf);
11168 }
11169 }
11170
11171 /*
11172 * Check special key names.
11173 */
11174 regmatch->rm_ic = TRUE; /* ignore case here */
11175 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11176 {
11177 name_buf[0] = '<';
11178 STRCPY(name_buf + 1, str);
11179 STRCAT(name_buf, ">");
11180
11181 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11182 {
11183 if (loop == 0)
11184 num_term++;
11185 else
11186 (*file)[count++] = vim_strsave(name_buf);
11187 }
11188 }
11189 }
11190 if (loop == 0)
11191 {
11192 if (num_normal > 0)
11193 *num_file = num_normal;
11194 else if (num_term > 0)
11195 *num_file = num_term;
11196 else
11197 return OK;
11198 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11199 if (*file == NULL)
11200 {
11201 *file = (char_u **)"";
11202 return FAIL;
11203 }
11204 }
11205 }
11206 return OK;
11207}
11208
11209 int
11210ExpandOldSetting(num_file, file)
11211 int *num_file;
11212 char_u ***file;
11213{
11214 char_u *var = NULL; /* init for GCC */
11215 char_u *buf;
11216
11217 *num_file = 0;
11218 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11219 if (*file == NULL)
11220 return FAIL;
11221
11222 /*
11223 * For a terminal key code expand_option_idx is < 0.
11224 */
11225 if (expand_option_idx < 0)
11226 {
11227 var = find_termcode(expand_option_name + 2);
11228 if (var == NULL)
11229 expand_option_idx = findoption(expand_option_name);
11230 }
11231
11232 if (expand_option_idx >= 0)
11233 {
11234 /* put string of option value in NameBuff */
11235 option_value2string(&options[expand_option_idx], expand_option_flags);
11236 var = NameBuff;
11237 }
11238 else if (var == NULL)
11239 var = (char_u *)"";
11240
11241 /* A backslash is required before some characters. This is the reverse of
11242 * what happens in do_set(). */
11243 buf = vim_strsave_escaped(var, escape_chars);
11244
11245 if (buf == NULL)
11246 {
11247 vim_free(*file);
11248 *file = NULL;
11249 return FAIL;
11250 }
11251
11252#ifdef BACKSLASH_IN_FILENAME
11253 /* For MS-Windows et al. we don't double backslashes at the start and
11254 * before a file name character. */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011255 for (var = buf; *var != NUL; mb_ptr_adv(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011256 if (var[0] == '\\' && var[1] == '\\'
11257 && expand_option_idx >= 0
11258 && (options[expand_option_idx].flags & P_EXPAND)
11259 && vim_isfilec(var[2])
11260 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011261 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011262#endif
11263
11264 *file[0] = buf;
11265 *num_file = 1;
11266 return OK;
11267}
11268#endif
11269
11270/*
11271 * Get the value for the numeric or string option *opp in a nice format into
11272 * NameBuff[]. Must not be called with a hidden option!
11273 */
11274 static void
11275option_value2string(opp, opt_flags)
11276 struct vimoption *opp;
11277 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
11278{
11279 char_u *varp;
11280
11281 varp = get_varp_scope(opp, opt_flags);
11282
11283 if (opp->flags & P_NUM)
11284 {
11285 long wc = 0;
11286
11287 if (wc_use_keyname(varp, &wc))
11288 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11289 else if (wc != 0)
11290 STRCPY(NameBuff, transchar((int)wc));
11291 else
11292 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11293 }
11294 else /* P_STRING */
11295 {
11296 varp = *(char_u **)(varp);
11297 if (varp == NULL) /* just in case */
11298 NameBuff[0] = NUL;
11299#ifdef FEAT_CRYPT
11300 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011301 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011302 STRCPY(NameBuff, "*****");
11303#endif
11304 else if (opp->flags & P_EXPAND)
11305 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11306 /* Translate 'pastetoggle' into special key names */
11307 else if ((char_u **)opp->var == &p_pt)
11308 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11309 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011310 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011311 }
11312}
11313
11314/*
11315 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11316 * printed as a keyname.
11317 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11318 */
11319 static int
11320wc_use_keyname(varp, wcp)
11321 char_u *varp;
11322 long *wcp;
11323{
11324 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11325 {
11326 *wcp = *(long *)varp;
11327 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11328 return TRUE;
11329 }
11330 return FALSE;
11331}
11332
Bram Moolenaar01615492015-02-03 13:00:38 +010011333#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011334/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011335 * Any character has an equivalent 'langmap' character. This is used for
11336 * keyboards that have a special language mode that sends characters above
11337 * 128 (although other characters can be translated too). The "to" field is a
11338 * Vim command character. This avoids having to switch the keyboard back to
11339 * ASCII mode when leaving Insert mode.
11340 *
11341 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11342 * commands.
11343 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11344 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11345 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011346 */
Bram Moolenaar01615492015-02-03 13:00:38 +010011347# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011348/*
11349 * With multi-byte support use growarray for 'langmap' chars >= 256
11350 */
11351typedef struct
11352{
11353 int from;
11354 int to;
11355} langmap_entry_T;
11356
11357static garray_T langmap_mapga;
11358static void langmap_set_entry __ARGS((int from, int to));
Bram Moolenaar071d4272004-06-13 20:20:40 +000011359
11360/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011361 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11362 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011363 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011364 static void
11365langmap_set_entry(from, to)
11366 int from;
11367 int to;
11368{
11369 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011370 int a = 0;
11371 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011372
11373 /* Do a binary search for an existing entry. */
11374 while (a != b)
11375 {
11376 int i = (a + b) / 2;
11377 int d = entries[i].from - from;
11378
11379 if (d == 0)
11380 {
11381 entries[i].to = to;
11382 return;
11383 }
11384 if (d < 0)
11385 a = i + 1;
11386 else
11387 b = i;
11388 }
11389
11390 if (ga_grow(&langmap_mapga, 1) != OK)
11391 return; /* out of memory */
11392
11393 /* insert new entry at position "a" */
11394 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11395 mch_memmove(entries + 1, entries,
11396 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11397 ++langmap_mapga.ga_len;
11398 entries[0].from = from;
11399 entries[0].to = to;
11400}
11401
11402/*
11403 * Apply 'langmap' to multi-byte character "c" and return the result.
11404 */
11405 int
11406langmap_adjust_mb(c)
11407 int c;
11408{
11409 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11410 int a = 0;
11411 int b = langmap_mapga.ga_len;
11412
11413 while (a != b)
11414 {
11415 int i = (a + b) / 2;
11416 int d = entries[i].from - c;
11417
11418 if (d == 0)
11419 return entries[i].to; /* found matching entry */
11420 if (d < 0)
11421 a = i + 1;
11422 else
11423 b = i;
11424 }
11425 return c; /* no entry found, return "c" unmodified */
11426}
11427# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011428
11429 static void
11430langmap_init()
11431{
11432 int i;
11433
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011434 for (i = 0; i < 256; i++)
11435 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11436# ifdef FEAT_MBYTE
11437 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11438# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011439}
11440
11441/*
11442 * Called when langmap option is set; the language map can be
11443 * changed at any time!
11444 */
11445 static void
11446langmap_set()
11447{
11448 char_u *p;
11449 char_u *p2;
11450 int from, to;
11451
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011452#ifdef FEAT_MBYTE
11453 ga_clear(&langmap_mapga); /* clear the previous map first */
11454#endif
11455 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011456
11457 for (p = p_langmap; p[0] != NUL; )
11458 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011459 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
11460 mb_ptr_adv(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011461 {
11462 if (p2[0] == '\\' && p2[1] != NUL)
11463 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011464 }
11465 if (p2[0] == ';')
11466 ++p2; /* abcd;ABCD form, p2 points to A */
11467 else
11468 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11469 while (p[0])
11470 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011471 if (p[0] == ',')
11472 {
11473 ++p;
11474 break;
11475 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011476 if (p[0] == '\\' && p[1] != NUL)
11477 ++p;
11478#ifdef FEAT_MBYTE
11479 from = (*mb_ptr2char)(p);
11480#else
11481 from = p[0];
11482#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011483 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011484 if (p2 == NULL)
11485 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011486 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011487 if (p[0] != ',')
11488 {
11489 if (p[0] == '\\')
11490 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011491#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011492 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011493#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011494 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011495#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011496 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011497 }
11498 else
11499 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011500 if (p2[0] != ',')
11501 {
11502 if (p2[0] == '\\')
11503 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011504#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011505 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011506#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011507 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011508#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011509 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011510 }
11511 if (to == NUL)
11512 {
11513 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
11514 transchar(from));
11515 return;
11516 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011517
11518#ifdef FEAT_MBYTE
11519 if (from >= 256)
11520 langmap_set_entry(from, to);
11521 else
11522#endif
11523 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011524
11525 /* Advance to next pair */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011526 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011527 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011528 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011529 mb_ptr_adv(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011530 if (*p == ';')
11531 {
11532 p = p2;
11533 if (p[0] != NUL)
11534 {
11535 if (p[0] != ',')
11536 {
11537 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
11538 return;
11539 }
11540 ++p;
11541 }
11542 break;
11543 }
11544 }
11545 }
11546 }
11547}
11548#endif
11549
11550/*
11551 * Return TRUE if format option 'x' is in effect.
11552 * Take care of no formatting when 'paste' is set.
11553 */
11554 int
11555has_format_option(x)
11556 int x;
11557{
11558 if (p_paste)
11559 return FALSE;
11560 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
11561}
11562
11563/*
11564 * Return TRUE if "x" is present in 'shortmess' option, or
11565 * 'shortmess' contains 'a' and "x" is present in SHM_A.
11566 */
11567 int
11568shortmess(x)
11569 int x;
11570{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010011571 return p_shm != NULL &&
11572 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000011573 || (vim_strchr(p_shm, 'a') != NULL
11574 && vim_strchr((char_u *)SHM_A, x) != NULL));
11575}
11576
11577/*
11578 * paste_option_changed() - Called after p_paste was set or reset.
11579 */
11580 static void
11581paste_option_changed()
11582{
11583 static int old_p_paste = FALSE;
11584 static int save_sm = 0;
11585#ifdef FEAT_CMDL_INFO
11586 static int save_ru = 0;
11587#endif
11588#ifdef FEAT_RIGHTLEFT
11589 static int save_ri = 0;
11590 static int save_hkmap = 0;
11591#endif
11592 buf_T *buf;
11593
11594 if (p_paste)
11595 {
11596 /*
11597 * Paste switched from off to on.
11598 * Save the current values, so they can be restored later.
11599 */
11600 if (!old_p_paste)
11601 {
11602 /* save options for each buffer */
11603 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11604 {
11605 buf->b_p_tw_nopaste = buf->b_p_tw;
11606 buf->b_p_wm_nopaste = buf->b_p_wm;
11607 buf->b_p_sts_nopaste = buf->b_p_sts;
11608 buf->b_p_ai_nopaste = buf->b_p_ai;
11609 }
11610
11611 /* save global options */
11612 save_sm = p_sm;
11613#ifdef FEAT_CMDL_INFO
11614 save_ru = p_ru;
11615#endif
11616#ifdef FEAT_RIGHTLEFT
11617 save_ri = p_ri;
11618 save_hkmap = p_hkmap;
11619#endif
11620 /* save global values for local buffer options */
11621 p_tw_nopaste = p_tw;
11622 p_wm_nopaste = p_wm;
11623 p_sts_nopaste = p_sts;
11624 p_ai_nopaste = p_ai;
11625 }
11626
11627 /*
11628 * Always set the option values, also when 'paste' is set when it is
11629 * already on.
11630 */
11631 /* set options for each buffer */
11632 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11633 {
11634 buf->b_p_tw = 0; /* textwidth is 0 */
11635 buf->b_p_wm = 0; /* wrapmargin is 0 */
11636 buf->b_p_sts = 0; /* softtabstop is 0 */
11637 buf->b_p_ai = 0; /* no auto-indent */
11638 }
11639
11640 /* set global options */
11641 p_sm = 0; /* no showmatch */
11642#ifdef FEAT_CMDL_INFO
11643# ifdef FEAT_WINDOWS
11644 if (p_ru)
11645 status_redraw_all(); /* redraw to remove the ruler */
11646# endif
11647 p_ru = 0; /* no ruler */
11648#endif
11649#ifdef FEAT_RIGHTLEFT
11650 p_ri = 0; /* no reverse insert */
11651 p_hkmap = 0; /* no Hebrew keyboard */
11652#endif
11653 /* set global values for local buffer options */
11654 p_tw = 0;
11655 p_wm = 0;
11656 p_sts = 0;
11657 p_ai = 0;
11658 }
11659
11660 /*
11661 * Paste switched from on to off: Restore saved values.
11662 */
11663 else if (old_p_paste)
11664 {
11665 /* restore options for each buffer */
11666 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11667 {
11668 buf->b_p_tw = buf->b_p_tw_nopaste;
11669 buf->b_p_wm = buf->b_p_wm_nopaste;
11670 buf->b_p_sts = buf->b_p_sts_nopaste;
11671 buf->b_p_ai = buf->b_p_ai_nopaste;
11672 }
11673
11674 /* restore global options */
11675 p_sm = save_sm;
11676#ifdef FEAT_CMDL_INFO
11677# ifdef FEAT_WINDOWS
11678 if (p_ru != save_ru)
11679 status_redraw_all(); /* redraw to draw the ruler */
11680# endif
11681 p_ru = save_ru;
11682#endif
11683#ifdef FEAT_RIGHTLEFT
11684 p_ri = save_ri;
11685 p_hkmap = save_hkmap;
11686#endif
11687 /* set global values for local buffer options */
11688 p_tw = p_tw_nopaste;
11689 p_wm = p_wm_nopaste;
11690 p_sts = p_sts_nopaste;
11691 p_ai = p_ai_nopaste;
11692 }
11693
11694 old_p_paste = p_paste;
11695}
11696
11697/*
11698 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
11699 *
11700 * Reset 'compatible' and set the values for options that didn't get set yet
11701 * to the Vim defaults.
11702 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011703 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011704 */
11705 void
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011706vimrc_found(fname, envname)
11707 char_u *fname;
11708 char_u *envname;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011709{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011710 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000011711 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011712 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011713
11714 if (!option_was_set((char_u *)"cp"))
11715 {
11716 p_cp = FALSE;
11717 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11718 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
11719 set_option_default(opt_idx, OPT_FREE, FALSE);
11720 didset_options();
11721 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011722
11723 if (fname != NULL)
11724 {
11725 p = vim_getenv(envname, &dofree);
11726 if (p == NULL)
11727 {
11728 /* Set $MYVIMRC to the first vimrc file found. */
11729 p = FullName_save(fname, FALSE);
11730 if (p != NULL)
11731 {
11732 vim_setenv(envname, p);
11733 vim_free(p);
11734 }
11735 }
11736 else if (dofree)
11737 vim_free(p);
11738 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011739}
11740
11741/*
11742 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
11743 */
11744 void
11745change_compatible(on)
11746 int on;
11747{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011748 int opt_idx;
11749
Bram Moolenaar071d4272004-06-13 20:20:40 +000011750 if (p_cp != on)
11751 {
11752 p_cp = on;
11753 compatible_set();
11754 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011755 opt_idx = findoption((char_u *)"cp");
11756 if (opt_idx >= 0)
11757 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011758}
11759
11760/*
11761 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020011762 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011763 */
11764 int
11765option_was_set(name)
11766 char_u *name;
11767{
11768 int idx;
11769
11770 idx = findoption(name);
11771 if (idx < 0) /* unknown option */
11772 return FALSE;
11773 if (options[idx].flags & P_WAS_SET)
11774 return TRUE;
11775 return FALSE;
11776}
11777
11778/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010011779 * Reset the flag indicating option "name" was set.
11780 */
11781 void
11782reset_option_was_set(name)
11783 char_u *name;
11784{
11785 int idx = findoption(name);
11786
11787 if (idx >= 0)
11788 options[idx].flags &= ~P_WAS_SET;
11789}
11790
11791/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011792 * compatible_set() - Called when 'compatible' has been set or unset.
11793 *
11794 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
11795 * flag) to a Vi compatible value.
11796 * When 'compatible' is unset: Set all options that have a different default
11797 * for Vim (without the P_VI_DEF flag) to that default.
11798 */
11799 static void
11800compatible_set()
11801{
11802 int opt_idx;
11803
11804 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11805 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
11806 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
11807 set_option_default(opt_idx, OPT_FREE, p_cp);
11808 didset_options();
11809}
11810
11811#ifdef FEAT_LINEBREAK
11812
11813# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
11814 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011815 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011816# endif
11817
11818/*
11819 * fill_breakat_flags() -- called when 'breakat' changes value.
11820 */
11821 static void
11822fill_breakat_flags()
11823{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011824 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011825 int i;
11826
11827 for (i = 0; i < 256; i++)
11828 breakat_flags[i] = FALSE;
11829
11830 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011831 for (p = p_breakat; *p; p++)
11832 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011833}
11834
11835# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011836 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011837# endif
11838
11839#endif
11840
11841/*
11842 * Check an option that can be a range of string values.
11843 *
11844 * Return OK for correct value, FAIL otherwise.
11845 * Empty is always OK.
11846 */
11847 static int
11848check_opt_strings(val, values, list)
11849 char_u *val;
11850 char **values;
11851 int list; /* when TRUE: accept a list of values */
11852{
11853 return opt_strings_flags(val, values, NULL, list);
11854}
11855
11856/*
11857 * Handle an option that can be a range of string values.
11858 * Set a flag in "*flagp" for each string present.
11859 *
11860 * Return OK for correct value, FAIL otherwise.
11861 * Empty is always OK.
11862 */
11863 static int
11864opt_strings_flags(val, values, flagp, list)
11865 char_u *val; /* new value */
11866 char **values; /* array of valid string values */
11867 unsigned *flagp;
11868 int list; /* when TRUE: accept a list of values */
11869{
11870 int i;
11871 int len;
11872 unsigned new_flags = 0;
11873
11874 while (*val)
11875 {
11876 for (i = 0; ; ++i)
11877 {
11878 if (values[i] == NULL) /* val not found in values[] */
11879 return FAIL;
11880
11881 len = (int)STRLEN(values[i]);
11882 if (STRNCMP(values[i], val, len) == 0
11883 && ((list && val[len] == ',') || val[len] == NUL))
11884 {
11885 val += len + (val[len] == ',');
11886 new_flags |= (1 << i);
11887 break; /* check next item in val list */
11888 }
11889 }
11890 }
11891 if (flagp != NULL)
11892 *flagp = new_flags;
11893
11894 return OK;
11895}
11896
11897/*
11898 * Read the 'wildmode' option, fill wim_flags[].
11899 */
11900 static int
11901check_opt_wim()
11902{
11903 char_u new_wim_flags[4];
11904 char_u *p;
11905 int i;
11906 int idx = 0;
11907
11908 for (i = 0; i < 4; ++i)
11909 new_wim_flags[i] = 0;
11910
11911 for (p = p_wim; *p; ++p)
11912 {
11913 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
11914 ;
11915 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
11916 return FAIL;
11917 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
11918 new_wim_flags[idx] |= WIM_LONGEST;
11919 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
11920 new_wim_flags[idx] |= WIM_FULL;
11921 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
11922 new_wim_flags[idx] |= WIM_LIST;
11923 else
11924 return FAIL;
11925 p += i;
11926 if (*p == NUL)
11927 break;
11928 if (*p == ',')
11929 {
11930 if (idx == 3)
11931 return FAIL;
11932 ++idx;
11933 }
11934 }
11935
11936 /* fill remaining entries with last flag */
11937 while (idx < 3)
11938 {
11939 new_wim_flags[idx + 1] = new_wim_flags[idx];
11940 ++idx;
11941 }
11942
11943 /* only when there are no errors, wim_flags[] is changed */
11944 for (i = 0; i < 4; ++i)
11945 wim_flags[i] = new_wim_flags[i];
11946 return OK;
11947}
11948
11949/*
11950 * Check if backspacing over something is allowed.
11951 */
11952 int
11953can_bs(what)
11954 int what; /* BS_INDENT, BS_EOL or BS_START */
11955{
11956 switch (*p_bs)
11957 {
11958 case '2': return TRUE;
11959 case '1': return (what != BS_START);
11960 case '0': return FALSE;
11961 }
11962 return vim_strchr(p_bs, what) != NULL;
11963}
11964
11965/*
11966 * Save the current values of 'fileformat' and 'fileencoding', so that we know
11967 * the file must be considered changed when the value is different.
11968 */
11969 void
11970save_file_ff(buf)
11971 buf_T *buf;
11972{
11973 buf->b_start_ffc = *buf->b_p_ff;
11974 buf->b_start_eol = buf->b_p_eol;
11975#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011976 buf->b_start_bomb = buf->b_p_bomb;
11977
Bram Moolenaar071d4272004-06-13 20:20:40 +000011978 /* Only use free/alloc when necessary, they take time. */
11979 if (buf->b_start_fenc == NULL
11980 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
11981 {
11982 vim_free(buf->b_start_fenc);
11983 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
11984 }
11985#endif
11986}
11987
11988/*
11989 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
11990 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011991 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
11992 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020011993 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010011994 * When "ignore_empty" is true don't consider a new, empty buffer to be
11995 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011996 */
11997 int
Bram Moolenaar164c60f2011-01-22 00:11:50 +010011998file_ff_differs(buf, ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011999 buf_T *buf;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012000 int ignore_empty;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012001{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012002 /* In a buffer that was never loaded the options are not valid. */
12003 if (buf->b_flags & BF_NEVERLOADED)
12004 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012005 if (ignore_empty
12006 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012007 && buf->b_ml.ml_line_count == 1
12008 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12009 return FALSE;
12010 if (buf->b_start_ffc != *buf->b_p_ff)
12011 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012012 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012013 return TRUE;
12014#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012015 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12016 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012017 if (buf->b_start_fenc == NULL)
12018 return (*buf->b_p_fenc != NUL);
12019 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12020#else
12021 return FALSE;
12022#endif
12023}
12024
12025/*
12026 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12027 */
12028 int
12029check_ff_value(p)
12030 char_u *p;
12031{
12032 return check_opt_strings(p, p_ff_values, FALSE);
12033}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012034
12035/*
12036 * Return the effective shiftwidth value for current buffer, using the
12037 * 'tabstop' value when 'shiftwidth' is zero.
12038 */
12039 long
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012040get_sw_value(buf)
12041 buf_T *buf;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012042{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012043 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012044}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012045
12046/*
12047 * Return the effective softtabstop value for the current buffer, using the
12048 * 'tabstop' value when 'softtabstop' is negative.
12049 */
12050 long
12051get_sts_value()
12052{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012053 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012054}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012055
12056/*
12057 * Check matchpairs option for "*initc".
12058 * If there is a match set "*initc" to the matching character and "*findc" to
12059 * the opposite character. Set "*backwards" to the direction.
12060 * When "switchit" is TRUE swap the direction.
12061 */
12062 void
12063find_mps_values(initc, findc, backwards, switchit)
12064 int *initc;
12065 int *findc;
12066 int *backwards;
12067 int switchit;
12068{
12069 char_u *ptr;
12070
12071 ptr = curbuf->b_p_mps;
12072 while (*ptr != NUL)
12073 {
12074#ifdef FEAT_MBYTE
12075 if (has_mbyte)
12076 {
12077 char_u *prev;
12078
12079 if (mb_ptr2char(ptr) == *initc)
12080 {
12081 if (switchit)
12082 {
12083 *findc = *initc;
12084 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12085 *backwards = TRUE;
12086 }
12087 else
12088 {
12089 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12090 *backwards = FALSE;
12091 }
12092 return;
12093 }
12094 prev = ptr;
12095 ptr += mb_ptr2len(ptr) + 1;
12096 if (mb_ptr2char(ptr) == *initc)
12097 {
12098 if (switchit)
12099 {
12100 *findc = *initc;
12101 *initc = mb_ptr2char(prev);
12102 *backwards = FALSE;
12103 }
12104 else
12105 {
12106 *findc = mb_ptr2char(prev);
12107 *backwards = TRUE;
12108 }
12109 return;
12110 }
12111 ptr += mb_ptr2len(ptr);
12112 }
12113 else
12114#endif
12115 {
12116 if (*ptr == *initc)
12117 {
12118 if (switchit)
12119 {
12120 *backwards = TRUE;
12121 *findc = *initc;
12122 *initc = ptr[2];
12123 }
12124 else
12125 {
12126 *backwards = FALSE;
12127 *findc = ptr[2];
12128 }
12129 return;
12130 }
12131 ptr += 2;
12132 if (*ptr == *initc)
12133 {
12134 if (switchit)
12135 {
12136 *backwards = FALSE;
12137 *findc = *initc;
12138 *initc = ptr[-2];
12139 }
12140 else
12141 {
12142 *backwards = TRUE;
12143 *findc = ptr[-2];
12144 }
12145 return;
12146 }
12147 ++ptr;
12148 }
12149 if (*ptr == ',')
12150 ++ptr;
12151 }
12152}
Bram Moolenaar597a4222014-06-25 14:39:50 +020012153
12154#if defined(FEAT_LINEBREAK) || defined(PROTO)
12155/*
12156 * This is called when 'breakindentopt' is changed and when a window is
12157 * initialized.
12158 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012159 static int
12160briopt_check(wp)
12161 win_T *wp;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012162{
12163 char_u *p;
12164 int bri_shift = 0;
12165 long bri_min = 20;
12166 int bri_sbr = FALSE;
12167
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012168 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012169 while (*p != NUL)
12170 {
12171 if (STRNCMP(p, "shift:", 6) == 0
12172 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
12173 {
12174 p += 6;
12175 bri_shift = getdigits(&p);
12176 }
12177 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
12178 {
12179 p += 4;
12180 bri_min = getdigits(&p);
12181 }
12182 else if (STRNCMP(p, "sbr", 3) == 0)
12183 {
12184 p += 3;
12185 bri_sbr = TRUE;
12186 }
12187 if (*p != ',' && *p != NUL)
12188 return FAIL;
12189 if (*p == ',')
12190 ++p;
12191 }
12192
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012193 wp->w_p_brishift = bri_shift;
12194 wp->w_p_brimin = bri_min;
12195 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012196
12197 return OK;
12198}
12199#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012200
12201/*
12202 * Get the local or global value of 'backupcopy'.
12203 */
12204 unsigned int
12205get_bkc_value(buf)
12206 buf_T *buf;
12207{
12208 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
12209}