blob: a356f961355800ed636c979fea5c53bc380c1a9d [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)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02004921 if (!starting
4922# ifdef FEAT_CRYPT
4923 && options[opt_idx].indir != PV_KEY
4924# endif
Bram Moolenaar53744302015-07-17 17:38:22 +02004925 && origval != NULL)
4926 /* origval may be freed by
4927 * did_set_string_option(), make a copy. */
4928 saved_origval = vim_strsave(origval);
4929#endif
4930
Bram Moolenaar071d4272004-06-13 20:20:40 +00004931 /* Handle side effects, and set the global value for
4932 * ":set" on local options. */
4933 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
4934 new_value_alloced, oldval, errbuf, opt_flags);
4935
4936 /* If error detected, print the error message. */
4937 if (errmsg != NULL)
4938 goto skip;
Bram Moolenaar53744302015-07-17 17:38:22 +02004939#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4940 if (saved_origval != NULL)
4941 {
4942 char_u buf_type[7];
4943
4944 sprintf((char *)buf_type, "%s",
4945 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02004946 set_vim_var_string(VV_OPTION_NEW,
4947 *(char_u **)varp, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02004948 set_vim_var_string(VV_OPTION_OLD, saved_origval, -1);
4949 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
4950 apply_autocmds(EVENT_OPTIONSET,
4951 (char_u *)options[opt_idx].fullname,
4952 NULL, FALSE, NULL);
4953 reset_v_option_vars();
4954 vim_free(saved_origval);
4955 }
4956#endif
4957
Bram Moolenaar071d4272004-06-13 20:20:40 +00004958 }
4959 else /* key code option */
4960 {
4961 char_u *p;
4962
4963 if (nextchar == '&')
4964 {
4965 if (add_termcap_entry(key_name, TRUE) == FAIL)
4966 errmsg = (char_u *)N_("E522: Not found in termcap");
4967 }
4968 else
4969 {
4970 ++arg; /* jump to after the '=' or ':' */
4971 for (p = arg; *p && !vim_iswhite(*p); ++p)
4972 if (*p == '\\' && p[1] != NUL)
4973 ++p;
4974 nextchar = *p;
4975 *p = NUL;
4976 add_termcode(key_name, arg, FALSE);
4977 *p = nextchar;
4978 }
4979 if (full_screen)
4980 ttest(FALSE);
4981 redraw_all_later(CLEAR);
4982 }
4983 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004984
Bram Moolenaar071d4272004-06-13 20:20:40 +00004985 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004986 did_set_option(opt_idx, opt_flags,
4987 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004988 }
4989
4990skip:
4991 /*
4992 * Advance to next argument.
4993 * - skip until a blank found, taking care of backslashes
4994 * - skip blanks
4995 * - skip one "=val" argument (for hidden options ":set gfn =xx")
4996 */
4997 for (i = 0; i < 2 ; ++i)
4998 {
4999 while (*arg != NUL && !vim_iswhite(*arg))
5000 if (*arg++ == '\\' && *arg != NUL)
5001 ++arg;
5002 arg = skipwhite(arg);
5003 if (*arg != '=')
5004 break;
5005 }
5006 }
5007
5008 if (errmsg != NULL)
5009 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005010 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005011 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005012 if (i + (arg - startarg) < IOSIZE)
5013 {
5014 /* append the argument with the error */
5015 STRCAT(IObuff, ": ");
5016 mch_memmove(IObuff + i, startarg, (arg - startarg));
5017 IObuff[i + (arg - startarg)] = NUL;
5018 }
5019 /* make sure all characters are printable */
5020 trans_characters(IObuff, IOSIZE);
5021
5022 ++no_wait_return; /* wait_return done later */
5023 emsg(IObuff); /* show error highlighted */
5024 --no_wait_return;
5025
5026 return FAIL;
5027 }
5028
5029 arg = skipwhite(arg);
5030 }
5031
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005032theend:
5033 if (silent_mode && did_show)
5034 {
5035 /* After displaying option values in silent mode. */
5036 silent_mode = FALSE;
5037 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5038 msg_putchar('\n');
5039 cursor_on(); /* msg_start() switches it off */
5040 out_flush();
5041 silent_mode = TRUE;
5042 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5043 }
5044
Bram Moolenaar071d4272004-06-13 20:20:40 +00005045 return OK;
5046}
5047
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005048/*
5049 * Call this when an option has been given a new value through a user command.
5050 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5051 */
5052 static void
5053did_set_option(opt_idx, opt_flags, new_value)
5054 int opt_idx;
5055 int opt_flags; /* possibly with OPT_MODELINE */
5056 int new_value; /* value was replaced completely */
5057{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005058 long_u *p;
5059
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005060 options[opt_idx].flags |= P_WAS_SET;
5061
5062 /* When an option is set in the sandbox, from a modeline or in secure mode
5063 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005064 * flag. */
5065 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005066 if (secure
5067#ifdef HAVE_SANDBOX
5068 || sandbox != 0
5069#endif
5070 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005071 *p = *p | P_INSECURE;
5072 else if (new_value)
5073 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005074}
5075
Bram Moolenaar071d4272004-06-13 20:20:40 +00005076 static char_u *
5077illegal_char(errbuf, c)
5078 char_u *errbuf;
5079 int c;
5080{
5081 if (errbuf == NULL)
5082 return (char_u *)"";
5083 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005084 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005085 return errbuf;
5086}
5087
5088/*
5089 * Convert a key name or string into a key value.
5090 * Used for 'wildchar' and 'cedit' options.
5091 */
5092 static int
5093string_to_key(arg)
5094 char_u *arg;
5095{
5096 if (*arg == '<')
5097 return find_key_option(arg + 1);
5098 if (*arg == '^')
5099 return Ctrl_chr(arg[1]);
5100 return *arg;
5101}
5102
5103#ifdef FEAT_CMDWIN
5104/*
5105 * Check value of 'cedit' and set cedit_key.
5106 * Returns NULL if value is OK, error message otherwise.
5107 */
5108 static char_u *
5109check_cedit()
5110{
5111 int n;
5112
5113 if (*p_cedit == NUL)
5114 cedit_key = -1;
5115 else
5116 {
5117 n = string_to_key(p_cedit);
5118 if (vim_isprintc(n))
5119 return e_invarg;
5120 cedit_key = n;
5121 }
5122 return NULL;
5123}
5124#endif
5125
5126#ifdef FEAT_TITLE
5127/*
5128 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5129 * maketitle() to create and display it.
5130 * When switching the title or icon off, call mch_restore_title() to get
5131 * the old value back.
5132 */
5133 static void
5134did_set_title(icon)
5135 int icon; /* Did set icon instead of title */
5136{
5137 if (starting != NO_SCREEN
5138#ifdef FEAT_GUI
5139 && !gui.starting
5140#endif
5141 )
5142 {
5143 maketitle();
5144 if (icon)
5145 {
5146 if (!p_icon)
5147 mch_restore_title(2);
5148 }
5149 else
5150 {
5151 if (!p_title)
5152 mch_restore_title(1);
5153 }
5154 }
5155}
5156#endif
5157
5158/*
5159 * set_options_bin - called when 'bin' changes value.
5160 */
5161 void
5162set_options_bin(oldval, newval, opt_flags)
5163 int oldval;
5164 int newval;
5165 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5166{
5167 /*
5168 * The option values that are changed when 'bin' changes are
5169 * copied when 'bin is set and restored when 'bin' is reset.
5170 */
5171 if (newval)
5172 {
5173 if (!oldval) /* switched on */
5174 {
5175 if (!(opt_flags & OPT_GLOBAL))
5176 {
5177 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5178 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5179 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5180 curbuf->b_p_et_nobin = curbuf->b_p_et;
5181 }
5182 if (!(opt_flags & OPT_LOCAL))
5183 {
5184 p_tw_nobin = p_tw;
5185 p_wm_nobin = p_wm;
5186 p_ml_nobin = p_ml;
5187 p_et_nobin = p_et;
5188 }
5189 }
5190
5191 if (!(opt_flags & OPT_GLOBAL))
5192 {
5193 curbuf->b_p_tw = 0; /* no automatic line wrap */
5194 curbuf->b_p_wm = 0; /* no automatic line wrap */
5195 curbuf->b_p_ml = 0; /* no modelines */
5196 curbuf->b_p_et = 0; /* no expandtab */
5197 }
5198 if (!(opt_flags & OPT_LOCAL))
5199 {
5200 p_tw = 0;
5201 p_wm = 0;
5202 p_ml = FALSE;
5203 p_et = FALSE;
5204 p_bin = TRUE; /* needed when called for the "-b" argument */
5205 }
5206 }
5207 else if (oldval) /* switched off */
5208 {
5209 if (!(opt_flags & OPT_GLOBAL))
5210 {
5211 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5212 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5213 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5214 curbuf->b_p_et = curbuf->b_p_et_nobin;
5215 }
5216 if (!(opt_flags & OPT_LOCAL))
5217 {
5218 p_tw = p_tw_nobin;
5219 p_wm = p_wm_nobin;
5220 p_ml = p_ml_nobin;
5221 p_et = p_et_nobin;
5222 }
5223 }
5224}
5225
5226#ifdef FEAT_VIMINFO
5227/*
5228 * Find the parameter represented by the given character (eg ', :, ", or /),
5229 * and return its associated value in the 'viminfo' string.
5230 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005231 * If the parameter is not specified in the string or there is no following
5232 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005233 */
5234 int
5235get_viminfo_parameter(type)
5236 int type;
5237{
5238 char_u *p;
5239
5240 p = find_viminfo_parameter(type);
5241 if (p != NULL && VIM_ISDIGIT(*p))
5242 return atoi((char *)p);
5243 return -1;
5244}
5245
5246/*
5247 * Find the parameter represented by the given character (eg ''', ':', '"', or
5248 * '/') in the 'viminfo' option and return a pointer to the string after it.
5249 * Return NULL if the parameter is not specified in the string.
5250 */
5251 char_u *
5252find_viminfo_parameter(type)
5253 int type;
5254{
5255 char_u *p;
5256
5257 for (p = p_viminfo; *p; ++p)
5258 {
5259 if (*p == type)
5260 return p + 1;
5261 if (*p == 'n') /* 'n' is always the last one */
5262 break;
5263 p = vim_strchr(p, ','); /* skip until next ',' */
5264 if (p == NULL) /* hit the end without finding parameter */
5265 break;
5266 }
5267 return NULL;
5268}
5269#endif
5270
5271/*
5272 * Expand environment variables for some string options.
5273 * These string options cannot be indirect!
5274 * If "val" is NULL expand the current value of the option.
5275 * Return pointer to NameBuff, or NULL when not expanded.
5276 */
5277 static char_u *
5278option_expand(opt_idx, val)
5279 int opt_idx;
5280 char_u *val;
5281{
5282 /* if option doesn't need expansion nothing to do */
5283 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5284 return NULL;
5285
5286 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5287 * expand_env() would truncate the string. */
5288 if (val != NULL && STRLEN(val) > MAXPATHL)
5289 return NULL;
5290
5291 if (val == NULL)
5292 val = *(char_u **)options[opt_idx].var;
5293
5294 /*
5295 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5296 * Escape spaces when expanding 'tags', they are used to separate file
5297 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005298 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005299 */
5300 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005301 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005302#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005303 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5304#endif
5305 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005306 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5307 return NULL;
5308
5309 return NameBuff;
5310}
5311
5312/*
5313 * After setting various option values: recompute variables that depend on
5314 * option values.
5315 */
5316 static void
5317didset_options()
5318{
5319 /* initialize the table for 'iskeyword' et.al. */
5320 (void)init_chartab();
5321
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005322#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005323 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005324#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005325 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
5326#ifdef FEAT_SESSION
5327 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5328 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5329#endif
5330#ifdef FEAT_FOLDING
5331 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5332#endif
5333 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
5334#ifdef FEAT_VIRTUALEDIT
5335 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5336#endif
5337#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5338 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5339#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005340#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005341 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005342 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005343 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005344#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005345#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5346 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5347#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005348#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005349 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5350#endif
5351#ifdef FEAT_CMDWIN
5352 /* set cedit_key */
5353 (void)check_cedit();
5354#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005355#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005356 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005357#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005358}
5359
5360/*
5361 * Check for string options that are NULL (normally only termcap options).
5362 */
5363 void
5364check_options()
5365{
5366 int opt_idx;
5367
5368 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5369 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5370 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5371}
5372
5373/*
5374 * Check string options in a buffer for NULL value.
5375 */
5376 void
5377check_buf_options(buf)
5378 buf_T *buf;
5379{
5380#if defined(FEAT_QUICKFIX)
5381 check_string_option(&buf->b_p_bh);
5382 check_string_option(&buf->b_p_bt);
5383#endif
5384#ifdef FEAT_MBYTE
5385 check_string_option(&buf->b_p_fenc);
5386#endif
5387 check_string_option(&buf->b_p_ff);
5388#ifdef FEAT_FIND_ID
5389 check_string_option(&buf->b_p_def);
5390 check_string_option(&buf->b_p_inc);
5391# ifdef FEAT_EVAL
5392 check_string_option(&buf->b_p_inex);
5393# endif
5394#endif
5395#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5396 check_string_option(&buf->b_p_inde);
5397 check_string_option(&buf->b_p_indk);
5398#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005399#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5400 check_string_option(&buf->b_p_bexpr);
5401#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005402#if defined(FEAT_CRYPT)
5403 check_string_option(&buf->b_p_cm);
5404#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005405#if defined(FEAT_EVAL)
5406 check_string_option(&buf->b_p_fex);
5407#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005408#ifdef FEAT_CRYPT
5409 check_string_option(&buf->b_p_key);
5410#endif
5411 check_string_option(&buf->b_p_kp);
5412 check_string_option(&buf->b_p_mps);
5413 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005414 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005415 check_string_option(&buf->b_p_isk);
5416#ifdef FEAT_COMMENTS
5417 check_string_option(&buf->b_p_com);
5418#endif
5419#ifdef FEAT_FOLDING
5420 check_string_option(&buf->b_p_cms);
5421#endif
5422 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005423#ifdef FEAT_TEXTOBJ
5424 check_string_option(&buf->b_p_qe);
5425#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005426#ifdef FEAT_SYN_HL
5427 check_string_option(&buf->b_p_syn);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005428#endif
5429#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005430 check_string_option(&buf->b_s.b_p_spc);
5431 check_string_option(&buf->b_s.b_p_spf);
5432 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005433#endif
5434#ifdef FEAT_SEARCHPATH
5435 check_string_option(&buf->b_p_sua);
5436#endif
5437#ifdef FEAT_CINDENT
5438 check_string_option(&buf->b_p_cink);
5439 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005440 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005441#endif
5442#ifdef FEAT_AUTOCMD
5443 check_string_option(&buf->b_p_ft);
5444#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005445#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5446 check_string_option(&buf->b_p_cinw);
5447#endif
5448#ifdef FEAT_INS_EXPAND
5449 check_string_option(&buf->b_p_cpt);
5450#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005451#ifdef FEAT_COMPL_FUNC
5452 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005453 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005454#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005455#ifdef FEAT_KEYMAP
5456 check_string_option(&buf->b_p_keymap);
5457#endif
5458#ifdef FEAT_QUICKFIX
5459 check_string_option(&buf->b_p_gp);
5460 check_string_option(&buf->b_p_mp);
5461 check_string_option(&buf->b_p_efm);
5462#endif
5463 check_string_option(&buf->b_p_ep);
5464 check_string_option(&buf->b_p_path);
5465 check_string_option(&buf->b_p_tags);
5466#ifdef FEAT_INS_EXPAND
5467 check_string_option(&buf->b_p_dict);
5468 check_string_option(&buf->b_p_tsr);
5469#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005470#ifdef FEAT_LISP
5471 check_string_option(&buf->b_p_lw);
5472#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005473 check_string_option(&buf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005474}
5475
5476/*
5477 * Free the string allocated for an option.
5478 * Checks for the string being empty_option. This may happen if we're out of
5479 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5480 * check_options().
5481 * Does NOT check for P_ALLOCED flag!
5482 */
5483 void
5484free_string_option(p)
5485 char_u *p;
5486{
5487 if (p != empty_option)
5488 vim_free(p);
5489}
5490
5491 void
5492clear_string_option(pp)
5493 char_u **pp;
5494{
5495 if (*pp != empty_option)
5496 vim_free(*pp);
5497 *pp = empty_option;
5498}
5499
5500 static void
5501check_string_option(pp)
5502 char_u **pp;
5503{
5504 if (*pp == NULL)
5505 *pp = empty_option;
5506}
5507
5508/*
5509 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5510 */
5511 void
5512set_term_option_alloced(p)
5513 char_u **p;
5514{
5515 int opt_idx;
5516
5517 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5518 if (options[opt_idx].var == (char_u *)p)
5519 {
5520 options[opt_idx].flags |= P_ALLOCED;
5521 return;
5522 }
5523 return; /* cannot happen: didn't find it! */
5524}
5525
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005526#if defined(FEAT_EVAL) || defined(PROTO)
5527/*
5528 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5529 * Return FALSE when it wasn't.
5530 * Return -1 for an unknown option.
5531 */
5532 int
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005533was_set_insecurely(opt, opt_flags)
5534 char_u *opt;
5535 int opt_flags;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005536{
5537 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005538 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005539
5540 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005541 {
5542 flagp = insecure_flag(idx, opt_flags);
5543 return (*flagp & P_INSECURE) != 0;
5544 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005545 EMSG2(_(e_intern2), "was_set_insecurely()");
5546 return -1;
5547}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005548
5549/*
5550 * Get a pointer to the flags used for the P_INSECURE flag of option
5551 * "opt_idx". For some local options a local flags field is used.
5552 */
5553 static long_u *
5554insecure_flag(opt_idx, opt_flags)
5555 int opt_idx;
5556 int opt_flags;
5557{
5558 if (opt_flags & OPT_LOCAL)
5559 switch ((int)options[opt_idx].indir)
5560 {
5561#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005562 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005563#endif
5564#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005565# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005566 case PV_FDE: return &curwin->w_p_fde_flags;
5567 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005568# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005569# ifdef FEAT_BEVAL
5570 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5571# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005572# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005573 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005574# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005575 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005576# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005577 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005578# endif
5579#endif
5580 }
5581
5582 /* Nothing special, return global flags field. */
5583 return &options[opt_idx].flags;
5584}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005585#endif
5586
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005587#ifdef FEAT_TITLE
5588static void redraw_titles __ARGS((void));
5589
5590/*
5591 * Redraw the window title and/or tab page text later.
5592 */
5593static void redraw_titles()
5594{
5595 need_maketitle = TRUE;
5596# ifdef FEAT_WINDOWS
5597 redraw_tabline = TRUE;
5598# endif
5599}
5600#endif
5601
Bram Moolenaar071d4272004-06-13 20:20:40 +00005602/*
5603 * Set a string option to a new value (without checking the effect).
5604 * The string is copied into allocated memory.
5605 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005606 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005607 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005608 */
5609 void
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005610set_string_option_direct(name, opt_idx, val, opt_flags, set_sid)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005611 char_u *name;
5612 int opt_idx;
5613 char_u *val;
5614 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar78a15312009-05-15 19:33:18 +00005615 int set_sid UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005616{
5617 char_u *s;
5618 char_u **varp;
5619 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005620 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005621
Bram Moolenaar89d40322006-08-29 15:30:07 +00005622 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005623 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005624 idx = findoption(name);
5625 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005626 {
5627 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar0b105412014-11-30 13:34:23 +01005628 EMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005629 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005630 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005631 }
5632
Bram Moolenaar89d40322006-08-29 15:30:07 +00005633 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005634 return;
5635
5636 s = vim_strsave(val);
5637 if (s != NULL)
5638 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005639 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005640 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005641 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005642 free_string_option(*varp);
5643 *varp = s;
5644
5645 /* For buffer/window local option may also set the global value. */
5646 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005647 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005648
Bram Moolenaar89d40322006-08-29 15:30:07 +00005649 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005650
5651 /* When setting both values of a global option with a local value,
5652 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005653 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005654 {
5655 free_string_option(*varp);
5656 *varp = empty_option;
5657 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005658# ifdef FEAT_EVAL
5659 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005660 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005661 set_sid == 0 ? current_SID : set_sid);
5662# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005663 }
5664}
5665
5666/*
5667 * Set global value for string option when it's a local option.
5668 */
5669 static void
5670set_string_option_global(opt_idx, varp)
5671 int opt_idx; /* option index */
5672 char_u **varp; /* pointer to option variable */
5673{
5674 char_u **p, *s;
5675
5676 /* the global value is always allocated */
5677 if (options[opt_idx].var == VAR_WIN)
5678 p = (char_u **)GLOBAL_WO(varp);
5679 else
5680 p = (char_u **)options[opt_idx].var;
5681 if (options[opt_idx].indir != PV_NONE
5682 && p != varp
5683 && (s = vim_strsave(*varp)) != NULL)
5684 {
5685 free_string_option(*p);
5686 *p = s;
5687 }
5688}
5689
5690/*
5691 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005692 *
5693 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005694 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005695 static char_u *
Bram Moolenaar071d4272004-06-13 20:20:40 +00005696set_string_option(opt_idx, value, opt_flags)
5697 int opt_idx;
5698 char_u *value;
5699 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5700{
5701 char_u *s;
5702 char_u **varp;
5703 char_u *oldval;
Bram Moolenaar53744302015-07-17 17:38:22 +02005704#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5705 char_u *saved_oldval = NULL;
5706#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005707 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005708
5709 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005710 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005711
5712 s = vim_strsave(value);
5713 if (s != NULL)
5714 {
5715 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5716 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005717 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005718 ? OPT_GLOBAL : OPT_LOCAL)
5719 : opt_flags);
5720 oldval = *varp;
5721 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02005722
5723#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005724 if (!starting
5725# ifdef FEAT_CRYPT
5726 && options[opt_idx].indir != PV_KEY
5727# endif
5728 )
Bram Moolenaar53744302015-07-17 17:38:22 +02005729 saved_oldval = vim_strsave(oldval);
5730#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005731 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5732 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005733 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02005734
5735 /* call autocomamnd after handling side effects */
5736#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5737 if (saved_oldval != NULL)
5738 {
5739 char_u buf_type[7];
5740 sprintf((char *)buf_type, "%s",
5741 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02005742 set_vim_var_string(VV_OPTION_NEW, *varp, -1);
5743 set_vim_var_string(VV_OPTION_OLD, saved_oldval, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02005744 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
5745 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
5746 reset_v_option_vars();
5747 vim_free(saved_oldval);
5748 }
5749#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005750 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005751 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005752}
5753
5754/*
5755 * Handle string options that need some action to perform when changed.
5756 * Returns NULL for success, or an error message for an error.
5757 */
5758 static char_u *
5759did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
5760 opt_flags)
5761 int opt_idx; /* index in options[] table */
5762 char_u **varp; /* pointer to the option variable */
5763 int new_value_alloced; /* new value was allocated */
5764 char_u *oldval; /* previous value of the option */
5765 char_u *errbuf; /* buffer for errors, or NULL */
5766 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5767{
5768 char_u *errmsg = NULL;
5769 char_u *s, *p;
5770 int did_chartab = FALSE;
5771 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005772 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00005773#ifdef FEAT_GUI
5774 /* set when changing an option that only requires a redraw in the GUI */
5775 int redraw_gui_only = FALSE;
5776#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005777
5778 /* Get the global option to compare with, otherwise we would have to check
5779 * two values for all local options. */
5780 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
5781
5782 /* Disallow changing some options from secure mode */
5783 if ((secure
5784#ifdef HAVE_SANDBOX
5785 || sandbox != 0
5786#endif
5787 ) && (options[opt_idx].flags & P_SECURE))
5788 {
5789 errmsg = e_secure;
5790 }
5791
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005792 /* Check for a "normal" file name in some options. Disallow a path
5793 * separator (slash and/or backslash), wildcards and characters that are
5794 * often illegal in a file name. */
5795 else if ((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005796 && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL)
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005797 {
5798 errmsg = e_invarg;
5799 }
5800
Bram Moolenaar071d4272004-06-13 20:20:40 +00005801 /* 'term' */
5802 else if (varp == &T_NAME)
5803 {
5804 if (T_NAME[0] == NUL)
5805 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
5806#ifdef FEAT_GUI
5807 if (gui.in_use)
5808 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
5809 else if (term_is_gui(T_NAME))
5810 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
5811#endif
5812 else if (set_termname(T_NAME) == FAIL)
5813 errmsg = (char_u *)N_("E522: Not found in termcap");
5814 else
5815 /* Screen colors may have changed. */
5816 redraw_later_clear();
5817 }
5818
5819 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005820 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005821 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005822 char_u *bkc = p_bkc;
5823 unsigned int *flags = &bkc_flags;
5824
5825 if (opt_flags & OPT_LOCAL)
5826 {
5827 bkc = curbuf->b_p_bkc;
5828 flags = &curbuf->b_bkc_flags;
5829 }
5830
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005831 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
5832 /* make the local value empty: use the global value */
5833 *flags = 0;
5834 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00005835 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005836 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
5837 errmsg = e_invarg;
5838 if ((((int)*flags & BKC_AUTO) != 0)
5839 + (((int)*flags & BKC_YES) != 0)
5840 + (((int)*flags & BKC_NO) != 0) != 1)
5841 {
5842 /* Must have exactly one of "auto", "yes" and "no". */
5843 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
5844 errmsg = e_invarg;
5845 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005846 }
5847 }
5848
5849 /* 'backupext' and 'patchmode' */
5850 else if (varp == &p_bex || varp == &p_pm)
5851 {
5852 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
5853 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
5854 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
5855 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02005856#ifdef FEAT_LINEBREAK
5857 /* 'breakindentopt' */
5858 else if (varp == &curwin->w_p_briopt)
5859 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005860 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02005861 errmsg = e_invarg;
5862 }
5863#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005864
5865 /*
5866 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[]
5867 * If the new option is invalid, use old value. 'lisp' option: refill
5868 * chartab[] for '-' char
5869 */
5870 else if ( varp == &p_isi
5871 || varp == &(curbuf->b_p_isk)
5872 || varp == &p_isp
5873 || varp == &p_isf)
5874 {
5875 if (init_chartab() == FAIL)
5876 {
5877 did_chartab = TRUE; /* need to restore it below */
5878 errmsg = e_invarg; /* error in value */
5879 }
5880 }
5881
5882 /* 'helpfile' */
5883 else if (varp == &p_hf)
5884 {
5885 /* May compute new values for $VIM and $VIMRUNTIME */
5886 if (didset_vim)
5887 {
5888 vim_setenv((char_u *)"VIM", (char_u *)"");
5889 didset_vim = FALSE;
5890 }
5891 if (didset_vimruntime)
5892 {
5893 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
5894 didset_vimruntime = FALSE;
5895 }
5896 }
5897
Bram Moolenaar1a384422010-07-14 19:53:30 +02005898#ifdef FEAT_SYN_HL
5899 /* 'colorcolumn' */
5900 else if (varp == &curwin->w_p_cc)
5901 errmsg = check_colorcolumn(curwin);
5902#endif
5903
Bram Moolenaar071d4272004-06-13 20:20:40 +00005904#ifdef FEAT_MULTI_LANG
5905 /* 'helplang' */
5906 else if (varp == &p_hlg)
5907 {
5908 /* Check for "", "ab", "ab,cd", etc. */
5909 for (s = p_hlg; *s != NUL; s += 3)
5910 {
5911 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
5912 {
5913 errmsg = e_invarg;
5914 break;
5915 }
5916 if (s[2] == NUL)
5917 break;
5918 }
5919 }
5920#endif
5921
5922 /* 'highlight' */
5923 else if (varp == &p_hl)
5924 {
5925 if (highlight_changed() == FAIL)
5926 errmsg = e_invarg; /* invalid flags */
5927 }
5928
5929 /* 'nrformats' */
5930 else if (gvarp == &p_nf)
5931 {
5932 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
5933 errmsg = e_invarg;
5934 }
5935
5936#ifdef FEAT_SESSION
5937 /* 'sessionoptions' */
5938 else if (varp == &p_ssop)
5939 {
5940 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
5941 errmsg = e_invarg;
5942 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
5943 {
5944 /* Don't allow both "sesdir" and "curdir". */
5945 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
5946 errmsg = e_invarg;
5947 }
5948 }
5949 /* 'viewoptions' */
5950 else if (varp == &p_vop)
5951 {
5952 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
5953 errmsg = e_invarg;
5954 }
5955#endif
5956
5957 /* 'scrollopt' */
5958#ifdef FEAT_SCROLLBIND
5959 else if (varp == &p_sbo)
5960 {
5961 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
5962 errmsg = e_invarg;
5963 }
5964#endif
5965
5966 /* 'ambiwidth' */
5967#ifdef FEAT_MBYTE
5968 else if (varp == &p_ambw)
5969 {
5970 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
5971 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02005972 else if (set_chars_option(&p_lcs) != NULL)
5973 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
5974# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5975 else if (set_chars_option(&p_fcs) != NULL)
5976 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
5977# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005978 }
5979#endif
5980
5981 /* 'background' */
5982 else if (varp == &p_bg)
5983 {
5984 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
5985 {
5986#ifdef FEAT_EVAL
5987 int dark = (*p_bg == 'd');
5988#endif
5989
5990 init_highlight(FALSE, FALSE);
5991
5992#ifdef FEAT_EVAL
5993 if (dark != (*p_bg == 'd')
5994 && get_var_value((char_u *)"g:colors_name") != NULL)
5995 {
5996 /* The color scheme must have set 'background' back to another
5997 * value, that's not what we want here. Disable the color
5998 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00005999 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006000 free_string_option(p_bg);
6001 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
6002 check_string_option(&p_bg);
6003 init_highlight(FALSE, FALSE);
6004 }
6005#endif
6006 }
6007 else
6008 errmsg = e_invarg;
6009 }
6010
6011 /* 'wildmode' */
6012 else if (varp == &p_wim)
6013 {
6014 if (check_opt_wim() == FAIL)
6015 errmsg = e_invarg;
6016 }
6017
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006018#ifdef FEAT_CMDL_COMPL
6019 /* 'wildoptions' */
6020 else if (varp == &p_wop)
6021 {
6022 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6023 errmsg = e_invarg;
6024 }
6025#endif
6026
Bram Moolenaar071d4272004-06-13 20:20:40 +00006027#ifdef FEAT_WAK
6028 /* 'winaltkeys' */
6029 else if (varp == &p_wak)
6030 {
6031 if (*p_wak == NUL
6032 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6033 errmsg = e_invarg;
6034# ifdef FEAT_MENU
6035# ifdef FEAT_GUI_MOTIF
6036 else if (gui.in_use)
6037 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6038# else
6039# ifdef FEAT_GUI_GTK
6040 else if (gui.in_use)
6041 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6042# endif
6043# endif
6044# endif
6045 }
6046#endif
6047
6048#ifdef FEAT_AUTOCMD
6049 /* 'eventignore' */
6050 else if (varp == &p_ei)
6051 {
6052 if (check_ei() == FAIL)
6053 errmsg = e_invarg;
6054 }
6055#endif
6056
6057#ifdef FEAT_MBYTE
6058 /* 'encoding' and 'fileencoding' */
6059 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc)
6060 {
6061 if (gvarp == &p_fenc)
6062 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006063 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006064 errmsg = e_modifiable;
6065 else if (vim_strchr(*varp, ',') != NULL)
6066 /* No comma allowed in 'fileencoding'; catches confusing it
6067 * with 'fileencodings'. */
6068 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006069 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006070 {
6071# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006072 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006073 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006074# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006075 /* Add 'fileencoding' to the swap file. */
6076 ml_setflags(curbuf);
6077 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006078 }
6079 if (errmsg == NULL)
6080 {
6081 /* canonize the value, so that STRCMP() can be used on it */
6082 p = enc_canonize(*varp);
6083 if (p != NULL)
6084 {
6085 vim_free(*varp);
6086 *varp = p;
6087 }
6088 if (varp == &p_enc)
6089 {
6090 errmsg = mb_init();
6091# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006092 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006093# endif
6094 }
6095 }
6096
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006097# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006098 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6099 {
6100 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6101 if (STRCMP(p_tenc, "utf-8") != 0)
6102 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6103 }
6104# endif
6105
6106 if (errmsg == NULL)
6107 {
6108# ifdef FEAT_KEYMAP
6109 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6110 * (with another encoding). */
6111 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6112 (void)keymap_init();
6113# endif
6114
6115 /* When 'termencoding' is not empty and 'encoding' changes or when
6116 * 'termencoding' changes, need to setup for keyboard input and
6117 * display output conversion. */
6118 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6119 {
6120 convert_setup(&input_conv, p_tenc, p_enc);
6121 convert_setup(&output_conv, p_enc, p_tenc);
6122 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006123
6124# if defined(WIN3264) && defined(FEAT_MBYTE)
6125 /* $HOME may have characters in active code page. */
6126 if (varp == &p_enc)
6127 init_homedir();
6128# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006129 }
6130 }
6131#endif
6132
6133#if defined(FEAT_POSTSCRIPT)
6134 else if (varp == &p_penc)
6135 {
6136 /* Canonize printencoding if VIM standard one */
6137 p = enc_canonize(p_penc);
6138 if (p != NULL)
6139 {
6140 vim_free(p_penc);
6141 p_penc = p;
6142 }
6143 else
6144 {
6145 /* Ensure lower case and '-' for '_' */
6146 for (s = p_penc; *s != NUL; s++)
6147 {
6148 if (*s == '_')
6149 *s = '-';
6150 else
6151 *s = TOLOWER_ASC(*s);
6152 }
6153 }
6154 }
6155#endif
6156
Bram Moolenaar9372a112005-12-06 19:59:18 +00006157#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006158 else if (varp == &p_imak)
6159 {
6160 if (gui.in_use && !im_xim_isvalid_imactivate())
6161 errmsg = e_invarg;
6162 }
6163#endif
6164
6165#ifdef FEAT_KEYMAP
6166 else if (varp == &curbuf->b_p_keymap)
6167 {
6168 /* load or unload key mapping tables */
6169 errmsg = keymap_init();
6170
Bram Moolenaarfab06232009-03-04 03:13:35 +00006171 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006172 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006173 if (*curbuf->b_p_keymap != NUL)
6174 {
6175 /* Installed a new keymap, switch on using it. */
6176 curbuf->b_p_iminsert = B_IMODE_LMAP;
6177 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6178 curbuf->b_p_imsearch = B_IMODE_LMAP;
6179 }
6180 else
6181 {
6182 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6183 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6184 curbuf->b_p_iminsert = B_IMODE_NONE;
6185 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6186 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6187 }
6188 if ((opt_flags & OPT_LOCAL) == 0)
6189 {
6190 set_iminsert_global();
6191 set_imsearch_global();
6192 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006193# ifdef FEAT_WINDOWS
6194 status_redraw_curbuf();
6195# endif
6196 }
6197 }
6198#endif
6199
6200 /* 'fileformat' */
6201 else if (gvarp == &p_ff)
6202 {
6203 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6204 errmsg = e_modifiable;
6205 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6206 errmsg = e_invarg;
6207 else
6208 {
6209 /* may also change 'textmode' */
6210 if (get_fileformat(curbuf) == EOL_DOS)
6211 curbuf->b_p_tx = TRUE;
6212 else
6213 curbuf->b_p_tx = FALSE;
6214#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006215 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006216#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006217 /* update flag in swap file */
6218 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006219 /* Redraw needed when switching to/from "mac": a CR in the text
6220 * will be displayed differently. */
6221 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6222 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006223 }
6224 }
6225
6226 /* 'fileformats' */
6227 else if (varp == &p_ffs)
6228 {
6229 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6230 errmsg = e_invarg;
6231 else
6232 {
6233 /* also change 'textauto' */
6234 if (*p_ffs == NUL)
6235 p_ta = FALSE;
6236 else
6237 p_ta = TRUE;
6238 }
6239 }
6240
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006241#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006242 /* 'cryptkey' */
6243 else if (gvarp == &p_key)
6244 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006245# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006246 /* Make sure the ":set" command doesn't show the new value in the
6247 * history. */
6248 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006249# endif
6250 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6251 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006252 ml_set_crypt_key(curbuf, oldval,
6253 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006254 }
6255
6256 else if (gvarp == &p_cm)
6257 {
6258 if (opt_flags & OPT_LOCAL)
6259 p = curbuf->b_p_cm;
6260 else
6261 p = p_cm;
6262 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6263 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006264 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006265 errmsg = e_invarg;
6266 else
6267 {
6268 /* When setting the global value to empty, make it "zip". */
6269 if (*p_cm == NUL)
6270 {
6271 if (new_value_alloced)
6272 free_string_option(p_cm);
6273 p_cm = vim_strsave((char_u *)"zip");
6274 new_value_alloced = TRUE;
6275 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006276 /* When using ":set cm=name" the local value is going to be empty.
6277 * Do that here, otherwise the crypt functions will still use the
6278 * local value. */
6279 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6280 {
6281 free_string_option(curbuf->b_p_cm);
6282 curbuf->b_p_cm = empty_option;
6283 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006284
6285 /* Need to update the swapfile when the effective method changed.
6286 * Set "s" to the effective old value, "p" to the effective new
6287 * method and compare. */
6288 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6289 s = p_cm; /* was previously using the global value */
6290 else
6291 s = oldval;
6292 if (*curbuf->b_p_cm == NUL)
6293 p = p_cm; /* is now using the global value */
6294 else
6295 p = curbuf->b_p_cm;
6296 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006297 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006298
6299 /* If the global value changes need to update the swapfile for all
6300 * buffers using that value. */
6301 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6302 {
6303 buf_T *buf;
6304
6305 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
6306 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006307 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006308 }
6309 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006310 }
6311#endif
6312
6313 /* 'matchpairs' */
6314 else if (gvarp == &p_mps)
6315 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006316#ifdef FEAT_MBYTE
6317 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006318 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006319 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006320 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006321 int x2 = -1;
6322 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006323
6324 if (*p != NUL)
6325 p += mb_ptr2len(p);
6326 if (*p != NUL)
6327 x2 = *p++;
6328 if (*p != NUL)
6329 {
6330 x3 = mb_ptr2char(p);
6331 p += mb_ptr2len(p);
6332 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006333 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006334 {
6335 errmsg = e_invarg;
6336 break;
6337 }
6338 if (*p == NUL)
6339 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006340 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006341 }
6342 else
6343#endif
6344 {
6345 /* Check for "x:y,x:y" */
6346 for (p = *varp; *p != NUL; p += 4)
6347 {
6348 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6349 {
6350 errmsg = e_invarg;
6351 break;
6352 }
6353 if (p[3] == NUL)
6354 break;
6355 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006356 }
6357 }
6358
6359#ifdef FEAT_COMMENTS
6360 /* 'comments' */
6361 else if (gvarp == &p_com)
6362 {
6363 for (s = *varp; *s; )
6364 {
6365 while (*s && *s != ':')
6366 {
6367 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6368 && !VIM_ISDIGIT(*s) && *s != '-')
6369 {
6370 errmsg = illegal_char(errbuf, *s);
6371 break;
6372 }
6373 ++s;
6374 }
6375 if (*s++ == NUL)
6376 errmsg = (char_u *)N_("E524: Missing colon");
6377 else if (*s == ',' || *s == NUL)
6378 errmsg = (char_u *)N_("E525: Zero length string");
6379 if (errmsg != NULL)
6380 break;
6381 while (*s && *s != ',')
6382 {
6383 if (*s == '\\' && s[1] != NUL)
6384 ++s;
6385 ++s;
6386 }
6387 s = skip_to_option_part(s);
6388 }
6389 }
6390#endif
6391
6392 /* 'listchars' */
6393 else if (varp == &p_lcs)
6394 {
6395 errmsg = set_chars_option(varp);
6396 }
6397
6398#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6399 /* 'fillchars' */
6400 else if (varp == &p_fcs)
6401 {
6402 errmsg = set_chars_option(varp);
6403 }
6404#endif
6405
6406#ifdef FEAT_CMDWIN
6407 /* 'cedit' */
6408 else if (varp == &p_cedit)
6409 {
6410 errmsg = check_cedit();
6411 }
6412#endif
6413
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006414 /* 'verbosefile' */
6415 else if (varp == &p_vfile)
6416 {
6417 verbose_stop();
6418 if (*p_vfile != NUL && verbose_open() == FAIL)
6419 errmsg = e_invarg;
6420 }
6421
Bram Moolenaar071d4272004-06-13 20:20:40 +00006422#ifdef FEAT_VIMINFO
6423 /* 'viminfo' */
6424 else if (varp == &p_viminfo)
6425 {
6426 for (s = p_viminfo; *s;)
6427 {
6428 /* Check it's a valid character */
6429 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6430 {
6431 errmsg = illegal_char(errbuf, *s);
6432 break;
6433 }
6434 if (*s == 'n') /* name is always last one */
6435 {
6436 break;
6437 }
6438 else if (*s == 'r') /* skip until next ',' */
6439 {
6440 while (*++s && *s != ',')
6441 ;
6442 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006443 else if (*s == '%')
6444 {
6445 /* optional number */
6446 while (vim_isdigit(*++s))
6447 ;
6448 }
6449 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006450 ++s; /* no extra chars */
6451 else /* must have a number */
6452 {
6453 while (vim_isdigit(*++s))
6454 ;
6455
6456 if (!VIM_ISDIGIT(*(s - 1)))
6457 {
6458 if (errbuf != NULL)
6459 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006460 sprintf((char *)errbuf,
6461 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006462 transchar_byte(*(s - 1)));
6463 errmsg = errbuf;
6464 }
6465 else
6466 errmsg = (char_u *)"";
6467 break;
6468 }
6469 }
6470 if (*s == ',')
6471 ++s;
6472 else if (*s)
6473 {
6474 if (errbuf != NULL)
6475 errmsg = (char_u *)N_("E527: Missing comma");
6476 else
6477 errmsg = (char_u *)"";
6478 break;
6479 }
6480 }
6481 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6482 errmsg = (char_u *)N_("E528: Must specify a ' value");
6483 }
6484#endif /* FEAT_VIMINFO */
6485
6486 /* terminal options */
6487 else if (istermoption(&options[opt_idx]) && full_screen)
6488 {
6489 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6490 if (varp == &T_CCO)
6491 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006492 int colors = atoi((char *)T_CCO);
6493
6494 /* Only reinitialize colors if t_Co value has really changed to
6495 * avoid expensive reload of colorscheme if t_Co is set to the
6496 * same value multiple times. */
6497 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006498 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006499 t_colors = colors;
6500 if (t_colors <= 1)
6501 {
6502 if (new_value_alloced)
6503 vim_free(T_CCO);
6504 T_CCO = empty_option;
6505 }
6506 /* We now have a different color setup, initialize it again. */
6507 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006508 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006509 }
6510 ttest(FALSE);
6511 if (varp == &T_ME)
6512 {
6513 out_str(T_ME);
6514 redraw_later(CLEAR);
6515#if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32))
6516 /* Since t_me has been set, this probably means that the user
6517 * wants to use this as default colors. Need to reset default
6518 * background/foreground colors. */
6519 mch_set_normal_colors();
6520#endif
6521 }
6522 }
6523
6524#ifdef FEAT_LINEBREAK
6525 /* 'showbreak' */
6526 else if (varp == &p_sbr)
6527 {
6528 for (s = p_sbr; *s; )
6529 {
6530 if (ptr2cells(s) != 1)
6531 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006532 mb_ptr_adv(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006533 }
6534 }
6535#endif
6536
6537#ifdef FEAT_GUI
6538 /* 'guifont' */
6539 else if (varp == &p_guifont)
6540 {
6541 if (gui.in_use)
6542 {
6543 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006544# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006545 /*
6546 * Put up a font dialog and let the user select a new value.
6547 * If this is cancelled go back to the old value but don't
6548 * give an error message.
6549 */
6550 if (STRCMP(p, "*") == 0)
6551 {
6552 p = gui_mch_font_dialog(oldval);
6553
6554 if (new_value_alloced)
6555 free_string_option(p_guifont);
6556
6557 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6558 new_value_alloced = TRUE;
6559 }
6560# endif
6561 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6562 {
6563# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6564 if (STRCMP(p_guifont, "*") == 0)
6565 {
6566 /* Dialog was cancelled: Keep the old value without giving
6567 * an error message. */
6568 if (new_value_alloced)
6569 free_string_option(p_guifont);
6570 p_guifont = vim_strsave(oldval);
6571 new_value_alloced = TRUE;
6572 }
6573 else
6574# endif
6575 errmsg = (char_u *)N_("E596: Invalid font(s)");
6576 }
6577 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006578 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006579 }
6580# ifdef FEAT_XFONTSET
6581 else if (varp == &p_guifontset)
6582 {
6583 if (STRCMP(p_guifontset, "*") == 0)
6584 errmsg = (char_u *)N_("E597: can't select fontset");
6585 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6586 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006587 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006588 }
6589# endif
6590# ifdef FEAT_MBYTE
6591 else if (varp == &p_guifontwide)
6592 {
6593 if (STRCMP(p_guifontwide, "*") == 0)
6594 errmsg = (char_u *)N_("E533: can't select wide font");
6595 else if (gui_get_wide_font() == FAIL)
6596 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006597 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006598 }
6599# endif
6600#endif
6601
6602#ifdef CURSOR_SHAPE
6603 /* 'guicursor' */
6604 else if (varp == &p_guicursor)
6605 errmsg = parse_shape_opt(SHAPE_CURSOR);
6606#endif
6607
6608#ifdef FEAT_MOUSESHAPE
6609 /* 'mouseshape' */
6610 else if (varp == &p_mouseshape)
6611 {
6612 errmsg = parse_shape_opt(SHAPE_MOUSE);
6613 update_mouseshape(-1);
6614 }
6615#endif
6616
6617#ifdef FEAT_PRINTER
6618 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006619 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006620# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006621 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006622 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006623# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006624#endif
6625
6626#ifdef FEAT_LANGMAP
6627 /* 'langmap' */
6628 else if (varp == &p_langmap)
6629 langmap_set();
6630#endif
6631
6632#ifdef FEAT_LINEBREAK
6633 /* 'breakat' */
6634 else if (varp == &p_breakat)
6635 fill_breakat_flags();
6636#endif
6637
6638#ifdef FEAT_TITLE
6639 /* 'titlestring' and 'iconstring' */
6640 else if (varp == &p_titlestring || varp == &p_iconstring)
6641 {
6642# ifdef FEAT_STL_OPT
6643 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6644
6645 /* NULL => statusline syntax */
6646 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6647 stl_syntax |= flagval;
6648 else
6649 stl_syntax &= ~flagval;
6650# endif
6651 did_set_title(varp == &p_iconstring);
6652
6653 }
6654#endif
6655
6656#ifdef FEAT_GUI
6657 /* 'guioptions' */
6658 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006659 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006660 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006661 redraw_gui_only = TRUE;
6662 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006663#endif
6664
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006665#if defined(FEAT_GUI_TABLINE)
6666 /* 'guitablabel' */
6667 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006668 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006669 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006670 redraw_gui_only = TRUE;
6671 }
6672 /* 'guitabtooltip' */
6673 else if (varp == &p_gtt)
6674 {
6675 redraw_gui_only = TRUE;
6676 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006677#endif
6678
Bram Moolenaar071d4272004-06-13 20:20:40 +00006679#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6680 /* 'ttymouse' */
6681 else if (varp == &p_ttym)
6682 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006683 /* Switch the mouse off before changing the escape sequences used for
6684 * that. */
6685 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006686 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6687 errmsg = e_invarg;
6688 else
6689 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006690 if (termcap_active)
6691 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006692 }
6693#endif
6694
Bram Moolenaar071d4272004-06-13 20:20:40 +00006695 /* 'selection' */
6696 else if (varp == &p_sel)
6697 {
6698 if (*p_sel == NUL
6699 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6700 errmsg = e_invarg;
6701 }
6702
6703 /* 'selectmode' */
6704 else if (varp == &p_slm)
6705 {
6706 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6707 errmsg = e_invarg;
6708 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006709
6710#ifdef FEAT_BROWSE
6711 /* 'browsedir' */
6712 else if (varp == &p_bsdir)
6713 {
6714 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
6715 && !mch_isdir(p_bsdir))
6716 errmsg = e_invarg;
6717 }
6718#endif
6719
Bram Moolenaar071d4272004-06-13 20:20:40 +00006720 /* 'keymodel' */
6721 else if (varp == &p_km)
6722 {
6723 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
6724 errmsg = e_invarg;
6725 else
6726 {
6727 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
6728 km_startsel = (vim_strchr(p_km, 'a') != NULL);
6729 }
6730 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006731
6732 /* 'mousemodel' */
6733 else if (varp == &p_mousem)
6734 {
6735 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
6736 errmsg = e_invarg;
6737#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
6738 else if (*p_mousem != *oldval)
6739 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
6740 * to create or delete the popup menus. */
6741 gui_motif_update_mousemodel(root_menu);
6742#endif
6743 }
6744
6745 /* 'switchbuf' */
6746 else if (varp == &p_swb)
6747 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00006748 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006749 errmsg = e_invarg;
6750 }
6751
6752 /* 'debug' */
6753 else if (varp == &p_debug)
6754 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00006755 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006756 errmsg = e_invarg;
6757 }
6758
6759 /* 'display' */
6760 else if (varp == &p_dy)
6761 {
6762 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
6763 errmsg = e_invarg;
6764 else
6765 (void)init_chartab();
6766
6767 }
6768
6769#ifdef FEAT_VERTSPLIT
6770 /* 'eadirection' */
6771 else if (varp == &p_ead)
6772 {
6773 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
6774 errmsg = e_invarg;
6775 }
6776#endif
6777
6778#ifdef FEAT_CLIPBOARD
6779 /* 'clipboard' */
6780 else if (varp == &p_cb)
6781 errmsg = check_clipboard_option();
6782#endif
6783
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00006784#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006785 /* When 'spelllang' or 'spellfile' is set and there is a window for this
6786 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006787 else if (varp == &(curwin->w_s->b_p_spl)
6788 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00006789 {
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006790 win_T *wp;
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006791 int l;
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006792
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006793 if (varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006794 {
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006795 l = (int)STRLEN(curwin->w_s->b_p_spf);
6796 if (l > 0 && (l < 4 || STRCMP(curwin->w_s->b_p_spf + l - 4,
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006797 ".add") != 0))
6798 errmsg = e_invarg;
6799 }
6800
6801 if (errmsg == NULL)
6802 {
6803 FOR_ALL_WINDOWS(wp)
6804 if (wp->w_buffer == curbuf && wp->w_p_spell)
6805 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006806 errmsg = did_set_spelllang(wp);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006807# ifdef FEAT_WINDOWS
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006808 break;
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006809# endif
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006810 }
6811 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006812 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006813 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006814 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006815 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006816 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006817 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006818 /* 'spellsuggest' */
6819 else if (varp == &p_sps)
6820 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00006821 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006822 errmsg = e_invarg;
6823 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00006824 /* 'mkspellmem' */
6825 else if (varp == &p_msm)
6826 {
6827 if (spell_check_msm() != OK)
6828 errmsg = e_invarg;
6829 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006830#endif
6831
Bram Moolenaar071d4272004-06-13 20:20:40 +00006832#ifdef FEAT_QUICKFIX
6833 /* When 'bufhidden' is set, check for valid value. */
6834 else if (gvarp == &p_bh)
6835 {
6836 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
6837 errmsg = e_invarg;
6838 }
6839
6840 /* When 'buftype' is set, check for valid value. */
6841 else if (gvarp == &p_bt)
6842 {
6843 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
6844 errmsg = e_invarg;
6845 else
6846 {
6847# ifdef FEAT_WINDOWS
6848 if (curwin->w_status_height)
6849 {
6850 curwin->w_redr_status = TRUE;
6851 redraw_later(VALID);
6852 }
6853# endif
6854 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar5075aad2010-01-27 15:58:13 +01006855# ifdef FEAT_TITLE
6856 redraw_titles();
6857# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006858 }
6859 }
6860#endif
6861
6862#ifdef FEAT_STL_OPT
6863 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006864 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006865 {
6866 int wid;
6867
6868 if (varp == &p_ruf) /* reset ru_wid first */
6869 ru_wid = 0;
6870 s = *varp;
6871 if (varp == &p_ruf && *s == '%')
6872 {
6873 /* set ru_wid if 'ruf' starts with "%99(" */
6874 if (*++s == '-') /* ignore a '-' */
6875 s++;
6876 wid = getdigits(&s);
6877 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
6878 ru_wid = wid;
6879 else
6880 errmsg = check_stl_option(p_ruf);
6881 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00006882 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00006883 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006884 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006885 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006886 comp_col();
6887 }
6888#endif
6889
6890#ifdef FEAT_INS_EXPAND
6891 /* check if it is a valid value for 'complete' -- Acevedo */
6892 else if (gvarp == &p_cpt)
6893 {
6894 for (s = *varp; *s;)
6895 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02006896 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006897 s++;
6898 if (!*s)
6899 break;
6900 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
6901 {
6902 errmsg = illegal_char(errbuf, *s);
6903 break;
6904 }
6905 if (*++s != NUL && *s != ',' && *s != ' ')
6906 {
6907 if (s[-1] == 'k' || s[-1] == 's')
6908 {
6909 /* skip optional filename after 'k' and 's' */
6910 while (*s && *s != ',' && *s != ' ')
6911 {
6912 if (*s == '\\')
6913 ++s;
6914 ++s;
6915 }
6916 }
6917 else
6918 {
6919 if (errbuf != NULL)
6920 {
6921 sprintf((char *)errbuf,
6922 _("E535: Illegal character after <%c>"),
6923 *--s);
6924 errmsg = errbuf;
6925 }
6926 else
6927 errmsg = (char_u *)"";
6928 break;
6929 }
6930 }
6931 }
6932 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00006933
6934 /* 'completeopt' */
6935 else if (varp == &p_cot)
6936 {
6937 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
6938 errmsg = e_invarg;
6939 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006940#endif /* FEAT_INS_EXPAND */
6941
6942
6943#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
6944 else if (varp == &p_toolbar)
6945 {
6946 if (opt_strings_flags(p_toolbar, p_toolbar_values,
6947 &toolbar_flags, TRUE) != OK)
6948 errmsg = e_invarg;
6949 else
6950 {
6951 out_flush();
6952 gui_mch_show_toolbar((toolbar_flags &
6953 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6954 }
6955 }
6956#endif
6957
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006958#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006959 /* 'toolbariconsize': GTK+ 2 only */
6960 else if (varp == &p_tbis)
6961 {
6962 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
6963 errmsg = e_invarg;
6964 else
6965 {
6966 out_flush();
6967 gui_mch_show_toolbar((toolbar_flags &
6968 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6969 }
6970 }
6971#endif
6972
6973 /* 'pastetoggle': translate key codes like in a mapping */
6974 else if (varp == &p_pt)
6975 {
6976 if (*p_pt)
6977 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00006978 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006979 if (p != NULL)
6980 {
6981 if (new_value_alloced)
6982 free_string_option(p_pt);
6983 p_pt = p;
6984 new_value_alloced = TRUE;
6985 }
6986 }
6987 }
6988
6989 /* 'backspace' */
6990 else if (varp == &p_bs)
6991 {
6992 if (VIM_ISDIGIT(*p_bs))
6993 {
6994 if (*p_bs >'2' || p_bs[1] != NUL)
6995 errmsg = e_invarg;
6996 }
6997 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
6998 errmsg = e_invarg;
6999 }
7000
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007001#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007002 /* 'casemap' */
7003 else if (varp == &p_cmp)
7004 {
7005 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
7006 errmsg = e_invarg;
7007 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007008#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007009
7010#ifdef FEAT_DIFF
7011 /* 'diffopt' */
7012 else if (varp == &p_dip)
7013 {
7014 if (diffopt_changed() == FAIL)
7015 errmsg = e_invarg;
7016 }
7017#endif
7018
7019#ifdef FEAT_FOLDING
7020 /* 'foldmethod' */
7021 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7022 {
7023 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7024 || *curwin->w_p_fdm == NUL)
7025 errmsg = e_invarg;
7026 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007027 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007028 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007029 if (foldmethodIsDiff(curwin))
7030 newFoldLevel();
7031 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007032 }
7033# ifdef FEAT_EVAL
7034 /* 'foldexpr' */
7035 else if (varp == &curwin->w_p_fde)
7036 {
7037 if (foldmethodIsExpr(curwin))
7038 foldUpdateAll(curwin);
7039 }
7040# endif
7041 /* 'foldmarker' */
7042 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7043 {
7044 p = vim_strchr(*varp, ',');
7045 if (p == NULL)
7046 errmsg = (char_u *)N_("E536: comma required");
7047 else if (p == *varp || p[1] == NUL)
7048 errmsg = e_invarg;
7049 else if (foldmethodIsMarker(curwin))
7050 foldUpdateAll(curwin);
7051 }
7052 /* 'commentstring' */
7053 else if (gvarp == &p_cms)
7054 {
7055 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7056 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7057 }
7058 /* 'foldopen' */
7059 else if (varp == &p_fdo)
7060 {
7061 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7062 errmsg = e_invarg;
7063 }
7064 /* 'foldclose' */
7065 else if (varp == &p_fcl)
7066 {
7067 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7068 errmsg = e_invarg;
7069 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007070 /* 'foldignore' */
7071 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7072 {
7073 if (foldmethodIsIndent(curwin))
7074 foldUpdateAll(curwin);
7075 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007076#endif
7077
7078#ifdef FEAT_VIRTUALEDIT
7079 /* 'virtualedit' */
7080 else if (varp == &p_ve)
7081 {
7082 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7083 errmsg = e_invarg;
7084 else if (STRCMP(p_ve, oldval) != 0)
7085 {
7086 /* Recompute cursor position in case the new 've' setting
7087 * changes something. */
7088 validate_virtcol();
7089 coladvance(curwin->w_virtcol);
7090 }
7091 }
7092#endif
7093
7094#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7095 else if (varp == &p_csqf)
7096 {
7097 if (p_csqf != NULL)
7098 {
7099 p = p_csqf;
7100 while (*p != NUL)
7101 {
7102 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7103 || p[1] == NUL
7104 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7105 || (p[2] != NUL && p[2] != ','))
7106 {
7107 errmsg = e_invarg;
7108 break;
7109 }
7110 else if (p[2] == NUL)
7111 break;
7112 else
7113 p += 3;
7114 }
7115 }
7116 }
7117#endif
7118
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007119#ifdef FEAT_CINDENT
7120 /* 'cinoptions' */
7121 else if (gvarp == &p_cino)
7122 {
7123 /* TODO: recognize errors */
7124 parse_cino(curbuf);
7125 }
7126#endif
7127
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007128#if defined(FEAT_RENDER_OPTIONS)
7129 else if (varp == &p_rop && gui.in_use)
7130 {
7131 if (!gui_mch_set_rendering_options(p_rop))
7132 errmsg = e_invarg;
7133 }
7134#endif
7135
Bram Moolenaar071d4272004-06-13 20:20:40 +00007136 /* Options that are a list of flags. */
7137 else
7138 {
7139 p = NULL;
7140 if (varp == &p_ww)
7141 p = (char_u *)WW_ALL;
7142 if (varp == &p_shm)
7143 p = (char_u *)SHM_ALL;
7144 else if (varp == &(p_cpo))
7145 p = (char_u *)CPO_ALL;
7146 else if (varp == &(curbuf->b_p_fo))
7147 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007148#ifdef FEAT_CONCEAL
7149 else if (varp == &curwin->w_p_cocu)
7150 p = (char_u *)COCU_ALL;
7151#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007152 else if (varp == &p_mouse)
7153 {
7154#ifdef FEAT_MOUSE
7155 p = (char_u *)MOUSE_ALL;
7156#else
7157 if (*p_mouse != NUL)
7158 errmsg = (char_u *)N_("E538: No mouse support");
7159#endif
7160 }
7161#if defined(FEAT_GUI)
7162 else if (varp == &p_go)
7163 p = (char_u *)GO_ALL;
7164#endif
7165 if (p != NULL)
7166 {
7167 for (s = *varp; *s; ++s)
7168 if (vim_strchr(p, *s) == NULL)
7169 {
7170 errmsg = illegal_char(errbuf, *s);
7171 break;
7172 }
7173 }
7174 }
7175
7176 /*
7177 * If error detected, restore the previous value.
7178 */
7179 if (errmsg != NULL)
7180 {
7181 if (new_value_alloced)
7182 free_string_option(*varp);
7183 *varp = oldval;
7184 /*
7185 * When resetting some values, need to act on it.
7186 */
7187 if (did_chartab)
7188 (void)init_chartab();
7189 if (varp == &p_hl)
7190 (void)highlight_changed();
7191 }
7192 else
7193 {
7194#ifdef FEAT_EVAL
7195 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007196 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007197#endif
7198 /*
7199 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007200 * Use "free_oldval", because recursiveness may change the flags under
7201 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007202 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007203 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007204 free_string_option(oldval);
7205 if (new_value_alloced)
7206 options[opt_idx].flags |= P_ALLOCED;
7207 else
7208 options[opt_idx].flags &= ~P_ALLOCED;
7209
7210 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007211 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007212 {
7213 /* global option with local value set to use global value; free
7214 * the local value and make it empty */
7215 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7216 free_string_option(*(char_u **)p);
7217 *(char_u **)p = empty_option;
7218 }
7219
7220 /* May set global value for local option. */
7221 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7222 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007223
7224#ifdef FEAT_AUTOCMD
7225 /*
7226 * Trigger the autocommand only after setting the flags.
7227 */
7228# ifdef FEAT_SYN_HL
7229 /* When 'syntax' is set, load the syntax of that name */
7230 if (varp == &(curbuf->b_p_syn))
7231 {
7232 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7233 curbuf->b_fname, TRUE, curbuf);
7234 }
7235# endif
7236 else if (varp == &(curbuf->b_p_ft))
7237 {
7238 /* 'filetype' is set, trigger the FileType autocommand */
7239 did_filetype = TRUE;
7240 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
7241 curbuf->b_fname, TRUE, curbuf);
7242 }
7243#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007244#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007245 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007246 {
7247 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007248 char_u *q = curwin->w_s->b_p_spl;
7249
7250 /* Skip the first name if it is "cjk". */
7251 if (STRNCMP(q, "cjk,", 4) == 0)
7252 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007253
7254 /*
7255 * Source the spell/LANG.vim in 'runtimepath'.
7256 * They could set 'spellcapcheck' depending on the language.
7257 * Use the first name in 'spelllang' up to '_region' or
7258 * '.encoding'.
7259 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007260 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007261 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7262 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007263 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007264 source_runtime(fname, TRUE);
7265 }
7266#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007267 }
7268
7269#ifdef FEAT_MOUSE
7270 if (varp == &p_mouse)
7271 {
7272# ifdef FEAT_MOUSE_TTY
7273 if (*p_mouse == NUL)
7274 mch_setmouse(FALSE); /* switch mouse off */
7275 else
7276# endif
7277 setmouse(); /* in case 'mouse' changed */
7278 }
7279#endif
7280
Bram Moolenaar913077c2012-03-28 19:59:04 +02007281 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007282 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007283 curwin->w_set_curswant = TRUE;
7284
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007285#ifdef FEAT_GUI
7286 /* check redraw when it's not a GUI option or the GUI is active. */
7287 if (!redraw_gui_only || gui.in_use)
7288#endif
7289 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007290
7291 return errmsg;
7292}
7293
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007294#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007295/*
7296 * Simple int comparison function for use with qsort()
7297 */
7298 static int
7299int_cmp(a, b)
7300 const void *a;
7301 const void *b;
7302{
7303 return *(const int *)a - *(const int *)b;
7304}
7305
7306/*
7307 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7308 * Returns error message, NULL if it's OK.
7309 */
7310 char_u *
7311check_colorcolumn(wp)
7312 win_T *wp;
7313{
7314 char_u *s;
7315 int col;
7316 int count = 0;
7317 int color_cols[256];
7318 int i;
7319 int j = 0;
7320
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007321 if (wp->w_buffer == NULL)
7322 return NULL; /* buffer was closed */
7323
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007324 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007325 {
7326 if (*s == '-' || *s == '+')
7327 {
7328 /* -N and +N: add to 'textwidth' */
7329 col = (*s == '-') ? -1 : 1;
7330 ++s;
7331 if (!VIM_ISDIGIT(*s))
7332 return e_invarg;
7333 col = col * getdigits(&s);
7334 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007335 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007336 col += wp->w_buffer->b_p_tw;
7337 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007338 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007339 }
7340 else if (VIM_ISDIGIT(*s))
7341 col = getdigits(&s);
7342 else
7343 return e_invarg;
7344 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007345skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007346 if (*s == NUL)
7347 break;
7348 if (*s != ',')
7349 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007350 if (*++s == NUL)
7351 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007352 }
7353
7354 vim_free(wp->w_p_cc_cols);
7355 if (count == 0)
7356 wp->w_p_cc_cols = NULL;
7357 else
7358 {
7359 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7360 if (wp->w_p_cc_cols != NULL)
7361 {
7362 /* sort the columns for faster usage on screen redraw inside
7363 * win_line() */
7364 qsort(color_cols, count, sizeof(int), int_cmp);
7365
7366 for (i = 0; i < count; ++i)
7367 /* skip duplicates */
7368 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7369 wp->w_p_cc_cols[j++] = color_cols[i];
7370 wp->w_p_cc_cols[j] = -1; /* end marker */
7371 }
7372 }
7373
7374 return NULL; /* no error */
7375}
7376#endif
7377
Bram Moolenaar071d4272004-06-13 20:20:40 +00007378/*
7379 * Handle setting 'listchars' or 'fillchars'.
7380 * Returns error message, NULL if it's OK.
7381 */
7382 static char_u *
7383set_chars_option(varp)
7384 char_u **varp;
7385{
7386 int round, i, len, entries;
7387 char_u *p, *s;
7388 int c1, c2 = 0;
7389 struct charstab
7390 {
7391 int *cp;
7392 char *name;
7393 };
7394#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7395 static struct charstab filltab[] =
7396 {
7397 {&fill_stl, "stl"},
7398 {&fill_stlnc, "stlnc"},
7399 {&fill_vert, "vert"},
7400 {&fill_fold, "fold"},
7401 {&fill_diff, "diff"},
7402 };
7403#endif
7404 static struct charstab lcstab[] =
7405 {
7406 {&lcs_eol, "eol"},
7407 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007408 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007409 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007410 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007411 {&lcs_tab2, "tab"},
7412 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007413#ifdef FEAT_CONCEAL
7414 {&lcs_conceal, "conceal"},
7415#else
7416 {NULL, "conceal"},
7417#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007418 };
7419 struct charstab *tab;
7420
7421#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7422 if (varp == &p_lcs)
7423#endif
7424 {
7425 tab = lcstab;
7426 entries = sizeof(lcstab) / sizeof(struct charstab);
7427 }
7428#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7429 else
7430 {
7431 tab = filltab;
7432 entries = sizeof(filltab) / sizeof(struct charstab);
7433 }
7434#endif
7435
7436 /* first round: check for valid value, second round: assign values */
7437 for (round = 0; round <= 1; ++round)
7438 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007439 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007440 {
7441 /* After checking that the value is valid: set defaults: space for
7442 * 'fillchars', NUL for 'listchars' */
7443 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007444 if (tab[i].cp != NULL)
7445 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007446 if (varp == &p_lcs)
7447 lcs_tab1 = NUL;
7448#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7449 else
7450 fill_diff = '-';
7451#endif
7452 }
7453 p = *varp;
7454 while (*p)
7455 {
7456 for (i = 0; i < entries; ++i)
7457 {
7458 len = (int)STRLEN(tab[i].name);
7459 if (STRNCMP(p, tab[i].name, len) == 0
7460 && p[len] == ':'
7461 && p[len + 1] != NUL)
7462 {
7463 s = p + len + 1;
7464#ifdef FEAT_MBYTE
7465 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007466 if (mb_char2cells(c1) > 1)
7467 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007468#else
7469 c1 = *s++;
7470#endif
7471 if (tab[i].cp == &lcs_tab2)
7472 {
7473 if (*s == NUL)
7474 continue;
7475#ifdef FEAT_MBYTE
7476 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007477 if (mb_char2cells(c2) > 1)
7478 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007479#else
7480 c2 = *s++;
7481#endif
7482 }
7483 if (*s == ',' || *s == NUL)
7484 {
7485 if (round)
7486 {
7487 if (tab[i].cp == &lcs_tab2)
7488 {
7489 lcs_tab1 = c1;
7490 lcs_tab2 = c2;
7491 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007492 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007493 *(tab[i].cp) = c1;
7494
7495 }
7496 p = s;
7497 break;
7498 }
7499 }
7500 }
7501
7502 if (i == entries)
7503 return e_invarg;
7504 if (*p == ',')
7505 ++p;
7506 }
7507 }
7508
7509 return NULL; /* no error */
7510}
7511
7512#ifdef FEAT_STL_OPT
7513/*
7514 * Check validity of options with the 'statusline' format.
7515 * Return error message or NULL.
7516 */
7517 char_u *
7518check_stl_option(s)
7519 char_u *s;
7520{
7521 int itemcnt = 0;
7522 int groupdepth = 0;
7523 static char_u errbuf[80];
7524
7525 while (*s && itemcnt < STL_MAX_ITEM)
7526 {
7527 /* Check for valid keys after % sequences */
7528 while (*s && *s != '%')
7529 s++;
7530 if (!*s)
7531 break;
7532 s++;
7533 if (*s != '%' && *s != ')')
7534 ++itemcnt;
7535 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7536 {
7537 s++;
7538 continue;
7539 }
7540 if (*s == ')')
7541 {
7542 s++;
7543 if (--groupdepth < 0)
7544 break;
7545 continue;
7546 }
7547 if (*s == '-')
7548 s++;
7549 while (VIM_ISDIGIT(*s))
7550 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007551 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007552 continue;
7553 if (*s == '.')
7554 {
7555 s++;
7556 while (*s && VIM_ISDIGIT(*s))
7557 s++;
7558 }
7559 if (*s == '(')
7560 {
7561 groupdepth++;
7562 continue;
7563 }
7564 if (vim_strchr(STL_ALL, *s) == NULL)
7565 {
7566 return illegal_char(errbuf, *s);
7567 }
7568 if (*s == '{')
7569 {
7570 s++;
7571 while (*s != '}' && *s)
7572 s++;
7573 if (*s != '}')
7574 return (char_u *)N_("E540: Unclosed expression sequence");
7575 }
7576 }
7577 if (itemcnt >= STL_MAX_ITEM)
7578 return (char_u *)N_("E541: too many items");
7579 if (groupdepth != 0)
7580 return (char_u *)N_("E542: unbalanced groups");
7581 return NULL;
7582}
7583#endif
7584
7585#ifdef FEAT_CLIPBOARD
7586/*
7587 * Extract the items in the 'clipboard' option and set global values.
7588 */
7589 static char_u *
7590check_clipboard_option()
7591{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007592 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007593 int new_autoselect_star = FALSE;
7594 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007595 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007596 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007597 regprog_T *new_exclude_prog = NULL;
7598 char_u *errmsg = NULL;
7599 char_u *p;
7600
7601 for (p = p_cb; *p != NUL; )
7602 {
7603 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7604 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007605 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007606 p += 7;
7607 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007608 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007609 && (p[11] == ',' || p[11] == NUL))
7610 {
7611 new_unnamed |= CLIP_UNNAMED_PLUS;
7612 p += 11;
7613 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007614 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007615 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007616 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007617 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007618 p += 10;
7619 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007620 else if (STRNCMP(p, "autoselectplus", 14) == 0
7621 && (p[14] == ',' || p[14] == NUL))
7622 {
7623 new_autoselect_plus = TRUE;
7624 p += 14;
7625 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007626 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007627 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007628 {
7629 new_autoselectml = TRUE;
7630 p += 12;
7631 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007632 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7633 {
7634 new_html = TRUE;
7635 p += 4;
7636 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007637 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7638 {
7639 p += 8;
7640 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7641 if (new_exclude_prog == NULL)
7642 errmsg = e_invarg;
7643 break;
7644 }
7645 else
7646 {
7647 errmsg = e_invarg;
7648 break;
7649 }
7650 if (*p == ',')
7651 ++p;
7652 }
7653 if (errmsg == NULL)
7654 {
7655 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007656 clip_autoselect_star = new_autoselect_star;
7657 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007658 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007659 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02007660 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007661 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02007662#ifdef FEAT_GUI_GTK
7663 if (gui.in_use)
7664 {
7665 gui_gtk_set_selection_targets();
7666 gui_gtk_set_dnd_targets();
7667 }
7668#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007669 }
7670 else
Bram Moolenaar473de612013-06-08 18:19:48 +02007671 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007672
7673 return errmsg;
7674}
7675#endif
7676
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007677#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007678/*
7679 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
7680 * Return error message when failed, NULL when OK.
7681 */
7682 static char_u *
Bram Moolenaar860cae12010-06-05 23:22:07 +02007683compile_cap_prog(synblock)
7684 synblock_T *synblock;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007685{
Bram Moolenaar860cae12010-06-05 23:22:07 +02007686 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007687 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007688
Bram Moolenaar860cae12010-06-05 23:22:07 +02007689 if (*synblock->b_p_spc == NUL)
7690 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007691 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007692 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007693 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007694 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007695 if (re != NULL)
7696 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007697 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02007698 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02007699 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007700 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007701 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007702 return e_invarg;
7703 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007704 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007705 }
7706
Bram Moolenaar473de612013-06-08 18:19:48 +02007707 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007708 return NULL;
7709}
7710#endif
7711
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007712#if defined(FEAT_EVAL) || defined(PROTO)
7713/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007714 * Set the scriptID for an option, taking care of setting the buffer- or
7715 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007716 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007717 static void
7718set_option_scriptID_idx(opt_idx, opt_flags, id)
7719 int opt_idx;
7720 int opt_flags;
7721 int id;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007722{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007723 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
7724 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007725
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007726 /* Remember where the option was set. For local options need to do that
7727 * in the buffer or window structure. */
7728 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007729 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007730 if (both || (opt_flags & OPT_LOCAL))
7731 {
7732 if (indir & PV_BUF)
7733 curbuf->b_p_scriptID[indir & PV_MASK] = id;
7734 else if (indir & PV_WIN)
7735 curwin->w_p_scriptID[indir & PV_MASK] = id;
7736 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007737}
7738#endif
7739
Bram Moolenaar071d4272004-06-13 20:20:40 +00007740/*
7741 * Set the value of a boolean option, and take care of side effects.
7742 * Returns NULL for success, or an error message for an error.
7743 */
7744 static char_u *
7745set_bool_option(opt_idx, varp, value, opt_flags)
7746 int opt_idx; /* index in options[] table */
7747 char_u *varp; /* pointer to the option variable */
7748 int value; /* new value */
7749 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
7750{
7751 int old_value = *(int *)varp;
7752
Bram Moolenaar071d4272004-06-13 20:20:40 +00007753 /* Disallow changing some options from secure mode */
7754 if ((secure
7755#ifdef HAVE_SANDBOX
7756 || sandbox != 0
7757#endif
7758 ) && (options[opt_idx].flags & P_SECURE))
7759 return e_secure;
7760
7761 *(int *)varp = value; /* set the new value */
7762#ifdef FEAT_EVAL
7763 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007764 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007765#endif
7766
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00007767#ifdef FEAT_GUI
7768 need_mouse_correct = TRUE;
7769#endif
7770
Bram Moolenaar071d4272004-06-13 20:20:40 +00007771 /* May set global value for local option. */
7772 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
7773 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
7774
7775 /*
7776 * Handle side effects of changing a bool option.
7777 */
7778
7779 /* 'compatible' */
7780 if ((int *)varp == &p_cp)
7781 {
7782 compatible_set();
7783 }
7784
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007785#ifdef FEAT_PERSISTENT_UNDO
7786 /* 'undofile' */
7787 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
7788 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007789 /* Only take action when the option was set. When reset we do not
7790 * delete the undo file, the option may be set again without making
7791 * any changes in between. */
7792 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007793 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007794 char_u hash[UNDO_HASH_SIZE];
7795 buf_T *save_curbuf = curbuf;
7796
7797 for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007798 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007799 /* When 'undofile' is set globally: for every buffer, otherwise
7800 * only for the current buffer: Try to read in the undofile,
7801 * if one exists, the buffer wasn't changed and the buffer was
7802 * loaded */
7803 if ((curbuf == save_curbuf
7804 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
7805 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
7806 {
7807 u_compute_hash(hash);
7808 u_read_undo(NULL, hash, curbuf->b_fname);
7809 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007810 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007811 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007812 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007813 }
7814#endif
7815
Bram Moolenaar071d4272004-06-13 20:20:40 +00007816 else if ((int *)varp == &curbuf->b_p_ro)
7817 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007818 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007819 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
7820 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007821
7822 /* when 'readonly' is set may give W10 again */
7823 if (curbuf->b_p_ro)
7824 curbuf->b_did_warn = FALSE;
7825
Bram Moolenaar071d4272004-06-13 20:20:40 +00007826#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007827 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007828#endif
7829 }
7830
Bram Moolenaar9c449722010-07-20 18:44:27 +02007831#ifdef FEAT_GUI
7832 else if ((int *)varp == &p_mh)
7833 {
7834 if (!p_mh)
7835 gui_mch_mousehide(FALSE);
7836 }
7837#endif
7838
Bram Moolenaara539df02010-08-01 14:35:05 +02007839#ifdef FEAT_TITLE
7840 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007841 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007842 {
7843 redraw_titles();
7844 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007845 /* when 'endofline' is changed, redraw the window title */
7846 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007847 {
7848 redraw_titles();
7849 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02007850 /* when 'fixeol' is changed, redraw the window title */
7851 else if ((int *)varp == &curbuf->b_p_fixeol)
7852 {
7853 redraw_titles();
7854 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007855# ifdef FEAT_MBYTE
7856 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00007857 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007858 {
7859 redraw_titles();
7860 }
7861# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007862#endif
7863
7864 /* when 'bin' is set also set some other options */
7865 else if ((int *)varp == &curbuf->b_p_bin)
7866 {
7867 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
7868#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007869 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007870#endif
7871 }
7872
7873#ifdef FEAT_AUTOCMD
7874 /* when 'buflisted' changes, trigger autocommands */
7875 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
7876 {
7877 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
7878 NULL, NULL, TRUE, curbuf);
7879 }
7880#endif
7881
7882 /* when 'swf' is set, create swapfile, when reset remove swapfile */
7883 else if ((int *)varp == &curbuf->b_p_swf)
7884 {
7885 if (curbuf->b_p_swf && p_uc)
7886 ml_open_file(curbuf); /* create the swap file */
7887 else
Bram Moolenaard55de222007-05-06 13:38:48 +00007888 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
7889 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007890 mf_close_file(curbuf, TRUE); /* remove the swap file */
7891 }
7892
7893 /* when 'terse' is set change 'shortmess' */
7894 else if ((int *)varp == &p_terse)
7895 {
7896 char_u *p;
7897
7898 p = vim_strchr(p_shm, SHM_SEARCH);
7899
7900 /* insert 's' in p_shm */
7901 if (p_terse && p == NULL)
7902 {
7903 STRCPY(IObuff, p_shm);
7904 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007905 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007906 }
7907 /* remove 's' from p_shm */
7908 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007909 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007910 }
7911
7912 /* when 'paste' is set or reset also change other options */
7913 else if ((int *)varp == &p_paste)
7914 {
7915 paste_option_changed();
7916 }
7917
7918 /* when 'insertmode' is set from an autocommand need to do work here */
7919 else if ((int *)varp == &p_im)
7920 {
7921 if (p_im)
7922 {
7923 if ((State & INSERT) == 0)
7924 need_start_insertmode = TRUE;
7925 stop_insert_mode = FALSE;
7926 }
7927 else
7928 {
7929 need_start_insertmode = FALSE;
7930 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00007931 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007932 clear_cmdline = TRUE; /* remove "(insert)" */
7933 restart_edit = 0;
7934 }
7935 }
7936
7937 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
7938 else if ((int *)varp == &p_ic && p_hls)
7939 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007940 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007941 }
7942
7943#ifdef FEAT_SEARCH_EXTRA
7944 /* when 'hlsearch' is set or reset: reset no_hlsearch */
7945 else if ((int *)varp == &p_hls)
7946 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01007947 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007948 }
7949#endif
7950
7951#ifdef FEAT_SCROLLBIND
7952 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
7953 * at the end of normal_cmd() */
7954 else if ((int *)varp == &curwin->w_p_scb)
7955 {
7956 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02007957 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007958 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02007959 curwin->w_scbind_pos = curwin->w_topline;
7960 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007961 }
7962#endif
7963
7964#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
7965 /* There can be only one window with 'previewwindow' set. */
7966 else if ((int *)varp == &curwin->w_p_pvw)
7967 {
7968 if (curwin->w_p_pvw)
7969 {
7970 win_T *win;
7971
7972 for (win = firstwin; win != NULL; win = win->w_next)
7973 if (win->w_p_pvw && win != curwin)
7974 {
7975 curwin->w_p_pvw = FALSE;
7976 return (char_u *)N_("E590: A preview window already exists");
7977 }
7978 }
7979 }
7980#endif
7981
7982 /* when 'textmode' is set or reset also change 'fileformat' */
7983 else if ((int *)varp == &curbuf->b_p_tx)
7984 {
7985 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
7986 }
7987
7988 /* when 'textauto' is set or reset also change 'fileformats' */
7989 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007990 set_string_option_direct((char_u *)"ffs", -1,
7991 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007992 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007993
7994 /*
7995 * When 'lisp' option changes include/exclude '-' in
7996 * keyword characters.
7997 */
7998#ifdef FEAT_LISP
7999 else if (varp == (char_u *)&(curbuf->b_p_lisp))
8000 {
8001 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
8002 }
8003#endif
8004
8005#ifdef FEAT_TITLE
8006 /* when 'title' changed, may need to change the title; same for 'icon' */
8007 else if ((int *)varp == &p_title)
8008 {
8009 did_set_title(FALSE);
8010 }
8011
8012 else if ((int *)varp == &p_icon)
8013 {
8014 did_set_title(TRUE);
8015 }
8016#endif
8017
8018 else if ((int *)varp == &curbuf->b_changed)
8019 {
8020 if (!value)
8021 save_file_ff(curbuf); /* Buffer is unchanged */
8022#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008023 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008024#endif
8025#ifdef FEAT_AUTOCMD
8026 modified_was_set = value;
8027#endif
8028 }
8029
8030#ifdef BACKSLASH_IN_FILENAME
8031 else if ((int *)varp == &p_ssl)
8032 {
8033 if (p_ssl)
8034 {
8035 psepc = '/';
8036 psepcN = '\\';
8037 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008038 }
8039 else
8040 {
8041 psepc = '\\';
8042 psepcN = '/';
8043 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008044 }
8045
8046 /* need to adjust the file name arguments and buffer names. */
8047 buflist_slash_adjust();
8048 alist_slash_adjust();
8049# ifdef FEAT_EVAL
8050 scriptnames_slash_adjust();
8051# endif
8052 }
8053#endif
8054
8055 /* If 'wrap' is set, set w_leftcol to zero. */
8056 else if ((int *)varp == &curwin->w_p_wrap)
8057 {
8058 if (curwin->w_p_wrap)
8059 curwin->w_leftcol = 0;
8060 }
8061
8062#ifdef FEAT_WINDOWS
8063 else if ((int *)varp == &p_ea)
8064 {
8065 if (p_ea && !old_value)
8066 win_equal(curwin, FALSE, 0);
8067 }
8068#endif
8069
8070 else if ((int *)varp == &p_wiv)
8071 {
8072 /*
8073 * When 'weirdinvert' changed, set/reset 't_xs'.
8074 * Then set 'weirdinvert' according to value of 't_xs'.
8075 */
8076 if (p_wiv && !old_value)
8077 T_XS = (char_u *)"y";
8078 else if (!p_wiv && old_value)
8079 T_XS = empty_option;
8080 p_wiv = (*T_XS != NUL);
8081 }
8082
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00008083#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00008084 else if ((int *)varp == &p_beval)
8085 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008086 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008087 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008088 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008089 gui_mch_disable_beval_area(balloonEval);
8090 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008091#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008092
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008093#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008094 else if ((int *)varp == &p_acd)
8095 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008096 /* Change directories when the 'acd' option is set now. */
8097 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008098 }
8099#endif
8100
8101#ifdef FEAT_DIFF
8102 /* 'diff' */
8103 else if ((int *)varp == &curwin->w_p_diff)
8104 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008105 /* May add or remove the buffer from the list of diff buffers. */
8106 diff_buf_adjust(curwin);
8107# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008108 if (foldmethodIsDiff(curwin))
8109 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008110# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008111 }
8112#endif
8113
8114#ifdef USE_IM_CONTROL
8115 /* 'imdisable' */
8116 else if ((int *)varp == &p_imdisable)
8117 {
8118 /* Only de-activate it here, it will be enabled when changing mode. */
8119 if (p_imdisable)
8120 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008121 else if (State & INSERT)
8122 /* When the option is set from an autocommand, it may need to take
8123 * effect right away. */
8124 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008125 }
8126#endif
8127
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008128#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008129 /* 'spell' */
8130 else if ((int *)varp == &curwin->w_p_spell)
8131 {
8132 if (curwin->w_p_spell)
8133 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008134 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008135 if (errmsg != NULL)
8136 EMSG(_(errmsg));
8137 }
8138 }
8139#endif
8140
Bram Moolenaar071d4272004-06-13 20:20:40 +00008141#ifdef FEAT_FKMAP
8142 else if ((int *)varp == &p_altkeymap)
8143 {
8144 if (old_value != p_altkeymap)
8145 {
8146 if (!p_altkeymap)
8147 {
8148 p_hkmap = p_fkmap;
8149 p_fkmap = 0;
8150 }
8151 else
8152 {
8153 p_fkmap = p_hkmap;
8154 p_hkmap = 0;
8155 }
8156 (void)init_chartab();
8157 }
8158 }
8159
8160 /*
8161 * In case some second language keymapping options have changed, check
8162 * and correct the setting in a consistent way.
8163 */
8164
8165 /*
8166 * If hkmap or fkmap are set, reset Arabic keymapping.
8167 */
8168 if ((p_hkmap || p_fkmap) && p_altkeymap)
8169 {
8170 p_altkeymap = p_fkmap;
8171# ifdef FEAT_ARABIC
8172 curwin->w_p_arab = FALSE;
8173# endif
8174 (void)init_chartab();
8175 }
8176
8177 /*
8178 * If hkmap set, reset Farsi keymapping.
8179 */
8180 if (p_hkmap && p_altkeymap)
8181 {
8182 p_altkeymap = 0;
8183 p_fkmap = 0;
8184# ifdef FEAT_ARABIC
8185 curwin->w_p_arab = FALSE;
8186# endif
8187 (void)init_chartab();
8188 }
8189
8190 /*
8191 * If fkmap set, reset Hebrew keymapping.
8192 */
8193 if (p_fkmap && !p_altkeymap)
8194 {
8195 p_altkeymap = 1;
8196 p_hkmap = 0;
8197# ifdef FEAT_ARABIC
8198 curwin->w_p_arab = FALSE;
8199# endif
8200 (void)init_chartab();
8201 }
8202#endif
8203
8204#ifdef FEAT_ARABIC
8205 if ((int *)varp == &curwin->w_p_arab)
8206 {
8207 if (curwin->w_p_arab)
8208 {
8209 /*
8210 * 'arabic' is set, handle various sub-settings.
8211 */
8212 if (!p_tbidi)
8213 {
8214 /* set rightleft mode */
8215 if (!curwin->w_p_rl)
8216 {
8217 curwin->w_p_rl = TRUE;
8218 changed_window_setting();
8219 }
8220
8221 /* Enable Arabic shaping (major part of what Arabic requires) */
8222 if (!p_arshape)
8223 {
8224 p_arshape = TRUE;
8225 redraw_later_clear();
8226 }
8227 }
8228
8229 /* Arabic requires a utf-8 encoding, inform the user if its not
8230 * set. */
8231 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008232 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008233 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8234
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008235 msg_source(hl_attr(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008236 MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
8237#ifdef FEAT_EVAL
8238 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8239#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008240 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008241
8242# ifdef FEAT_MBYTE
8243 /* set 'delcombine' */
8244 p_deco = TRUE;
8245# endif
8246
8247# ifdef FEAT_KEYMAP
8248 /* Force-set the necessary keymap for arabic */
8249 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8250 OPT_LOCAL);
8251# endif
8252# ifdef FEAT_FKMAP
8253 p_altkeymap = 0;
8254 p_hkmap = 0;
8255 p_fkmap = 0;
8256 (void)init_chartab();
8257# endif
8258 }
8259 else
8260 {
8261 /*
8262 * 'arabic' is reset, handle various sub-settings.
8263 */
8264 if (!p_tbidi)
8265 {
8266 /* reset rightleft mode */
8267 if (curwin->w_p_rl)
8268 {
8269 curwin->w_p_rl = FALSE;
8270 changed_window_setting();
8271 }
8272
8273 /* 'arabicshape' isn't reset, it is a global option and
8274 * another window may still need it "on". */
8275 }
8276
8277 /* 'delcombine' isn't reset, it is a global option and another
8278 * window may still want it "on". */
8279
8280# ifdef FEAT_KEYMAP
8281 /* Revert to the default keymap */
8282 curbuf->b_p_iminsert = B_IMODE_NONE;
8283 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8284# endif
8285 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008286 }
8287
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008288#endif
8289
Bram Moolenaar071d4272004-06-13 20:20:40 +00008290 /*
8291 * End of handling side effects for bool options.
8292 */
8293
Bram Moolenaar53744302015-07-17 17:38:22 +02008294 /* after handling side effects, call autocommand */
8295
Bram Moolenaar071d4272004-06-13 20:20:40 +00008296 options[opt_idx].flags |= P_WAS_SET;
8297
Bram Moolenaar53744302015-07-17 17:38:22 +02008298#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8299 if (!starting)
8300 {
8301 char_u buf_old[2], buf_new[2], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008302 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8303 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8304 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008305 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8306 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8307 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8308 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8309 reset_v_option_vars();
8310 }
8311#endif
8312
Bram Moolenaar071d4272004-06-13 20:20:40 +00008313 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008314 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008315 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008316 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008317 check_redraw(options[opt_idx].flags);
8318
8319 return NULL;
8320}
8321
8322/*
8323 * Set the value of a number option, and take care of side effects.
8324 * Returns NULL for success, or an error message for an error.
8325 */
8326 static char_u *
Bram Moolenaar555b2802005-05-19 21:08:39 +00008327set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008328 int opt_idx; /* index in options[] table */
8329 char_u *varp; /* pointer to the option variable */
8330 long value; /* new value */
8331 char_u *errbuf; /* buffer for error messages */
Bram Moolenaar555b2802005-05-19 21:08:39 +00008332 size_t errbuflen; /* length of "errbuf" */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008333 int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and
8334 OPT_MODELINE */
8335{
8336 char_u *errmsg = NULL;
8337 long old_value = *(long *)varp;
8338 long old_Rows = Rows; /* remember old Rows */
8339 long old_Columns = Columns; /* remember old Columns */
8340 long *pp = (long *)varp;
8341
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008342 /* Disallow changing some options from secure mode. */
8343 if ((secure
8344#ifdef HAVE_SANDBOX
8345 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008346#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008347 ) && (options[opt_idx].flags & P_SECURE))
8348 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008349
8350 *pp = value;
8351#ifdef FEAT_EVAL
8352 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008353 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008354#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008355#ifdef FEAT_GUI
8356 need_mouse_correct = TRUE;
8357#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008358
Bram Moolenaar14f24742012-08-08 18:01:05 +02008359 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008360 {
8361 errmsg = e_positive;
8362 curbuf->b_p_sw = curbuf->b_p_ts;
8363 }
8364
8365 /*
8366 * Number options that need some action when changed
8367 */
8368#ifdef FEAT_WINDOWS
8369 if (pp == &p_wh || pp == &p_hh)
8370 {
8371 if (p_wh < 1)
8372 {
8373 errmsg = e_positive;
8374 p_wh = 1;
8375 }
8376 if (p_wmh > p_wh)
8377 {
8378 errmsg = e_winheight;
8379 p_wh = p_wmh;
8380 }
8381 if (p_hh < 0)
8382 {
8383 errmsg = e_positive;
8384 p_hh = 0;
8385 }
8386
8387 /* Change window height NOW */
8388 if (lastwin != firstwin)
8389 {
8390 if (pp == &p_wh && curwin->w_height < p_wh)
8391 win_setheight((int)p_wh);
8392 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8393 win_setheight((int)p_hh);
8394 }
8395 }
8396
8397 /* 'winminheight' */
8398 else if (pp == &p_wmh)
8399 {
8400 if (p_wmh < 0)
8401 {
8402 errmsg = e_positive;
8403 p_wmh = 0;
8404 }
8405 if (p_wmh > p_wh)
8406 {
8407 errmsg = e_winheight;
8408 p_wmh = p_wh;
8409 }
8410 win_setminheight();
8411 }
8412
8413# ifdef FEAT_VERTSPLIT
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008414 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008415 {
8416 if (p_wiw < 1)
8417 {
8418 errmsg = e_positive;
8419 p_wiw = 1;
8420 }
8421 if (p_wmw > p_wiw)
8422 {
8423 errmsg = e_winwidth;
8424 p_wiw = p_wmw;
8425 }
8426
8427 /* Change window width NOW */
8428 if (lastwin != firstwin && curwin->w_width < p_wiw)
8429 win_setwidth((int)p_wiw);
8430 }
8431
8432 /* 'winminwidth' */
8433 else if (pp == &p_wmw)
8434 {
8435 if (p_wmw < 0)
8436 {
8437 errmsg = e_positive;
8438 p_wmw = 0;
8439 }
8440 if (p_wmw > p_wiw)
8441 {
8442 errmsg = e_winwidth;
8443 p_wmw = p_wiw;
8444 }
8445 win_setminheight();
8446 }
8447# endif
8448
8449#endif
8450
8451#ifdef FEAT_WINDOWS
8452 /* (re)set last window status line */
8453 else if (pp == &p_ls)
8454 {
8455 last_status(FALSE);
8456 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008457
8458 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008459 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008460 {
8461 shell_new_rows(); /* recompute window positions and heights */
8462 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008463#endif
8464
8465#ifdef FEAT_GUI
8466 else if (pp == &p_linespace)
8467 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008468 /* Recompute gui.char_height and resize the Vim window to keep the
8469 * same number of lines. */
8470 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008471 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008472 }
8473#endif
8474
8475#ifdef FEAT_FOLDING
8476 /* 'foldlevel' */
8477 else if (pp == &curwin->w_p_fdl)
8478 {
8479 if (curwin->w_p_fdl < 0)
8480 curwin->w_p_fdl = 0;
8481 newFoldLevel();
8482 }
8483
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008484 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008485 else if (pp == &curwin->w_p_fml)
8486 {
8487 foldUpdateAll(curwin);
8488 }
8489
8490 /* 'foldnestmax' */
8491 else if (pp == &curwin->w_p_fdn)
8492 {
8493 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8494 foldUpdateAll(curwin);
8495 }
8496
8497 /* 'foldcolumn' */
8498 else if (pp == &curwin->w_p_fdc)
8499 {
8500 if (curwin->w_p_fdc < 0)
8501 {
8502 errmsg = e_positive;
8503 curwin->w_p_fdc = 0;
8504 }
8505 else if (curwin->w_p_fdc > 12)
8506 {
8507 errmsg = e_invarg;
8508 curwin->w_p_fdc = 12;
8509 }
8510 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008511#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008512
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008513#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008514 /* 'shiftwidth' or 'tabstop' */
8515 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8516 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008517# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008518 if (foldmethodIsIndent(curwin))
8519 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008520# endif
8521# ifdef FEAT_CINDENT
8522 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8523 * parse 'cinoptions'. */
8524 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8525 parse_cino(curbuf);
8526# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008527 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008528#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008529
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008530#ifdef FEAT_MBYTE
8531 /* 'maxcombine' */
8532 else if (pp == &p_mco)
8533 {
8534 if (p_mco > MAX_MCO)
8535 p_mco = MAX_MCO;
8536 else if (p_mco < 0)
8537 p_mco = 0;
8538 screenclear(); /* will re-allocate the screen */
8539 }
8540#endif
8541
Bram Moolenaar071d4272004-06-13 20:20:40 +00008542 else if (pp == &curbuf->b_p_iminsert)
8543 {
8544 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8545 {
8546 errmsg = e_invarg;
8547 curbuf->b_p_iminsert = B_IMODE_NONE;
8548 }
8549 p_iminsert = curbuf->b_p_iminsert;
8550 if (termcap_active) /* don't do this in the alternate screen */
8551 showmode();
8552#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8553 /* Show/unshow value of 'keymap' in status lines. */
8554 status_redraw_curbuf();
8555#endif
8556 }
8557
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008558 else if (pp == &p_window)
8559 {
8560 if (p_window < 1)
8561 p_window = 1;
8562 else if (p_window >= Rows)
8563 p_window = Rows - 1;
8564 }
8565
Bram Moolenaar071d4272004-06-13 20:20:40 +00008566 else if (pp == &curbuf->b_p_imsearch)
8567 {
8568 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8569 {
8570 errmsg = e_invarg;
8571 curbuf->b_p_imsearch = B_IMODE_NONE;
8572 }
8573 p_imsearch = curbuf->b_p_imsearch;
8574 }
8575
8576#ifdef FEAT_TITLE
8577 /* if 'titlelen' has changed, redraw the title */
8578 else if (pp == &p_titlelen)
8579 {
8580 if (p_titlelen < 0)
8581 {
8582 errmsg = e_positive;
8583 p_titlelen = 85;
8584 }
8585 if (starting != NO_SCREEN && old_value != p_titlelen)
8586 need_maketitle = TRUE;
8587 }
8588#endif
8589
8590 /* if p_ch changed value, change the command line height */
8591 else if (pp == &p_ch)
8592 {
8593 if (p_ch < 1)
8594 {
8595 errmsg = e_positive;
8596 p_ch = 1;
8597 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008598 if (p_ch > Rows - min_rows() + 1)
8599 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008600
8601 /* Only compute the new window layout when startup has been
8602 * completed. Otherwise the frame sizes may be wrong. */
8603 if (p_ch != old_value && full_screen
8604#ifdef FEAT_GUI
8605 && !gui.starting
8606#endif
8607 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008608 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008609 }
8610
8611 /* when 'updatecount' changes from zero to non-zero, open swap files */
8612 else if (pp == &p_uc)
8613 {
8614 if (p_uc < 0)
8615 {
8616 errmsg = e_positive;
8617 p_uc = 100;
8618 }
8619 if (p_uc && !old_value)
8620 ml_open_files();
8621 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008622#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008623 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008624 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008625 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008626 {
8627 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008628 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008629 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008630 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008631 {
8632 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008633 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008634 }
8635 }
8636#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008637#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008638 else if (pp == &p_mzq)
8639 mzvim_reset_timer();
8640#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008641
8642 /* sync undo before 'undolevels' changes */
8643 else if (pp == &p_ul)
8644 {
8645 /* use the old value, otherwise u_sync() may not work properly */
8646 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00008647 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008648 p_ul = value;
8649 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01008650 else if (pp == &curbuf->b_p_ul)
8651 {
8652 /* use the old value, otherwise u_sync() may not work properly */
8653 curbuf->b_p_ul = old_value;
8654 u_sync(TRUE);
8655 curbuf->b_p_ul = value;
8656 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008657
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008658#ifdef FEAT_LINEBREAK
8659 /* 'numberwidth' must be positive */
8660 else if (pp == &curwin->w_p_nuw)
8661 {
8662 if (curwin->w_p_nuw < 1)
8663 {
8664 errmsg = e_positive;
8665 curwin->w_p_nuw = 1;
8666 }
8667 if (curwin->w_p_nuw > 10)
8668 {
8669 errmsg = e_invarg;
8670 curwin->w_p_nuw = 10;
8671 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02008672 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008673 }
8674#endif
8675
Bram Moolenaar1a384422010-07-14 19:53:30 +02008676 else if (pp == &curbuf->b_p_tw)
8677 {
8678 if (curbuf->b_p_tw < 0)
8679 {
8680 errmsg = e_positive;
8681 curbuf->b_p_tw = 0;
8682 }
8683#ifdef FEAT_SYN_HL
8684# ifdef FEAT_WINDOWS
8685 {
8686 win_T *wp;
8687 tabpage_T *tp;
8688
8689 FOR_ALL_TAB_WINDOWS(tp, wp)
8690 check_colorcolumn(wp);
8691 }
8692# else
8693 check_colorcolumn(curwin);
8694# endif
8695#endif
8696 }
8697
Bram Moolenaar071d4272004-06-13 20:20:40 +00008698 /*
8699 * Check the bounds for numeric options here
8700 */
8701 if (Rows < min_rows() && full_screen)
8702 {
8703 if (errbuf != NULL)
8704 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008705 vim_snprintf((char *)errbuf, errbuflen,
8706 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00008707 errmsg = errbuf;
8708 }
8709 Rows = min_rows();
8710 }
8711 if (Columns < MIN_COLUMNS && full_screen)
8712 {
8713 if (errbuf != NULL)
8714 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008715 vim_snprintf((char *)errbuf, errbuflen,
8716 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008717 errmsg = errbuf;
8718 }
8719 Columns = MIN_COLUMNS;
8720 }
Bram Moolenaare057d402013-06-30 17:51:51 +02008721 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008722
8723#ifdef DJGPP
8724 /* avoid a crash by checking for a too large value of 'columns' */
8725 if (old_Columns != Columns && full_screen && term_console)
8726 mch_check_columns();
8727#endif
8728
8729 /*
8730 * If the screen (shell) height has been changed, assume it is the
8731 * physical screenheight.
8732 */
8733 if (old_Rows != Rows || old_Columns != Columns)
8734 {
8735 /* Changing the screen size is not allowed while updating the screen. */
8736 if (updating_screen)
8737 *pp = old_value;
8738 else if (full_screen
8739#ifdef FEAT_GUI
8740 && !gui.starting
8741#endif
8742 )
8743 set_shellsize((int)Columns, (int)Rows, TRUE);
8744 else
8745 {
8746 /* Postpone the resizing; check the size and cmdline position for
8747 * messages. */
8748 check_shellsize();
8749 if (cmdline_row > Rows - p_ch && Rows > p_ch)
8750 cmdline_row = Rows - p_ch;
8751 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00008752 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008753 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008754 }
8755
Bram Moolenaar071d4272004-06-13 20:20:40 +00008756 if (curbuf->b_p_ts <= 0)
8757 {
8758 errmsg = e_positive;
8759 curbuf->b_p_ts = 8;
8760 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008761 if (p_tm < 0)
8762 {
8763 errmsg = e_positive;
8764 p_tm = 0;
8765 }
8766 if ((curwin->w_p_scr <= 0
8767 || (curwin->w_p_scr > curwin->w_height
8768 && curwin->w_height > 0))
8769 && full_screen)
8770 {
8771 if (pp == &(curwin->w_p_scr))
8772 {
8773 if (curwin->w_p_scr != 0)
8774 errmsg = e_scroll;
8775 win_comp_scroll(curwin);
8776 }
8777 /* If 'scroll' became invalid because of a side effect silently adjust
8778 * it. */
8779 else if (curwin->w_p_scr <= 0)
8780 curwin->w_p_scr = 1;
8781 else /* curwin->w_p_scr > curwin->w_height */
8782 curwin->w_p_scr = curwin->w_height;
8783 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00008784 if (p_hi < 0)
8785 {
8786 errmsg = e_positive;
8787 p_hi = 0;
8788 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02008789 else if (p_hi > 10000)
8790 {
8791 errmsg = e_invarg;
8792 p_hi = 10000;
8793 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02008794 if (p_re < 0 || p_re > 2)
8795 {
8796 errmsg = e_invarg;
8797 p_re = 0;
8798 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008799 if (p_report < 0)
8800 {
8801 errmsg = e_positive;
8802 p_report = 1;
8803 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00008804 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008805 {
8806 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
8807 p_sj = Rows / 2;
8808 else
8809 {
8810 errmsg = e_scroll;
8811 p_sj = 1;
8812 }
8813 }
8814 if (p_so < 0 && full_screen)
8815 {
8816 errmsg = e_scroll;
8817 p_so = 0;
8818 }
8819 if (p_siso < 0 && full_screen)
8820 {
8821 errmsg = e_positive;
8822 p_siso = 0;
8823 }
8824#ifdef FEAT_CMDWIN
8825 if (p_cwh < 1)
8826 {
8827 errmsg = e_positive;
8828 p_cwh = 1;
8829 }
8830#endif
8831 if (p_ut < 0)
8832 {
8833 errmsg = e_positive;
8834 p_ut = 2000;
8835 }
8836 if (p_ss < 0)
8837 {
8838 errmsg = e_positive;
8839 p_ss = 0;
8840 }
8841
8842 /* May set global value for local option. */
8843 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8844 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
8845
8846 options[opt_idx].flags |= P_WAS_SET;
8847
Bram Moolenaar53744302015-07-17 17:38:22 +02008848#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8849 if (!starting && errmsg == NULL)
8850 {
8851 char_u buf_old[11], buf_new[11], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008852 vim_snprintf((char *)buf_old, 10, "%ld", old_value);
8853 vim_snprintf((char *)buf_new, 10, "%ld", value);
8854 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008855 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8856 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8857 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8858 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8859 reset_v_option_vars();
8860 }
8861#endif
8862
Bram Moolenaar071d4272004-06-13 20:20:40 +00008863 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008864 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008865 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008866 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008867 check_redraw(options[opt_idx].flags);
8868
8869 return errmsg;
8870}
8871
8872/*
8873 * Called after an option changed: check if something needs to be redrawn.
8874 */
8875 static void
8876check_redraw(flags)
8877 long_u flags;
8878{
8879 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008880 int doclear = (flags & P_RCLR) == P_RCLR;
8881 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008882
8883#ifdef FEAT_WINDOWS
8884 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
8885 status_redraw_all();
8886#endif
8887
8888 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
8889 changed_window_setting();
8890 if (flags & P_RBUF)
8891 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008892 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008893 redraw_all_later(CLEAR);
8894 else if (all)
8895 redraw_all_later(NOT_VALID);
8896}
8897
8898/*
8899 * Find index for option 'arg'.
8900 * Return -1 if not found.
8901 */
8902 static int
8903findoption(arg)
8904 char_u *arg;
8905{
8906 int opt_idx;
8907 char *s, *p;
8908 static short quick_tab[27] = {0, 0}; /* quick access table */
8909 int is_term_opt;
8910
8911 /*
8912 * For first call: Initialize the quick-access table.
8913 * It contains the index for the first option that starts with a certain
8914 * letter. There are 26 letters, plus the first "t_" option.
8915 */
8916 if (quick_tab[1] == 0)
8917 {
8918 p = options[0].fullname;
8919 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8920 {
8921 if (s[0] != p[0])
8922 {
8923 if (s[0] == 't' && s[1] == '_')
8924 quick_tab[26] = opt_idx;
8925 else
8926 quick_tab[CharOrdLow(s[0])] = opt_idx;
8927 }
8928 p = s;
8929 }
8930 }
8931
8932 /*
8933 * Check for name starting with an illegal character.
8934 */
8935#ifdef EBCDIC
8936 if (!islower(arg[0]))
8937#else
8938 if (arg[0] < 'a' || arg[0] > 'z')
8939#endif
8940 return -1;
8941
8942 is_term_opt = (arg[0] == 't' && arg[1] == '_');
8943 if (is_term_opt)
8944 opt_idx = quick_tab[26];
8945 else
8946 opt_idx = quick_tab[CharOrdLow(arg[0])];
8947 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8948 {
8949 if (STRCMP(arg, s) == 0) /* match full name */
8950 break;
8951 }
8952 if (s == NULL && !is_term_opt)
8953 {
8954 opt_idx = quick_tab[CharOrdLow(arg[0])];
8955 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
8956 {
8957 s = options[opt_idx].shortname;
8958 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
8959 break;
8960 s = NULL;
8961 }
8962 }
8963 if (s == NULL)
8964 opt_idx = -1;
8965 return opt_idx;
8966}
8967
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008968#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008969/*
8970 * Get the value for an option.
8971 *
8972 * Returns:
8973 * Number or Toggle option: 1, *numval gets value.
8974 * String option: 0, *stringval gets allocated string.
8975 * Hidden Number or Toggle option: -1.
8976 * hidden String option: -2.
8977 * unknown option: -3.
8978 */
8979 int
8980get_option_value(name, numval, stringval, opt_flags)
8981 char_u *name;
8982 long *numval;
Bram Moolenaar370df582010-06-22 05:16:38 +02008983 char_u **stringval; /* NULL when only checking existence */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008984 int opt_flags;
8985{
8986 int opt_idx;
8987 char_u *varp;
8988
8989 opt_idx = findoption(name);
8990 if (opt_idx < 0) /* unknown option */
8991 return -3;
8992
8993 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
8994
8995 if (options[opt_idx].flags & P_STRING)
8996 {
8997 if (varp == NULL) /* hidden option */
8998 return -2;
8999 if (stringval != NULL)
9000 {
9001#ifdef FEAT_CRYPT
9002 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00009003 if ((char_u **)varp == &curbuf->b_p_key
9004 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009005 *stringval = vim_strsave((char_u *)"*****");
9006 else
9007#endif
9008 *stringval = vim_strsave(*(char_u **)(varp));
9009 }
9010 return 0;
9011 }
9012
9013 if (varp == NULL) /* hidden option */
9014 return -1;
9015 if (options[opt_idx].flags & P_NUM)
9016 *numval = *(long *)varp;
9017 else
9018 {
9019 /* Special case: 'modified' is b_changed, but we also want to consider
9020 * it set when 'ff' or 'fenc' changed. */
9021 if ((int *)varp == &curbuf->b_changed)
9022 *numval = curbufIsChanged();
9023 else
9024 *numval = *(int *)varp;
9025 }
9026 return 1;
9027}
9028#endif
9029
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009030#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009031/*
9032 * Returns the option attributes and its value. Unlike the above function it
9033 * will return either global value or local value of the option depending on
9034 * what was requested, but it will never return global value if it was
9035 * requested to return local one and vice versa. Neither it will return
9036 * buffer-local value if it was requested to return window-local one.
9037 *
9038 * Pretends that option is absent if it is not present in the requested scope
9039 * (i.e. has no global, window-local or buffer-local value depending on
9040 * opt_type). Uses
9041 *
9042 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009043 * 0 hidden or unknown option, also option that does not have requested
9044 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009045 * see SOPT_* in vim.h for other flags
9046 *
9047 * Possible opt_type values: see SREQ_* in vim.h
9048 */
9049 int
9050get_option_value_strict(name, numval, stringval, opt_type, from)
9051 char_u *name;
9052 long *numval;
9053 char_u **stringval; /* NULL when only obtaining attributes */
9054 int opt_type;
9055 void *from;
9056{
9057 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009058 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009059 struct vimoption *p;
9060 int r = 0;
9061
9062 opt_idx = findoption(name);
9063 if (opt_idx < 0)
9064 return 0;
9065
9066 p = &(options[opt_idx]);
9067
9068 /* Hidden option */
9069 if (p->var == NULL)
9070 return 0;
9071
9072 if (p->flags & P_BOOL)
9073 r |= SOPT_BOOL;
9074 else if (p->flags & P_NUM)
9075 r |= SOPT_NUM;
9076 else if (p->flags & P_STRING)
9077 r |= SOPT_STRING;
9078
9079 if (p->indir == PV_NONE)
9080 {
9081 if (opt_type == SREQ_GLOBAL)
9082 r |= SOPT_GLOBAL;
9083 else
9084 return 0; /* Did not request global-only option */
9085 }
9086 else
9087 {
9088 if (p->indir & PV_BOTH)
9089 r |= SOPT_GLOBAL;
9090 else if (opt_type == SREQ_GLOBAL)
9091 return 0; /* Requested global option */
9092
9093 if (p->indir & PV_WIN)
9094 {
9095 if (opt_type == SREQ_BUF)
9096 return 0; /* Did not request window-local option */
9097 else
9098 r |= SOPT_WIN;
9099 }
9100 else if (p->indir & PV_BUF)
9101 {
9102 if (opt_type == SREQ_WIN)
9103 return 0; /* Did not request buffer-local option */
9104 else
9105 r |= SOPT_BUF;
9106 }
9107 }
9108
9109 if (stringval == NULL)
9110 return r;
9111
9112 if (opt_type == SREQ_GLOBAL)
9113 varp = p->var;
9114 else
9115 {
9116 if (opt_type == SREQ_BUF)
9117 {
9118 /* Special case: 'modified' is b_changed, but we also want to
9119 * consider it set when 'ff' or 'fenc' changed. */
9120 if (p->indir == PV_MOD)
9121 {
9122 *numval = bufIsChanged((buf_T *) from);
9123 varp = NULL;
9124 }
9125#ifdef FEAT_CRYPT
9126 else if (p->indir == PV_KEY)
9127 {
9128 /* never return the value of the crypt key */
9129 *stringval = NULL;
9130 varp = NULL;
9131 }
9132#endif
9133 else
9134 {
9135 aco_save_T aco;
9136 aucmd_prepbuf(&aco, (buf_T *) from);
9137 varp = get_varp(p);
9138 aucmd_restbuf(&aco);
9139 }
9140 }
9141 else if (opt_type == SREQ_WIN)
9142 {
9143 win_T *save_curwin;
9144 save_curwin = curwin;
9145 curwin = (win_T *) from;
9146 curbuf = curwin->w_buffer;
9147 varp = get_varp(p);
9148 curwin = save_curwin;
9149 curbuf = curwin->w_buffer;
9150 }
9151 if (varp == p->var)
9152 return (r | SOPT_UNSET);
9153 }
9154
9155 if (varp != NULL)
9156 {
9157 if (p->flags & P_STRING)
9158 *stringval = vim_strsave(*(char_u **)(varp));
9159 else if (p->flags & P_NUM)
9160 *numval = *(long *) varp;
9161 else
9162 *numval = *(int *)varp;
9163 }
9164
9165 return r;
9166}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009167
9168/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009169 * Iterate over options. First argument is a pointer to a pointer to a
9170 * structure inside options[] array, second is option type like in the above
9171 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009172 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009173 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009174 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009175 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009176 * first argument to NULL.
9177 *
9178 * Returns full option name for current option on each call.
9179 */
9180 char_u *
9181option_iter_next(option, opt_type)
9182 void **option;
9183 int opt_type;
9184{
9185 struct vimoption *ret = NULL;
9186 do
9187 {
9188 if (*option == NULL)
9189 *option = (void *) options;
9190 else if (((struct vimoption *) (*option))->fullname == NULL)
9191 {
9192 *option = NULL;
9193 return NULL;
9194 }
9195 else
9196 *option = (void *) (((struct vimoption *) (*option)) + 1);
9197
9198 ret = ((struct vimoption *) (*option));
9199
9200 /* Hidden option */
9201 if (ret->var == NULL)
9202 {
9203 ret = NULL;
9204 continue;
9205 }
9206
9207 switch (opt_type)
9208 {
9209 case SREQ_GLOBAL:
9210 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9211 ret = NULL;
9212 break;
9213 case SREQ_BUF:
9214 if (!(ret->indir & PV_BUF))
9215 ret = NULL;
9216 break;
9217 case SREQ_WIN:
9218 if (!(ret->indir & PV_WIN))
9219 ret = NULL;
9220 break;
9221 default:
9222 EMSG2(_(e_intern2), "option_iter_next()");
9223 return NULL;
9224 }
9225 }
9226 while (ret == NULL);
9227
9228 return (char_u *)ret->fullname;
9229}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009230#endif
9231
Bram Moolenaar071d4272004-06-13 20:20:40 +00009232/*
9233 * Set the value of option "name".
9234 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009235 *
9236 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009237 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009238 char_u *
Bram Moolenaar071d4272004-06-13 20:20:40 +00009239set_option_value(name, number, string, opt_flags)
9240 char_u *name;
9241 long number;
9242 char_u *string;
9243 int opt_flags; /* OPT_LOCAL or 0 (both) */
9244{
9245 int opt_idx;
9246 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009247 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009248
9249 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009250 if (opt_idx < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009251 EMSG2(_("E355: Unknown option: %s"), name);
9252 else
9253 {
9254 flags = options[opt_idx].flags;
9255#ifdef HAVE_SANDBOX
9256 /* Disallow changing some options in the sandbox */
9257 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009258 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009259 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009260 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009261 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009262#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009263 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009264 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009265 else
9266 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009267 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009268 if (varp != NULL) /* hidden option is not changed */
9269 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009270 if (number == 0 && string != NULL)
9271 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009272 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009273
9274 /* Either we are given a string or we are setting option
9275 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009276 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009277 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009278 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009279 {
9280 /* There's another character after zeros or the string
9281 * is empty. In both cases, we are trying to set a
9282 * num option using a string. */
9283 EMSG3(_("E521: Number required: &%s = '%s'"),
9284 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009285 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009286
9287 }
9288 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009289 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009290 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009291 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009292 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009293 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009294 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009295 }
9296 }
9297 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009298 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009299}
9300
9301/*
9302 * Get the terminal code for a terminal option.
9303 * Returns NULL when not found.
9304 */
9305 char_u *
9306get_term_code(tname)
9307 char_u *tname;
9308{
9309 int opt_idx;
9310 char_u *varp;
9311
9312 if (tname[0] != 't' || tname[1] != '_' ||
9313 tname[2] == NUL || tname[3] == NUL)
9314 return NULL;
9315 if ((opt_idx = findoption(tname)) >= 0)
9316 {
9317 varp = get_varp(&(options[opt_idx]));
9318 if (varp != NULL)
9319 varp = *(char_u **)(varp);
9320 return varp;
9321 }
9322 return find_termcode(tname + 2);
9323}
9324
9325 char_u *
9326get_highlight_default()
9327{
9328 int i;
9329
9330 i = findoption((char_u *)"hl");
9331 if (i >= 0)
9332 return options[i].def_val[VI_DEFAULT];
9333 return (char_u *)NULL;
9334}
9335
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009336#if defined(FEAT_MBYTE) || defined(PROTO)
9337 char_u *
9338get_encoding_default()
9339{
9340 int i;
9341
9342 i = findoption((char_u *)"enc");
9343 if (i >= 0)
9344 return options[i].def_val[VI_DEFAULT];
9345 return (char_u *)NULL;
9346}
9347#endif
9348
Bram Moolenaar071d4272004-06-13 20:20:40 +00009349/*
9350 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9351 */
9352 static int
9353find_key_option(arg)
9354 char_u *arg;
9355{
9356 int key;
9357 int modifiers;
9358
9359 /*
9360 * Don't use get_special_key_code() for t_xx, we don't want it to call
9361 * add_termcap_entry().
9362 */
9363 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9364 key = TERMCAP2KEY(arg[2], arg[3]);
9365 else
9366 {
9367 --arg; /* put arg at the '<' */
9368 modifiers = 0;
Bram Moolenaar2a8ced02008-12-24 11:54:31 +00009369 key = find_special_key(&arg, &modifiers, TRUE, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009370 if (modifiers) /* can't handle modifiers here */
9371 key = 0;
9372 }
9373 return key;
9374}
9375
9376/*
9377 * if 'all' == 0: show changed options
9378 * if 'all' == 1: show all normal options
9379 * if 'all' == 2: show all terminal options
9380 */
9381 static void
9382showoptions(all, opt_flags)
9383 int all;
9384 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
9385{
9386 struct vimoption *p;
9387 int col;
9388 int isterm;
9389 char_u *varp;
9390 struct vimoption **items;
9391 int item_count;
9392 int run;
9393 int row, rows;
9394 int cols;
9395 int i;
9396 int len;
9397
9398#define INC 20
9399#define GAP 3
9400
9401 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9402 PARAM_COUNT));
9403 if (items == NULL)
9404 return;
9405
9406 /* Highlight title */
9407 if (all == 2)
9408 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9409 else if (opt_flags & OPT_GLOBAL)
9410 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9411 else if (opt_flags & OPT_LOCAL)
9412 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9413 else
9414 MSG_PUTS_TITLE(_("\n--- Options ---"));
9415
9416 /*
9417 * do the loop two times:
9418 * 1. display the short items
9419 * 2. display the long items (only strings and numbers)
9420 */
9421 for (run = 1; run <= 2 && !got_int; ++run)
9422 {
9423 /*
9424 * collect the items in items[]
9425 */
9426 item_count = 0;
9427 for (p = &options[0]; p->fullname != NULL; p++)
9428 {
9429 varp = NULL;
9430 isterm = istermoption(p);
9431 if (opt_flags != 0)
9432 {
9433 if (p->indir != PV_NONE && !isterm)
9434 varp = get_varp_scope(p, opt_flags);
9435 }
9436 else
9437 varp = get_varp(p);
9438 if (varp != NULL
9439 && ((all == 2 && isterm)
9440 || (all == 1 && !isterm)
9441 || (all == 0 && !optval_default(p, varp))))
9442 {
9443 if (p->flags & P_BOOL)
9444 len = 1; /* a toggle option fits always */
9445 else
9446 {
9447 option_value2string(p, opt_flags);
9448 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9449 }
9450 if ((len <= INC - GAP && run == 1) ||
9451 (len > INC - GAP && run == 2))
9452 items[item_count++] = p;
9453 }
9454 }
9455
9456 /*
9457 * display the items
9458 */
9459 if (run == 1)
9460 {
9461 cols = (Columns + GAP - 3) / INC;
9462 if (cols == 0)
9463 cols = 1;
9464 rows = (item_count + cols - 1) / cols;
9465 }
9466 else /* run == 2 */
9467 rows = item_count;
9468 for (row = 0; row < rows && !got_int; ++row)
9469 {
9470 msg_putchar('\n'); /* go to next line */
9471 if (got_int) /* 'q' typed in more */
9472 break;
9473 col = 0;
9474 for (i = row; i < item_count; i += rows)
9475 {
9476 msg_col = col; /* make columns */
9477 showoneopt(items[i], opt_flags);
9478 col += INC;
9479 }
9480 out_flush();
9481 ui_breakcheck();
9482 }
9483 }
9484 vim_free(items);
9485}
9486
9487/*
9488 * Return TRUE if option "p" has its default value.
9489 */
9490 static int
9491optval_default(p, varp)
9492 struct vimoption *p;
9493 char_u *varp;
9494{
9495 int dvi;
9496
9497 if (varp == NULL)
9498 return TRUE; /* hidden option is always at default */
9499 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9500 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009501 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009502 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009503 /* the cast to long is required for Manx C, long_i is
9504 * needed for MSVC */
9505 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009506 /* P_STRING */
9507 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9508}
9509
9510/*
9511 * showoneopt: show the value of one option
9512 * must not be called with a hidden option!
9513 */
9514 static void
9515showoneopt(p, opt_flags)
9516 struct vimoption *p;
9517 int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */
9518{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009519 char_u *varp;
9520 int save_silent = silent_mode;
9521
9522 silent_mode = FALSE;
9523 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009524
9525 varp = get_varp_scope(p, opt_flags);
9526
9527 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9528 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9529 ? !curbufIsChanged() : !*(int *)varp))
9530 MSG_PUTS("no");
9531 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9532 MSG_PUTS("--");
9533 else
9534 MSG_PUTS(" ");
9535 MSG_PUTS(p->fullname);
9536 if (!(p->flags & P_BOOL))
9537 {
9538 msg_putchar('=');
9539 /* put value string in NameBuff */
9540 option_value2string(p, opt_flags);
9541 msg_outtrans(NameBuff);
9542 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009543
9544 silent_mode = save_silent;
9545 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009546}
9547
9548/*
9549 * Write modified options as ":set" commands to a file.
9550 *
9551 * There are three values for "opt_flags":
9552 * OPT_GLOBAL: Write global option values and fresh values of
9553 * buffer-local options (used for start of a session
9554 * file).
9555 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
9556 * curwin (used for a vimrc file).
9557 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
9558 * and local values for window-local options of
9559 * curwin. Local values are also written when at the
9560 * default value, because a modeline or autocommand
9561 * may have set them when doing ":edit file" and the
9562 * user has set them back at the default or fresh
9563 * value.
9564 * When "local_only" is TRUE, don't write fresh
9565 * values, only local values (for ":mkview").
9566 * (fresh value = value used for a new buffer or window for a local option).
9567 *
9568 * Return FAIL on error, OK otherwise.
9569 */
9570 int
9571makeset(fd, opt_flags, local_only)
9572 FILE *fd;
9573 int opt_flags;
9574 int local_only;
9575{
9576 struct vimoption *p;
9577 char_u *varp; /* currently used value */
9578 char_u *varp_fresh; /* local value */
9579 char_u *varp_local = NULL; /* fresh value */
9580 char *cmd;
9581 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009582 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009583
9584 /*
9585 * The options that don't have a default (terminal name, columns, lines)
9586 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009587 * Do the loop over "options[]" twice: once for options with the
9588 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009589 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009590 for (pri = 1; pri >= 0; --pri)
9591 {
9592 for (p = &options[0]; !istermoption(p); p++)
9593 if (!(p->flags & P_NO_MKRC)
9594 && !istermoption(p)
9595 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009596 {
9597 /* skip global option when only doing locals */
9598 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
9599 continue;
9600
9601 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
9602 * file, they are always buffer-specific. */
9603 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
9604 continue;
9605
9606 /* Global values are only written when not at the default value. */
9607 varp = get_varp_scope(p, opt_flags);
9608 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
9609 continue;
9610
9611 round = 2;
9612 if (p->indir != PV_NONE)
9613 {
9614 if (p->var == VAR_WIN)
9615 {
9616 /* skip window-local option when only doing globals */
9617 if (!(opt_flags & OPT_LOCAL))
9618 continue;
9619 /* When fresh value of window-local option is not at the
9620 * default, need to write it too. */
9621 if (!(opt_flags & OPT_GLOBAL) && !local_only)
9622 {
9623 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
9624 if (!optval_default(p, varp_fresh))
9625 {
9626 round = 1;
9627 varp_local = varp;
9628 varp = varp_fresh;
9629 }
9630 }
9631 }
9632 }
9633
9634 /* Round 1: fresh value for window-local options.
9635 * Round 2: other values */
9636 for ( ; round <= 2; varp = varp_local, ++round)
9637 {
9638 if (round == 1 || (opt_flags & OPT_GLOBAL))
9639 cmd = "set";
9640 else
9641 cmd = "setlocal";
9642
9643 if (p->flags & P_BOOL)
9644 {
9645 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
9646 return FAIL;
9647 }
9648 else if (p->flags & P_NUM)
9649 {
9650 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
9651 return FAIL;
9652 }
9653 else /* P_STRING */
9654 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009655#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9656 int do_endif = FALSE;
9657
Bram Moolenaar071d4272004-06-13 20:20:40 +00009658 /* Don't set 'syntax' and 'filetype' again if the value is
9659 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009660 if (
9661# if defined(FEAT_SYN_HL)
9662 p->indir == PV_SYN
9663# if defined(FEAT_AUTOCMD)
9664 ||
9665# endif
9666# endif
9667# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009668 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009669# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009670 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00009671 {
9672 if (fprintf(fd, "if &%s != '%s'", p->fullname,
9673 *(char_u **)(varp)) < 0
9674 || put_eol(fd) < 0)
9675 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009676 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009677 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009678#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009679 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
9680 (p->flags & P_EXPAND) != 0) == FAIL)
9681 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009682#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9683 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009684 {
9685 if (put_line(fd, "endif") == FAIL)
9686 return FAIL;
9687 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009688#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009689 }
9690 }
9691 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009692 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009693 return OK;
9694}
9695
9696#if defined(FEAT_FOLDING) || defined(PROTO)
9697/*
9698 * Generate set commands for the local fold options only. Used when
9699 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
9700 */
9701 int
9702makefoldset(fd)
9703 FILE *fd;
9704{
9705 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
9706# ifdef FEAT_EVAL
9707 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
9708 == FAIL
9709# endif
9710 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
9711 == FAIL
9712 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
9713 == FAIL
9714 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
9715 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
9716 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
9717 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
9718 )
9719 return FAIL;
9720
9721 return OK;
9722}
9723#endif
9724
9725 static int
9726put_setstring(fd, cmd, name, valuep, expand)
9727 FILE *fd;
9728 char *cmd;
9729 char *name;
9730 char_u **valuep;
9731 int expand;
9732{
9733 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009734 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009735
9736 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9737 return FAIL;
9738 if (*valuep != NULL)
9739 {
9740 /* Output 'pastetoggle' as key names. For other
9741 * options some characters have to be escaped with
9742 * CTRL-V or backslash */
9743 if (valuep == &p_pt)
9744 {
9745 s = *valuep;
9746 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +00009747 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009748 return FAIL;
9749 }
9750 else if (expand)
9751 {
Bram Moolenaarf8441472011-04-28 17:24:58 +02009752 buf = alloc(MAXPATHL);
9753 if (buf == NULL)
9754 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009755 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
9756 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +02009757 {
9758 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009759 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009760 }
9761 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009762 }
9763 else if (put_escstr(fd, *valuep, 2) == FAIL)
9764 return FAIL;
9765 }
9766 if (put_eol(fd) < 0)
9767 return FAIL;
9768 return OK;
9769}
9770
9771 static int
9772put_setnum(fd, cmd, name, valuep)
9773 FILE *fd;
9774 char *cmd;
9775 char *name;
9776 long *valuep;
9777{
9778 long wc;
9779
9780 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9781 return FAIL;
9782 if (wc_use_keyname((char_u *)valuep, &wc))
9783 {
9784 /* print 'wildchar' and 'wildcharm' as a key name */
9785 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
9786 return FAIL;
9787 }
9788 else if (fprintf(fd, "%ld", *valuep) < 0)
9789 return FAIL;
9790 if (put_eol(fd) < 0)
9791 return FAIL;
9792 return OK;
9793}
9794
9795 static int
9796put_setbool(fd, cmd, name, value)
9797 FILE *fd;
9798 char *cmd;
9799 char *name;
9800 int value;
9801{
Bram Moolenaar893de922007-10-02 18:40:57 +00009802 if (value < 0) /* global/local option using global value */
9803 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009804 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
9805 || put_eol(fd) < 0)
9806 return FAIL;
9807 return OK;
9808}
9809
9810/*
9811 * Clear all the terminal options.
9812 * If the option has been allocated, free the memory.
9813 * Terminal options are never hidden or indirect.
9814 */
9815 void
9816clear_termoptions()
9817{
Bram Moolenaar071d4272004-06-13 20:20:40 +00009818 /*
9819 * Reset a few things before clearing the old options. This may cause
9820 * outputting a few things that the terminal doesn't understand, but the
9821 * screen will be cleared later, so this is OK.
9822 */
9823#ifdef FEAT_MOUSE_TTY
9824 mch_setmouse(FALSE); /* switch mouse off */
9825#endif
9826#ifdef FEAT_TITLE
9827 mch_restore_title(3); /* restore window titles */
9828#endif
9829#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
9830 /* When starting the GUI close the display opened for the clipboard.
9831 * After restoring the title, because that will need the display. */
9832 if (gui.starting)
9833 clear_xterm_clip();
9834#endif
9835#ifdef WIN3264
9836 /*
9837 * Check if this is allowed now.
9838 */
9839 if (can_end_termcap_mode(FALSE) == TRUE)
9840#endif
9841 stoptermcap(); /* stop termcap mode */
9842
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00009843 free_termoptions();
9844}
9845
9846 void
9847free_termoptions()
9848{
9849 struct vimoption *p;
9850
Bram Moolenaar071d4272004-06-13 20:20:40 +00009851 for (p = &options[0]; p->fullname != NULL; p++)
9852 if (istermoption(p))
9853 {
9854 if (p->flags & P_ALLOCED)
9855 free_string_option(*(char_u **)(p->var));
9856 if (p->flags & P_DEF_ALLOCED)
9857 free_string_option(p->def_val[VI_DEFAULT]);
9858 *(char_u **)(p->var) = empty_option;
9859 p->def_val[VI_DEFAULT] = empty_option;
9860 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
9861 }
9862 clear_termcodes();
9863}
9864
9865/*
Bram Moolenaar363cb672009-07-22 12:28:17 +00009866 * Free the string for one term option, if it was allocated.
9867 * Set the string to empty_option and clear allocated flag.
9868 * "var" points to the option value.
9869 */
9870 void
9871free_one_termoption(var)
9872 char_u *var;
9873{
9874 struct vimoption *p;
9875
9876 for (p = &options[0]; p->fullname != NULL; p++)
9877 if (p->var == var)
9878 {
9879 if (p->flags & P_ALLOCED)
9880 free_string_option(*(char_u **)(p->var));
9881 *(char_u **)(p->var) = empty_option;
9882 p->flags &= ~P_ALLOCED;
9883 break;
9884 }
9885}
9886
9887/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00009888 * Set the terminal option defaults to the current value.
9889 * Used after setting the terminal name.
9890 */
9891 void
9892set_term_defaults()
9893{
9894 struct vimoption *p;
9895
9896 for (p = &options[0]; p->fullname != NULL; p++)
9897 {
9898 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
9899 {
9900 if (p->flags & P_DEF_ALLOCED)
9901 {
9902 free_string_option(p->def_val[VI_DEFAULT]);
9903 p->flags &= ~P_DEF_ALLOCED;
9904 }
9905 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
9906 if (p->flags & P_ALLOCED)
9907 {
9908 p->flags |= P_DEF_ALLOCED;
9909 p->flags &= ~P_ALLOCED; /* don't free the value now */
9910 }
9911 }
9912 }
9913}
9914
9915/*
9916 * return TRUE if 'p' starts with 't_'
9917 */
9918 static int
9919istermoption(p)
9920 struct vimoption *p;
9921{
9922 return (p->fullname[0] == 't' && p->fullname[1] == '_');
9923}
9924
9925/*
9926 * Compute columns for ruler and shown command. 'sc_col' is also used to
9927 * decide what the maximum length of a message on the status line can be.
9928 * If there is a status line for the last window, 'sc_col' is independent
9929 * of 'ru_col'.
9930 */
9931
9932#define COL_RULER 17 /* columns needed by standard ruler */
9933
9934 void
9935comp_col()
9936{
9937#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
9938 int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin));
9939
9940 sc_col = 0;
9941 ru_col = 0;
9942 if (p_ru)
9943 {
9944#ifdef FEAT_STL_OPT
9945 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
9946#else
9947 ru_col = COL_RULER + 1;
9948#endif
9949 /* no last status line, adjust sc_col */
9950 if (!last_has_status)
9951 sc_col = ru_col;
9952 }
9953 if (p_sc)
9954 {
9955 sc_col += SHOWCMD_COLS;
9956 if (!p_ru || last_has_status) /* no need for separating space */
9957 ++sc_col;
9958 }
9959 sc_col = Columns - sc_col;
9960 ru_col = Columns - ru_col;
9961 if (sc_col <= 0) /* screen too narrow, will become a mess */
9962 sc_col = 1;
9963 if (ru_col <= 0)
9964 ru_col = 1;
9965#else
9966 sc_col = Columns;
9967 ru_col = Columns;
9968#endif
9969}
9970
9971/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009972 * Unset local option value, similar to ":set opt<".
9973 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009974 void
9975unset_global_local_option(name, from)
9976 char_u *name;
9977 void *from;
9978{
9979 struct vimoption *p;
9980 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009981 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009982
9983 opt_idx = findoption(name);
9984 p = &(options[opt_idx]);
9985
9986 switch ((int)p->indir)
9987 {
9988 /* global option with local value: use local value if it's been set */
9989 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009990 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009991 break;
9992 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009993 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009994 break;
9995 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009996 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009997 break;
9998 case PV_AR:
9999 buf->b_p_ar = -1;
10000 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010001 case PV_BKC:
10002 clear_string_option(&buf->b_p_bkc);
10003 buf->b_bkc_flags = 0;
10004 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010005 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010006 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010007 break;
10008#ifdef FEAT_FIND_ID
10009 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010010 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010011 break;
10012 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010013 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010014 break;
10015#endif
10016#ifdef FEAT_INS_EXPAND
10017 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010018 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010019 break;
10020 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010021 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010022 break;
10023#endif
10024#ifdef FEAT_QUICKFIX
10025 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010026 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010027 break;
10028 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010029 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010030 break;
10031 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010032 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010033 break;
10034#endif
10035#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10036 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010037 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010038 break;
10039#endif
10040#if defined(FEAT_CRYPT)
10041 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010042 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010043 break;
10044#endif
10045#ifdef FEAT_STL_OPT
10046 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010047 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010048 break;
10049#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010050 case PV_UL:
10051 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10052 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010053#ifdef FEAT_LISP
10054 case PV_LW:
10055 clear_string_option(&buf->b_p_lw);
10056 break;
10057#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010058 }
10059}
10060
10061/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010062 * Get pointer to option variable, depending on local or global scope.
10063 */
10064 static char_u *
10065get_varp_scope(p, opt_flags)
10066 struct vimoption *p;
10067 int opt_flags;
10068{
10069 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10070 {
10071 if (p->var == VAR_WIN)
10072 return (char_u *)GLOBAL_WO(get_varp(p));
10073 return p->var;
10074 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010075 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010076 {
10077 switch ((int)p->indir)
10078 {
10079#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010080 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10081 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10082 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010083#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010084 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10085 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10086 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010087 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010088 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010089#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010090 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10091 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010092#endif
10093#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010094 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10095 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010096#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010097#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10098 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10099#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010100#if defined(FEAT_CRYPT)
10101 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10102#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010103#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010104 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010105#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010106 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010107#ifdef FEAT_LISP
10108 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10109#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010110 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010111 }
10112 return NULL; /* "cannot happen" */
10113 }
10114 return get_varp(p);
10115}
10116
10117/*
10118 * Get pointer to option variable.
10119 */
10120 static char_u *
10121get_varp(p)
10122 struct vimoption *p;
10123{
10124 /* hidden option, always return NULL */
10125 if (p->var == NULL)
10126 return NULL;
10127
10128 switch ((int)p->indir)
10129 {
10130 case PV_NONE: return p->var;
10131
10132 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010133 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010134 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010135 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010136 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010137 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010138 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010139 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010140 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010141 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010142 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010143 case PV_BKC: return *curbuf->b_p_bkc != NUL
10144 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010145#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010146 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010147 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010148 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010149 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10150#endif
10151#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010152 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010153 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010154 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010155 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10156#endif
10157#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010158 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010159 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010160 case PV_GP: return *curbuf->b_p_gp != NUL
10161 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10162 case PV_MP: return *curbuf->b_p_mp != NUL
10163 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010164#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010165#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10166 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10167 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10168#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010169#if defined(FEAT_CRYPT)
10170 case PV_CM: return *curbuf->b_p_cm != NUL
10171 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10172#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010173#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010174 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010175 ? (char_u *)&(curwin->w_p_stl) : p->var;
10176#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010177 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10178 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010179#ifdef FEAT_LISP
10180 case PV_LW: return *curbuf->b_p_lw != NUL
10181 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10182#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010183
10184#ifdef FEAT_ARABIC
10185 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10186#endif
10187 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010188#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010189 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10190#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010191#ifdef FEAT_SYN_HL
10192 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10193 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010194 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010195#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010196#ifdef FEAT_DIFF
10197 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10198#endif
10199#ifdef FEAT_FOLDING
10200 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10201 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10202 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10203 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10204 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10205 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10206 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10207# ifdef FEAT_EVAL
10208 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10209 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10210# endif
10211 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10212#endif
10213 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010214 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010215#ifdef FEAT_LINEBREAK
10216 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10217#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010218#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010219 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
10220#endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010221#ifdef FEAT_VERTSPLIT
10222 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10223#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010224#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10225 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10226#endif
10227#ifdef FEAT_RIGHTLEFT
10228 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10229 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10230#endif
10231 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10232 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10233#ifdef FEAT_LINEBREAK
10234 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010235 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10236 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010237#endif
10238#ifdef FEAT_SCROLLBIND
10239 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10240#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010241#ifdef FEAT_CURSORBIND
10242 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10243#endif
10244#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010245 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10246 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010247#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010248
10249 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10250 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10251#ifdef FEAT_MBYTE
10252 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10253#endif
10254#if defined(FEAT_QUICKFIX)
10255 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10256 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
10257#endif
10258 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10259 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10260#ifdef FEAT_CINDENT
10261 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10262 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10263 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10264#endif
10265#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10266 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10267#endif
10268#ifdef FEAT_COMMENTS
10269 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10270#endif
10271#ifdef FEAT_FOLDING
10272 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10273#endif
10274#ifdef FEAT_INS_EXPAND
10275 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10276#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010277#ifdef FEAT_COMPL_FUNC
10278 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010279 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010280#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010281 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010282 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010283 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10284#ifdef FEAT_MBYTE
10285 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10286#endif
10287 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10288#ifdef FEAT_AUTOCMD
10289 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10290#endif
10291 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010292 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010293 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10294 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10295 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10296 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10297#ifdef FEAT_FIND_ID
10298# ifdef FEAT_EVAL
10299 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10300# endif
10301#endif
10302#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10303 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10304 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10305#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010306#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010307 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10308#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010309#ifdef FEAT_CRYPT
10310 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10311#endif
10312#ifdef FEAT_LISP
10313 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10314#endif
10315 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10316 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10317 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10318 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10319 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010320 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010321#ifdef FEAT_TEXTOBJ
10322 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10323#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010324 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10325#ifdef FEAT_SMARTINDENT
10326 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10327#endif
10328#ifndef SHORT_FNAME
10329 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
10330#endif
10331 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10332#ifdef FEAT_SEARCHPATH
10333 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10334#endif
10335 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10336#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010337 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010338 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10339#endif
10340#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010341 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10342 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10343 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010344#endif
10345 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10346 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10347 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10348 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010349#ifdef FEAT_PERSISTENT_UNDO
10350 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10351#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010352 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10353#ifdef FEAT_KEYMAP
10354 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10355#endif
10356 default: EMSG(_("E356: get_varp ERROR"));
10357 }
10358 /* always return a valid pointer to avoid a crash! */
10359 return (char_u *)&(curbuf->b_p_wm);
10360}
10361
10362/*
10363 * Get the value of 'equalprg', either the buffer-local one or the global one.
10364 */
10365 char_u *
10366get_equalprg()
10367{
10368 if (*curbuf->b_p_ep == NUL)
10369 return p_ep;
10370 return curbuf->b_p_ep;
10371}
10372
10373#if defined(FEAT_WINDOWS) || defined(PROTO)
10374/*
10375 * Copy options from one window to another.
10376 * Used when splitting a window.
10377 */
10378 void
10379win_copy_options(wp_from, wp_to)
10380 win_T *wp_from;
10381 win_T *wp_to;
10382{
10383 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10384 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10385# ifdef FEAT_RIGHTLEFT
10386# ifdef FEAT_FKMAP
10387 /* Is this right? */
10388 wp_to->w_farsi = wp_from->w_farsi;
10389# endif
10390# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020010391#if defined(FEAT_LINEBREAK)
10392 briopt_check(wp_to);
10393#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010394}
10395#endif
10396
10397/*
10398 * Copy the options from one winopt_T to another.
10399 * Doesn't free the old option values in "to", use clear_winopt() for that.
10400 * The 'scroll' option is not copied, because it depends on the window height.
10401 * The 'previewwindow' option is reset, there can be only one preview window.
10402 */
10403 void
10404copy_winopt(from, to)
10405 winopt_T *from;
10406 winopt_T *to;
10407{
10408#ifdef FEAT_ARABIC
10409 to->wo_arab = from->wo_arab;
10410#endif
10411 to->wo_list = from->wo_list;
10412 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010413 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010414#ifdef FEAT_LINEBREAK
10415 to->wo_nuw = from->wo_nuw;
10416#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010417#ifdef FEAT_RIGHTLEFT
10418 to->wo_rl = from->wo_rl;
10419 to->wo_rlc = vim_strsave(from->wo_rlc);
10420#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010421#ifdef FEAT_STL_OPT
10422 to->wo_stl = vim_strsave(from->wo_stl);
10423#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010424 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010425#ifdef FEAT_DIFF
10426 to->wo_wrap_save = from->wo_wrap_save;
10427#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010428#ifdef FEAT_LINEBREAK
10429 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020010430 to->wo_bri = from->wo_bri;
10431 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010432#endif
10433#ifdef FEAT_SCROLLBIND
10434 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010435 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010436#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010437#ifdef FEAT_CURSORBIND
10438 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010439 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010440#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010441#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010442 to->wo_spell = from->wo_spell;
10443#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010444#ifdef FEAT_SYN_HL
10445 to->wo_cuc = from->wo_cuc;
10446 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010447 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010448#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010449#ifdef FEAT_DIFF
10450 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010451 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010452#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010453#ifdef FEAT_CONCEAL
10454 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010455 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010456#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010457#ifdef FEAT_FOLDING
10458 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010459 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010460 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010461 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010462 to->wo_fdi = vim_strsave(from->wo_fdi);
10463 to->wo_fml = from->wo_fml;
10464 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010465 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010466 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010467 to->wo_fdm_save = from->wo_diff_saved
10468 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010469 to->wo_fdn = from->wo_fdn;
10470# ifdef FEAT_EVAL
10471 to->wo_fde = vim_strsave(from->wo_fde);
10472 to->wo_fdt = vim_strsave(from->wo_fdt);
10473# endif
10474 to->wo_fmr = vim_strsave(from->wo_fmr);
10475#endif
10476 check_winopt(to); /* don't want NULL pointers */
10477}
10478
10479/*
10480 * Check string options in a window for a NULL value.
10481 */
10482 void
10483check_win_options(win)
10484 win_T *win;
10485{
10486 check_winopt(&win->w_onebuf_opt);
10487 check_winopt(&win->w_allbuf_opt);
10488}
10489
10490/*
10491 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10492 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020010493 static void
Bram Moolenaar071d4272004-06-13 20:20:40 +000010494check_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010495 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010496{
10497#ifdef FEAT_FOLDING
10498 check_string_option(&wop->wo_fdi);
10499 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010500 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010501# ifdef FEAT_EVAL
10502 check_string_option(&wop->wo_fde);
10503 check_string_option(&wop->wo_fdt);
10504# endif
10505 check_string_option(&wop->wo_fmr);
10506#endif
10507#ifdef FEAT_RIGHTLEFT
10508 check_string_option(&wop->wo_rlc);
10509#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010510#ifdef FEAT_STL_OPT
10511 check_string_option(&wop->wo_stl);
10512#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010513#ifdef FEAT_SYN_HL
10514 check_string_option(&wop->wo_cc);
10515#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010516#ifdef FEAT_CONCEAL
10517 check_string_option(&wop->wo_cocu);
10518#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010519#ifdef FEAT_LINEBREAK
10520 check_string_option(&wop->wo_briopt);
10521#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010522}
10523
10524/*
10525 * Free the allocated memory inside a winopt_T.
10526 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010527 void
10528clear_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010529 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010530{
10531#ifdef FEAT_FOLDING
10532 clear_string_option(&wop->wo_fdi);
10533 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010534 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010535# ifdef FEAT_EVAL
10536 clear_string_option(&wop->wo_fde);
10537 clear_string_option(&wop->wo_fdt);
10538# endif
10539 clear_string_option(&wop->wo_fmr);
10540#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010541#ifdef FEAT_LINEBREAK
10542 clear_string_option(&wop->wo_briopt);
10543#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010544#ifdef FEAT_RIGHTLEFT
10545 clear_string_option(&wop->wo_rlc);
10546#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010547#ifdef FEAT_STL_OPT
10548 clear_string_option(&wop->wo_stl);
10549#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010550#ifdef FEAT_SYN_HL
10551 clear_string_option(&wop->wo_cc);
10552#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010553#ifdef FEAT_CONCEAL
10554 clear_string_option(&wop->wo_cocu);
10555#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010556}
10557
10558/*
10559 * Copy global option values to local options for one buffer.
10560 * Used when creating a new buffer and sometimes when entering a buffer.
10561 * flags:
10562 * BCO_ENTER We will enter the buf buffer.
10563 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
10564 * appropriate.
10565 * BCO_NOHELP Don't copy the values to a help buffer.
10566 */
10567 void
10568buf_copy_options(buf, flags)
10569 buf_T *buf;
10570 int flags;
10571{
10572 int should_copy = TRUE;
10573 char_u *save_p_isk = NULL; /* init for GCC */
10574 int dont_do_help;
10575 int did_isk = FALSE;
10576
10577 /*
Bram Moolenaar1a384422010-07-14 19:53:30 +020010578 * Don't do anything if the buffer is invalid.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010579 */
10580 if (buf == NULL || !buf_valid(buf))
10581 return;
10582
10583 /*
10584 * Skip this when the option defaults have not been set yet. Happens when
10585 * main() allocates the first buffer.
10586 */
10587 if (p_cpo != NULL)
10588 {
10589 /*
10590 * Always copy when entering and 'cpo' contains 'S'.
10591 * Don't copy when already initialized.
10592 * Don't copy when 'cpo' contains 's' and not entering.
10593 * 'S' BCO_ENTER initialized 's' should_copy
10594 * yes yes X X TRUE
10595 * yes no yes X FALSE
10596 * no X yes X FALSE
10597 * X no no yes FALSE
10598 * X no no no TRUE
10599 * no yes no X TRUE
10600 */
10601 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
10602 && (buf->b_p_initialized
10603 || (!(flags & BCO_ENTER)
10604 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
10605 should_copy = FALSE;
10606
10607 if (should_copy || (flags & BCO_ALWAYS))
10608 {
10609 /* Don't copy the options specific to a help buffer when
10610 * BCO_NOHELP is given or the options were initialized already
10611 * (jumping back to a help file with CTRL-T or CTRL-O) */
10612 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
10613 || buf->b_p_initialized;
10614 if (dont_do_help) /* don't free b_p_isk */
10615 {
10616 save_p_isk = buf->b_p_isk;
10617 buf->b_p_isk = NULL;
10618 }
10619 /*
10620 * Always free the allocated strings.
10621 * If not already initialized, set 'readonly' and copy 'fileformat'.
10622 */
10623 if (!buf->b_p_initialized)
10624 {
10625 free_buf_options(buf, TRUE);
10626 buf->b_p_ro = FALSE; /* don't copy readonly */
10627 buf->b_p_tx = p_tx;
10628#ifdef FEAT_MBYTE
10629 buf->b_p_fenc = vim_strsave(p_fenc);
10630#endif
10631 buf->b_p_ff = vim_strsave(p_ff);
10632#if defined(FEAT_QUICKFIX)
10633 buf->b_p_bh = empty_option;
10634 buf->b_p_bt = empty_option;
10635#endif
10636 }
10637 else
10638 free_buf_options(buf, FALSE);
10639
10640 buf->b_p_ai = p_ai;
10641 buf->b_p_ai_nopaste = p_ai_nopaste;
10642 buf->b_p_sw = p_sw;
10643 buf->b_p_tw = p_tw;
10644 buf->b_p_tw_nopaste = p_tw_nopaste;
10645 buf->b_p_tw_nobin = p_tw_nobin;
10646 buf->b_p_wm = p_wm;
10647 buf->b_p_wm_nopaste = p_wm_nopaste;
10648 buf->b_p_wm_nobin = p_wm_nobin;
10649 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000010650#ifdef FEAT_MBYTE
10651 buf->b_p_bomb = p_bomb;
10652#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010653 buf->b_p_et = p_et;
10654 buf->b_p_et_nobin = p_et_nobin;
10655 buf->b_p_ml = p_ml;
10656 buf->b_p_ml_nobin = p_ml_nobin;
10657 buf->b_p_inf = p_inf;
10658 buf->b_p_swf = p_swf;
10659#ifdef FEAT_INS_EXPAND
10660 buf->b_p_cpt = vim_strsave(p_cpt);
10661#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010662#ifdef FEAT_COMPL_FUNC
10663 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010664 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010665#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010666 buf->b_p_sts = p_sts;
10667 buf->b_p_sts_nopaste = p_sts_nopaste;
10668#ifndef SHORT_FNAME
10669 buf->b_p_sn = p_sn;
10670#endif
10671#ifdef FEAT_COMMENTS
10672 buf->b_p_com = vim_strsave(p_com);
10673#endif
10674#ifdef FEAT_FOLDING
10675 buf->b_p_cms = vim_strsave(p_cms);
10676#endif
10677 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010678 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010679 buf->b_p_nf = vim_strsave(p_nf);
10680 buf->b_p_mps = vim_strsave(p_mps);
10681#ifdef FEAT_SMARTINDENT
10682 buf->b_p_si = p_si;
10683#endif
10684 buf->b_p_ci = p_ci;
10685#ifdef FEAT_CINDENT
10686 buf->b_p_cin = p_cin;
10687 buf->b_p_cink = vim_strsave(p_cink);
10688 buf->b_p_cino = vim_strsave(p_cino);
10689#endif
10690#ifdef FEAT_AUTOCMD
10691 /* Don't copy 'filetype', it must be detected */
10692 buf->b_p_ft = empty_option;
10693#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010694 buf->b_p_pi = p_pi;
10695#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10696 buf->b_p_cinw = vim_strsave(p_cinw);
10697#endif
10698#ifdef FEAT_LISP
10699 buf->b_p_lisp = p_lisp;
10700#endif
10701#ifdef FEAT_SYN_HL
10702 /* Don't copy 'syntax', it must be set */
10703 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010704 buf->b_p_smc = p_smc;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010705#endif
10706#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020010707 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010708 (void)compile_cap_prog(&buf->b_s);
10709 buf->b_s.b_p_spf = vim_strsave(p_spf);
10710 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010711#endif
10712#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10713 buf->b_p_inde = vim_strsave(p_inde);
10714 buf->b_p_indk = vim_strsave(p_indk);
10715#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010716#if defined(FEAT_EVAL)
10717 buf->b_p_fex = vim_strsave(p_fex);
10718#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010719#ifdef FEAT_CRYPT
10720 buf->b_p_key = vim_strsave(p_key);
10721#endif
10722#ifdef FEAT_SEARCHPATH
10723 buf->b_p_sua = vim_strsave(p_sua);
10724#endif
10725#ifdef FEAT_KEYMAP
10726 buf->b_p_keymap = vim_strsave(p_keymap);
10727 buf->b_kmap_state |= KEYMAP_INIT;
10728#endif
10729 /* This isn't really an option, but copying the langmap and IME
10730 * state from the current buffer is better than resetting it. */
10731 buf->b_p_iminsert = p_iminsert;
10732 buf->b_p_imsearch = p_imsearch;
10733
10734 /* options that are normally global but also have a local value
10735 * are not copied, start using the global value */
10736 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010737 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010738 buf->b_p_bkc = empty_option;
10739 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010740#ifdef FEAT_QUICKFIX
10741 buf->b_p_gp = empty_option;
10742 buf->b_p_mp = empty_option;
10743 buf->b_p_efm = empty_option;
10744#endif
10745 buf->b_p_ep = empty_option;
10746 buf->b_p_kp = empty_option;
10747 buf->b_p_path = empty_option;
10748 buf->b_p_tags = empty_option;
10749#ifdef FEAT_FIND_ID
10750 buf->b_p_def = empty_option;
10751 buf->b_p_inc = empty_option;
10752# ifdef FEAT_EVAL
10753 buf->b_p_inex = vim_strsave(p_inex);
10754# endif
10755#endif
10756#ifdef FEAT_INS_EXPAND
10757 buf->b_p_dict = empty_option;
10758 buf->b_p_tsr = empty_option;
10759#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010760#ifdef FEAT_TEXTOBJ
10761 buf->b_p_qe = vim_strsave(p_qe);
10762#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010763#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10764 buf->b_p_bexpr = empty_option;
10765#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010766#if defined(FEAT_CRYPT)
10767 buf->b_p_cm = empty_option;
10768#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010769#ifdef FEAT_PERSISTENT_UNDO
10770 buf->b_p_udf = p_udf;
10771#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010772#ifdef FEAT_LISP
10773 buf->b_p_lw = empty_option;
10774#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010775
10776 /*
10777 * Don't copy the options set by ex_help(), use the saved values,
10778 * when going from a help buffer to a non-help buffer.
10779 * Don't touch these at all when BCO_NOHELP is used and going from
10780 * or to a help buffer.
10781 */
10782 if (dont_do_help)
10783 buf->b_p_isk = save_p_isk;
10784 else
10785 {
10786 buf->b_p_isk = vim_strsave(p_isk);
10787 did_isk = TRUE;
10788 buf->b_p_ts = p_ts;
10789 buf->b_help = FALSE;
10790#ifdef FEAT_QUICKFIX
10791 if (buf->b_p_bt[0] == 'h')
10792 clear_string_option(&buf->b_p_bt);
10793#endif
10794 buf->b_p_ma = p_ma;
10795 }
10796 }
10797
10798 /*
10799 * When the options should be copied (ignoring BCO_ALWAYS), set the
10800 * flag that indicates that the options have been initialized.
10801 */
10802 if (should_copy)
10803 buf->b_p_initialized = TRUE;
10804 }
10805
10806 check_buf_options(buf); /* make sure we don't have NULLs */
10807 if (did_isk)
10808 (void)buf_init_chartab(buf, FALSE);
10809}
10810
10811/*
10812 * Reset the 'modifiable' option and its default value.
10813 */
10814 void
10815reset_modifiable()
10816{
10817 int opt_idx;
10818
10819 curbuf->b_p_ma = FALSE;
10820 p_ma = FALSE;
10821 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000010822 if (opt_idx >= 0)
10823 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010824}
10825
10826/*
10827 * Set the global value for 'iminsert' to the local value.
10828 */
10829 void
10830set_iminsert_global()
10831{
10832 p_iminsert = curbuf->b_p_iminsert;
10833}
10834
10835/*
10836 * Set the global value for 'imsearch' to the local value.
10837 */
10838 void
10839set_imsearch_global()
10840{
10841 p_imsearch = curbuf->b_p_imsearch;
10842}
10843
10844#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
10845static int expand_option_idx = -1;
10846static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
10847static int expand_option_flags = 0;
10848
10849 void
10850set_context_in_set_cmd(xp, arg, opt_flags)
10851 expand_T *xp;
10852 char_u *arg;
10853 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
10854{
10855 int nextchar;
10856 long_u flags = 0; /* init for GCC */
10857 int opt_idx = 0; /* init for GCC */
10858 char_u *p;
10859 char_u *s;
10860 int is_term_option = FALSE;
10861 int key;
10862
10863 expand_option_flags = opt_flags;
10864
10865 xp->xp_context = EXPAND_SETTINGS;
10866 if (*arg == NUL)
10867 {
10868 xp->xp_pattern = arg;
10869 return;
10870 }
10871 p = arg + STRLEN(arg) - 1;
10872 if (*p == ' ' && *(p - 1) != '\\')
10873 {
10874 xp->xp_pattern = p + 1;
10875 return;
10876 }
10877 while (p > arg)
10878 {
10879 s = p;
10880 /* count number of backslashes before ' ' or ',' */
10881 if (*p == ' ' || *p == ',')
10882 {
10883 while (s > arg && *(s - 1) == '\\')
10884 --s;
10885 }
10886 /* break at a space with an even number of backslashes */
10887 if (*p == ' ' && ((p - s) & 1) == 0)
10888 {
10889 ++p;
10890 break;
10891 }
10892 --p;
10893 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000010894 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010895 {
10896 xp->xp_context = EXPAND_BOOL_SETTINGS;
10897 p += 2;
10898 }
10899 if (STRNCMP(p, "inv", 3) == 0)
10900 {
10901 xp->xp_context = EXPAND_BOOL_SETTINGS;
10902 p += 3;
10903 }
10904 xp->xp_pattern = arg = p;
10905 if (*arg == '<')
10906 {
10907 while (*p != '>')
10908 if (*p++ == NUL) /* expand terminal option name */
10909 return;
10910 key = get_special_key_code(arg + 1);
10911 if (key == 0) /* unknown name */
10912 {
10913 xp->xp_context = EXPAND_NOTHING;
10914 return;
10915 }
10916 nextchar = *++p;
10917 is_term_option = TRUE;
10918 expand_option_name[2] = KEY2TERMCAP0(key);
10919 expand_option_name[3] = KEY2TERMCAP1(key);
10920 }
10921 else
10922 {
10923 if (p[0] == 't' && p[1] == '_')
10924 {
10925 p += 2;
10926 if (*p != NUL)
10927 ++p;
10928 if (*p == NUL)
10929 return; /* expand option name */
10930 nextchar = *++p;
10931 is_term_option = TRUE;
10932 expand_option_name[2] = p[-2];
10933 expand_option_name[3] = p[-1];
10934 }
10935 else
10936 {
10937 /* Allow * wildcard */
10938 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
10939 p++;
10940 if (*p == NUL)
10941 return;
10942 nextchar = *p;
10943 *p = NUL;
10944 opt_idx = findoption(arg);
10945 *p = nextchar;
10946 if (opt_idx == -1 || options[opt_idx].var == NULL)
10947 {
10948 xp->xp_context = EXPAND_NOTHING;
10949 return;
10950 }
10951 flags = options[opt_idx].flags;
10952 if (flags & P_BOOL)
10953 {
10954 xp->xp_context = EXPAND_NOTHING;
10955 return;
10956 }
10957 }
10958 }
10959 /* handle "-=" and "+=" */
10960 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
10961 {
10962 ++p;
10963 nextchar = '=';
10964 }
10965 if ((nextchar != '=' && nextchar != ':')
10966 || xp->xp_context == EXPAND_BOOL_SETTINGS)
10967 {
10968 xp->xp_context = EXPAND_UNSUCCESSFUL;
10969 return;
10970 }
10971 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
10972 {
10973 xp->xp_context = EXPAND_OLD_SETTING;
10974 if (is_term_option)
10975 expand_option_idx = -1;
10976 else
10977 expand_option_idx = opt_idx;
10978 xp->xp_pattern = p + 1;
10979 return;
10980 }
10981 xp->xp_context = EXPAND_NOTHING;
10982 if (is_term_option || (flags & P_NUM))
10983 return;
10984
10985 xp->xp_pattern = p + 1;
10986
10987 if (flags & P_EXPAND)
10988 {
10989 p = options[opt_idx].var;
10990 if (p == (char_u *)&p_bdir
10991 || p == (char_u *)&p_dir
10992 || p == (char_u *)&p_path
10993 || p == (char_u *)&p_rtp
10994#ifdef FEAT_SEARCHPATH
10995 || p == (char_u *)&p_cdpath
10996#endif
10997#ifdef FEAT_SESSION
10998 || p == (char_u *)&p_vdir
10999#endif
11000 )
11001 {
11002 xp->xp_context = EXPAND_DIRECTORIES;
11003 if (p == (char_u *)&p_path
11004#ifdef FEAT_SEARCHPATH
11005 || p == (char_u *)&p_cdpath
11006#endif
11007 )
11008 xp->xp_backslash = XP_BS_THREE;
11009 else
11010 xp->xp_backslash = XP_BS_ONE;
11011 }
11012 else
11013 {
11014 xp->xp_context = EXPAND_FILES;
11015 /* for 'tags' need three backslashes for a space */
11016 if (p == (char_u *)&p_tags)
11017 xp->xp_backslash = XP_BS_THREE;
11018 else
11019 xp->xp_backslash = XP_BS_ONE;
11020 }
11021 }
11022
11023 /* For an option that is a list of file names, find the start of the
11024 * last file name. */
11025 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11026 {
11027 /* count number of backslashes before ' ' or ',' */
11028 if (*p == ' ' || *p == ',')
11029 {
11030 s = p;
11031 while (s > xp->xp_pattern && *(s - 1) == '\\')
11032 --s;
11033 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11034 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11035 {
11036 xp->xp_pattern = p + 1;
11037 break;
11038 }
11039 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011040
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011041#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011042 /* for 'spellsuggest' start at "file:" */
11043 if (options[opt_idx].var == (char_u *)&p_sps
11044 && STRNCMP(p, "file:", 5) == 0)
11045 {
11046 xp->xp_pattern = p + 5;
11047 break;
11048 }
11049#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011050 }
11051
11052 return;
11053}
11054
11055 int
11056ExpandSettings(xp, regmatch, num_file, file)
11057 expand_T *xp;
11058 regmatch_T *regmatch;
11059 int *num_file;
11060 char_u ***file;
11061{
11062 int num_normal = 0; /* Nr of matching non-term-code settings */
11063 int num_term = 0; /* Nr of matching terminal code settings */
11064 int opt_idx;
11065 int match;
11066 int count = 0;
11067 char_u *str;
11068 int loop;
11069 int is_term_opt;
11070 char_u name_buf[MAX_KEY_NAME_LEN];
11071 static char *(names[]) = {"all", "termcap"};
11072 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11073
11074 /* do this loop twice:
11075 * loop == 0: count the number of matching options
11076 * loop == 1: copy the matching options into allocated memory
11077 */
11078 for (loop = 0; loop <= 1; ++loop)
11079 {
11080 regmatch->rm_ic = ic;
11081 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11082 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011083 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11084 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011085 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11086 {
11087 if (loop == 0)
11088 num_normal++;
11089 else
11090 (*file)[count++] = vim_strsave((char_u *)names[match]);
11091 }
11092 }
11093 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11094 opt_idx++)
11095 {
11096 if (options[opt_idx].var == NULL)
11097 continue;
11098 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11099 && !(options[opt_idx].flags & P_BOOL))
11100 continue;
11101 is_term_opt = istermoption(&options[opt_idx]);
11102 if (is_term_opt && num_normal > 0)
11103 continue;
11104 match = FALSE;
11105 if (vim_regexec(regmatch, str, (colnr_T)0)
11106 || (options[opt_idx].shortname != NULL
11107 && vim_regexec(regmatch,
11108 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11109 match = TRUE;
11110 else if (is_term_opt)
11111 {
11112 name_buf[0] = '<';
11113 name_buf[1] = 't';
11114 name_buf[2] = '_';
11115 name_buf[3] = str[2];
11116 name_buf[4] = str[3];
11117 name_buf[5] = '>';
11118 name_buf[6] = NUL;
11119 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11120 {
11121 match = TRUE;
11122 str = name_buf;
11123 }
11124 }
11125 if (match)
11126 {
11127 if (loop == 0)
11128 {
11129 if (is_term_opt)
11130 num_term++;
11131 else
11132 num_normal++;
11133 }
11134 else
11135 (*file)[count++] = vim_strsave(str);
11136 }
11137 }
11138 /*
11139 * Check terminal key codes, these are not in the option table
11140 */
11141 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11142 {
11143 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11144 {
11145 if (!isprint(str[0]) || !isprint(str[1]))
11146 continue;
11147
11148 name_buf[0] = 't';
11149 name_buf[1] = '_';
11150 name_buf[2] = str[0];
11151 name_buf[3] = str[1];
11152 name_buf[4] = NUL;
11153
11154 match = FALSE;
11155 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11156 match = TRUE;
11157 else
11158 {
11159 name_buf[0] = '<';
11160 name_buf[1] = 't';
11161 name_buf[2] = '_';
11162 name_buf[3] = str[0];
11163 name_buf[4] = str[1];
11164 name_buf[5] = '>';
11165 name_buf[6] = NUL;
11166
11167 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11168 match = TRUE;
11169 }
11170 if (match)
11171 {
11172 if (loop == 0)
11173 num_term++;
11174 else
11175 (*file)[count++] = vim_strsave(name_buf);
11176 }
11177 }
11178
11179 /*
11180 * Check special key names.
11181 */
11182 regmatch->rm_ic = TRUE; /* ignore case here */
11183 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11184 {
11185 name_buf[0] = '<';
11186 STRCPY(name_buf + 1, str);
11187 STRCAT(name_buf, ">");
11188
11189 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11190 {
11191 if (loop == 0)
11192 num_term++;
11193 else
11194 (*file)[count++] = vim_strsave(name_buf);
11195 }
11196 }
11197 }
11198 if (loop == 0)
11199 {
11200 if (num_normal > 0)
11201 *num_file = num_normal;
11202 else if (num_term > 0)
11203 *num_file = num_term;
11204 else
11205 return OK;
11206 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11207 if (*file == NULL)
11208 {
11209 *file = (char_u **)"";
11210 return FAIL;
11211 }
11212 }
11213 }
11214 return OK;
11215}
11216
11217 int
11218ExpandOldSetting(num_file, file)
11219 int *num_file;
11220 char_u ***file;
11221{
11222 char_u *var = NULL; /* init for GCC */
11223 char_u *buf;
11224
11225 *num_file = 0;
11226 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11227 if (*file == NULL)
11228 return FAIL;
11229
11230 /*
11231 * For a terminal key code expand_option_idx is < 0.
11232 */
11233 if (expand_option_idx < 0)
11234 {
11235 var = find_termcode(expand_option_name + 2);
11236 if (var == NULL)
11237 expand_option_idx = findoption(expand_option_name);
11238 }
11239
11240 if (expand_option_idx >= 0)
11241 {
11242 /* put string of option value in NameBuff */
11243 option_value2string(&options[expand_option_idx], expand_option_flags);
11244 var = NameBuff;
11245 }
11246 else if (var == NULL)
11247 var = (char_u *)"";
11248
11249 /* A backslash is required before some characters. This is the reverse of
11250 * what happens in do_set(). */
11251 buf = vim_strsave_escaped(var, escape_chars);
11252
11253 if (buf == NULL)
11254 {
11255 vim_free(*file);
11256 *file = NULL;
11257 return FAIL;
11258 }
11259
11260#ifdef BACKSLASH_IN_FILENAME
11261 /* For MS-Windows et al. we don't double backslashes at the start and
11262 * before a file name character. */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011263 for (var = buf; *var != NUL; mb_ptr_adv(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011264 if (var[0] == '\\' && var[1] == '\\'
11265 && expand_option_idx >= 0
11266 && (options[expand_option_idx].flags & P_EXPAND)
11267 && vim_isfilec(var[2])
11268 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011269 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011270#endif
11271
11272 *file[0] = buf;
11273 *num_file = 1;
11274 return OK;
11275}
11276#endif
11277
11278/*
11279 * Get the value for the numeric or string option *opp in a nice format into
11280 * NameBuff[]. Must not be called with a hidden option!
11281 */
11282 static void
11283option_value2string(opp, opt_flags)
11284 struct vimoption *opp;
11285 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
11286{
11287 char_u *varp;
11288
11289 varp = get_varp_scope(opp, opt_flags);
11290
11291 if (opp->flags & P_NUM)
11292 {
11293 long wc = 0;
11294
11295 if (wc_use_keyname(varp, &wc))
11296 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11297 else if (wc != 0)
11298 STRCPY(NameBuff, transchar((int)wc));
11299 else
11300 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11301 }
11302 else /* P_STRING */
11303 {
11304 varp = *(char_u **)(varp);
11305 if (varp == NULL) /* just in case */
11306 NameBuff[0] = NUL;
11307#ifdef FEAT_CRYPT
11308 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011309 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011310 STRCPY(NameBuff, "*****");
11311#endif
11312 else if (opp->flags & P_EXPAND)
11313 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11314 /* Translate 'pastetoggle' into special key names */
11315 else if ((char_u **)opp->var == &p_pt)
11316 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11317 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011318 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011319 }
11320}
11321
11322/*
11323 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11324 * printed as a keyname.
11325 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11326 */
11327 static int
11328wc_use_keyname(varp, wcp)
11329 char_u *varp;
11330 long *wcp;
11331{
11332 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11333 {
11334 *wcp = *(long *)varp;
11335 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11336 return TRUE;
11337 }
11338 return FALSE;
11339}
11340
Bram Moolenaar01615492015-02-03 13:00:38 +010011341#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011342/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011343 * Any character has an equivalent 'langmap' character. This is used for
11344 * keyboards that have a special language mode that sends characters above
11345 * 128 (although other characters can be translated too). The "to" field is a
11346 * Vim command character. This avoids having to switch the keyboard back to
11347 * ASCII mode when leaving Insert mode.
11348 *
11349 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11350 * commands.
11351 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11352 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11353 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011354 */
Bram Moolenaar01615492015-02-03 13:00:38 +010011355# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011356/*
11357 * With multi-byte support use growarray for 'langmap' chars >= 256
11358 */
11359typedef struct
11360{
11361 int from;
11362 int to;
11363} langmap_entry_T;
11364
11365static garray_T langmap_mapga;
11366static void langmap_set_entry __ARGS((int from, int to));
Bram Moolenaar071d4272004-06-13 20:20:40 +000011367
11368/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011369 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11370 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011371 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011372 static void
11373langmap_set_entry(from, to)
11374 int from;
11375 int to;
11376{
11377 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011378 int a = 0;
11379 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011380
11381 /* Do a binary search for an existing entry. */
11382 while (a != b)
11383 {
11384 int i = (a + b) / 2;
11385 int d = entries[i].from - from;
11386
11387 if (d == 0)
11388 {
11389 entries[i].to = to;
11390 return;
11391 }
11392 if (d < 0)
11393 a = i + 1;
11394 else
11395 b = i;
11396 }
11397
11398 if (ga_grow(&langmap_mapga, 1) != OK)
11399 return; /* out of memory */
11400
11401 /* insert new entry at position "a" */
11402 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11403 mch_memmove(entries + 1, entries,
11404 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11405 ++langmap_mapga.ga_len;
11406 entries[0].from = from;
11407 entries[0].to = to;
11408}
11409
11410/*
11411 * Apply 'langmap' to multi-byte character "c" and return the result.
11412 */
11413 int
11414langmap_adjust_mb(c)
11415 int c;
11416{
11417 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11418 int a = 0;
11419 int b = langmap_mapga.ga_len;
11420
11421 while (a != b)
11422 {
11423 int i = (a + b) / 2;
11424 int d = entries[i].from - c;
11425
11426 if (d == 0)
11427 return entries[i].to; /* found matching entry */
11428 if (d < 0)
11429 a = i + 1;
11430 else
11431 b = i;
11432 }
11433 return c; /* no entry found, return "c" unmodified */
11434}
11435# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011436
11437 static void
11438langmap_init()
11439{
11440 int i;
11441
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011442 for (i = 0; i < 256; i++)
11443 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11444# ifdef FEAT_MBYTE
11445 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11446# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011447}
11448
11449/*
11450 * Called when langmap option is set; the language map can be
11451 * changed at any time!
11452 */
11453 static void
11454langmap_set()
11455{
11456 char_u *p;
11457 char_u *p2;
11458 int from, to;
11459
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011460#ifdef FEAT_MBYTE
11461 ga_clear(&langmap_mapga); /* clear the previous map first */
11462#endif
11463 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011464
11465 for (p = p_langmap; p[0] != NUL; )
11466 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011467 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
11468 mb_ptr_adv(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011469 {
11470 if (p2[0] == '\\' && p2[1] != NUL)
11471 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011472 }
11473 if (p2[0] == ';')
11474 ++p2; /* abcd;ABCD form, p2 points to A */
11475 else
11476 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11477 while (p[0])
11478 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011479 if (p[0] == ',')
11480 {
11481 ++p;
11482 break;
11483 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011484 if (p[0] == '\\' && p[1] != NUL)
11485 ++p;
11486#ifdef FEAT_MBYTE
11487 from = (*mb_ptr2char)(p);
11488#else
11489 from = p[0];
11490#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011491 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011492 if (p2 == NULL)
11493 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011494 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011495 if (p[0] != ',')
11496 {
11497 if (p[0] == '\\')
11498 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011499#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011500 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011501#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011502 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011503#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011504 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011505 }
11506 else
11507 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011508 if (p2[0] != ',')
11509 {
11510 if (p2[0] == '\\')
11511 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011512#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011513 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011514#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011515 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011516#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011517 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011518 }
11519 if (to == NUL)
11520 {
11521 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
11522 transchar(from));
11523 return;
11524 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011525
11526#ifdef FEAT_MBYTE
11527 if (from >= 256)
11528 langmap_set_entry(from, to);
11529 else
11530#endif
11531 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011532
11533 /* Advance to next pair */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011534 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011535 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011536 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011537 mb_ptr_adv(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011538 if (*p == ';')
11539 {
11540 p = p2;
11541 if (p[0] != NUL)
11542 {
11543 if (p[0] != ',')
11544 {
11545 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
11546 return;
11547 }
11548 ++p;
11549 }
11550 break;
11551 }
11552 }
11553 }
11554 }
11555}
11556#endif
11557
11558/*
11559 * Return TRUE if format option 'x' is in effect.
11560 * Take care of no formatting when 'paste' is set.
11561 */
11562 int
11563has_format_option(x)
11564 int x;
11565{
11566 if (p_paste)
11567 return FALSE;
11568 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
11569}
11570
11571/*
11572 * Return TRUE if "x" is present in 'shortmess' option, or
11573 * 'shortmess' contains 'a' and "x" is present in SHM_A.
11574 */
11575 int
11576shortmess(x)
11577 int x;
11578{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010011579 return p_shm != NULL &&
11580 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000011581 || (vim_strchr(p_shm, 'a') != NULL
11582 && vim_strchr((char_u *)SHM_A, x) != NULL));
11583}
11584
11585/*
11586 * paste_option_changed() - Called after p_paste was set or reset.
11587 */
11588 static void
11589paste_option_changed()
11590{
11591 static int old_p_paste = FALSE;
11592 static int save_sm = 0;
11593#ifdef FEAT_CMDL_INFO
11594 static int save_ru = 0;
11595#endif
11596#ifdef FEAT_RIGHTLEFT
11597 static int save_ri = 0;
11598 static int save_hkmap = 0;
11599#endif
11600 buf_T *buf;
11601
11602 if (p_paste)
11603 {
11604 /*
11605 * Paste switched from off to on.
11606 * Save the current values, so they can be restored later.
11607 */
11608 if (!old_p_paste)
11609 {
11610 /* save options for each buffer */
11611 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11612 {
11613 buf->b_p_tw_nopaste = buf->b_p_tw;
11614 buf->b_p_wm_nopaste = buf->b_p_wm;
11615 buf->b_p_sts_nopaste = buf->b_p_sts;
11616 buf->b_p_ai_nopaste = buf->b_p_ai;
11617 }
11618
11619 /* save global options */
11620 save_sm = p_sm;
11621#ifdef FEAT_CMDL_INFO
11622 save_ru = p_ru;
11623#endif
11624#ifdef FEAT_RIGHTLEFT
11625 save_ri = p_ri;
11626 save_hkmap = p_hkmap;
11627#endif
11628 /* save global values for local buffer options */
11629 p_tw_nopaste = p_tw;
11630 p_wm_nopaste = p_wm;
11631 p_sts_nopaste = p_sts;
11632 p_ai_nopaste = p_ai;
11633 }
11634
11635 /*
11636 * Always set the option values, also when 'paste' is set when it is
11637 * already on.
11638 */
11639 /* set options for each buffer */
11640 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11641 {
11642 buf->b_p_tw = 0; /* textwidth is 0 */
11643 buf->b_p_wm = 0; /* wrapmargin is 0 */
11644 buf->b_p_sts = 0; /* softtabstop is 0 */
11645 buf->b_p_ai = 0; /* no auto-indent */
11646 }
11647
11648 /* set global options */
11649 p_sm = 0; /* no showmatch */
11650#ifdef FEAT_CMDL_INFO
11651# ifdef FEAT_WINDOWS
11652 if (p_ru)
11653 status_redraw_all(); /* redraw to remove the ruler */
11654# endif
11655 p_ru = 0; /* no ruler */
11656#endif
11657#ifdef FEAT_RIGHTLEFT
11658 p_ri = 0; /* no reverse insert */
11659 p_hkmap = 0; /* no Hebrew keyboard */
11660#endif
11661 /* set global values for local buffer options */
11662 p_tw = 0;
11663 p_wm = 0;
11664 p_sts = 0;
11665 p_ai = 0;
11666 }
11667
11668 /*
11669 * Paste switched from on to off: Restore saved values.
11670 */
11671 else if (old_p_paste)
11672 {
11673 /* restore options for each buffer */
11674 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11675 {
11676 buf->b_p_tw = buf->b_p_tw_nopaste;
11677 buf->b_p_wm = buf->b_p_wm_nopaste;
11678 buf->b_p_sts = buf->b_p_sts_nopaste;
11679 buf->b_p_ai = buf->b_p_ai_nopaste;
11680 }
11681
11682 /* restore global options */
11683 p_sm = save_sm;
11684#ifdef FEAT_CMDL_INFO
11685# ifdef FEAT_WINDOWS
11686 if (p_ru != save_ru)
11687 status_redraw_all(); /* redraw to draw the ruler */
11688# endif
11689 p_ru = save_ru;
11690#endif
11691#ifdef FEAT_RIGHTLEFT
11692 p_ri = save_ri;
11693 p_hkmap = save_hkmap;
11694#endif
11695 /* set global values for local buffer options */
11696 p_tw = p_tw_nopaste;
11697 p_wm = p_wm_nopaste;
11698 p_sts = p_sts_nopaste;
11699 p_ai = p_ai_nopaste;
11700 }
11701
11702 old_p_paste = p_paste;
11703}
11704
11705/*
11706 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
11707 *
11708 * Reset 'compatible' and set the values for options that didn't get set yet
11709 * to the Vim defaults.
11710 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011711 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011712 */
11713 void
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011714vimrc_found(fname, envname)
11715 char_u *fname;
11716 char_u *envname;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011717{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011718 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000011719 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011720 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011721
11722 if (!option_was_set((char_u *)"cp"))
11723 {
11724 p_cp = FALSE;
11725 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11726 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
11727 set_option_default(opt_idx, OPT_FREE, FALSE);
11728 didset_options();
11729 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011730
11731 if (fname != NULL)
11732 {
11733 p = vim_getenv(envname, &dofree);
11734 if (p == NULL)
11735 {
11736 /* Set $MYVIMRC to the first vimrc file found. */
11737 p = FullName_save(fname, FALSE);
11738 if (p != NULL)
11739 {
11740 vim_setenv(envname, p);
11741 vim_free(p);
11742 }
11743 }
11744 else if (dofree)
11745 vim_free(p);
11746 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011747}
11748
11749/*
11750 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
11751 */
11752 void
11753change_compatible(on)
11754 int on;
11755{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011756 int opt_idx;
11757
Bram Moolenaar071d4272004-06-13 20:20:40 +000011758 if (p_cp != on)
11759 {
11760 p_cp = on;
11761 compatible_set();
11762 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011763 opt_idx = findoption((char_u *)"cp");
11764 if (opt_idx >= 0)
11765 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011766}
11767
11768/*
11769 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020011770 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011771 */
11772 int
11773option_was_set(name)
11774 char_u *name;
11775{
11776 int idx;
11777
11778 idx = findoption(name);
11779 if (idx < 0) /* unknown option */
11780 return FALSE;
11781 if (options[idx].flags & P_WAS_SET)
11782 return TRUE;
11783 return FALSE;
11784}
11785
11786/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010011787 * Reset the flag indicating option "name" was set.
11788 */
11789 void
11790reset_option_was_set(name)
11791 char_u *name;
11792{
11793 int idx = findoption(name);
11794
11795 if (idx >= 0)
11796 options[idx].flags &= ~P_WAS_SET;
11797}
11798
11799/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011800 * compatible_set() - Called when 'compatible' has been set or unset.
11801 *
11802 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
11803 * flag) to a Vi compatible value.
11804 * When 'compatible' is unset: Set all options that have a different default
11805 * for Vim (without the P_VI_DEF flag) to that default.
11806 */
11807 static void
11808compatible_set()
11809{
11810 int opt_idx;
11811
11812 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11813 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
11814 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
11815 set_option_default(opt_idx, OPT_FREE, p_cp);
11816 didset_options();
11817}
11818
11819#ifdef FEAT_LINEBREAK
11820
11821# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
11822 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011823 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011824# endif
11825
11826/*
11827 * fill_breakat_flags() -- called when 'breakat' changes value.
11828 */
11829 static void
11830fill_breakat_flags()
11831{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011832 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011833 int i;
11834
11835 for (i = 0; i < 256; i++)
11836 breakat_flags[i] = FALSE;
11837
11838 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011839 for (p = p_breakat; *p; p++)
11840 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011841}
11842
11843# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011844 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011845# endif
11846
11847#endif
11848
11849/*
11850 * Check an option that can be a range of string values.
11851 *
11852 * Return OK for correct value, FAIL otherwise.
11853 * Empty is always OK.
11854 */
11855 static int
11856check_opt_strings(val, values, list)
11857 char_u *val;
11858 char **values;
11859 int list; /* when TRUE: accept a list of values */
11860{
11861 return opt_strings_flags(val, values, NULL, list);
11862}
11863
11864/*
11865 * Handle an option that can be a range of string values.
11866 * Set a flag in "*flagp" for each string present.
11867 *
11868 * Return OK for correct value, FAIL otherwise.
11869 * Empty is always OK.
11870 */
11871 static int
11872opt_strings_flags(val, values, flagp, list)
11873 char_u *val; /* new value */
11874 char **values; /* array of valid string values */
11875 unsigned *flagp;
11876 int list; /* when TRUE: accept a list of values */
11877{
11878 int i;
11879 int len;
11880 unsigned new_flags = 0;
11881
11882 while (*val)
11883 {
11884 for (i = 0; ; ++i)
11885 {
11886 if (values[i] == NULL) /* val not found in values[] */
11887 return FAIL;
11888
11889 len = (int)STRLEN(values[i]);
11890 if (STRNCMP(values[i], val, len) == 0
11891 && ((list && val[len] == ',') || val[len] == NUL))
11892 {
11893 val += len + (val[len] == ',');
11894 new_flags |= (1 << i);
11895 break; /* check next item in val list */
11896 }
11897 }
11898 }
11899 if (flagp != NULL)
11900 *flagp = new_flags;
11901
11902 return OK;
11903}
11904
11905/*
11906 * Read the 'wildmode' option, fill wim_flags[].
11907 */
11908 static int
11909check_opt_wim()
11910{
11911 char_u new_wim_flags[4];
11912 char_u *p;
11913 int i;
11914 int idx = 0;
11915
11916 for (i = 0; i < 4; ++i)
11917 new_wim_flags[i] = 0;
11918
11919 for (p = p_wim; *p; ++p)
11920 {
11921 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
11922 ;
11923 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
11924 return FAIL;
11925 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
11926 new_wim_flags[idx] |= WIM_LONGEST;
11927 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
11928 new_wim_flags[idx] |= WIM_FULL;
11929 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
11930 new_wim_flags[idx] |= WIM_LIST;
11931 else
11932 return FAIL;
11933 p += i;
11934 if (*p == NUL)
11935 break;
11936 if (*p == ',')
11937 {
11938 if (idx == 3)
11939 return FAIL;
11940 ++idx;
11941 }
11942 }
11943
11944 /* fill remaining entries with last flag */
11945 while (idx < 3)
11946 {
11947 new_wim_flags[idx + 1] = new_wim_flags[idx];
11948 ++idx;
11949 }
11950
11951 /* only when there are no errors, wim_flags[] is changed */
11952 for (i = 0; i < 4; ++i)
11953 wim_flags[i] = new_wim_flags[i];
11954 return OK;
11955}
11956
11957/*
11958 * Check if backspacing over something is allowed.
11959 */
11960 int
11961can_bs(what)
11962 int what; /* BS_INDENT, BS_EOL or BS_START */
11963{
11964 switch (*p_bs)
11965 {
11966 case '2': return TRUE;
11967 case '1': return (what != BS_START);
11968 case '0': return FALSE;
11969 }
11970 return vim_strchr(p_bs, what) != NULL;
11971}
11972
11973/*
11974 * Save the current values of 'fileformat' and 'fileencoding', so that we know
11975 * the file must be considered changed when the value is different.
11976 */
11977 void
11978save_file_ff(buf)
11979 buf_T *buf;
11980{
11981 buf->b_start_ffc = *buf->b_p_ff;
11982 buf->b_start_eol = buf->b_p_eol;
11983#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011984 buf->b_start_bomb = buf->b_p_bomb;
11985
Bram Moolenaar071d4272004-06-13 20:20:40 +000011986 /* Only use free/alloc when necessary, they take time. */
11987 if (buf->b_start_fenc == NULL
11988 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
11989 {
11990 vim_free(buf->b_start_fenc);
11991 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
11992 }
11993#endif
11994}
11995
11996/*
11997 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
11998 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011999 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
12000 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012001 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012002 * When "ignore_empty" is true don't consider a new, empty buffer to be
12003 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012004 */
12005 int
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012006file_ff_differs(buf, ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012007 buf_T *buf;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012008 int ignore_empty;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012009{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012010 /* In a buffer that was never loaded the options are not valid. */
12011 if (buf->b_flags & BF_NEVERLOADED)
12012 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012013 if (ignore_empty
12014 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012015 && buf->b_ml.ml_line_count == 1
12016 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12017 return FALSE;
12018 if (buf->b_start_ffc != *buf->b_p_ff)
12019 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012020 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012021 return TRUE;
12022#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012023 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12024 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012025 if (buf->b_start_fenc == NULL)
12026 return (*buf->b_p_fenc != NUL);
12027 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12028#else
12029 return FALSE;
12030#endif
12031}
12032
12033/*
12034 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12035 */
12036 int
12037check_ff_value(p)
12038 char_u *p;
12039{
12040 return check_opt_strings(p, p_ff_values, FALSE);
12041}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012042
12043/*
12044 * Return the effective shiftwidth value for current buffer, using the
12045 * 'tabstop' value when 'shiftwidth' is zero.
12046 */
12047 long
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012048get_sw_value(buf)
12049 buf_T *buf;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012050{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012051 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012052}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012053
12054/*
12055 * Return the effective softtabstop value for the current buffer, using the
12056 * 'tabstop' value when 'softtabstop' is negative.
12057 */
12058 long
12059get_sts_value()
12060{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012061 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012062}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012063
12064/*
12065 * Check matchpairs option for "*initc".
12066 * If there is a match set "*initc" to the matching character and "*findc" to
12067 * the opposite character. Set "*backwards" to the direction.
12068 * When "switchit" is TRUE swap the direction.
12069 */
12070 void
12071find_mps_values(initc, findc, backwards, switchit)
12072 int *initc;
12073 int *findc;
12074 int *backwards;
12075 int switchit;
12076{
12077 char_u *ptr;
12078
12079 ptr = curbuf->b_p_mps;
12080 while (*ptr != NUL)
12081 {
12082#ifdef FEAT_MBYTE
12083 if (has_mbyte)
12084 {
12085 char_u *prev;
12086
12087 if (mb_ptr2char(ptr) == *initc)
12088 {
12089 if (switchit)
12090 {
12091 *findc = *initc;
12092 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12093 *backwards = TRUE;
12094 }
12095 else
12096 {
12097 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12098 *backwards = FALSE;
12099 }
12100 return;
12101 }
12102 prev = ptr;
12103 ptr += mb_ptr2len(ptr) + 1;
12104 if (mb_ptr2char(ptr) == *initc)
12105 {
12106 if (switchit)
12107 {
12108 *findc = *initc;
12109 *initc = mb_ptr2char(prev);
12110 *backwards = FALSE;
12111 }
12112 else
12113 {
12114 *findc = mb_ptr2char(prev);
12115 *backwards = TRUE;
12116 }
12117 return;
12118 }
12119 ptr += mb_ptr2len(ptr);
12120 }
12121 else
12122#endif
12123 {
12124 if (*ptr == *initc)
12125 {
12126 if (switchit)
12127 {
12128 *backwards = TRUE;
12129 *findc = *initc;
12130 *initc = ptr[2];
12131 }
12132 else
12133 {
12134 *backwards = FALSE;
12135 *findc = ptr[2];
12136 }
12137 return;
12138 }
12139 ptr += 2;
12140 if (*ptr == *initc)
12141 {
12142 if (switchit)
12143 {
12144 *backwards = FALSE;
12145 *findc = *initc;
12146 *initc = ptr[-2];
12147 }
12148 else
12149 {
12150 *backwards = TRUE;
12151 *findc = ptr[-2];
12152 }
12153 return;
12154 }
12155 ++ptr;
12156 }
12157 if (*ptr == ',')
12158 ++ptr;
12159 }
12160}
Bram Moolenaar597a4222014-06-25 14:39:50 +020012161
12162#if defined(FEAT_LINEBREAK) || defined(PROTO)
12163/*
12164 * This is called when 'breakindentopt' is changed and when a window is
12165 * initialized.
12166 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012167 static int
12168briopt_check(wp)
12169 win_T *wp;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012170{
12171 char_u *p;
12172 int bri_shift = 0;
12173 long bri_min = 20;
12174 int bri_sbr = FALSE;
12175
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012176 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012177 while (*p != NUL)
12178 {
12179 if (STRNCMP(p, "shift:", 6) == 0
12180 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
12181 {
12182 p += 6;
12183 bri_shift = getdigits(&p);
12184 }
12185 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
12186 {
12187 p += 4;
12188 bri_min = getdigits(&p);
12189 }
12190 else if (STRNCMP(p, "sbr", 3) == 0)
12191 {
12192 p += 3;
12193 bri_sbr = TRUE;
12194 }
12195 if (*p != ',' && *p != NUL)
12196 return FAIL;
12197 if (*p == ',')
12198 ++p;
12199 }
12200
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012201 wp->w_p_brishift = bri_shift;
12202 wp->w_p_brimin = bri_min;
12203 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012204
12205 return OK;
12206}
12207#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012208
12209/*
12210 * Get the local or global value of 'backupcopy'.
12211 */
12212 unsigned int
12213get_bkc_value(buf)
12214 buf_T *buf;
12215{
12216 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
12217}