blob: f0d1996a2d080a9e8f5f7b45c0d88c9b9abeefff [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 Moolenaar165bc692015-07-21 17:53:25 +0200635 {"belloff", "bo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
636 (char_u *)&p_bo, PV_NONE,
637 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000638 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
639 (char_u *)&p_bin, PV_BIN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000640 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000641 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
642#ifdef MSDOS
643 (char_u *)&p_biosk, PV_NONE,
644#else
645 (char_u *)NULL, PV_NONE,
646#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000647 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000648 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
649#ifdef FEAT_MBYTE
650 (char_u *)&p_bomb, PV_BOMB,
651#else
652 (char_u *)NULL, PV_NONE,
653#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000654 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000655 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
656#ifdef FEAT_LINEBREAK
657 (char_u *)&p_breakat, PV_NONE,
658 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
659#else
660 (char_u *)NULL, PV_NONE,
661 {(char_u *)0L, (char_u *)0L}
662#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000663 SCRIPTID_INIT},
Bram Moolenaar597a4222014-06-25 14:39:50 +0200664 {"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
665#ifdef FEAT_LINEBREAK
666 (char_u *)VAR_WIN, PV_BRI,
667 {(char_u *)FALSE, (char_u *)0L}
668#else
669 (char_u *)NULL, PV_NONE,
670 {(char_u *)0L, (char_u *)0L}
671#endif
672 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200673 {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF
674 |P_ONECOMMA|P_NODUP,
Bram Moolenaar597a4222014-06-25 14:39:50 +0200675#ifdef FEAT_LINEBREAK
676 (char_u *)VAR_WIN, PV_BRIOPT,
677 {(char_u *)"", (char_u *)NULL}
678#else
679 (char_u *)NULL, PV_NONE,
680 {(char_u *)"", (char_u *)NULL}
681#endif
682 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000683 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
684#ifdef FEAT_BROWSE
685 (char_u *)&p_bsdir, PV_NONE,
686 {(char_u *)"last", (char_u *)0L}
687#else
688 (char_u *)NULL, PV_NONE,
689 {(char_u *)0L, (char_u *)0L}
690#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000691 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000692 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
693#if defined(FEAT_QUICKFIX)
694 (char_u *)&p_bh, PV_BH,
695 {(char_u *)"", (char_u *)0L}
696#else
697 (char_u *)NULL, PV_NONE,
698 {(char_u *)0L, (char_u *)0L}
699#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000700 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000701 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
702 (char_u *)&p_bl, PV_BL,
703 {(char_u *)1L, (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000704 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000705 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
706#if defined(FEAT_QUICKFIX)
707 (char_u *)&p_bt, PV_BT,
708 {(char_u *)"", (char_u *)0L}
709#else
710 (char_u *)NULL, PV_NONE,
711 {(char_u *)0L, (char_u *)0L}
712#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000713 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200714 {"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000715#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000716 (char_u *)&p_cmp, PV_NONE,
717 {(char_u *)"internal,keepascii", (char_u *)0L}
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000718#else
719 (char_u *)NULL, PV_NONE,
720 {(char_u *)0L, (char_u *)0L}
721#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000722 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000723 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
724#ifdef FEAT_SEARCHPATH
725 (char_u *)&p_cdpath, PV_NONE,
726 {(char_u *)",,", (char_u *)0L}
727#else
728 (char_u *)NULL, PV_NONE,
729 {(char_u *)0L, (char_u *)0L}
730#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000731 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000732 {"cedit", NULL, P_STRING,
733#ifdef FEAT_CMDWIN
734 (char_u *)&p_cedit, PV_NONE,
735 {(char_u *)"", (char_u *)CTRL_F_STR}
736#else
737 (char_u *)NULL, PV_NONE,
738 {(char_u *)0L, (char_u *)0L}
739#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000740 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000741 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
742#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
743 (char_u *)&p_ccv, PV_NONE,
744 {(char_u *)"", (char_u *)0L}
745#else
746 (char_u *)NULL, PV_NONE,
747 {(char_u *)0L, (char_u *)0L}
748#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000749 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000750 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
751#ifdef FEAT_CINDENT
752 (char_u *)&p_cin, PV_CIN,
753#else
754 (char_u *)NULL, PV_NONE,
755#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000756 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200757 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000758#ifdef FEAT_CINDENT
759 (char_u *)&p_cink, PV_CINK,
760 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
761#else
762 (char_u *)NULL, PV_NONE,
763 {(char_u *)0L, (char_u *)0L}
764#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000765 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200766 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000767#ifdef FEAT_CINDENT
768 (char_u *)&p_cino, PV_CINO,
769#else
770 (char_u *)NULL, PV_NONE,
771#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000772 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200773 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000774#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
775 (char_u *)&p_cinw, PV_CINW,
776 {(char_u *)"if,else,while,do,for,switch",
777 (char_u *)0L}
778#else
779 (char_u *)NULL, PV_NONE,
780 {(char_u *)0L, (char_u *)0L}
781#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000782 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200783 {"clipboard", "cb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000784#ifdef FEAT_CLIPBOARD
785 (char_u *)&p_cb, PV_NONE,
786# ifdef FEAT_XCLIPBOARD
787 {(char_u *)"autoselect,exclude:cons\\|linux",
788 (char_u *)0L}
789# else
790 {(char_u *)"", (char_u *)0L}
791# endif
792#else
793 (char_u *)NULL, PV_NONE,
794 {(char_u *)"", (char_u *)0L}
795#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000796 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000797 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
798 (char_u *)&p_ch, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000799 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000800 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
801#ifdef FEAT_CMDWIN
802 (char_u *)&p_cwh, PV_NONE,
803#else
804 (char_u *)NULL, PV_NONE,
805#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000806 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200807 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar1a384422010-07-14 19:53:30 +0200808#ifdef FEAT_SYN_HL
809 (char_u *)VAR_WIN, PV_CC,
810#else
811 (char_u *)NULL, PV_NONE,
812#endif
813 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000814 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
815 (char_u *)&Columns, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000816 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200817 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
818 |P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000819#ifdef FEAT_COMMENTS
820 (char_u *)&p_com, PV_COM,
821 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
822 (char_u *)0L}
823#else
824 (char_u *)NULL, PV_NONE,
825 {(char_u *)0L, (char_u *)0L}
826#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000827 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200828 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000829#ifdef FEAT_FOLDING
830 (char_u *)&p_cms, PV_CMS,
831 {(char_u *)"/*%s*/", (char_u *)0L}
832#else
833 (char_u *)NULL, PV_NONE,
834 {(char_u *)0L, (char_u *)0L}
835#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000836 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000837 /* P_PRI_MKRC isn't needed here, optval_default()
838 * always returns TRUE for 'compatible' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000839 {"compatible", "cp", P_BOOL|P_RALL,
840 (char_u *)&p_cp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000841 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200842 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000843#ifdef FEAT_INS_EXPAND
844 (char_u *)&p_cpt, PV_CPT,
845 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
846#else
847 (char_u *)NULL, PV_NONE,
848 {(char_u *)0L, (char_u *)0L}
849#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000850 SCRIPTID_INIT},
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200851 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200852#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200853 (char_u *)VAR_WIN, PV_COCU,
854 {(char_u *)"", (char_u *)NULL}
855#else
856 (char_u *)NULL, PV_NONE,
857 {(char_u *)NULL, (char_u *)0L}
858#endif
859 SCRIPTID_INIT},
860 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
861#ifdef FEAT_CONCEAL
862 (char_u *)VAR_WIN, PV_COLE,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200863#else
864 (char_u *)NULL, PV_NONE,
865#endif
866 {(char_u *)0L, (char_u *)0L}
867 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000868 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
869#ifdef FEAT_COMPL_FUNC
870 (char_u *)&p_cfu, PV_CFU,
871 {(char_u *)"", (char_u *)0L}
872#else
873 (char_u *)NULL, PV_NONE,
874 {(char_u *)0L, (char_u *)0L}
875#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000876 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200877 {"completeopt", "cot", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000878#ifdef FEAT_INS_EXPAND
879 (char_u *)&p_cot, PV_NONE,
Bram Moolenaarc270d802006-03-11 21:29:41 +0000880 {(char_u *)"menu,preview", (char_u *)0L}
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000881#else
882 (char_u *)NULL, PV_NONE,
883 {(char_u *)0L, (char_u *)0L}
884#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000885 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000886 {"confirm", "cf", P_BOOL|P_VI_DEF,
887#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
888 (char_u *)&p_confirm, PV_NONE,
889#else
890 (char_u *)NULL, PV_NONE,
891#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000892 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000893 {"conskey", "consk",P_BOOL|P_VI_DEF,
894#ifdef MSDOS
895 (char_u *)&p_consk, PV_NONE,
896#else
897 (char_u *)NULL, PV_NONE,
898#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000899 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000900 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
901 (char_u *)&p_ci, PV_CI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000902 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000903 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
904 (char_u *)&p_cpo, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000905 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
906 SCRIPTID_INIT},
Bram Moolenaar49771f42010-07-20 17:32:38 +0200907 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200908#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200909 (char_u *)&p_cm, PV_CM,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200910 {(char_u *)"zip", (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200911#else
912 (char_u *)NULL, PV_NONE,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200913 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200914#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +0200915 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000916 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
917#ifdef FEAT_CSCOPE
918 (char_u *)&p_cspc, PV_NONE,
919#else
920 (char_u *)NULL, PV_NONE,
921#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000922 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000923 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
924#ifdef FEAT_CSCOPE
925 (char_u *)&p_csprg, PV_NONE,
926 {(char_u *)"cscope", (char_u *)0L}
927#else
928 (char_u *)NULL, PV_NONE,
929 {(char_u *)0L, (char_u *)0L}
930#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000931 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200932 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000933#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
934 (char_u *)&p_csqf, PV_NONE,
935 {(char_u *)"", (char_u *)0L}
936#else
937 (char_u *)NULL, PV_NONE,
938 {(char_u *)0L, (char_u *)0L}
939#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000940 SCRIPTID_INIT},
Bram Moolenaarf7befa92011-06-12 22:13:40 +0200941 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM,
942#ifdef FEAT_CSCOPE
943 (char_u *)&p_csre, PV_NONE,
944#else
945 (char_u *)NULL, PV_NONE,
946#endif
947 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000948 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
949#ifdef FEAT_CSCOPE
950 (char_u *)&p_cst, PV_NONE,
951#else
952 (char_u *)NULL, PV_NONE,
953#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000954 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000955 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
956#ifdef FEAT_CSCOPE
957 (char_u *)&p_csto, PV_NONE,
958#else
959 (char_u *)NULL, PV_NONE,
960#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000961 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000962 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
963#ifdef FEAT_CSCOPE
964 (char_u *)&p_csverbose, PV_NONE,
965#else
966 (char_u *)NULL, PV_NONE,
967#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000968 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200969 {"cursorbind", "crb", P_BOOL|P_VI_DEF,
970#ifdef FEAT_CURSORBIND
971 (char_u *)VAR_WIN, PV_CRBIND,
972#else
973 (char_u *)NULL, PV_NONE,
974#endif
975 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000976 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
977#ifdef FEAT_SYN_HL
978 (char_u *)VAR_WIN, PV_CUC,
979#else
980 (char_u *)NULL, PV_NONE,
981#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000982 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000983 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWIN,
984#ifdef FEAT_SYN_HL
985 (char_u *)VAR_WIN, PV_CUL,
986#else
987 (char_u *)NULL, PV_NONE,
988#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000989 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000990 {"debug", NULL, P_STRING|P_VI_DEF,
991 (char_u *)&p_debug, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000992 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200993 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000994#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000995 (char_u *)&p_def, PV_DEF,
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000996 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000997#else
998 (char_u *)NULL, PV_NONE,
999 {(char_u *)NULL, (char_u *)0L}
1000#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001001 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001002 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
1003#ifdef FEAT_MBYTE
1004 (char_u *)&p_deco, PV_NONE,
1005#else
1006 (char_u *)NULL, PV_NONE,
1007#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001008 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001009 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001010#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001011 (char_u *)&p_dict, PV_DICT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001012#else
1013 (char_u *)NULL, PV_NONE,
1014#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001015 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001016 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
1017#ifdef FEAT_DIFF
1018 (char_u *)VAR_WIN, PV_DIFF,
1019#else
1020 (char_u *)NULL, PV_NONE,
1021#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001022 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001023 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001024#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1025 (char_u *)&p_dex, PV_NONE,
1026 {(char_u *)"", (char_u *)0L}
1027#else
1028 (char_u *)NULL, PV_NONE,
1029 {(char_u *)0L, (char_u *)0L}
1030#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001031 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001032 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_ONECOMMA
1033 |P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001034#ifdef FEAT_DIFF
1035 (char_u *)&p_dip, PV_NONE,
1036 {(char_u *)"filler", (char_u *)NULL}
1037#else
1038 (char_u *)NULL, PV_NONE,
1039 {(char_u *)"", (char_u *)NULL}
1040#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001041 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001042 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
1043#ifdef FEAT_DIGRAPHS
1044 (char_u *)&p_dg, PV_NONE,
1045#else
1046 (char_u *)NULL, PV_NONE,
1047#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001048 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001049 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
1050 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001051 (char_u *)&p_dir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001052 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001053 {"display", "dy", P_STRING|P_VI_DEF|P_ONECOMMA|P_RALL|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001054 (char_u *)&p_dy, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001055 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001056 {"eadirection", "ead", P_STRING|P_VI_DEF,
1057#ifdef FEAT_VERTSPLIT
1058 (char_u *)&p_ead, PV_NONE,
1059 {(char_u *)"both", (char_u *)0L}
1060#else
1061 (char_u *)NULL, PV_NONE,
1062 {(char_u *)NULL, (char_u *)0L}
1063#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001064 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001065 {"edcompatible","ed", P_BOOL|P_VI_DEF,
1066 (char_u *)&p_ed, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001067 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar865242e2010-07-14 21:12:05 +02001068 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001069#ifdef FEAT_MBYTE
1070 (char_u *)&p_enc, PV_NONE,
1071 {(char_u *)ENC_DFLT, (char_u *)0L}
1072#else
1073 (char_u *)NULL, PV_NONE,
1074 {(char_u *)0L, (char_u *)0L}
1075#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001076 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001077 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1078 (char_u *)&p_eol, PV_EOL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001079 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001080 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1081 (char_u *)&p_ea, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001082 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001083 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001084 (char_u *)&p_ep, PV_EP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001085 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001086 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1087 (char_u *)&p_eb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001088 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001089 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1090#ifdef FEAT_QUICKFIX
1091 (char_u *)&p_ef, PV_NONE,
1092 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1093#else
1094 (char_u *)NULL, PV_NONE,
1095 {(char_u *)NULL, (char_u *)0L}
1096#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001097 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001098 {"errorformat", "efm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001099#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001100 (char_u *)&p_efm, PV_EFM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001101 {(char_u *)DFLT_EFM, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001102#else
1103 (char_u *)NULL, PV_NONE,
1104 {(char_u *)NULL, (char_u *)0L}
1105#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001106 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001107 {"esckeys", "ek", P_BOOL|P_VIM,
1108 (char_u *)&p_ek, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001109 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001110 {"eventignore", "ei", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001111#ifdef FEAT_AUTOCMD
1112 (char_u *)&p_ei, PV_NONE,
1113#else
1114 (char_u *)NULL, PV_NONE,
1115#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001116 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001117 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1118 (char_u *)&p_et, PV_ET,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001119 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001120 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1121 (char_u *)&p_exrc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001122 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001123 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF
1124 |P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001125#ifdef FEAT_MBYTE
1126 (char_u *)&p_fenc, PV_FENC,
1127 {(char_u *)"", (char_u *)0L}
1128#else
1129 (char_u *)NULL, PV_NONE,
1130 {(char_u *)0L, (char_u *)0L}
1131#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001132 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001133 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001134#ifdef FEAT_MBYTE
1135 (char_u *)&p_fencs, PV_NONE,
1136 {(char_u *)"ucs-bom", (char_u *)0L}
1137#else
1138 (char_u *)NULL, PV_NONE,
1139 {(char_u *)0L, (char_u *)0L}
1140#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001141 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001142 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC
1143 |P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001144 (char_u *)&p_ff, PV_FF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001145 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001146 {"fileformats", "ffs", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001147 (char_u *)&p_ffs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001148 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1149 SCRIPTID_INIT},
Bram Moolenaar71afbfe2013-03-19 16:49:16 +01001150 {"fileignorecase", "fic", P_BOOL|P_VI_DEF,
1151 (char_u *)&p_fic, PV_NONE,
1152 {
1153#ifdef CASE_INSENSITIVE_FILENAME
1154 (char_u *)TRUE,
1155#else
1156 (char_u *)FALSE,
1157#endif
1158 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001159 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001160#ifdef FEAT_AUTOCMD
1161 (char_u *)&p_ft, PV_FT,
1162 {(char_u *)"", (char_u *)0L}
1163#else
1164 (char_u *)NULL, PV_NONE,
1165 {(char_u *)0L, (char_u *)0L}
1166#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001167 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001168 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001169#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1170 (char_u *)&p_fcs, PV_NONE,
1171 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1172#else
1173 (char_u *)NULL, PV_NONE,
1174 {(char_u *)"", (char_u *)0L}
1175#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001176 SCRIPTID_INIT},
Bram Moolenaar34d72d42015-07-17 14:18:08 +02001177 {"fixendofline", "fixeol", P_BOOL|P_VI_DEF|P_RSTAT,
1178 (char_u *)&p_fixeol, PV_FIXEOL,
1179 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001180 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1181#ifdef FEAT_FKMAP
1182 (char_u *)&p_fkmap, PV_NONE,
1183#else
1184 (char_u *)NULL, PV_NONE,
1185#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001186 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001187 {"flash", "fl", P_BOOL|P_VI_DEF,
1188 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001189 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001190#ifdef FEAT_FOLDING
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001191 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001192 (char_u *)&p_fcl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001193 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001194 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1195 (char_u *)VAR_WIN, PV_FDC,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001196 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001197 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1198 (char_u *)VAR_WIN, PV_FEN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001199 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001200 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1201# ifdef FEAT_EVAL
1202 (char_u *)VAR_WIN, PV_FDE,
1203 {(char_u *)"0", (char_u *)NULL}
1204# else
1205 (char_u *)NULL, PV_NONE,
1206 {(char_u *)NULL, (char_u *)0L}
1207# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001208 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001209 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1210 (char_u *)VAR_WIN, PV_FDI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001211 {(char_u *)"#", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001212 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
1213 (char_u *)VAR_WIN, PV_FDL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001214 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001215 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001216 (char_u *)&p_fdls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001217 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001218 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001219 P_RWIN|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001220 (char_u *)VAR_WIN, PV_FMR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001221 {(char_u *)"{{{,}}}", (char_u *)NULL}
1222 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001223 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1224 (char_u *)VAR_WIN, PV_FDM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001225 {(char_u *)"manual", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001226 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1227 (char_u *)VAR_WIN, PV_FML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001228 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001229 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1230 (char_u *)VAR_WIN, PV_FDN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001231 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001232 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001233 (char_u *)&p_fdo, PV_NONE,
1234 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001235 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001236 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1237# ifdef FEAT_EVAL
1238 (char_u *)VAR_WIN, PV_FDT,
1239 {(char_u *)"foldtext()", (char_u *)NULL}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001240# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001241 (char_u *)NULL, PV_NONE,
1242 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001243# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001244 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001245#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001246 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001247#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001248 (char_u *)&p_fex, PV_FEX,
1249 {(char_u *)"", (char_u *)0L}
1250#else
1251 (char_u *)NULL, PV_NONE,
1252 {(char_u *)0L, (char_u *)0L}
1253#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001254 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001255 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1256 (char_u *)&p_fo, PV_FO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001257 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1258 SCRIPTID_INIT},
Bram Moolenaar86b68352004-12-27 21:59:20 +00001259 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1260 (char_u *)&p_flp, PV_FLP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001261 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1262 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001263 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1264 (char_u *)&p_fp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001265 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001266 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1267#ifdef HAVE_FSYNC
1268 (char_u *)&p_fs, PV_NONE,
1269 {(char_u *)TRUE, (char_u *)0L}
1270#else
1271 (char_u *)NULL, PV_NONE,
1272 {(char_u *)FALSE, (char_u *)0L}
1273#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001274 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001275 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1276 (char_u *)&p_gd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001277 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001278 {"graphic", "gr", P_BOOL|P_VI_DEF,
1279 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001280 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001281 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001282#ifdef FEAT_QUICKFIX
1283 (char_u *)&p_gefm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001284 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001285#else
1286 (char_u *)NULL, PV_NONE,
1287 {(char_u *)NULL, (char_u *)0L}
1288#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001289 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001290 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1291#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001292 (char_u *)&p_gp, PV_GP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001293 {
1294# ifdef WIN3264
1295 /* may be changed to "grep -n" in os_win32.c */
1296 (char_u *)"findstr /n",
1297# else
1298# ifdef UNIX
1299 /* Add an extra file name so that grep will always
1300 * insert a file name in the match line. */
1301 (char_u *)"grep -n $* /dev/null",
1302# else
1303# ifdef VMS
1304 (char_u *)"SEARCH/NUMBERS ",
1305# else
1306 (char_u *)"grep -n ",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001307# endif
1308# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001309# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001310 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001311#else
1312 (char_u *)NULL, PV_NONE,
1313 {(char_u *)NULL, (char_u *)0L}
1314#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001315 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001316 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001317#ifdef CURSOR_SHAPE
1318 (char_u *)&p_guicursor, PV_NONE,
1319 {
1320# ifdef FEAT_GUI
1321 (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",
1322# else /* MSDOS or Win32 console */
1323 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1324# endif
1325 (char_u *)0L}
1326#else
1327 (char_u *)NULL, PV_NONE,
1328 {(char_u *)NULL, (char_u *)0L}
1329#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001330 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001331 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001332#ifdef FEAT_GUI
1333 (char_u *)&p_guifont, PV_NONE,
1334 {(char_u *)"", (char_u *)0L}
1335#else
1336 (char_u *)NULL, PV_NONE,
1337 {(char_u *)NULL, (char_u *)0L}
1338#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001339 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001340 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001341#if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1342 (char_u *)&p_guifontset, PV_NONE,
1343 {(char_u *)"", (char_u *)0L}
1344#else
1345 (char_u *)NULL, PV_NONE,
1346 {(char_u *)NULL, (char_u *)0L}
1347#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001348 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001349 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001350#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1351 (char_u *)&p_guifontwide, PV_NONE,
1352 {(char_u *)"", (char_u *)0L}
1353#else
1354 (char_u *)NULL, PV_NONE,
1355 {(char_u *)NULL, (char_u *)0L}
1356#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001357 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001358 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001359#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001360 (char_u *)&p_ghr, PV_NONE,
1361#else
1362 (char_u *)NULL, PV_NONE,
1363#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001364 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001365 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001366#if defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001367 (char_u *)&p_go, PV_NONE,
1368# if defined(UNIX) && !defined(MACOS)
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001369 {(char_u *)"aegimrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001370# else
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001371 {(char_u *)"egmrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001372# endif
1373#else
1374 (char_u *)NULL, PV_NONE,
1375 {(char_u *)NULL, (char_u *)0L}
1376#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001377 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001378 {"guipty", NULL, P_BOOL|P_VI_DEF,
1379#if defined(FEAT_GUI)
1380 (char_u *)&p_guipty, PV_NONE,
1381#else
1382 (char_u *)NULL, PV_NONE,
1383#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001384 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar18144c82006-04-12 21:52:12 +00001385 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00001386#if defined(FEAT_GUI_TABLINE)
1387 (char_u *)&p_gtl, PV_NONE,
1388 {(char_u *)"", (char_u *)0L}
1389#else
1390 (char_u *)NULL, PV_NONE,
1391 {(char_u *)NULL, (char_u *)0L}
1392#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001393 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001394 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar57657d82006-04-21 22:12:41 +00001395#if defined(FEAT_GUI_TABLINE)
1396 (char_u *)&p_gtt, PV_NONE,
1397 {(char_u *)"", (char_u *)0L}
1398#else
1399 (char_u *)NULL, PV_NONE,
1400 {(char_u *)NULL, (char_u *)0L}
1401#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001402 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001403 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1404 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001405 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001406 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1407 (char_u *)&p_hf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001408 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1409 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001410 {"helpheight", "hh", P_NUM|P_VI_DEF,
1411#ifdef FEAT_WINDOWS
1412 (char_u *)&p_hh, PV_NONE,
1413#else
1414 (char_u *)NULL, PV_NONE,
1415#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001416 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001417 {"helplang", "hlg", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001418#ifdef FEAT_MULTI_LANG
1419 (char_u *)&p_hlg, PV_NONE,
1420 {(char_u *)"", (char_u *)0L}
1421#else
1422 (char_u *)NULL, PV_NONE,
1423 {(char_u *)0L, (char_u *)0L}
1424#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001425 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001426 {"hidden", "hid", P_BOOL|P_VI_DEF,
1427 (char_u *)&p_hid, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001428 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001429 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001430 (char_u *)&p_hl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001431 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1432 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001433 {"history", "hi", P_NUM|P_VIM,
1434 (char_u *)&p_hi, PV_NONE,
Bram Moolenaar78159bb2014-06-25 11:48:54 +02001435 {(char_u *)0L, (char_u *)50L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001436 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1437#ifdef FEAT_RIGHTLEFT
1438 (char_u *)&p_hkmap, PV_NONE,
1439#else
1440 (char_u *)NULL, PV_NONE,
1441#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001442 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001443 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1444#ifdef FEAT_RIGHTLEFT
1445 (char_u *)&p_hkmapp, PV_NONE,
1446#else
1447 (char_u *)NULL, PV_NONE,
1448#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001449 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001450 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1451 (char_u *)&p_hls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001452 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001453 {"icon", NULL, P_BOOL|P_VI_DEF,
1454#ifdef FEAT_TITLE
1455 (char_u *)&p_icon, PV_NONE,
1456#else
1457 (char_u *)NULL, PV_NONE,
1458#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001459 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001460 {"iconstring", NULL, P_STRING|P_VI_DEF,
1461#ifdef FEAT_TITLE
1462 (char_u *)&p_iconstring, PV_NONE,
1463#else
1464 (char_u *)NULL, PV_NONE,
1465#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001466 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001467 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1468 (char_u *)&p_ic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001469 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001470 {"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
1471# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1472 (char_u *)&p_imaf, PV_NONE,
1473 {(char_u *)"", (char_u *)NULL}
1474# else
1475 (char_u *)NULL, PV_NONE,
1476 {(char_u *)NULL, (char_u *)0L}
1477# endif
1478 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001479 {"imactivatekey","imak",P_STRING|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001480#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001481 (char_u *)&p_imak, PV_NONE,
1482#else
1483 (char_u *)NULL, PV_NONE,
1484#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001485 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001486 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1487#ifdef USE_IM_CONTROL
1488 (char_u *)&p_imcmdline, PV_NONE,
1489#else
1490 (char_u *)NULL, PV_NONE,
1491#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001492 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001493 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1494#ifdef USE_IM_CONTROL
1495 (char_u *)&p_imdisable, PV_NONE,
1496#else
1497 (char_u *)NULL, PV_NONE,
1498#endif
1499#ifdef __sgi
1500 {(char_u *)TRUE, (char_u *)0L}
1501#else
1502 {(char_u *)FALSE, (char_u *)0L}
1503#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001504 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001505 {"iminsert", "imi", P_NUM|P_VI_DEF,
1506 (char_u *)&p_iminsert, PV_IMI,
1507#ifdef B_IMODE_IM
1508 {(char_u *)B_IMODE_IM, (char_u *)0L}
1509#else
1510 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1511#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001512 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001513 {"imsearch", "ims", P_NUM|P_VI_DEF,
1514 (char_u *)&p_imsearch, PV_IMS,
1515#ifdef B_IMODE_IM
1516 {(char_u *)B_IMODE_IM, (char_u *)0L}
1517#else
1518 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1519#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001520 SCRIPTID_INIT},
Bram Moolenaar4a460702013-06-29 14:42:26 +02001521 {"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001522# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1523 (char_u *)&p_imsf, PV_NONE,
1524 {(char_u *)"", (char_u *)NULL}
1525# else
1526 (char_u *)NULL, PV_NONE,
1527 {(char_u *)NULL, (char_u *)0L}
1528# endif
1529 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001530 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1531#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001532 (char_u *)&p_inc, PV_INC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001533 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1534#else
1535 (char_u *)NULL, PV_NONE,
1536 {(char_u *)0L, (char_u *)0L}
1537#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001538 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001539 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1540#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1541 (char_u *)&p_inex, PV_INEX,
1542 {(char_u *)"", (char_u *)0L}
1543#else
1544 (char_u *)NULL, PV_NONE,
1545 {(char_u *)0L, (char_u *)0L}
1546#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001547 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001548 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1549 (char_u *)&p_is, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001550 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001551 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1552#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1553 (char_u *)&p_inde, PV_INDE,
1554 {(char_u *)"", (char_u *)0L}
1555#else
1556 (char_u *)NULL, PV_NONE,
1557 {(char_u *)0L, (char_u *)0L}
1558#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001559 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001560 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001561#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1562 (char_u *)&p_indk, PV_INDK,
1563 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1564#else
1565 (char_u *)NULL, PV_NONE,
1566 {(char_u *)0L, (char_u *)0L}
1567#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001568 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001569 {"infercase", "inf", P_BOOL|P_VI_DEF,
1570 (char_u *)&p_inf, PV_INF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001571 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001572 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1573 (char_u *)&p_im, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001574 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001575 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1576 (char_u *)&p_isf, PV_NONE,
1577 {
1578#ifdef BACKSLASH_IN_FILENAME
1579 /* Excluded are: & and ^ are special in cmd.exe
1580 * ( and ) are used in text separating fnames */
1581 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1582#else
1583# ifdef AMIGA
1584 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1585# else
1586# ifdef VMS
1587 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1588# else /* UNIX et al. */
1589# ifdef EBCDIC
1590 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1591# else
1592 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1593# endif
1594# endif
1595# endif
1596#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001597 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001598 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1599 (char_u *)&p_isi, PV_NONE,
1600 {
1601#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1602 (char_u *)"@,48-57,_,128-167,224-235",
1603#else
1604# ifdef EBCDIC
1605 /* TODO: EBCDIC Check this! @ == isalpha()*/
1606 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1607 "112-120,128,140-142,156,158,172,"
1608 "174,186,191,203-207,219-225,235-239,"
1609 "251-254",
1610# else
1611 (char_u *)"@,48-57,_,192-255",
1612# endif
1613#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001614 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001615 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1616 (char_u *)&p_isk, PV_ISK,
1617 {
1618#ifdef EBCDIC
1619 (char_u *)"@,240-249,_",
1620 /* TODO: EBCDIC Check this! @ == isalpha()*/
1621 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1622 "112-120,128,140-142,156,158,172,"
1623 "174,186,191,203-207,219-225,235-239,"
1624 "251-254",
1625#else
1626 (char_u *)"@,48-57,_",
1627# if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1628 (char_u *)"@,48-57,_,128-167,224-235"
1629# else
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001630 ISK_LATIN1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001631# endif
1632#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001633 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001634 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1635 (char_u *)&p_isp, PV_NONE,
1636 {
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001637#if defined(MSDOS) || defined(MSWIN) || defined(OS2) \
1638 || (defined(MACOS) && !defined(MACOS_X)) \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001639 || defined(VMS)
1640 (char_u *)"@,~-255",
1641#else
1642# ifdef EBCDIC
1643 /* all chars above 63 are printable */
1644 (char_u *)"63-255",
1645# else
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00001646 ISP_LATIN1,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001647# endif
1648#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001649 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001650 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1651 (char_u *)&p_js, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001652 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001653 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1654#ifdef FEAT_CRYPT
1655 (char_u *)&p_key, PV_KEY,
1656 {(char_u *)"", (char_u *)0L}
1657#else
1658 (char_u *)NULL, PV_NONE,
1659 {(char_u *)0L, (char_u *)0L}
1660#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001661 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001662 {"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 +00001663#ifdef FEAT_KEYMAP
1664 (char_u *)&p_keymap, PV_KMAP,
1665 {(char_u *)"", (char_u *)0L}
1666#else
1667 (char_u *)NULL, PV_NONE,
1668 {(char_u *)"", (char_u *)0L}
1669#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001670 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001671 {"keymodel", "km", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001672 (char_u *)&p_km, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001673 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001674 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001675 (char_u *)&p_kp, PV_KP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001676 {
1677#if defined(MSDOS) || defined(MSWIN)
1678 (char_u *)":help",
1679#else
1680#ifdef VMS
1681 (char_u *)"help",
1682#else
1683# if defined(OS2)
1684 (char_u *)"view /",
1685# else
1686# ifdef USEMAN_S
1687 (char_u *)"man -s",
1688# else
1689 (char_u *)"man",
1690# endif
1691# endif
1692#endif
1693#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001694 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001695 {"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001696#ifdef FEAT_LANGMAP
1697 (char_u *)&p_langmap, PV_NONE,
1698 {(char_u *)"", /* unmatched } */
1699#else
1700 (char_u *)NULL, PV_NONE,
1701 {(char_u *)NULL,
1702#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001703 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001704 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001705#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1706 (char_u *)&p_lm, PV_NONE,
1707#else
1708 (char_u *)NULL, PV_NONE,
1709#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001710 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar4391cf92014-11-05 17:44:52 +01001711 {"langnoremap", "lnr", P_BOOL|P_VI_DEF,
1712#ifdef FEAT_LANGMAP
1713 (char_u *)&p_lnr, PV_NONE,
1714#else
1715 (char_u *)NULL, PV_NONE,
1716#endif
1717 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001718 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1719#ifdef FEAT_WINDOWS
1720 (char_u *)&p_ls, PV_NONE,
1721#else
1722 (char_u *)NULL, PV_NONE,
1723#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001724 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001725 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1726 (char_u *)&p_lz, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001727 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001728 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1729#ifdef FEAT_LINEBREAK
1730 (char_u *)VAR_WIN, PV_LBR,
1731#else
1732 (char_u *)NULL, PV_NONE,
1733#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001734 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001735 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1736 (char_u *)&Rows, PV_NONE,
1737 {
1738#if defined(MSDOS) || defined(WIN3264) || defined(OS2)
1739 (char_u *)25L,
1740#else
1741 (char_u *)24L,
1742#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001743 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001744 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1745#ifdef FEAT_GUI
1746 (char_u *)&p_linespace, PV_NONE,
1747#else
1748 (char_u *)NULL, PV_NONE,
1749#endif
1750#ifdef FEAT_GUI_W32
1751 {(char_u *)1L, (char_u *)0L}
1752#else
1753 {(char_u *)0L, (char_u *)0L}
1754#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001755 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001756 {"lisp", NULL, P_BOOL|P_VI_DEF,
1757#ifdef FEAT_LISP
1758 (char_u *)&p_lisp, PV_LISP,
1759#else
1760 (char_u *)NULL, PV_NONE,
1761#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001762 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001763 {"lispwords", "lw", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001764#ifdef FEAT_LISP
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01001765 (char_u *)&p_lispwords, PV_LW,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001766 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1767#else
1768 (char_u *)NULL, PV_NONE,
1769 {(char_u *)"", (char_u *)0L}
1770#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001771 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001772 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1773 (char_u *)VAR_WIN, PV_LIST,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001774 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001775 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001776 (char_u *)&p_lcs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001777 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001778 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1779 (char_u *)&p_lpl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001780 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001781#ifdef FEAT_GUI_MAC
1782 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
1783 (char_u *)&p_macatsui, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001784 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001785#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001786 {"magic", NULL, P_BOOL|P_VI_DEF,
1787 (char_u *)&p_magic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001788 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00001789 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001790#ifdef FEAT_QUICKFIX
1791 (char_u *)&p_mef, PV_NONE,
1792 {(char_u *)"", (char_u *)0L}
1793#else
1794 (char_u *)NULL, PV_NONE,
1795 {(char_u *)NULL, (char_u *)0L}
1796#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001797 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001798 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1799#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001800 (char_u *)&p_mp, PV_MP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001801# ifdef VMS
1802 {(char_u *)"MMS", (char_u *)0L}
1803# else
1804 {(char_u *)"make", (char_u *)0L}
1805# endif
1806#else
1807 (char_u *)NULL, PV_NONE,
1808 {(char_u *)NULL, (char_u *)0L}
1809#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001810 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001811 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001812 (char_u *)&p_mps, PV_MPS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001813 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1814 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001815 {"matchtime", "mat", P_NUM|P_VI_DEF,
1816 (char_u *)&p_mat, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001817 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001818 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001819#ifdef FEAT_MBYTE
1820 (char_u *)&p_mco, PV_NONE,
1821#else
1822 (char_u *)NULL, PV_NONE,
1823#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001824 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001825 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1826#ifdef FEAT_EVAL
1827 (char_u *)&p_mfd, PV_NONE,
1828#else
1829 (char_u *)NULL, PV_NONE,
1830#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001831 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001832 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1833 (char_u *)&p_mmd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001834 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001835 {"maxmem", "mm", P_NUM|P_VI_DEF,
1836 (char_u *)&p_mm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001837 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1838 SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00001839 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1840 (char_u *)&p_mmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001841 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001842 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1843 (char_u *)&p_mmt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001844 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1845 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001846 {"menuitems", "mis", P_NUM|P_VI_DEF,
1847#ifdef FEAT_MENU
1848 (char_u *)&p_mis, PV_NONE,
1849#else
1850 (char_u *)NULL, PV_NONE,
1851#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001852 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001853 {"mesg", NULL, P_BOOL|P_VI_DEF,
1854 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001855 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001856 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001857#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001858 (char_u *)&p_msm, PV_NONE,
1859 {(char_u *)"460000,2000,500", (char_u *)0L}
1860#else
1861 (char_u *)NULL, PV_NONE,
1862 {(char_u *)0L, (char_u *)0L}
1863#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001864 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001865 {"modeline", "ml", P_BOOL|P_VIM,
1866 (char_u *)&p_ml, PV_ML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001867 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001868 {"modelines", "mls", P_NUM|P_VI_DEF,
1869 (char_u *)&p_mls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001870 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001871 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1872 (char_u *)&p_ma, PV_MA,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001873 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001874 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1875 (char_u *)&p_mod, PV_MOD,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001876 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001877 {"more", NULL, P_BOOL|P_VIM,
1878 (char_u *)&p_more, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001879 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001880 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
1881 (char_u *)&p_mouse, PV_NONE,
1882 {
1883#if defined(MSDOS) || defined(WIN3264)
1884 (char_u *)"a",
1885#else
1886 (char_u *)"",
1887#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001888 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001889 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
1890#ifdef FEAT_GUI
1891 (char_u *)&p_mousef, PV_NONE,
1892#else
1893 (char_u *)NULL, PV_NONE,
1894#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001895 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001896 {"mousehide", "mh", P_BOOL|P_VI_DEF,
1897#ifdef FEAT_GUI
1898 (char_u *)&p_mh, PV_NONE,
1899#else
1900 (char_u *)NULL, PV_NONE,
1901#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001902 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001903 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
1904 (char_u *)&p_mousem, PV_NONE,
1905 {
1906#if defined(MSDOS) || defined(MSWIN)
1907 (char_u *)"popup",
1908#else
1909# if defined(MACOS)
1910 (char_u *)"popup_setpos",
1911# else
1912 (char_u *)"extend",
1913# endif
1914#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001915 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001916 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001917#ifdef FEAT_MOUSESHAPE
1918 (char_u *)&p_mouseshape, PV_NONE,
1919 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
1920#else
1921 (char_u *)NULL, PV_NONE,
1922 {(char_u *)NULL, (char_u *)0L}
1923#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001924 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001925 {"mousetime", "mouset", P_NUM|P_VI_DEF,
1926 (char_u *)&p_mouset, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001927 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001928 {"mzquantum", "mzq", P_NUM,
1929#ifdef FEAT_MZSCHEME
1930 (char_u *)&p_mzq, PV_NONE,
1931#else
1932 (char_u *)NULL, PV_NONE,
1933#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001934 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001935 {"novice", NULL, P_BOOL|P_VI_DEF,
1936 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001937 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001938 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001939 (char_u *)&p_nf, PV_NF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001940 {(char_u *)"octal,hex", (char_u *)0L}
1941 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001942 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
1943 (char_u *)VAR_WIN, PV_NU,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001944 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00001945 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
1946#ifdef FEAT_LINEBREAK
1947 (char_u *)VAR_WIN, PV_NUW,
1948#else
1949 (char_u *)NULL, PV_NONE,
1950#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001951 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
Bram Moolenaarf75a9632005-09-13 21:20:47 +00001952 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
Bram Moolenaare344bea2005-09-01 20:46:49 +00001953#ifdef FEAT_COMPL_FUNC
1954 (char_u *)&p_ofu, PV_OFU,
1955 {(char_u *)"", (char_u *)0L}
1956#else
1957 (char_u *)NULL, PV_NONE,
1958 {(char_u *)0L, (char_u *)0L}
1959#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001960 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001961 {"open", NULL, P_BOOL|P_VI_DEF,
1962 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001963 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar043545e2006-10-10 16:44:07 +00001964 {"opendevice", "odev", P_BOOL|P_VI_DEF,
1965#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1966 (char_u *)&p_odev, PV_NONE,
1967#else
1968 (char_u *)NULL, PV_NONE,
1969#endif
1970 {(char_u *)FALSE, (char_u *)FALSE}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001971 SCRIPTID_INIT},
Bram Moolenaar2c7a29c2005-12-12 22:02:31 +00001972 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
1973 (char_u *)&p_opfunc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001974 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001975 {"optimize", "opt", P_BOOL|P_VI_DEF,
1976 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001977 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001978 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001979 (char_u *)NULL, PV_NONE,
Bram Moolenaarb07269a2011-05-19 13:41:14 +02001980 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001981 {"paragraphs", "para", P_STRING|P_VI_DEF,
1982 (char_u *)&p_para, PV_NONE,
Bram Moolenaar57e48462008-03-12 16:38:55 +00001983 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001984 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001985 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001986 (char_u *)&p_paste, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001987 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001988 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
1989 (char_u *)&p_pt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001990 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001991 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
1992#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1993 (char_u *)&p_pex, PV_NONE,
1994 {(char_u *)"", (char_u *)0L}
1995#else
1996 (char_u *)NULL, PV_NONE,
1997 {(char_u *)0L, (char_u *)0L}
1998#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001999 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002000 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002001 (char_u *)&p_pm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002002 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002003 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002004 (char_u *)&p_path, PV_PATH,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002005 {
2006#if defined AMIGA || defined MSDOS || defined MSWIN
2007 (char_u *)".,,",
2008#else
2009# if defined(__EMX__)
2010 (char_u *)".,/emx/include,,",
2011# else /* Unix, probably */
2012 (char_u *)".,/usr/include,,",
2013# endif
2014#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002015 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002016 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
2017 (char_u *)&p_pi, PV_PI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002018 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002019 {"previewheight", "pvh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002020#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2021 (char_u *)&p_pvh, PV_NONE,
2022#else
2023 (char_u *)NULL, PV_NONE,
2024#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002025 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002026 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2027#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2028 (char_u *)VAR_WIN, PV_PVW,
2029#else
2030 (char_u *)NULL, PV_NONE,
2031#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002032 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002033 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002034#ifdef FEAT_PRINTER
2035 (char_u *)&p_pdev, PV_NONE,
2036 {(char_u *)"", (char_u *)0L}
2037#else
2038 (char_u *)NULL, PV_NONE,
2039 {(char_u *)NULL, (char_u *)0L}
2040#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002041 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002042 {"printencoding", "penc", P_STRING|P_VI_DEF,
2043#ifdef FEAT_POSTSCRIPT
2044 (char_u *)&p_penc, PV_NONE,
2045 {(char_u *)"", (char_u *)0L}
2046#else
2047 (char_u *)NULL, PV_NONE,
2048 {(char_u *)NULL, (char_u *)0L}
2049#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002050 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002051 {"printexpr", "pexpr", P_STRING|P_VI_DEF,
2052#ifdef FEAT_POSTSCRIPT
2053 (char_u *)&p_pexpr, PV_NONE,
2054 {(char_u *)"", (char_u *)0L}
2055#else
2056 (char_u *)NULL, PV_NONE,
2057 {(char_u *)NULL, (char_u *)0L}
2058#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002059 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002060 {"printfont", "pfn", P_STRING|P_VI_DEF,
2061#ifdef FEAT_PRINTER
2062 (char_u *)&p_pfn, PV_NONE,
2063 {
2064# ifdef MSWIN
2065 (char_u *)"Courier_New:h10",
2066# else
2067 (char_u *)"courier",
2068# endif
2069 (char_u *)0L}
2070#else
2071 (char_u *)NULL, PV_NONE,
2072 {(char_u *)NULL, (char_u *)0L}
2073#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002074 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002075 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
2076#ifdef FEAT_PRINTER
2077 (char_u *)&p_header, PV_NONE,
2078 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
2079#else
2080 (char_u *)NULL, PV_NONE,
2081 {(char_u *)NULL, (char_u *)0L}
2082#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002083 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002084 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
2085#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2086 (char_u *)&p_pmcs, PV_NONE,
2087 {(char_u *)"", (char_u *)0L}
2088#else
2089 (char_u *)NULL, PV_NONE,
2090 {(char_u *)NULL, (char_u *)0L}
2091#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002092 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002093 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2094#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2095 (char_u *)&p_pmfn, PV_NONE,
2096 {(char_u *)"", (char_u *)0L}
2097#else
2098 (char_u *)NULL, PV_NONE,
2099 {(char_u *)NULL, (char_u *)0L}
2100#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002101 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002102 {"printoptions", "popt", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002103#ifdef FEAT_PRINTER
2104 (char_u *)&p_popt, PV_NONE,
2105 {(char_u *)"", (char_u *)0L}
2106#else
2107 (char_u *)NULL, PV_NONE,
2108 {(char_u *)NULL, (char_u *)0L}
2109#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002110 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002111 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002112 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002113 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002114 {"pumheight", "ph", P_NUM|P_VI_DEF,
2115#ifdef FEAT_INS_EXPAND
2116 (char_u *)&p_ph, PV_NONE,
2117#else
2118 (char_u *)NULL, PV_NONE,
2119#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002120 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002121 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2122#ifdef FEAT_TEXTOBJ
2123 (char_u *)&p_qe, PV_QE,
2124 {(char_u *)"\\", (char_u *)0L}
2125#else
2126 (char_u *)NULL, PV_NONE,
2127 {(char_u *)NULL, (char_u *)0L}
2128#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002129 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002130 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2131 (char_u *)&p_ro, PV_RO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002132 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002133 {"redraw", NULL, P_BOOL|P_VI_DEF,
2134 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002135 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002136 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2137#ifdef FEAT_RELTIME
2138 (char_u *)&p_rdt, PV_NONE,
2139#else
2140 (char_u *)NULL, PV_NONE,
2141#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002142 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02002143 {"regexpengine", "re", P_NUM|P_VI_DEF,
2144 (char_u *)&p_re, PV_NONE,
2145 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002146 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2147 (char_u *)VAR_WIN, PV_RNU,
2148 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002149 {"remap", NULL, P_BOOL|P_VI_DEF,
2150 (char_u *)&p_remap, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002151 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002152 {"renderoptions", "rop", P_STRING|P_ONECOMMA|P_RCLR|P_VI_DEF,
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02002153#ifdef FEAT_RENDER_OPTIONS
2154 (char_u *)&p_rop, PV_NONE,
2155 {(char_u *)"", (char_u *)0L}
2156#else
2157 (char_u *)NULL, PV_NONE,
2158 {(char_u *)NULL, (char_u *)0L}
2159#endif
2160 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002161 {"report", NULL, P_NUM|P_VI_DEF,
2162 (char_u *)&p_report, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002163 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002164 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2165#ifdef WIN3264
2166 (char_u *)&p_rs, PV_NONE,
2167#else
2168 (char_u *)NULL, PV_NONE,
2169#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002170 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002171 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2172#ifdef FEAT_RIGHTLEFT
2173 (char_u *)&p_ri, PV_NONE,
2174#else
2175 (char_u *)NULL, PV_NONE,
2176#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002177 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002178 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2179#ifdef FEAT_RIGHTLEFT
2180 (char_u *)VAR_WIN, PV_RL,
2181#else
2182 (char_u *)NULL, PV_NONE,
2183#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002184 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002185 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2186#ifdef FEAT_RIGHTLEFT
2187 (char_u *)VAR_WIN, PV_RLC,
2188 {(char_u *)"search", (char_u *)NULL}
2189#else
2190 (char_u *)NULL, PV_NONE,
2191 {(char_u *)NULL, (char_u *)0L}
2192#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002193 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002194 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2195#ifdef FEAT_CMDL_INFO
2196 (char_u *)&p_ru, PV_NONE,
2197#else
2198 (char_u *)NULL, PV_NONE,
2199#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002200 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002201 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2202#ifdef FEAT_STL_OPT
2203 (char_u *)&p_ruf, PV_NONE,
2204#else
2205 (char_u *)NULL, PV_NONE,
2206#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002207 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002208 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2209 |P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002210 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002211 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2212 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002213 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2214 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002215 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002216 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2217#ifdef FEAT_SCROLLBIND
2218 (char_u *)VAR_WIN, PV_SCBIND,
2219#else
2220 (char_u *)NULL, PV_NONE,
2221#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002222 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002223 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2224 (char_u *)&p_sj, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002225 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002226 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2227 (char_u *)&p_so, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002228 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002229 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002230#ifdef FEAT_SCROLLBIND
2231 (char_u *)&p_sbo, PV_NONE,
2232 {(char_u *)"ver,jump", (char_u *)0L}
2233#else
2234 (char_u *)NULL, PV_NONE,
2235 {(char_u *)0L, (char_u *)0L}
2236#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002237 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002238 {"sections", "sect", P_STRING|P_VI_DEF,
2239 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002240 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2241 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002242 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2243 (char_u *)&p_secure, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002244 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002245 {"selection", "sel", P_STRING|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002246 (char_u *)&p_sel, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002247 {(char_u *)"inclusive", (char_u *)0L}
2248 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002249 {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002250 (char_u *)&p_slm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002251 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002252 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002253#ifdef FEAT_SESSION
2254 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002255 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002256 (char_u *)0L}
2257#else
2258 (char_u *)NULL, PV_NONE,
2259 {(char_u *)0L, (char_u *)0L}
2260#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002261 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002262 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2263 (char_u *)&p_sh, PV_NONE,
2264 {
2265#ifdef VMS
2266 (char_u *)"-",
2267#else
2268# if defined(MSDOS)
2269 (char_u *)"command",
2270# else
2271# if defined(WIN16)
2272 (char_u *)"command.com",
2273# else
2274# if defined(WIN3264)
2275 (char_u *)"", /* set in set_init_1() */
2276# else
2277# if defined(OS2)
2278 (char_u *)"cmd.exe",
2279# else
2280# if defined(ARCHIE)
2281 (char_u *)"gos",
2282# else
2283 (char_u *)"sh",
2284# endif
2285# endif
2286# endif
2287# endif
2288# endif
2289#endif /* VMS */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002290 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002291 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2292 (char_u *)&p_shcf, PV_NONE,
2293 {
2294#if defined(MSDOS) || defined(MSWIN)
2295 (char_u *)"/c",
2296#else
2297# if defined(OS2)
2298 (char_u *)"/c",
2299# else
2300 (char_u *)"-c",
2301# endif
2302#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002303 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002304 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2305#ifdef FEAT_QUICKFIX
2306 (char_u *)&p_sp, PV_NONE,
2307 {
2308#if defined(UNIX) || defined(OS2)
2309# ifdef ARCHIE
2310 (char_u *)"2>",
2311# else
2312 (char_u *)"| tee",
2313# endif
2314#else
2315 (char_u *)">",
2316#endif
2317 (char_u *)0L}
2318#else
2319 (char_u *)NULL, PV_NONE,
2320 {(char_u *)0L, (char_u *)0L}
2321#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002322 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002323 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2324 (char_u *)&p_shq, 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 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2327 (char_u *)&p_srr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002328 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002329 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2330#ifdef BACKSLASH_IN_FILENAME
2331 (char_u *)&p_ssl, PV_NONE,
2332#else
2333 (char_u *)NULL, PV_NONE,
2334#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002335 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002336 {"shelltemp", "stmp", P_BOOL,
2337 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002338 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002339 {"shelltype", "st", P_NUM|P_VI_DEF,
2340#ifdef AMIGA
2341 (char_u *)&p_st, PV_NONE,
2342#else
2343 (char_u *)NULL, PV_NONE,
2344#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002345 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002346 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2347 (char_u *)&p_sxq, PV_NONE,
2348 {
2349#if defined(UNIX) && defined(USE_SYSTEM) && !defined(__EMX__)
2350 (char_u *)"\"",
2351#else
2352 (char_u *)"",
2353#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002354 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002355 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
2356 (char_u *)&p_sxe, PV_NONE,
2357 {
2358#if defined(MSDOS) || defined(WIN16) || defined(WIN3264)
2359 (char_u *)"\"&|<>()@^",
2360#else
2361 (char_u *)"",
2362#endif
2363 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002364 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2365 (char_u *)&p_sr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002366 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002367 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2368 (char_u *)&p_sw, PV_SW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002369 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002370 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2371 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002372 {(char_u *)"", (char_u *)"filnxtToO"}
2373 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002374 {"shortname", "sn", P_BOOL|P_VI_DEF,
2375#ifdef SHORT_FNAME
2376 (char_u *)NULL, PV_NONE,
2377#else
2378 (char_u *)&p_sn, PV_SN,
2379#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002380 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002381 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2382#ifdef FEAT_LINEBREAK
2383 (char_u *)&p_sbr, PV_NONE,
2384#else
2385 (char_u *)NULL, PV_NONE,
2386#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002387 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002388 {"showcmd", "sc", P_BOOL|P_VIM,
2389#ifdef FEAT_CMDL_INFO
2390 (char_u *)&p_sc, PV_NONE,
2391#else
2392 (char_u *)NULL, PV_NONE,
2393#endif
2394 {(char_u *)FALSE,
2395#ifdef UNIX
2396 (char_u *)FALSE
2397#else
2398 (char_u *)TRUE
2399#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002400 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002401 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2402 (char_u *)&p_sft, 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 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2405 (char_u *)&p_sm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002406 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002407 {"showmode", "smd", P_BOOL|P_VIM,
2408 (char_u *)&p_smd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002409 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002410 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2411#ifdef FEAT_WINDOWS
2412 (char_u *)&p_stal, PV_NONE,
2413#else
2414 (char_u *)NULL, PV_NONE,
2415#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002416 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002417 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2418 (char_u *)&p_ss, 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 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2421 (char_u *)&p_siso, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002422 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002423 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2424 (char_u *)NULL, 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 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2427 (char_u *)&p_scs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002428 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002429 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2430#ifdef FEAT_SMARTINDENT
2431 (char_u *)&p_si, PV_SI,
2432#else
2433 (char_u *)NULL, PV_NONE,
2434#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002435 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002436 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2437 (char_u *)&p_sta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002438 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002439 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2440 (char_u *)&p_sts, PV_STS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002441 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002442 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2443 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002444 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002445 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002446#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002447 (char_u *)VAR_WIN, PV_SPELL,
2448#else
2449 (char_u *)NULL, PV_NONE,
2450#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002451 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002452 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002453#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002454 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002455 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002456#else
2457 (char_u *)NULL, PV_NONE,
2458 {(char_u *)0L, (char_u *)0L}
2459#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002460 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002461 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE
2462 |P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002463#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002464 (char_u *)&p_spf, PV_SPF,
2465 {(char_u *)"", (char_u *)0L}
2466#else
2467 (char_u *)NULL, PV_NONE,
2468 {(char_u *)0L, (char_u *)0L}
2469#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002470 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002471 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
2472 |P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002473#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002474 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002475 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002476#else
2477 (char_u *)NULL, PV_NONE,
2478 {(char_u *)0L, (char_u *)0L}
2479#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002480 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002481 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002482#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002483 (char_u *)&p_sps, PV_NONE,
2484 {(char_u *)"best", (char_u *)0L}
2485#else
2486 (char_u *)NULL, PV_NONE,
2487 {(char_u *)0L, (char_u *)0L}
2488#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002489 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002490 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2491#ifdef FEAT_WINDOWS
2492 (char_u *)&p_sb, PV_NONE,
2493#else
2494 (char_u *)NULL, PV_NONE,
2495#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002496 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002497 {"splitright", "spr", P_BOOL|P_VI_DEF,
2498#ifdef FEAT_VERTSPLIT
2499 (char_u *)&p_spr, PV_NONE,
2500#else
2501 (char_u *)NULL, PV_NONE,
2502#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002503 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002504 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2505 (char_u *)&p_sol, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002506 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002507 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2508#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002509 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002510#else
2511 (char_u *)NULL, PV_NONE,
2512#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002513 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002514 {"suffixes", "su", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002515 (char_u *)&p_su, PV_NONE,
2516 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002517 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002518 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002519#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002520 (char_u *)&p_sua, PV_SUA,
2521 {(char_u *)"", (char_u *)0L}
2522#else
2523 (char_u *)NULL, PV_NONE,
2524 {(char_u *)0L, (char_u *)0L}
2525#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002526 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002527 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2528 (char_u *)&p_swf, PV_SWF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002529 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002530 {"swapsync", "sws", P_STRING|P_VI_DEF,
2531 (char_u *)&p_sws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002532 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002533 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002534 (char_u *)&p_swb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002535 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002536 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2537#ifdef FEAT_SYN_HL
2538 (char_u *)&p_smc, PV_SMC,
2539 {(char_u *)3000L, (char_u *)0L}
2540#else
2541 (char_u *)NULL, PV_NONE,
2542 {(char_u *)0L, (char_u *)0L}
2543#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002544 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002545 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002546#ifdef FEAT_SYN_HL
2547 (char_u *)&p_syn, PV_SYN,
2548 {(char_u *)"", (char_u *)0L}
2549#else
2550 (char_u *)NULL, PV_NONE,
2551 {(char_u *)0L, (char_u *)0L}
2552#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002553 SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002554 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2555#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002556 (char_u *)&p_tal, PV_NONE,
2557#else
2558 (char_u *)NULL, PV_NONE,
2559#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002560 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002561 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2562#ifdef FEAT_WINDOWS
2563 (char_u *)&p_tpm, PV_NONE,
2564#else
2565 (char_u *)NULL, PV_NONE,
2566#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002567 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002568 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2569 (char_u *)&p_ts, PV_TS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002570 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002571 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2572 (char_u *)&p_tbs, PV_NONE,
2573#ifdef VMS /* binary searching doesn't appear to work on VMS */
2574 {(char_u *)0L, (char_u *)0L}
2575#else
2576 {(char_u *)TRUE, (char_u *)0L}
2577#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002578 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002579 {"taglength", "tl", P_NUM|P_VI_DEF,
2580 (char_u *)&p_tl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002581 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002582 {"tagrelative", "tr", P_BOOL|P_VIM,
2583 (char_u *)&p_tr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002584 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002585 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002586 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002587 {
2588#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2589 (char_u *)"./tags,./TAGS,tags,TAGS",
2590#else
2591 (char_u *)"./tags,tags",
2592#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002593 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002594 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2595 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002596 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002597 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2598 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002599 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002600 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2601#ifdef FEAT_ARABIC
2602 (char_u *)&p_tbidi, PV_NONE,
2603#else
2604 (char_u *)NULL, PV_NONE,
2605#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002606 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002607 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2608#ifdef FEAT_MBYTE
2609 (char_u *)&p_tenc, PV_NONE,
2610 {(char_u *)"", (char_u *)0L}
2611#else
2612 (char_u *)NULL, PV_NONE,
2613 {(char_u *)0L, (char_u *)0L}
2614#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002615 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002616 {"terse", NULL, P_BOOL|P_VI_DEF,
2617 (char_u *)&p_terse, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002618 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002619 {"textauto", "ta", P_BOOL|P_VIM,
2620 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002621 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2622 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002623 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2624 (char_u *)&p_tx, PV_TX,
2625 {
2626#ifdef USE_CRNL
2627 (char_u *)TRUE,
2628#else
2629 (char_u *)FALSE,
2630#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002631 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +02002632 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002633 (char_u *)&p_tw, PV_TW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002634 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002635 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002636#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002637 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002638#else
2639 (char_u *)NULL, PV_NONE,
2640#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002641 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002642 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2643 (char_u *)&p_to, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002644 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002645 {"timeout", "to", P_BOOL|P_VI_DEF,
2646 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002647 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002648 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2649 (char_u *)&p_tm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002650 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002651 {"title", NULL, P_BOOL|P_VI_DEF,
2652#ifdef FEAT_TITLE
2653 (char_u *)&p_title, PV_NONE,
2654#else
2655 (char_u *)NULL, PV_NONE,
2656#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002657 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002658 {"titlelen", NULL, P_NUM|P_VI_DEF,
2659#ifdef FEAT_TITLE
2660 (char_u *)&p_titlelen, PV_NONE,
2661#else
2662 (char_u *)NULL, PV_NONE,
2663#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002664 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002665 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002666#ifdef FEAT_TITLE
2667 (char_u *)&p_titleold, PV_NONE,
2668 {(char_u *)N_("Thanks for flying Vim"),
2669 (char_u *)0L}
2670#else
2671 (char_u *)NULL, PV_NONE,
2672 {(char_u *)0L, (char_u *)0L}
2673#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002674 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002675 {"titlestring", NULL, P_STRING|P_VI_DEF,
2676#ifdef FEAT_TITLE
2677 (char_u *)&p_titlestring, PV_NONE,
2678#else
2679 (char_u *)NULL, PV_NONE,
2680#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002681 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002682#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002683 {"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002684 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002685 {(char_u *)"icons,tooltips", (char_u *)0L}
2686 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002687#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002688#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002689 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
2690 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002691 {(char_u *)"small", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002692#endif
2693 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2694 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002695 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002696 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2697 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002698 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002699 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2700 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002701 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002702 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2703 (char_u *)&p_tf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002704 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002705 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2706#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2707 (char_u *)&p_ttym, PV_NONE,
2708#else
2709 (char_u *)NULL, PV_NONE,
2710#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002711 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002712 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2713 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002714 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002715 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2716 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002717 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002718 {"undodir", "udir", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP|P_SECURE
2719 |P_VI_DEF,
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002720#ifdef FEAT_PERSISTENT_UNDO
2721 (char_u *)&p_udir, PV_NONE,
2722 {(char_u *)".", (char_u *)0L}
2723#else
2724 (char_u *)NULL, PV_NONE,
2725 {(char_u *)0L, (char_u *)0L}
2726#endif
2727 SCRIPTID_INIT},
2728 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2729#ifdef FEAT_PERSISTENT_UNDO
2730 (char_u *)&p_udf, PV_UDF,
2731#else
2732 (char_u *)NULL, PV_NONE,
2733#endif
2734 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002735 {"undolevels", "ul", P_NUM|P_VI_DEF,
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01002736 (char_u *)&p_ul, PV_UL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002737 {
2738#if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS)
2739 (char_u *)1000L,
2740#else
2741 (char_u *)100L,
2742#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002743 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar59f931e2010-07-24 20:27:03 +02002744 {"undoreload", "ur", P_NUM|P_VI_DEF,
2745 (char_u *)&p_ur, PV_NONE,
2746 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002747 {"updatecount", "uc", P_NUM|P_VI_DEF,
2748 (char_u *)&p_uc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002749 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002750 {"updatetime", "ut", P_NUM|P_VI_DEF,
2751 (char_u *)&p_ut, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002752 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002753 {"verbose", "vbs", P_NUM|P_VI_DEF,
2754 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002755 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002756 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2757 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002758 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002759 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2760#ifdef FEAT_SESSION
2761 (char_u *)&p_vdir, PV_NONE,
2762 {(char_u *)DFLT_VDIR, (char_u *)0L}
2763#else
2764 (char_u *)NULL, PV_NONE,
2765 {(char_u *)0L, (char_u *)0L}
2766#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002767 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002768 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002769#ifdef FEAT_SESSION
2770 (char_u *)&p_vop, PV_NONE,
2771 {(char_u *)"folds,options,cursor", (char_u *)0L}
2772#else
2773 (char_u *)NULL, PV_NONE,
2774 {(char_u *)0L, (char_u *)0L}
2775#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002776 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002777 {"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002778#ifdef FEAT_VIMINFO
2779 (char_u *)&p_viminfo, PV_NONE,
2780#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
Bram Moolenaard812df62008-11-09 12:46:09 +00002781 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002782#else
2783# ifdef AMIGA
2784 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002785 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002786# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002787 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002788# endif
2789#endif
2790#else
2791 (char_u *)NULL, PV_NONE,
2792 {(char_u *)0L, (char_u *)0L}
2793#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002794 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002795 {"virtualedit", "ve", P_STRING|P_ONECOMMA|P_NODUP|P_VI_DEF
2796 |P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002797#ifdef FEAT_VIRTUALEDIT
2798 (char_u *)&p_ve, PV_NONE,
2799 {(char_u *)"", (char_u *)""}
2800#else
2801 (char_u *)NULL, PV_NONE,
2802 {(char_u *)0L, (char_u *)0L}
2803#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002804 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002805 {"visualbell", "vb", P_BOOL|P_VI_DEF,
2806 (char_u *)&p_vb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002807 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002808 {"w300", 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 {"w1200", 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 {"w9600", NULL, P_NUM|P_VI_DEF,
2815 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002816 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002817 {"warn", NULL, P_BOOL|P_VI_DEF,
2818 (char_u *)&p_warn, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002819 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002820 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
2821 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002822 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002823 {"whichwrap", "ww", P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002824 (char_u *)&p_ww, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002825 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002826 {"wildchar", "wc", P_NUM|P_VIM,
2827 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002828 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
2829 SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002830 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002831 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002832 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002833 {"wildignore", "wig", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002834#ifdef FEAT_WILDIGN
2835 (char_u *)&p_wig, PV_NONE,
2836#else
2837 (char_u *)NULL, PV_NONE,
2838#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002839 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002840 {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
2841 (char_u *)&p_wic, PV_NONE,
2842 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002843 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
2844#ifdef FEAT_WILDMENU
2845 (char_u *)&p_wmnu, PV_NONE,
2846#else
2847 (char_u *)NULL, PV_NONE,
2848#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002849 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002850 {"wildmode", "wim", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002851 (char_u *)&p_wim, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002852 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00002853 {"wildoptions", "wop", P_STRING|P_VI_DEF,
2854#ifdef FEAT_CMDL_COMPL
2855 (char_u *)&p_wop, PV_NONE,
2856 {(char_u *)"", (char_u *)0L}
2857#else
2858 (char_u *)NULL, PV_NONE,
2859 {(char_u *)NULL, (char_u *)0L}
2860#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002861 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002862 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
2863#ifdef FEAT_WAK
2864 (char_u *)&p_wak, PV_NONE,
2865 {(char_u *)"menu", (char_u *)0L}
2866#else
2867 (char_u *)NULL, PV_NONE,
2868 {(char_u *)NULL, (char_u *)0L}
2869#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002870 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002871 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00002872 (char_u *)&p_window, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002873 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002874 {"winheight", "wh", P_NUM|P_VI_DEF,
2875#ifdef FEAT_WINDOWS
2876 (char_u *)&p_wh, PV_NONE,
2877#else
2878 (char_u *)NULL, PV_NONE,
2879#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002880 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002881 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002882#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002883 (char_u *)VAR_WIN, PV_WFH,
2884#else
2885 (char_u *)NULL, PV_NONE,
2886#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002887 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002888 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
2889#ifdef FEAT_VERTSPLIT
2890 (char_u *)VAR_WIN, PV_WFW,
2891#else
2892 (char_u *)NULL, PV_NONE,
2893#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002894 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002895 {"winminheight", "wmh", P_NUM|P_VI_DEF,
2896#ifdef FEAT_WINDOWS
2897 (char_u *)&p_wmh, PV_NONE,
2898#else
2899 (char_u *)NULL, PV_NONE,
2900#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002901 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002902 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
2903#ifdef FEAT_VERTSPLIT
2904 (char_u *)&p_wmw, PV_NONE,
2905#else
2906 (char_u *)NULL, PV_NONE,
2907#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002908 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002909 {"winwidth", "wiw", P_NUM|P_VI_DEF,
2910#ifdef FEAT_VERTSPLIT
2911 (char_u *)&p_wiw, PV_NONE,
2912#else
2913 (char_u *)NULL, PV_NONE,
2914#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002915 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002916 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
2917 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002918 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002919 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
2920 (char_u *)&p_wm, PV_WM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002921 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002922 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
2923 (char_u *)&p_ws, 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 {"write", NULL, P_BOOL|P_VI_DEF,
2926 (char_u *)&p_write, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002927 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002928 {"writeany", "wa", P_BOOL|P_VI_DEF,
2929 (char_u *)&p_wa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002930 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002931 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
2932 (char_u *)&p_wb, PV_NONE,
2933 {
2934#ifdef FEAT_WRITEBACKUP
2935 (char_u *)TRUE,
2936#else
2937 (char_u *)FALSE,
2938#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002939 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002940 {"writedelay", "wd", P_NUM|P_VI_DEF,
2941 (char_u *)&p_wd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002942 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002943
2944/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002945#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00002946 (char_u *)&vvv, PV_NONE, \
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002947 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002948
2949 p_term("t_AB", T_CAB)
2950 p_term("t_AF", T_CAF)
2951 p_term("t_AL", T_CAL)
2952 p_term("t_al", T_AL)
2953 p_term("t_bc", T_BC)
2954 p_term("t_cd", T_CD)
2955 p_term("t_ce", T_CE)
2956 p_term("t_cl", T_CL)
2957 p_term("t_cm", T_CM)
2958 p_term("t_Co", T_CCO)
2959 p_term("t_CS", T_CCS)
2960 p_term("t_cs", T_CS)
2961#ifdef FEAT_VERTSPLIT
2962 p_term("t_CV", T_CSV)
2963#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002964 p_term("t_da", T_DA)
2965 p_term("t_db", T_DB)
2966 p_term("t_DL", T_CDL)
2967 p_term("t_dl", T_DL)
Bram Moolenaare5401222015-06-25 19:16:56 +02002968 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002969 p_term("t_fs", T_FS)
2970 p_term("t_IE", T_CIE)
2971 p_term("t_IS", T_CIS)
2972 p_term("t_ke", T_KE)
2973 p_term("t_ks", T_KS)
2974 p_term("t_le", T_LE)
2975 p_term("t_mb", T_MB)
2976 p_term("t_md", T_MD)
2977 p_term("t_me", T_ME)
2978 p_term("t_mr", T_MR)
2979 p_term("t_ms", T_MS)
2980 p_term("t_nd", T_ND)
2981 p_term("t_op", T_OP)
Bram Moolenaare5401222015-06-25 19:16:56 +02002982 p_term("t_RB", T_RBG)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002983 p_term("t_RI", T_CRI)
2984 p_term("t_RV", T_CRV)
2985 p_term("t_Sb", T_CSB)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002986 p_term("t_se", T_SE)
Bram Moolenaare5401222015-06-25 19:16:56 +02002987 p_term("t_Sf", T_CSF)
2988 p_term("t_SI", T_CSI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002989 p_term("t_so", T_SO)
Bram Moolenaare5401222015-06-25 19:16:56 +02002990 p_term("t_SR", T_CSR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002991 p_term("t_sr", T_SR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002992 p_term("t_te", T_TE)
2993 p_term("t_ti", T_TI)
Bram Moolenaare5401222015-06-25 19:16:56 +02002994 p_term("t_ts", T_TS)
2995 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002996 p_term("t_ue", T_UE)
2997 p_term("t_us", T_US)
Bram Moolenaare5401222015-06-25 19:16:56 +02002998 p_term("t_ut", T_UT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002999 p_term("t_vb", T_VB)
3000 p_term("t_ve", T_VE)
3001 p_term("t_vi", T_VI)
3002 p_term("t_vs", T_VS)
3003 p_term("t_WP", T_CWP)
3004 p_term("t_WS", T_CWS)
Bram Moolenaar494838a2015-02-10 19:20:37 +01003005 p_term("t_xn", T_XN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003006 p_term("t_xs", T_XS)
3007 p_term("t_ZH", T_CZH)
3008 p_term("t_ZR", T_CZR)
3009
3010/* terminal key codes are not in here */
3011
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003012 /* end marker */
3013 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00003014};
3015
3016#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
3017
3018#ifdef FEAT_MBYTE
3019static char *(p_ambw_values[]) = {"single", "double", NULL};
3020#endif
3021static char *(p_bg_values[]) = {"light", "dark", NULL};
3022static char *(p_nf_values[]) = {"octal", "hex", "alpha", NULL};
3023static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003024#ifdef FEAT_CRYPT
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02003025static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2", NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003026#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003027#ifdef FEAT_CMDL_COMPL
3028static char *(p_wop_values[]) = {"tagfile", NULL};
3029#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003030#ifdef FEAT_WAK
3031static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
3032#endif
3033static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003034static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
3035static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003036static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003037#ifdef FEAT_BROWSE
3038static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
3039#endif
3040#ifdef FEAT_SCROLLBIND
3041static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
3042#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00003043static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003044#ifdef FEAT_VERTSPLIT
3045static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
3046#endif
3047#if defined(FEAT_QUICKFIX)
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003048# ifdef FEAT_AUTOCMD
3049static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
3050# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003051static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003052# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003053static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
3054#endif
3055static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
3056#ifdef FEAT_FOLDING
3057static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003058# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00003059 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003060# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003061 NULL};
3062static char *(p_fcl_values[]) = {"all", NULL};
3063#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003064#ifdef FEAT_INS_EXPAND
Bram Moolenaarb6be1e22015-07-10 18:18:40 +02003065static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003066#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003067
3068static void set_option_default __ARGS((int, int opt_flags, int compatible));
3069static void set_options_default __ARGS((int opt_flags));
Bram Moolenaarf740b292006-02-16 22:11:02 +00003070static char_u *term_bg_default __ARGS((void));
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003071static void did_set_option __ARGS((int opt_idx, int opt_flags, int new_value));
Bram Moolenaar071d4272004-06-13 20:20:40 +00003072static char_u *illegal_char __ARGS((char_u *, int));
3073static int string_to_key __ARGS((char_u *arg));
3074#ifdef FEAT_CMDWIN
3075static char_u *check_cedit __ARGS((void));
3076#endif
3077#ifdef FEAT_TITLE
3078static void did_set_title __ARGS((int icon));
3079#endif
3080static char_u *option_expand __ARGS((int opt_idx, char_u *val));
3081static void didset_options __ARGS((void));
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003082static void didset_options2 __ARGS((void));
Bram Moolenaar071d4272004-06-13 20:20:40 +00003083static void check_string_option __ARGS((char_u **pp));
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003084#if defined(FEAT_EVAL) || defined(PROTO)
3085static long_u *insecure_flag __ARGS((int opt_idx, int opt_flags));
3086#else
3087# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3088#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003089static void set_string_option_global __ARGS((int opt_idx, char_u **varp));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02003090static char_u *set_string_option __ARGS((int opt_idx, char_u *value, int opt_flags));
Bram Moolenaar071d4272004-06-13 20:20:40 +00003091static 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));
3092static char_u *set_chars_option __ARGS((char_u **varp));
Bram Moolenaar1a384422010-07-14 19:53:30 +02003093#ifdef FEAT_SYN_HL
3094static int int_cmp __ARGS((const void *a, const void *b));
3095#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003096#ifdef FEAT_CLIPBOARD
3097static char_u *check_clipboard_option __ARGS((void));
3098#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003099#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003100static char_u *did_set_spell_option __ARGS((int is_spellfile));
Bram Moolenaar860cae12010-06-05 23:22:07 +02003101static char_u *compile_cap_prog __ARGS((synblock_T *synblock));
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003102#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003103#ifdef FEAT_EVAL
3104static void set_option_scriptID_idx __ARGS((int opt_idx, int opt_flags, int id));
3105#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003106static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value, int opt_flags));
Bram Moolenaar555b2802005-05-19 21:08:39 +00003107static 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 +00003108static void check_redraw __ARGS((long_u flags));
3109static int findoption __ARGS((char_u *));
3110static int find_key_option __ARGS((char_u *));
3111static void showoptions __ARGS((int all, int opt_flags));
3112static int optval_default __ARGS((struct vimoption *, char_u *varp));
3113static void showoneopt __ARGS((struct vimoption *, int opt_flags));
3114static int put_setstring __ARGS((FILE *fd, char *cmd, char *name, char_u **valuep, int expand));
3115static int put_setnum __ARGS((FILE *fd, char *cmd, char *name, long *valuep));
3116static int put_setbool __ARGS((FILE *fd, char *cmd, char *name, int value));
3117static int istermoption __ARGS((struct vimoption *));
3118static char_u *get_varp_scope __ARGS((struct vimoption *p, int opt_flags));
3119static char_u *get_varp __ARGS((struct vimoption *));
3120static void option_value2string __ARGS((struct vimoption *, int opt_flags));
Bram Moolenaar8dc907d2014-06-25 14:44:10 +02003121static void check_winopt __ARGS((winopt_T *wop));
Bram Moolenaar071d4272004-06-13 20:20:40 +00003122static int wc_use_keyname __ARGS((char_u *varp, long *wcp));
3123#ifdef FEAT_LANGMAP
3124static void langmap_init __ARGS((void));
3125static void langmap_set __ARGS((void));
3126#endif
3127static void paste_option_changed __ARGS((void));
3128static void compatible_set __ARGS((void));
3129#ifdef FEAT_LINEBREAK
3130static void fill_breakat_flags __ARGS((void));
3131#endif
3132static int opt_strings_flags __ARGS((char_u *val, char **values, unsigned *flagp, int list));
3133static int check_opt_strings __ARGS((char_u *val, char **values, int));
3134static int check_opt_wim __ARGS((void));
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003135#ifdef FEAT_LINEBREAK
3136static int briopt_check __ARGS((win_T *wp));
3137#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003138
3139/*
3140 * Initialize the options, first part.
3141 *
3142 * Called only once from main(), just after creating the first buffer.
3143 */
3144 void
3145set_init_1()
3146{
3147 char_u *p;
3148 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003149 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003150
3151#ifdef FEAT_LANGMAP
3152 langmap_init();
3153#endif
3154
3155 /* Be Vi compatible by default */
3156 p_cp = TRUE;
3157
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003158 /* Use POSIX compatibility when $VIM_POSIX is set. */
3159 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003160 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003161 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003162 set_string_default("shm", (char_u *)"A");
3163 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003164
Bram Moolenaar071d4272004-06-13 20:20:40 +00003165 /*
3166 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003167 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003168 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003169 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003170#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
3171# ifdef __EMX__
Bram Moolenaar7c626922005-02-07 22:01:03 +00003172 || ((p = mch_getenv((char_u *)"EMXSHELL")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003173# endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003174 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003175# ifdef WIN3264
Bram Moolenaar7c626922005-02-07 22:01:03 +00003176 || ((p = default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003177# endif
3178#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003179 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003180 set_string_default("sh", p);
3181
3182#ifdef FEAT_WILDIGN
3183 /*
3184 * Set the default for 'backupskip' to include environment variables for
3185 * temp files.
3186 */
3187 {
3188# ifdef UNIX
3189 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3190# else
3191 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3192# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003193 int len;
3194 garray_T ga;
3195 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003196
3197 ga_init2(&ga, 1, 100);
3198 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3199 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003200 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003201# ifdef UNIX
3202 if (*names[n] == NUL)
3203 p = (char_u *)"/tmp";
3204 else
3205# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003206 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003207 if (p != NULL && *p != NUL)
3208 {
3209 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003210 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003211 if (ga_grow(&ga, len) == OK)
3212 {
3213 if (ga.ga_len > 0)
3214 STRCAT(ga.ga_data, ",");
3215 STRCAT(ga.ga_data, p);
3216 add_pathsep(ga.ga_data);
3217 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003218 ga.ga_len += len;
3219 }
3220 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003221 if (mustfree)
3222 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003223 }
3224 if (ga.ga_data != NULL)
3225 {
3226 set_string_default("bsk", ga.ga_data);
3227 vim_free(ga.ga_data);
3228 }
3229 }
3230#endif
3231
3232 /*
3233 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3234 */
3235 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003236 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003237 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003238#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3239 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3240#endif
3241 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003242#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003243 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003244 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003245#else
3246# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003247 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003248 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003249# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003250 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003251# endif
3252#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003253 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003254 opt_idx = findoption((char_u *)"maxmem");
3255 if (opt_idx >= 0)
3256 {
3257#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
Bram Moolenaar427d51c2013-06-16 16:01:25 +02003258 if ((long)options[opt_idx].def_val[VI_DEFAULT] > (long)n
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003259 || (long)options[opt_idx].def_val[VI_DEFAULT] == 0L)
3260#endif
3261 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3262 }
3263 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003264 }
3265
3266#ifdef FEAT_GUI_W32
3267 /* force 'shortname' for Win32s */
3268 if (gui_is_win32s())
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003269 {
3270 opt_idx = findoption((char_u *)"shortname");
3271 if (opt_idx >= 0)
3272 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)TRUE;
3273 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003274#endif
3275
3276#ifdef FEAT_SEARCHPATH
3277 {
3278 char_u *cdpath;
3279 char_u *buf;
3280 int i;
3281 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003282 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003283
3284 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003285 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003286 if (cdpath != NULL)
3287 {
3288 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3289 if (buf != NULL)
3290 {
3291 buf[0] = ','; /* start with ",", current dir first */
3292 j = 1;
3293 for (i = 0; cdpath[i] != NUL; ++i)
3294 {
3295 if (vim_ispathlistsep(cdpath[i]))
3296 buf[j++] = ',';
3297 else
3298 {
3299 if (cdpath[i] == ' ' || cdpath[i] == ',')
3300 buf[j++] = '\\';
3301 buf[j++] = cdpath[i];
3302 }
3303 }
3304 buf[j] = NUL;
3305 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003306 if (opt_idx >= 0)
3307 {
3308 options[opt_idx].def_val[VI_DEFAULT] = buf;
3309 options[opt_idx].flags |= P_DEF_ALLOCED;
3310 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003311 else
3312 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003313 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003314 if (mustfree)
3315 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003316 }
3317 }
3318#endif
3319
3320#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(OS2) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
3321 /* Set print encoding on platforms that don't default to latin1 */
3322 set_string_default("penc",
3323# if defined(MSWIN) || defined(OS2)
3324 (char_u *)"cp1252"
3325# else
3326# ifdef VMS
3327 (char_u *)"dec-mcs"
3328# else
3329# ifdef EBCDIC
3330 (char_u *)"ebcdic-uk"
3331# else
3332# ifdef MAC
3333 (char_u *)"mac-roman"
3334# else /* HPUX */
3335 (char_u *)"hp-roman8"
3336# endif
3337# endif
3338# endif
3339# endif
3340 );
3341#endif
3342
3343#ifdef FEAT_POSTSCRIPT
3344 /* 'printexpr' must be allocated to be able to evaluate it. */
3345 set_string_default("pexpr",
Bram Moolenaared203462004-06-16 11:19:22 +00003346# if defined(MSWIN) || defined(MSDOS) || defined(OS2)
3347 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003348# else
3349# ifdef VMS
3350 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3351
3352# else
3353 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3354# endif
3355# endif
3356 );
3357#endif
3358
3359 /*
3360 * Set all the options (except the terminal options) to their default
3361 * value. Also set the global value for local options.
3362 */
3363 set_options_default(0);
3364
3365#ifdef FEAT_GUI
3366 if (found_reverse_arg)
3367 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3368#endif
3369
3370 curbuf->b_p_initialized = TRUE;
3371 curbuf->b_p_ar = -1; /* no local 'autoread' value */
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01003372 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003373 check_buf_options(curbuf);
3374 check_win_options(curwin);
3375 check_options();
3376
3377 /* Must be before option_expand(), because that one needs vim_isIDc() */
3378 didset_options();
3379
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003380#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003381 /* Use the current chartab for the generic chartab. This is not in
3382 * didset_options() because it only depends on 'encoding'. */
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003383 init_spell_chartab();
3384#endif
3385
Bram Moolenaar071d4272004-06-13 20:20:40 +00003386 /*
3387 * Expand environment variables and things like "~" for the defaults.
3388 * If option_expand() returns non-NULL the variable is expanded. This can
3389 * only happen for non-indirect options.
3390 * Also set the default to the expanded value, so ":set" does not list
3391 * them.
3392 * Don't set the P_ALLOCED flag, because we don't want to free the
3393 * default.
3394 */
3395 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3396 {
3397 if ((options[opt_idx].flags & P_GETTEXT)
3398 && options[opt_idx].var != NULL)
3399 p = (char_u *)_(*(char **)options[opt_idx].var);
3400 else
3401 p = option_expand(opt_idx, NULL);
3402 if (p != NULL && (p = vim_strsave(p)) != NULL)
3403 {
3404 *(char_u **)options[opt_idx].var = p;
3405 /* VIMEXP
3406 * Defaults for all expanded options are currently the same for Vi
3407 * and Vim. When this changes, add some code here! Also need to
3408 * split P_DEF_ALLOCED in two.
3409 */
3410 if (options[opt_idx].flags & P_DEF_ALLOCED)
3411 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3412 options[opt_idx].def_val[VI_DEFAULT] = p;
3413 options[opt_idx].flags |= P_DEF_ALLOCED;
3414 }
3415 }
3416
Bram Moolenaar071d4272004-06-13 20:20:40 +00003417 save_file_ff(curbuf); /* Buffer is unchanged */
3418
Bram Moolenaar071d4272004-06-13 20:20:40 +00003419#if defined(FEAT_ARABIC)
3420 /* Detect use of mlterm.
3421 * Mlterm is a terminal emulator akin to xterm that has some special
3422 * abilities (bidi namely).
3423 * NOTE: mlterm's author is being asked to 'set' a variable
3424 * instead of an environment variable due to inheritance.
3425 */
3426 if (mch_getenv((char_u *)"MLTERM") != NULL)
3427 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3428#endif
3429
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003430 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003431
3432#ifdef FEAT_MBYTE
3433# if defined(WIN3264) && defined(FEAT_GETTEXT)
3434 /*
3435 * If $LANG isn't set, try to get a good value for it. This makes the
3436 * right language be used automatically. Don't do this for English.
3437 */
3438 if (mch_getenv((char_u *)"LANG") == NULL)
3439 {
3440 char buf[20];
3441
3442 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3443 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3444 * only the first two. */
3445 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3446 (LPTSTR)buf, 20);
3447 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3448 {
3449 /* There are a few exceptions (probably more) */
3450 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3451 STRCPY(buf, "zh_TW");
3452 else if (STRNICMP(buf, "chs", 3) == 0
3453 || STRNICMP(buf, "zhc", 3) == 0)
3454 STRCPY(buf, "zh_CN");
3455 else if (STRNICMP(buf, "jp", 2) == 0)
3456 STRCPY(buf, "ja");
3457 else
3458 buf[2] = NUL; /* truncate to two-letter code */
3459 vim_setenv("LANG", buf);
3460 }
3461 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003462# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003463# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003464 /* Moved to os_mac_conv.c to avoid dependency problems. */
3465 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003466# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003467# endif
3468
3469 /* enc_locale() will try to find the encoding of the current locale. */
3470 p = enc_locale();
3471 if (p != NULL)
3472 {
3473 char_u *save_enc;
3474
3475 /* Try setting 'encoding' and check if the value is valid.
3476 * If not, go back to the default "latin1". */
3477 save_enc = p_enc;
3478 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003479 if (STRCMP(p_enc, "gb18030") == 0)
3480 {
3481 /* We don't support "gb18030", but "cp936" is a good substitute
3482 * for practical purposes, thus use that. It's not an alias to
3483 * still support conversion between gb18030 and utf-8. */
3484 p_enc = vim_strsave((char_u *)"cp936");
3485 vim_free(p);
3486 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003487 if (mb_init() == NULL)
3488 {
3489 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003490 if (opt_idx >= 0)
3491 {
3492 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3493 options[opt_idx].flags |= P_DEF_ALLOCED;
3494 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003495
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003496#if defined(MSDOS) || defined(MSWIN) || defined(OS2) || defined(MACOS) \
3497 || defined(VMS)
3498 if (STRCMP(p_enc, "latin1") == 0
3499# ifdef FEAT_MBYTE
3500 || enc_utf8
3501# endif
3502 )
3503 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003504 /* Adjust the default for 'isprint' and 'iskeyword' to match
3505 * latin1. Also set the defaults for when 'nocompatible' is
3506 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003507 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003508 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003509 set_string_option_direct((char_u *)"isk", -1,
3510 ISK_LATIN1, OPT_FREE, SID_NONE);
3511 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003512 if (opt_idx >= 0)
3513 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003514 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003515 if (opt_idx >= 0)
3516 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003517 (void)init_chartab();
3518 }
3519#endif
3520
Bram Moolenaar071d4272004-06-13 20:20:40 +00003521# if defined(WIN3264) && !defined(FEAT_GUI)
3522 /* Win32 console: When GetACP() returns a different value from
3523 * GetConsoleCP() set 'termencoding'. */
3524 if (GetACP() != GetConsoleCP())
3525 {
3526 char buf[50];
3527
3528 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3529 p_tenc = vim_strsave((char_u *)buf);
3530 if (p_tenc != NULL)
3531 {
3532 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003533 if (opt_idx >= 0)
3534 {
3535 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3536 options[opt_idx].flags |= P_DEF_ALLOCED;
3537 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003538 convert_setup(&input_conv, p_tenc, p_enc);
3539 convert_setup(&output_conv, p_enc, p_tenc);
3540 }
3541 else
3542 p_tenc = empty_option;
3543 }
3544# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003545# if defined(WIN3264) && defined(FEAT_MBYTE)
3546 /* $HOME may have characters in active code page. */
3547 init_homedir();
3548# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003549 }
3550 else
3551 {
3552 vim_free(p_enc);
3553 p_enc = save_enc;
3554 }
3555 }
3556#endif
3557
3558#ifdef FEAT_MULTI_LANG
3559 /* Set the default for 'helplang'. */
3560 set_helplang_default(get_mess_lang());
3561#endif
3562}
3563
3564/*
3565 * Set an option to its default value.
3566 * This does not take care of side effects!
3567 */
3568 static void
3569set_option_default(opt_idx, opt_flags, compatible)
3570 int opt_idx;
3571 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3572 int compatible; /* use Vi default value */
3573{
3574 char_u *varp; /* pointer to variable for current option */
3575 int dvi; /* index in def_val[] */
3576 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003577 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003578 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3579
3580 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3581 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003582 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003583 {
3584 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3585 if (flags & P_STRING)
3586 {
3587 /* Use set_string_option_direct() for local options to handle
3588 * freeing and allocating the value. */
3589 if (options[opt_idx].indir != PV_NONE)
3590 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003591 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003592 else
3593 {
3594 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3595 free_string_option(*(char_u **)(varp));
3596 *(char_u **)varp = options[opt_idx].def_val[dvi];
3597 options[opt_idx].flags &= ~P_ALLOCED;
3598 }
3599 }
3600 else if (flags & P_NUM)
3601 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003602 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003603 win_comp_scroll(curwin);
3604 else
3605 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003606 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003607 /* May also set global value for local option. */
3608 if (both)
3609 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3610 *(long *)varp;
3611 }
3612 }
3613 else /* P_BOOL */
3614 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003615 /* the cast to long is required for Manx C, long_i is needed for
3616 * MSVC */
3617 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003618#ifdef UNIX
3619 /* 'modeline' defaults to off for root */
3620 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3621 *(int *)varp = FALSE;
3622#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003623 /* May also set global value for local option. */
3624 if (both)
3625 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3626 *(int *)varp;
3627 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003628
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003629 /* The default value is not insecure. */
3630 flagsp = insecure_flag(opt_idx, opt_flags);
3631 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003632 }
3633
3634#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003635 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003636#endif
3637}
3638
3639/*
3640 * Set all options (except terminal options) to their default value.
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003641 * When "opt_flags" is non-zero skip 'encoding'.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003642 */
3643 static void
3644set_options_default(opt_flags)
3645 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3646{
3647 int i;
3648#ifdef FEAT_WINDOWS
3649 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003650 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003651#endif
3652
3653 for (i = 0; !istermoption(&options[i]); i++)
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003654 if (!(options[i].flags & P_NODEFAULT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003655 && (opt_flags == 0
3656 || (options[i].var != (char_u *)&p_enc
Bram Moolenaar80606872015-08-25 21:27:35 +02003657#if defined(FEAT_CRYPT)
Bram Moolenaare68c25c2015-08-25 15:39:55 +02003658 && options[i].var != (char_u *)&p_cm
Bram Moolenaar80606872015-08-25 21:27:35 +02003659 && options[i].var != (char_u *)&p_key
3660#endif
3661 )))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003662 set_option_default(i, opt_flags, p_cp);
3663
3664#ifdef FEAT_WINDOWS
3665 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003666 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003667 win_comp_scroll(wp);
3668#else
3669 win_comp_scroll(curwin);
3670#endif
Bram Moolenaar5a4eceb2014-09-09 17:33:07 +02003671#ifdef FEAT_CINDENT
3672 parse_cino(curbuf);
3673#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003674}
3675
3676/*
3677 * Set the Vi-default value of a string option.
3678 * Used for 'sh', 'backupskip' and 'term'.
3679 */
3680 void
3681set_string_default(name, val)
3682 char *name;
3683 char_u *val;
3684{
3685 char_u *p;
3686 int opt_idx;
3687
3688 p = vim_strsave(val);
3689 if (p != NULL) /* we don't want a NULL */
3690 {
3691 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003692 if (opt_idx >= 0)
3693 {
3694 if (options[opt_idx].flags & P_DEF_ALLOCED)
3695 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3696 options[opt_idx].def_val[VI_DEFAULT] = p;
3697 options[opt_idx].flags |= P_DEF_ALLOCED;
3698 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003699 }
3700}
3701
3702/*
3703 * Set the Vi-default value of a number option.
3704 * Used for 'lines' and 'columns'.
3705 */
3706 void
3707set_number_default(name, val)
3708 char *name;
3709 long val;
3710{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003711 int opt_idx;
3712
3713 opt_idx = findoption((char_u *)name);
3714 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003715 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003716}
3717
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003718#if defined(EXITFREE) || defined(PROTO)
3719/*
3720 * Free all options.
3721 */
3722 void
3723free_all_options()
3724{
3725 int i;
3726
3727 for (i = 0; !istermoption(&options[i]); i++)
3728 {
3729 if (options[i].indir == PV_NONE)
3730 {
3731 /* global option: free value and default value. */
3732 if (options[i].flags & P_ALLOCED && options[i].var != NULL)
3733 free_string_option(*(char_u **)options[i].var);
3734 if (options[i].flags & P_DEF_ALLOCED)
3735 free_string_option(options[i].def_val[VI_DEFAULT]);
3736 }
3737 else if (options[i].var != VAR_WIN
3738 && (options[i].flags & P_STRING))
3739 /* buffer-local option: free global value */
3740 free_string_option(*(char_u **)options[i].var);
3741 }
3742}
3743#endif
3744
3745
Bram Moolenaar071d4272004-06-13 20:20:40 +00003746/*
3747 * Initialize the options, part two: After getting Rows and Columns and
3748 * setting 'term'.
3749 */
3750 void
3751set_init_2()
3752{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003753 int idx;
3754
Bram Moolenaar071d4272004-06-13 20:20:40 +00003755 /*
3756 * 'scroll' defaults to half the window height. Note that this default is
3757 * wrong when the window height changes.
3758 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003759 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003760 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003761 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003762 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003763 comp_col();
3764
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003765 /*
3766 * 'window' is only for backwards compatibility with Vi.
3767 * Default is Rows - 1.
3768 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003769 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003770 p_window = Rows - 1;
3771 set_number_default("window", Rows - 1);
3772
Bram Moolenaarf740b292006-02-16 22:11:02 +00003773 /* For DOS console the default is always black. */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003774#if !((defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003775 /*
3776 * If 'background' wasn't set by the user, try guessing the value,
3777 * depending on the terminal name. Only need to check for terminals
3778 * with a dark background, that can handle color.
3779 */
3780 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003781 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3782 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003783 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003784 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003785 /* don't mark it as set, when starting the GUI it may be
3786 * changed again */
3787 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003788 }
3789#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003790
3791#ifdef CURSOR_SHAPE
3792 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3793#endif
3794#ifdef FEAT_MOUSESHAPE
3795 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3796#endif
3797#ifdef FEAT_PRINTER
3798 (void)parse_printoptions(); /* parse 'printoptions' default value */
3799#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003800}
3801
3802/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00003803 * Return "dark" or "light" depending on the kind of terminal.
3804 * This is just guessing! Recognized are:
3805 * "linux" Linux console
3806 * "screen.linux" Linux console with screen
3807 * "cygwin" Cygwin shell
3808 * "putty" Putty program
3809 * We also check the COLORFGBG environment variable, which is set by
3810 * rxvt and derivatives. This variable contains either two or three
3811 * values separated by semicolons; we want the last value in either
3812 * case. If this value is 0-6 or 8, our background is dark.
3813 */
3814 static char_u *
3815term_bg_default()
3816{
Bram Moolenaarf740b292006-02-16 22:11:02 +00003817#if defined(MSDOS) || defined(OS2) || defined(WIN3264)
3818 /* DOS console nearly always black */
3819 return (char_u *)"dark";
3820#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00003821 char_u *p;
3822
Bram Moolenaarf740b292006-02-16 22:11:02 +00003823 if (STRCMP(T_NAME, "linux") == 0
3824 || STRCMP(T_NAME, "screen.linux") == 0
3825 || STRCMP(T_NAME, "cygwin") == 0
3826 || STRCMP(T_NAME, "putty") == 0
3827 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
3828 && (p = vim_strrchr(p, ';')) != NULL
3829 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
3830 && p[2] == NUL))
3831 return (char_u *)"dark";
3832 return (char_u *)"light";
3833#endif
3834}
3835
3836/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00003837 * Initialize the options, part three: After reading the .vimrc
3838 */
3839 void
3840set_init_3()
3841{
3842#if defined(UNIX) || defined(OS2) || defined(WIN3264)
3843/*
3844 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
3845 * This is done after other initializations, where 'shell' might have been
3846 * set, but only if they have not been set before.
3847 */
3848 char_u *p;
3849 int idx_srr;
3850 int do_srr;
3851#ifdef FEAT_QUICKFIX
3852 int idx_sp;
3853 int do_sp;
3854#endif
3855
3856 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003857 if (idx_srr < 0)
3858 do_srr = FALSE;
3859 else
3860 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003861#ifdef FEAT_QUICKFIX
3862 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003863 if (idx_sp < 0)
3864 do_sp = FALSE;
3865 else
3866 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003867#endif
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003868 p = get_isolated_shell_name();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003869 if (p != NULL)
3870 {
3871 /*
3872 * Default for p_sp is "| tee", for p_srr is ">".
3873 * For known shells it is changed here to include stderr.
3874 */
3875 if ( fnamecmp(p, "csh") == 0
3876 || fnamecmp(p, "tcsh") == 0
3877# if defined(OS2) || defined(WIN3264) /* also check with .exe extension */
3878 || fnamecmp(p, "csh.exe") == 0
3879 || fnamecmp(p, "tcsh.exe") == 0
3880# endif
3881 )
3882 {
3883#if defined(FEAT_QUICKFIX)
3884 if (do_sp)
3885 {
3886# ifdef WIN3264
3887 p_sp = (char_u *)">&";
3888# else
3889 p_sp = (char_u *)"|& tee";
3890# endif
3891 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3892 }
3893#endif
3894 if (do_srr)
3895 {
3896 p_srr = (char_u *)">&";
3897 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3898 }
3899 }
3900 else
3901# ifndef OS2 /* Always use bourne shell style redirection if we reach this */
3902 if ( fnamecmp(p, "sh") == 0
3903 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003904 || fnamecmp(p, "mksh") == 0
3905 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003906 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003907 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003908 || fnamecmp(p, "bash") == 0
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003909 || fnamecmp(p, "fish") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003910# ifdef WIN3264
3911 || fnamecmp(p, "cmd") == 0
3912 || fnamecmp(p, "sh.exe") == 0
3913 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003914 || fnamecmp(p, "mksh.exe") == 0
3915 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003916 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003917 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003918 || fnamecmp(p, "bash.exe") == 0
3919 || fnamecmp(p, "cmd.exe") == 0
3920# endif
3921 )
3922# endif
3923 {
3924#if defined(FEAT_QUICKFIX)
3925 if (do_sp)
3926 {
3927# ifdef WIN3264
3928 p_sp = (char_u *)">%s 2>&1";
3929# else
3930 p_sp = (char_u *)"2>&1| tee";
3931# endif
3932 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3933 }
3934#endif
3935 if (do_srr)
3936 {
3937 p_srr = (char_u *)">%s 2>&1";
3938 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3939 }
3940 }
3941 vim_free(p);
3942 }
3943#endif
3944
3945#if defined(MSDOS) || defined(WIN3264) || defined(OS2)
3946 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01003947 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
3948 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003949 * This is done after other initializations, where 'shell' might have been
3950 * set, but only if they have not been set before. Default for p_shcf is
3951 * "/c", for p_shq is "". For "sh" like shells it is changed here to
3952 * "-c" and "\"", but not for DJGPP, because it starts the shell without
3953 * command.com. And for Win32 we need to set p_sxq instead.
3954 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00003955 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003956 {
3957 int idx3;
3958
3959 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003960 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003961 {
3962 p_shcf = (char_u *)"-c";
3963 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3964 }
3965
3966# ifndef DJGPP
3967# ifdef WIN3264
3968 /* Somehow Win32 requires the quotes around the redirection too */
3969 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003970 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003971 {
3972 p_sxq = (char_u *)"\"";
3973 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3974 }
3975# else
3976 idx3 = findoption((char_u *)"shq");
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_shq = (char_u *)"\"";
3980 options[idx3].def_val[VI_DEFAULT] = p_shq;
3981 }
3982# endif
3983# endif
3984 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01003985 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
3986 {
3987 int idx3;
3988
3989 /*
3990 * cmd.exe on Windows will strip the first and last double quote given
3991 * on the command line, e.g. most of the time things like:
3992 * cmd /c "my path/to/echo" "my args to echo"
3993 * become:
3994 * my path/to/echo" "my args to echo
3995 * when executed.
3996 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01003997 * To avoid this, set shellxquote to surround the command in
3998 * parenthesis. This appears to make most commands work, without
3999 * breaking commands that worked previously, such as
4000 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01004001 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01004002 idx3 = findoption((char_u *)"sxq");
4003 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4004 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004005 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004006 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4007 }
4008
Bram Moolenaara64ba222012-02-12 23:23:31 +01004009 idx3 = findoption((char_u *)"shcf");
4010 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4011 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004012 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004013 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4014 }
4015 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004016#endif
4017
4018#ifdef FEAT_TITLE
4019 set_title_defaults();
4020#endif
4021}
4022
4023#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4024/*
4025 * When 'helplang' is still at its default value, set it to "lang".
4026 * Only the first two characters of "lang" are used.
4027 */
4028 void
4029set_helplang_default(lang)
4030 char_u *lang;
4031{
4032 int idx;
4033
4034 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4035 return;
4036 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004037 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004038 {
4039 if (options[idx].flags & P_ALLOCED)
4040 free_string_option(p_hlg);
4041 p_hlg = vim_strsave(lang);
4042 if (p_hlg == NULL)
4043 p_hlg = empty_option;
4044 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004045 {
4046 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4047 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4048 {
4049 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4050 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4051 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004052 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004053 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004054 options[idx].flags |= P_ALLOCED;
4055 }
4056}
4057#endif
4058
4059#ifdef FEAT_GUI
4060static char_u *gui_bg_default __ARGS((void));
4061
4062 static char_u *
4063gui_bg_default()
4064{
4065 if (gui_get_lightness(gui.back_pixel) < 127)
4066 return (char_u *)"dark";
4067 return (char_u *)"light";
4068}
4069
4070/*
4071 * Option initializations that can only be done after opening the GUI window.
4072 */
4073 void
4074init_gui_options()
4075{
4076 /* Set the 'background' option according to the lightness of the
4077 * background color, unless the user has set it already. */
4078 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4079 {
4080 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4081 highlight_changed();
4082 }
4083}
4084#endif
4085
4086#ifdef FEAT_TITLE
4087/*
4088 * 'title' and 'icon' only default to true if they have not been set or reset
4089 * in .vimrc and we can read the old value.
4090 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4091 * they can be reset. This reduces startup time when using X on a remote
4092 * machine.
4093 */
4094 void
4095set_title_defaults()
4096{
4097 int idx1;
4098 long val;
4099
4100 /*
4101 * If GUI is (going to be) used, we can always set the window title and
4102 * icon name. Saves a bit of time, because the X11 display server does
4103 * not need to be contacted.
4104 */
4105 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004106 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004107 {
4108#ifdef FEAT_GUI
4109 if (gui.starting || gui.in_use)
4110 val = TRUE;
4111 else
4112#endif
4113 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004114 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004115 p_title = val;
4116 }
4117 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004118 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004119 {
4120#ifdef FEAT_GUI
4121 if (gui.starting || gui.in_use)
4122 val = TRUE;
4123 else
4124#endif
4125 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004126 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004127 p_icon = val;
4128 }
4129}
4130#endif
4131
4132/*
4133 * Parse 'arg' for option settings.
4134 *
4135 * 'arg' may be IObuff, but only when no errors can be present and option
4136 * does not need to be expanded with option_expand().
4137 * "opt_flags":
4138 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004139 * OPT_GLOBAL for ":setglobal"
4140 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004141 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004142 * OPT_WINONLY to only set window-local options
4143 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004144 *
4145 * returns FAIL if an error is detected, OK otherwise
4146 */
4147 int
4148do_set(arg, opt_flags)
4149 char_u *arg; /* option string (may be written to!) */
4150 int opt_flags;
4151{
4152 int opt_idx;
4153 char_u *errmsg;
4154 char_u errbuf[80];
4155 char_u *startarg;
4156 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4157 int nextchar; /* next non-white char after option name */
4158 int afterchar; /* character just after option name */
4159 int len;
4160 int i;
4161 long value;
4162 int key;
4163 long_u flags; /* flags for current option */
4164 char_u *varp = NULL; /* pointer to variable for current option */
4165 int did_show = FALSE; /* already showed one value */
4166 int adding; /* "opt+=arg" */
4167 int prepending; /* "opt^=arg" */
4168 int removing; /* "opt-=arg" */
4169 int cp_val = 0;
4170 char_u key_name[2];
4171
4172 if (*arg == NUL)
4173 {
4174 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004175 did_show = TRUE;
4176 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004177 }
4178
4179 while (*arg != NUL) /* loop to process all options */
4180 {
4181 errmsg = NULL;
4182 startarg = arg; /* remember for error message */
4183
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004184 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4185 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004186 {
4187 /*
4188 * ":set all" show all options.
4189 * ":set all&" set all options to their default value.
4190 */
4191 arg += 3;
4192 if (*arg == '&')
4193 {
4194 ++arg;
4195 /* Only for :set command set global value of local options. */
4196 set_options_default(OPT_FREE | opt_flags);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02004197 didset_options();
4198 didset_options2();
Bram Moolenaarb341dda2015-08-25 12:56:31 +02004199 redraw_all_later(CLEAR);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004200 }
4201 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004202 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004203 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004204 did_show = TRUE;
4205 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004206 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004207 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004208 {
4209 showoptions(2, opt_flags);
4210 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004211 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004212 arg += 7;
4213 }
4214 else
4215 {
4216 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004217 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004218 {
4219 prefix = 0;
4220 arg += 2;
4221 }
4222 else if (STRNCMP(arg, "inv", 3) == 0)
4223 {
4224 prefix = 2;
4225 arg += 3;
4226 }
4227
4228 /* find end of name */
4229 key = 0;
4230 if (*arg == '<')
4231 {
4232 nextchar = 0;
4233 opt_idx = -1;
4234 /* look out for <t_>;> */
4235 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4236 len = 5;
4237 else
4238 {
4239 len = 1;
4240 while (arg[len] != NUL && arg[len] != '>')
4241 ++len;
4242 }
4243 if (arg[len] != '>')
4244 {
4245 errmsg = e_invarg;
4246 goto skip;
4247 }
4248 arg[len] = NUL; /* put NUL after name */
4249 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4250 opt_idx = findoption(arg + 1);
4251 arg[len++] = '>'; /* restore '>' */
4252 if (opt_idx == -1)
4253 key = find_key_option(arg + 1);
4254 }
4255 else
4256 {
4257 len = 0;
4258 /*
4259 * The two characters after "t_" may not be alphanumeric.
4260 */
4261 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4262 len = 4;
4263 else
4264 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4265 ++len;
4266 nextchar = arg[len];
4267 arg[len] = NUL; /* put NUL after name */
4268 opt_idx = findoption(arg);
4269 arg[len] = nextchar; /* restore nextchar */
4270 if (opt_idx == -1)
4271 key = find_key_option(arg);
4272 }
4273
4274 /* remember character after option name */
4275 afterchar = arg[len];
4276
4277 /* skip white space, allow ":set ai ?" */
4278 while (vim_iswhite(arg[len]))
4279 ++len;
4280
4281 adding = FALSE;
4282 prepending = FALSE;
4283 removing = FALSE;
4284 if (arg[len] != NUL && arg[len + 1] == '=')
4285 {
4286 if (arg[len] == '+')
4287 {
4288 adding = TRUE; /* "+=" */
4289 ++len;
4290 }
4291 else if (arg[len] == '^')
4292 {
4293 prepending = TRUE; /* "^=" */
4294 ++len;
4295 }
4296 else if (arg[len] == '-')
4297 {
4298 removing = TRUE; /* "-=" */
4299 ++len;
4300 }
4301 }
4302 nextchar = arg[len];
4303
4304 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4305 {
4306 errmsg = (char_u *)N_("E518: Unknown option");
4307 goto skip;
4308 }
4309
4310 if (opt_idx >= 0)
4311 {
4312 if (options[opt_idx].var == NULL) /* hidden option: skip */
4313 {
4314 /* Only give an error message when requesting the value of
4315 * a hidden option, ignore setting it. */
4316 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4317 && (!(options[opt_idx].flags & P_BOOL)
4318 || nextchar == '?'))
4319 errmsg = (char_u *)N_("E519: Option not supported");
4320 goto skip;
4321 }
4322
4323 flags = options[opt_idx].flags;
4324 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4325 }
4326 else
4327 {
4328 flags = P_STRING;
4329 if (key < 0)
4330 {
4331 key_name[0] = KEY2TERMCAP0(key);
4332 key_name[1] = KEY2TERMCAP1(key);
4333 }
4334 else
4335 {
4336 key_name[0] = KS_KEY;
4337 key_name[1] = (key & 0xff);
4338 }
4339 }
4340
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004341 /* Skip all options that are not window-local (used when showing
4342 * an already loaded buffer in a window). */
4343 if ((opt_flags & OPT_WINONLY)
4344 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4345 goto skip;
4346
Bram Moolenaara3227e22006-03-08 21:32:40 +00004347 /* Skip all options that are window-local (used for :vimgrep). */
4348 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4349 && options[opt_idx].var == VAR_WIN)
4350 goto skip;
4351
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004352 /* Disallow changing some options from modelines. */
4353 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004354 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004355 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004356 {
4357 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4358 goto skip;
4359 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004360#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004361 /* In diff mode some options are overruled. This avoids that
4362 * 'foldmethod' becomes "marker" instead of "diff" and that
4363 * "wrap" gets set. */
4364 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004365 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004366 && (options[opt_idx].indir == PV_FDM
4367 || options[opt_idx].indir == PV_WRAP))
4368 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004369#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004370 }
4371
4372#ifdef HAVE_SANDBOX
4373 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004374 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004375 {
4376 errmsg = (char_u *)_(e_sandbox);
4377 goto skip;
4378 }
4379#endif
4380
4381 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4382 {
4383 arg += len;
4384 cp_val = p_cp;
4385 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4386 {
4387 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4388 {
4389 cp_val = FALSE;
4390 arg += 3;
4391 }
4392 else /* "opt&vi": set to Vi default */
4393 {
4394 cp_val = TRUE;
4395 arg += 2;
4396 }
4397 }
4398 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
4399 && arg[1] != NUL && !vim_iswhite(arg[1]))
4400 {
4401 errmsg = e_trailing;
4402 goto skip;
4403 }
4404 }
4405
4406 /*
4407 * allow '=' and ':' as MSDOS command.com allows only one
4408 * '=' character per "set" command line. grrr. (jw)
4409 */
4410 if (nextchar == '?'
4411 || (prefix == 1
4412 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4413 && !(flags & P_BOOL)))
4414 {
4415 /*
4416 * print value
4417 */
4418 if (did_show)
4419 msg_putchar('\n'); /* cursor below last one */
4420 else
4421 {
4422 gotocmdline(TRUE); /* cursor at status line */
4423 did_show = TRUE; /* remember that we did a line */
4424 }
4425 if (opt_idx >= 0)
4426 {
4427 showoneopt(&options[opt_idx], opt_flags);
4428#ifdef FEAT_EVAL
4429 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004430 {
4431 /* Mention where the option was last set. */
4432 if (varp == options[opt_idx].var)
4433 last_set_msg(options[opt_idx].scriptID);
4434 else if ((int)options[opt_idx].indir & PV_WIN)
4435 last_set_msg(curwin->w_p_scriptID[
4436 (int)options[opt_idx].indir & PV_MASK]);
4437 else if ((int)options[opt_idx].indir & PV_BUF)
4438 last_set_msg(curbuf->b_p_scriptID[
4439 (int)options[opt_idx].indir & PV_MASK]);
4440 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004441#endif
4442 }
4443 else
4444 {
4445 char_u *p;
4446
4447 p = find_termcode(key_name);
4448 if (p == NULL)
4449 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004450 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004451 goto skip;
4452 }
4453 else
4454 (void)show_one_termcode(key_name, p, TRUE);
4455 }
4456 if (nextchar != '?'
4457 && nextchar != NUL && !vim_iswhite(afterchar))
4458 errmsg = e_trailing;
4459 }
4460 else
4461 {
4462 if (flags & P_BOOL) /* boolean */
4463 {
4464 if (nextchar == '=' || nextchar == ':')
4465 {
4466 errmsg = e_invarg;
4467 goto skip;
4468 }
4469
4470 /*
4471 * ":set opt!": invert
4472 * ":set opt&": reset to default value
4473 * ":set opt<": reset to global value
4474 */
4475 if (nextchar == '!')
4476 value = *(int *)(varp) ^ 1;
4477 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004478 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004479 ((flags & P_VI_DEF) || cp_val)
4480 ? VI_DEFAULT : VIM_DEFAULT];
4481 else if (nextchar == '<')
4482 {
4483 /* For 'autoread' -1 means to use global value. */
4484 if ((int *)varp == &curbuf->b_p_ar
4485 && opt_flags == OPT_LOCAL)
4486 value = -1;
4487 else
4488 value = *(int *)get_varp_scope(&(options[opt_idx]),
4489 OPT_GLOBAL);
4490 }
4491 else
4492 {
4493 /*
4494 * ":set invopt": invert
4495 * ":set opt" or ":set noopt": set or reset
4496 */
4497 if (nextchar != NUL && !vim_iswhite(afterchar))
4498 {
4499 errmsg = e_trailing;
4500 goto skip;
4501 }
4502 if (prefix == 2) /* inv */
4503 value = *(int *)(varp) ^ 1;
4504 else
4505 value = prefix;
4506 }
4507
4508 errmsg = set_bool_option(opt_idx, varp, (int)value,
4509 opt_flags);
4510 }
4511 else /* numeric or string */
4512 {
4513 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4514 || prefix != 1)
4515 {
4516 errmsg = e_invarg;
4517 goto skip;
4518 }
4519
4520 if (flags & P_NUM) /* numeric */
4521 {
4522 /*
4523 * Different ways to set a number option:
4524 * & set to default value
4525 * < set to global value
4526 * <xx> accept special key codes for 'wildchar'
4527 * c accept any non-digit for 'wildchar'
4528 * [-]0-9 set number
4529 * other error
4530 */
4531 ++arg;
4532 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004533 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004534 ((flags & P_VI_DEF) || cp_val)
4535 ? VI_DEFAULT : VIM_DEFAULT];
4536 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004537 {
4538 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4539 * use the global value. */
4540 if ((long *)varp == &curbuf->b_p_ul
4541 && opt_flags == OPT_LOCAL)
4542 value = NO_LOCAL_UNDOLEVEL;
4543 else
4544 value = *(long *)get_varp_scope(
4545 &(options[opt_idx]), OPT_GLOBAL);
4546 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004547 else if (((long *)varp == &p_wc
4548 || (long *)varp == &p_wcm)
4549 && (*arg == '<'
4550 || *arg == '^'
4551 || ((!arg[1] || vim_iswhite(arg[1]))
4552 && !VIM_ISDIGIT(*arg))))
4553 {
4554 value = string_to_key(arg);
4555 if (value == 0 && (long *)varp != &p_wcm)
4556 {
4557 errmsg = e_invarg;
4558 goto skip;
4559 }
4560 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004561 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4562 {
Bram Moolenaar18400e62015-01-27 15:58:40 +01004563 /* Allow negative (for 'undolevels'), octal and
4564 * hex numbers. */
Bram Moolenaar5d1bc782015-07-17 13:03:48 +02004565 vim_str2nr(arg, NULL, &i, TRUE, TRUE, &value, NULL, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004566 if (arg[i] != NUL && !vim_iswhite(arg[i]))
4567 {
4568 errmsg = e_invarg;
4569 goto skip;
4570 }
4571 }
4572 else
4573 {
4574 errmsg = (char_u *)N_("E521: Number required after =");
4575 goto skip;
4576 }
4577
4578 if (adding)
4579 value = *(long *)varp + value;
4580 if (prepending)
4581 value = *(long *)varp * value;
4582 if (removing)
4583 value = *(long *)varp - value;
4584 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004585 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004586 }
4587 else if (opt_idx >= 0) /* string */
4588 {
4589 char_u *save_arg = NULL;
4590 char_u *s = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004591 char_u *oldval = NULL; /* previous value if *varp */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004592 char_u *newval;
Bram Moolenaar53744302015-07-17 17:38:22 +02004593 char_u *origval = NULL;
4594#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4595 char_u *saved_origval = NULL;
4596#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004597 unsigned newlen;
4598 int comma;
4599 int bs;
4600 int new_value_alloced; /* new string option
4601 was allocated */
4602
4603 /* When using ":set opt=val" for a global option
4604 * with a local value the local value will be
4605 * reset, use the global value here. */
4606 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004607 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004608 varp = options[opt_idx].var;
4609
4610 /* The old value is kept until we are sure that the
4611 * new value is valid. */
4612 oldval = *(char_u **)varp;
4613 if (nextchar == '&') /* set to default val */
4614 {
4615 newval = options[opt_idx].def_val[
4616 ((flags & P_VI_DEF) || cp_val)
4617 ? VI_DEFAULT : VIM_DEFAULT];
4618 if ((char_u **)varp == &p_bg)
4619 {
4620 /* guess the value of 'background' */
4621#ifdef FEAT_GUI
4622 if (gui.in_use)
4623 newval = gui_bg_default();
4624 else
4625#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004626 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004627 }
4628
4629 /* expand environment variables and ~ (since the
4630 * default value was already expanded, only
4631 * required when an environment variable was set
4632 * later */
4633 if (newval == NULL)
4634 newval = empty_option;
4635 else
4636 {
4637 s = option_expand(opt_idx, newval);
4638 if (s == NULL)
4639 s = newval;
4640 newval = vim_strsave(s);
4641 }
4642 new_value_alloced = TRUE;
4643 }
4644 else if (nextchar == '<') /* set to global val */
4645 {
4646 newval = vim_strsave(*(char_u **)get_varp_scope(
4647 &(options[opt_idx]), OPT_GLOBAL));
4648 new_value_alloced = TRUE;
4649 }
4650 else
4651 {
4652 ++arg; /* jump to after the '=' or ':' */
4653
4654 /*
4655 * Set 'keywordprg' to ":help" if an empty
4656 * value was passed to :set by the user.
4657 * Misuse errbuf[] for the resulting string.
4658 */
4659 if (varp == (char_u *)&p_kp
4660 && (*arg == NUL || *arg == ' '))
4661 {
4662 STRCPY(errbuf, ":help");
4663 save_arg = arg;
4664 arg = errbuf;
4665 }
4666 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004667 * Convert 'backspace' number to string, for
4668 * adding, prepending and removing string.
4669 */
4670 else if (varp == (char_u *)&p_bs
4671 && VIM_ISDIGIT(**(char_u **)varp))
4672 {
4673 i = getdigits((char_u **)varp);
4674 switch (i)
4675 {
4676 case 0:
4677 *(char_u **)varp = empty_option;
4678 break;
4679 case 1:
4680 *(char_u **)varp = vim_strsave(
4681 (char_u *)"indent,eol");
4682 break;
4683 case 2:
4684 *(char_u **)varp = vim_strsave(
4685 (char_u *)"indent,eol,start");
4686 break;
4687 }
4688 vim_free(oldval);
4689 oldval = *(char_u **)varp;
4690 }
4691 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004692 * Convert 'whichwrap' number to string, for
4693 * backwards compatibility with Vim 3.0.
4694 * Misuse errbuf[] for the resulting string.
4695 */
4696 else if (varp == (char_u *)&p_ww
4697 && VIM_ISDIGIT(*arg))
4698 {
4699 *errbuf = NUL;
4700 i = getdigits(&arg);
4701 if (i & 1)
4702 STRCAT(errbuf, "b,");
4703 if (i & 2)
4704 STRCAT(errbuf, "s,");
4705 if (i & 4)
4706 STRCAT(errbuf, "h,l,");
4707 if (i & 8)
4708 STRCAT(errbuf, "<,>,");
4709 if (i & 16)
4710 STRCAT(errbuf, "[,],");
4711 if (*errbuf != NUL) /* remove trailing , */
4712 errbuf[STRLEN(errbuf) - 1] = NUL;
4713 save_arg = arg;
4714 arg = errbuf;
4715 }
4716 /*
4717 * Remove '>' before 'dir' and 'bdir', for
4718 * backwards compatibility with version 3.0
4719 */
4720 else if ( *arg == '>'
4721 && (varp == (char_u *)&p_dir
4722 || varp == (char_u *)&p_bdir))
4723 {
4724 ++arg;
4725 }
4726
4727 /* When setting the local value of a global
4728 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004729 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004730 && (opt_flags & OPT_LOCAL))
4731 origval = *(char_u **)get_varp(
4732 &options[opt_idx]);
4733 else
4734 origval = oldval;
4735
4736 /*
4737 * Copy the new string into allocated memory.
4738 * Can't use set_string_option_direct(), because
4739 * we need to remove the backslashes.
4740 */
4741 /* get a bit too much */
4742 newlen = (unsigned)STRLEN(arg) + 1;
4743 if (adding || prepending || removing)
4744 newlen += (unsigned)STRLEN(origval) + 1;
4745 newval = alloc(newlen);
4746 if (newval == NULL) /* out of mem, don't change */
4747 break;
4748 s = newval;
4749
4750 /*
4751 * Copy the string, skip over escaped chars.
4752 * For MS-DOS and WIN32 backslashes before normal
4753 * file name characters are not removed, and keep
4754 * backslash at start, for "\\machine\path", but
4755 * do remove it for "\\\\machine\\path".
4756 * The reverse is found in ExpandOldSetting().
4757 */
4758 while (*arg && !vim_iswhite(*arg))
4759 {
4760 if (*arg == '\\' && arg[1] != NUL
4761#ifdef BACKSLASH_IN_FILENAME
4762 && !((flags & P_EXPAND)
4763 && vim_isfilec(arg[1])
4764 && (arg[1] != '\\'
4765 || (s == newval
4766 && arg[2] != '\\')))
4767#endif
4768 )
4769 ++arg; /* remove backslash */
4770#ifdef FEAT_MBYTE
4771 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00004772 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004773 {
4774 /* copy multibyte char */
4775 mch_memmove(s, arg, (size_t)i);
4776 arg += i;
4777 s += i;
4778 }
4779 else
4780#endif
4781 *s++ = *arg++;
4782 }
4783 *s = NUL;
4784
4785 /*
4786 * Expand environment variables and ~.
4787 * Don't do it when adding without inserting a
4788 * comma.
4789 */
4790 if (!(adding || prepending || removing)
4791 || (flags & P_COMMA))
4792 {
4793 s = option_expand(opt_idx, newval);
4794 if (s != NULL)
4795 {
4796 vim_free(newval);
4797 newlen = (unsigned)STRLEN(s) + 1;
4798 if (adding || prepending || removing)
4799 newlen += (unsigned)STRLEN(origval) + 1;
4800 newval = alloc(newlen);
4801 if (newval == NULL)
4802 break;
4803 STRCPY(newval, s);
4804 }
4805 }
4806
4807 /* locate newval[] in origval[] when removing it
4808 * and when adding to avoid duplicates */
4809 i = 0; /* init for GCC */
4810 if (removing || (flags & P_NODUP))
4811 {
4812 i = (int)STRLEN(newval);
4813 bs = 0;
4814 for (s = origval; *s; ++s)
4815 {
4816 if ((!(flags & P_COMMA)
4817 || s == origval
4818 || (s[-1] == ',' && !(bs & 1)))
4819 && STRNCMP(s, newval, i) == 0
4820 && (!(flags & P_COMMA)
4821 || s[i] == ','
4822 || s[i] == NUL))
4823 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004824 /* Count backslashes. Only a comma with an
4825 * even number of backslashes before it is
Bram Moolenaar071d4272004-06-13 20:20:40 +00004826 * recognized as a separator */
4827 if (s > origval && s[-1] == '\\')
4828 ++bs;
4829 else
4830 bs = 0;
4831 }
4832
4833 /* do not add if already there */
4834 if ((adding || prepending) && *s)
4835 {
4836 prepending = FALSE;
4837 adding = FALSE;
4838 STRCPY(newval, origval);
4839 }
4840 }
4841
4842 /* concatenate the two strings; add a ',' if
4843 * needed */
4844 if (adding || prepending)
4845 {
4846 comma = ((flags & P_COMMA) && *origval != NUL
4847 && *newval != NUL);
4848 if (adding)
4849 {
4850 i = (int)STRLEN(origval);
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004851 /* strip a trailing comma, would get 2 */
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02004852 if (comma && (flags & P_ONECOMMA) && i > 1
4853 && origval[i - 1] == ','
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004854 && origval[i - 2] != '\\')
4855 i--;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004856 mch_memmove(newval + i + comma, newval,
4857 STRLEN(newval) + 1);
4858 mch_memmove(newval, origval, (size_t)i);
4859 }
4860 else
4861 {
4862 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004863 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004864 }
4865 if (comma)
4866 newval[i] = ',';
4867 }
4868
4869 /* Remove newval[] from origval[]. (Note: "i" has
4870 * been set above and is used here). */
4871 if (removing)
4872 {
4873 STRCPY(newval, origval);
4874 if (*s)
4875 {
4876 /* may need to remove a comma */
4877 if (flags & P_COMMA)
4878 {
4879 if (s == origval)
4880 {
4881 /* include comma after string */
4882 if (s[i] == ',')
4883 ++i;
4884 }
4885 else
4886 {
4887 /* include comma before string */
4888 --s;
4889 ++i;
4890 }
4891 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004892 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004893 }
4894 }
4895
4896 if (flags & P_FLAGLIST)
4897 {
4898 /* Remove flags that appear twice. */
4899 for (s = newval; *s; ++s)
4900 if ((!(flags & P_COMMA) || *s != ',')
4901 && vim_strchr(s + 1, *s) != NULL)
4902 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004903 STRMOVE(s, s + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004904 --s;
4905 }
4906 }
4907
4908 if (save_arg != NULL) /* number for 'whichwrap' */
4909 arg = save_arg;
4910 new_value_alloced = TRUE;
4911 }
4912
4913 /* Set the new value. */
4914 *(char_u **)(varp) = newval;
4915
Bram Moolenaar53744302015-07-17 17:38:22 +02004916#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02004917 if (!starting
4918# ifdef FEAT_CRYPT
4919 && options[opt_idx].indir != PV_KEY
4920# endif
Bram Moolenaar53744302015-07-17 17:38:22 +02004921 && origval != NULL)
4922 /* origval may be freed by
4923 * did_set_string_option(), make a copy. */
4924 saved_origval = vim_strsave(origval);
4925#endif
4926
Bram Moolenaar071d4272004-06-13 20:20:40 +00004927 /* Handle side effects, and set the global value for
4928 * ":set" on local options. */
4929 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
4930 new_value_alloced, oldval, errbuf, opt_flags);
4931
4932 /* If error detected, print the error message. */
4933 if (errmsg != NULL)
4934 goto skip;
Bram Moolenaar53744302015-07-17 17:38:22 +02004935#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4936 if (saved_origval != NULL)
4937 {
4938 char_u buf_type[7];
4939
4940 sprintf((char *)buf_type, "%s",
4941 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02004942 set_vim_var_string(VV_OPTION_NEW,
4943 *(char_u **)varp, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02004944 set_vim_var_string(VV_OPTION_OLD, saved_origval, -1);
4945 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
4946 apply_autocmds(EVENT_OPTIONSET,
4947 (char_u *)options[opt_idx].fullname,
4948 NULL, FALSE, NULL);
4949 reset_v_option_vars();
4950 vim_free(saved_origval);
4951 }
4952#endif
4953
Bram Moolenaar071d4272004-06-13 20:20:40 +00004954 }
4955 else /* key code option */
4956 {
4957 char_u *p;
4958
4959 if (nextchar == '&')
4960 {
4961 if (add_termcap_entry(key_name, TRUE) == FAIL)
4962 errmsg = (char_u *)N_("E522: Not found in termcap");
4963 }
4964 else
4965 {
4966 ++arg; /* jump to after the '=' or ':' */
4967 for (p = arg; *p && !vim_iswhite(*p); ++p)
4968 if (*p == '\\' && p[1] != NUL)
4969 ++p;
4970 nextchar = *p;
4971 *p = NUL;
4972 add_termcode(key_name, arg, FALSE);
4973 *p = nextchar;
4974 }
4975 if (full_screen)
4976 ttest(FALSE);
4977 redraw_all_later(CLEAR);
4978 }
4979 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004980
Bram Moolenaar071d4272004-06-13 20:20:40 +00004981 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004982 did_set_option(opt_idx, opt_flags,
4983 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004984 }
4985
4986skip:
4987 /*
4988 * Advance to next argument.
4989 * - skip until a blank found, taking care of backslashes
4990 * - skip blanks
4991 * - skip one "=val" argument (for hidden options ":set gfn =xx")
4992 */
4993 for (i = 0; i < 2 ; ++i)
4994 {
4995 while (*arg != NUL && !vim_iswhite(*arg))
4996 if (*arg++ == '\\' && *arg != NUL)
4997 ++arg;
4998 arg = skipwhite(arg);
4999 if (*arg != '=')
5000 break;
5001 }
5002 }
5003
5004 if (errmsg != NULL)
5005 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005006 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005007 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005008 if (i + (arg - startarg) < IOSIZE)
5009 {
5010 /* append the argument with the error */
5011 STRCAT(IObuff, ": ");
5012 mch_memmove(IObuff + i, startarg, (arg - startarg));
5013 IObuff[i + (arg - startarg)] = NUL;
5014 }
5015 /* make sure all characters are printable */
5016 trans_characters(IObuff, IOSIZE);
5017
5018 ++no_wait_return; /* wait_return done later */
5019 emsg(IObuff); /* show error highlighted */
5020 --no_wait_return;
5021
5022 return FAIL;
5023 }
5024
5025 arg = skipwhite(arg);
5026 }
5027
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005028theend:
5029 if (silent_mode && did_show)
5030 {
5031 /* After displaying option values in silent mode. */
5032 silent_mode = FALSE;
5033 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5034 msg_putchar('\n');
5035 cursor_on(); /* msg_start() switches it off */
5036 out_flush();
5037 silent_mode = TRUE;
5038 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5039 }
5040
Bram Moolenaar071d4272004-06-13 20:20:40 +00005041 return OK;
5042}
5043
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005044/*
5045 * Call this when an option has been given a new value through a user command.
5046 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5047 */
5048 static void
5049did_set_option(opt_idx, opt_flags, new_value)
5050 int opt_idx;
5051 int opt_flags; /* possibly with OPT_MODELINE */
5052 int new_value; /* value was replaced completely */
5053{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005054 long_u *p;
5055
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005056 options[opt_idx].flags |= P_WAS_SET;
5057
5058 /* When an option is set in the sandbox, from a modeline or in secure mode
5059 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005060 * flag. */
5061 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005062 if (secure
5063#ifdef HAVE_SANDBOX
5064 || sandbox != 0
5065#endif
5066 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005067 *p = *p | P_INSECURE;
5068 else if (new_value)
5069 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005070}
5071
Bram Moolenaar071d4272004-06-13 20:20:40 +00005072 static char_u *
5073illegal_char(errbuf, c)
5074 char_u *errbuf;
5075 int c;
5076{
5077 if (errbuf == NULL)
5078 return (char_u *)"";
5079 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005080 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005081 return errbuf;
5082}
5083
5084/*
5085 * Convert a key name or string into a key value.
5086 * Used for 'wildchar' and 'cedit' options.
5087 */
5088 static int
5089string_to_key(arg)
5090 char_u *arg;
5091{
5092 if (*arg == '<')
5093 return find_key_option(arg + 1);
5094 if (*arg == '^')
5095 return Ctrl_chr(arg[1]);
5096 return *arg;
5097}
5098
5099#ifdef FEAT_CMDWIN
5100/*
5101 * Check value of 'cedit' and set cedit_key.
5102 * Returns NULL if value is OK, error message otherwise.
5103 */
5104 static char_u *
5105check_cedit()
5106{
5107 int n;
5108
5109 if (*p_cedit == NUL)
5110 cedit_key = -1;
5111 else
5112 {
5113 n = string_to_key(p_cedit);
5114 if (vim_isprintc(n))
5115 return e_invarg;
5116 cedit_key = n;
5117 }
5118 return NULL;
5119}
5120#endif
5121
5122#ifdef FEAT_TITLE
5123/*
5124 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5125 * maketitle() to create and display it.
5126 * When switching the title or icon off, call mch_restore_title() to get
5127 * the old value back.
5128 */
5129 static void
5130did_set_title(icon)
5131 int icon; /* Did set icon instead of title */
5132{
5133 if (starting != NO_SCREEN
5134#ifdef FEAT_GUI
5135 && !gui.starting
5136#endif
5137 )
5138 {
5139 maketitle();
5140 if (icon)
5141 {
5142 if (!p_icon)
5143 mch_restore_title(2);
5144 }
5145 else
5146 {
5147 if (!p_title)
5148 mch_restore_title(1);
5149 }
5150 }
5151}
5152#endif
5153
5154/*
5155 * set_options_bin - called when 'bin' changes value.
5156 */
5157 void
5158set_options_bin(oldval, newval, opt_flags)
5159 int oldval;
5160 int newval;
5161 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5162{
5163 /*
5164 * The option values that are changed when 'bin' changes are
5165 * copied when 'bin is set and restored when 'bin' is reset.
5166 */
5167 if (newval)
5168 {
5169 if (!oldval) /* switched on */
5170 {
5171 if (!(opt_flags & OPT_GLOBAL))
5172 {
5173 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5174 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5175 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5176 curbuf->b_p_et_nobin = curbuf->b_p_et;
5177 }
5178 if (!(opt_flags & OPT_LOCAL))
5179 {
5180 p_tw_nobin = p_tw;
5181 p_wm_nobin = p_wm;
5182 p_ml_nobin = p_ml;
5183 p_et_nobin = p_et;
5184 }
5185 }
5186
5187 if (!(opt_flags & OPT_GLOBAL))
5188 {
5189 curbuf->b_p_tw = 0; /* no automatic line wrap */
5190 curbuf->b_p_wm = 0; /* no automatic line wrap */
5191 curbuf->b_p_ml = 0; /* no modelines */
5192 curbuf->b_p_et = 0; /* no expandtab */
5193 }
5194 if (!(opt_flags & OPT_LOCAL))
5195 {
5196 p_tw = 0;
5197 p_wm = 0;
5198 p_ml = FALSE;
5199 p_et = FALSE;
5200 p_bin = TRUE; /* needed when called for the "-b" argument */
5201 }
5202 }
5203 else if (oldval) /* switched off */
5204 {
5205 if (!(opt_flags & OPT_GLOBAL))
5206 {
5207 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5208 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5209 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5210 curbuf->b_p_et = curbuf->b_p_et_nobin;
5211 }
5212 if (!(opt_flags & OPT_LOCAL))
5213 {
5214 p_tw = p_tw_nobin;
5215 p_wm = p_wm_nobin;
5216 p_ml = p_ml_nobin;
5217 p_et = p_et_nobin;
5218 }
5219 }
5220}
5221
5222#ifdef FEAT_VIMINFO
5223/*
5224 * Find the parameter represented by the given character (eg ', :, ", or /),
5225 * and return its associated value in the 'viminfo' string.
5226 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005227 * If the parameter is not specified in the string or there is no following
5228 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005229 */
5230 int
5231get_viminfo_parameter(type)
5232 int type;
5233{
5234 char_u *p;
5235
5236 p = find_viminfo_parameter(type);
5237 if (p != NULL && VIM_ISDIGIT(*p))
5238 return atoi((char *)p);
5239 return -1;
5240}
5241
5242/*
5243 * Find the parameter represented by the given character (eg ''', ':', '"', or
5244 * '/') in the 'viminfo' option and return a pointer to the string after it.
5245 * Return NULL if the parameter is not specified in the string.
5246 */
5247 char_u *
5248find_viminfo_parameter(type)
5249 int type;
5250{
5251 char_u *p;
5252
5253 for (p = p_viminfo; *p; ++p)
5254 {
5255 if (*p == type)
5256 return p + 1;
5257 if (*p == 'n') /* 'n' is always the last one */
5258 break;
5259 p = vim_strchr(p, ','); /* skip until next ',' */
5260 if (p == NULL) /* hit the end without finding parameter */
5261 break;
5262 }
5263 return NULL;
5264}
5265#endif
5266
5267/*
5268 * Expand environment variables for some string options.
5269 * These string options cannot be indirect!
5270 * If "val" is NULL expand the current value of the option.
5271 * Return pointer to NameBuff, or NULL when not expanded.
5272 */
5273 static char_u *
5274option_expand(opt_idx, val)
5275 int opt_idx;
5276 char_u *val;
5277{
5278 /* if option doesn't need expansion nothing to do */
5279 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5280 return NULL;
5281
5282 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5283 * expand_env() would truncate the string. */
5284 if (val != NULL && STRLEN(val) > MAXPATHL)
5285 return NULL;
5286
5287 if (val == NULL)
5288 val = *(char_u **)options[opt_idx].var;
5289
5290 /*
5291 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5292 * Escape spaces when expanding 'tags', they are used to separate file
5293 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005294 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005295 */
5296 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005297 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005298#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005299 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5300#endif
5301 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005302 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5303 return NULL;
5304
5305 return NameBuff;
5306}
5307
5308/*
5309 * After setting various option values: recompute variables that depend on
5310 * option values.
5311 */
5312 static void
5313didset_options()
5314{
5315 /* initialize the table for 'iskeyword' et.al. */
5316 (void)init_chartab();
5317
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005318#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005319 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005320#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005321 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
Bram Moolenaar165bc692015-07-21 17:53:25 +02005322 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005323#ifdef FEAT_SESSION
5324 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5325 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5326#endif
5327#ifdef FEAT_FOLDING
5328 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5329#endif
5330 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
5331#ifdef FEAT_VIRTUALEDIT
5332 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5333#endif
5334#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5335 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5336#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005337#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005338 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005339 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005340 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005341 (void)did_set_spell_option(TRUE);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005342#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005343#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5344 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5345#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005346#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005347 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5348#endif
5349#ifdef FEAT_CMDWIN
5350 /* set cedit_key */
5351 (void)check_cedit();
5352#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005353#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005354 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005355#endif
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005356#ifdef FEAT_LINEBREAK
5357 /* initialize the table for 'breakat'. */
5358 fill_breakat_flags();
5359#endif
5360
5361}
5362
5363/*
5364 * More side effects of setting options.
5365 */
5366 static void
5367didset_options2()
5368{
5369 /* Initialize the highlight_attr[] table. */
5370 (void)highlight_changed();
5371
5372 /* Parse default for 'wildmode' */
5373 check_opt_wim();
5374
5375 (void)set_chars_option(&p_lcs);
5376#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5377 /* Parse default for 'fillchars'. */
5378 (void)set_chars_option(&p_fcs);
5379#endif
5380
5381#ifdef FEAT_CLIPBOARD
5382 /* Parse default for 'clipboard' */
5383 (void)check_clipboard_option();
5384#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005385}
5386
5387/*
5388 * Check for string options that are NULL (normally only termcap options).
5389 */
5390 void
5391check_options()
5392{
5393 int opt_idx;
5394
5395 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5396 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5397 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5398}
5399
5400/*
5401 * Check string options in a buffer for NULL value.
5402 */
5403 void
5404check_buf_options(buf)
5405 buf_T *buf;
5406{
5407#if defined(FEAT_QUICKFIX)
5408 check_string_option(&buf->b_p_bh);
5409 check_string_option(&buf->b_p_bt);
5410#endif
5411#ifdef FEAT_MBYTE
5412 check_string_option(&buf->b_p_fenc);
5413#endif
5414 check_string_option(&buf->b_p_ff);
5415#ifdef FEAT_FIND_ID
5416 check_string_option(&buf->b_p_def);
5417 check_string_option(&buf->b_p_inc);
5418# ifdef FEAT_EVAL
5419 check_string_option(&buf->b_p_inex);
5420# endif
5421#endif
5422#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5423 check_string_option(&buf->b_p_inde);
5424 check_string_option(&buf->b_p_indk);
5425#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005426#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5427 check_string_option(&buf->b_p_bexpr);
5428#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005429#if defined(FEAT_CRYPT)
5430 check_string_option(&buf->b_p_cm);
5431#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005432#if defined(FEAT_EVAL)
5433 check_string_option(&buf->b_p_fex);
5434#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005435#ifdef FEAT_CRYPT
5436 check_string_option(&buf->b_p_key);
5437#endif
5438 check_string_option(&buf->b_p_kp);
5439 check_string_option(&buf->b_p_mps);
5440 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005441 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005442 check_string_option(&buf->b_p_isk);
5443#ifdef FEAT_COMMENTS
5444 check_string_option(&buf->b_p_com);
5445#endif
5446#ifdef FEAT_FOLDING
5447 check_string_option(&buf->b_p_cms);
5448#endif
5449 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005450#ifdef FEAT_TEXTOBJ
5451 check_string_option(&buf->b_p_qe);
5452#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005453#ifdef FEAT_SYN_HL
5454 check_string_option(&buf->b_p_syn);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005455#endif
5456#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005457 check_string_option(&buf->b_s.b_p_spc);
5458 check_string_option(&buf->b_s.b_p_spf);
5459 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005460#endif
5461#ifdef FEAT_SEARCHPATH
5462 check_string_option(&buf->b_p_sua);
5463#endif
5464#ifdef FEAT_CINDENT
5465 check_string_option(&buf->b_p_cink);
5466 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005467 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005468#endif
5469#ifdef FEAT_AUTOCMD
5470 check_string_option(&buf->b_p_ft);
5471#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005472#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5473 check_string_option(&buf->b_p_cinw);
5474#endif
5475#ifdef FEAT_INS_EXPAND
5476 check_string_option(&buf->b_p_cpt);
5477#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005478#ifdef FEAT_COMPL_FUNC
5479 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005480 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005481#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005482#ifdef FEAT_KEYMAP
5483 check_string_option(&buf->b_p_keymap);
5484#endif
5485#ifdef FEAT_QUICKFIX
5486 check_string_option(&buf->b_p_gp);
5487 check_string_option(&buf->b_p_mp);
5488 check_string_option(&buf->b_p_efm);
5489#endif
5490 check_string_option(&buf->b_p_ep);
5491 check_string_option(&buf->b_p_path);
5492 check_string_option(&buf->b_p_tags);
5493#ifdef FEAT_INS_EXPAND
5494 check_string_option(&buf->b_p_dict);
5495 check_string_option(&buf->b_p_tsr);
5496#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005497#ifdef FEAT_LISP
5498 check_string_option(&buf->b_p_lw);
5499#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005500 check_string_option(&buf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005501}
5502
5503/*
5504 * Free the string allocated for an option.
5505 * Checks for the string being empty_option. This may happen if we're out of
5506 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5507 * check_options().
5508 * Does NOT check for P_ALLOCED flag!
5509 */
5510 void
5511free_string_option(p)
5512 char_u *p;
5513{
5514 if (p != empty_option)
5515 vim_free(p);
5516}
5517
5518 void
5519clear_string_option(pp)
5520 char_u **pp;
5521{
5522 if (*pp != empty_option)
5523 vim_free(*pp);
5524 *pp = empty_option;
5525}
5526
5527 static void
5528check_string_option(pp)
5529 char_u **pp;
5530{
5531 if (*pp == NULL)
5532 *pp = empty_option;
5533}
5534
5535/*
5536 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5537 */
5538 void
5539set_term_option_alloced(p)
5540 char_u **p;
5541{
5542 int opt_idx;
5543
5544 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5545 if (options[opt_idx].var == (char_u *)p)
5546 {
5547 options[opt_idx].flags |= P_ALLOCED;
5548 return;
5549 }
5550 return; /* cannot happen: didn't find it! */
5551}
5552
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005553#if defined(FEAT_EVAL) || defined(PROTO)
5554/*
5555 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5556 * Return FALSE when it wasn't.
5557 * Return -1 for an unknown option.
5558 */
5559 int
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005560was_set_insecurely(opt, opt_flags)
5561 char_u *opt;
5562 int opt_flags;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005563{
5564 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005565 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005566
5567 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005568 {
5569 flagp = insecure_flag(idx, opt_flags);
5570 return (*flagp & P_INSECURE) != 0;
5571 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005572 EMSG2(_(e_intern2), "was_set_insecurely()");
5573 return -1;
5574}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005575
5576/*
5577 * Get a pointer to the flags used for the P_INSECURE flag of option
5578 * "opt_idx". For some local options a local flags field is used.
5579 */
5580 static long_u *
5581insecure_flag(opt_idx, opt_flags)
5582 int opt_idx;
5583 int opt_flags;
5584{
5585 if (opt_flags & OPT_LOCAL)
5586 switch ((int)options[opt_idx].indir)
5587 {
5588#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005589 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005590#endif
5591#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005592# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005593 case PV_FDE: return &curwin->w_p_fde_flags;
5594 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005595# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005596# ifdef FEAT_BEVAL
5597 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5598# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005599# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005600 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005601# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005602 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005603# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005604 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005605# endif
5606#endif
5607 }
5608
5609 /* Nothing special, return global flags field. */
5610 return &options[opt_idx].flags;
5611}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005612#endif
5613
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005614#ifdef FEAT_TITLE
5615static void redraw_titles __ARGS((void));
5616
5617/*
5618 * Redraw the window title and/or tab page text later.
5619 */
5620static void redraw_titles()
5621{
5622 need_maketitle = TRUE;
5623# ifdef FEAT_WINDOWS
5624 redraw_tabline = TRUE;
5625# endif
5626}
5627#endif
5628
Bram Moolenaar071d4272004-06-13 20:20:40 +00005629/*
5630 * Set a string option to a new value (without checking the effect).
5631 * The string is copied into allocated memory.
5632 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005633 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005634 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005635 */
5636 void
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005637set_string_option_direct(name, opt_idx, val, opt_flags, set_sid)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005638 char_u *name;
5639 int opt_idx;
5640 char_u *val;
5641 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar78a15312009-05-15 19:33:18 +00005642 int set_sid UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005643{
5644 char_u *s;
5645 char_u **varp;
5646 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005647 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005648
Bram Moolenaar89d40322006-08-29 15:30:07 +00005649 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005650 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005651 idx = findoption(name);
5652 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005653 {
5654 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar0b105412014-11-30 13:34:23 +01005655 EMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005656 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005657 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005658 }
5659
Bram Moolenaar89d40322006-08-29 15:30:07 +00005660 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005661 return;
5662
5663 s = vim_strsave(val);
5664 if (s != NULL)
5665 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005666 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005667 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005668 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005669 free_string_option(*varp);
5670 *varp = s;
5671
5672 /* For buffer/window local option may also set the global value. */
5673 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005674 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005675
Bram Moolenaar89d40322006-08-29 15:30:07 +00005676 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005677
5678 /* When setting both values of a global option with a local value,
5679 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005680 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005681 {
5682 free_string_option(*varp);
5683 *varp = empty_option;
5684 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005685# ifdef FEAT_EVAL
5686 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005687 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005688 set_sid == 0 ? current_SID : set_sid);
5689# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005690 }
5691}
5692
5693/*
5694 * Set global value for string option when it's a local option.
5695 */
5696 static void
5697set_string_option_global(opt_idx, varp)
5698 int opt_idx; /* option index */
5699 char_u **varp; /* pointer to option variable */
5700{
5701 char_u **p, *s;
5702
5703 /* the global value is always allocated */
5704 if (options[opt_idx].var == VAR_WIN)
5705 p = (char_u **)GLOBAL_WO(varp);
5706 else
5707 p = (char_u **)options[opt_idx].var;
5708 if (options[opt_idx].indir != PV_NONE
5709 && p != varp
5710 && (s = vim_strsave(*varp)) != NULL)
5711 {
5712 free_string_option(*p);
5713 *p = s;
5714 }
5715}
5716
5717/*
5718 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005719 *
5720 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005721 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005722 static char_u *
Bram Moolenaar071d4272004-06-13 20:20:40 +00005723set_string_option(opt_idx, value, opt_flags)
5724 int opt_idx;
5725 char_u *value;
5726 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5727{
5728 char_u *s;
5729 char_u **varp;
5730 char_u *oldval;
Bram Moolenaar53744302015-07-17 17:38:22 +02005731#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5732 char_u *saved_oldval = NULL;
5733#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005734 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005735
5736 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005737 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005738
5739 s = vim_strsave(value);
5740 if (s != NULL)
5741 {
5742 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5743 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005744 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005745 ? OPT_GLOBAL : OPT_LOCAL)
5746 : opt_flags);
5747 oldval = *varp;
5748 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02005749
5750#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005751 if (!starting
5752# ifdef FEAT_CRYPT
5753 && options[opt_idx].indir != PV_KEY
5754# endif
5755 )
Bram Moolenaar53744302015-07-17 17:38:22 +02005756 saved_oldval = vim_strsave(oldval);
5757#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005758 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5759 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005760 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02005761
5762 /* call autocomamnd after handling side effects */
5763#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5764 if (saved_oldval != NULL)
5765 {
5766 char_u buf_type[7];
5767 sprintf((char *)buf_type, "%s",
5768 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02005769 set_vim_var_string(VV_OPTION_NEW, *varp, -1);
5770 set_vim_var_string(VV_OPTION_OLD, saved_oldval, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02005771 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
5772 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
5773 reset_v_option_vars();
5774 vim_free(saved_oldval);
5775 }
5776#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005777 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005778 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005779}
5780
5781/*
5782 * Handle string options that need some action to perform when changed.
5783 * Returns NULL for success, or an error message for an error.
5784 */
5785 static char_u *
5786did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
5787 opt_flags)
5788 int opt_idx; /* index in options[] table */
5789 char_u **varp; /* pointer to the option variable */
5790 int new_value_alloced; /* new value was allocated */
5791 char_u *oldval; /* previous value of the option */
5792 char_u *errbuf; /* buffer for errors, or NULL */
5793 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5794{
5795 char_u *errmsg = NULL;
5796 char_u *s, *p;
5797 int did_chartab = FALSE;
5798 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005799 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00005800#ifdef FEAT_GUI
5801 /* set when changing an option that only requires a redraw in the GUI */
5802 int redraw_gui_only = FALSE;
5803#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005804
5805 /* Get the global option to compare with, otherwise we would have to check
5806 * two values for all local options. */
5807 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
5808
5809 /* Disallow changing some options from secure mode */
5810 if ((secure
5811#ifdef HAVE_SANDBOX
5812 || sandbox != 0
5813#endif
5814 ) && (options[opt_idx].flags & P_SECURE))
5815 {
5816 errmsg = e_secure;
5817 }
5818
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005819 /* Check for a "normal" file name in some options. Disallow a path
5820 * separator (slash and/or backslash), wildcards and characters that are
5821 * often illegal in a file name. */
5822 else if ((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005823 && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL)
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005824 {
5825 errmsg = e_invarg;
5826 }
5827
Bram Moolenaar071d4272004-06-13 20:20:40 +00005828 /* 'term' */
5829 else if (varp == &T_NAME)
5830 {
5831 if (T_NAME[0] == NUL)
5832 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
5833#ifdef FEAT_GUI
5834 if (gui.in_use)
5835 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
5836 else if (term_is_gui(T_NAME))
5837 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
5838#endif
5839 else if (set_termname(T_NAME) == FAIL)
5840 errmsg = (char_u *)N_("E522: Not found in termcap");
5841 else
5842 /* Screen colors may have changed. */
5843 redraw_later_clear();
5844 }
5845
5846 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005847 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005848 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005849 char_u *bkc = p_bkc;
5850 unsigned int *flags = &bkc_flags;
5851
5852 if (opt_flags & OPT_LOCAL)
5853 {
5854 bkc = curbuf->b_p_bkc;
5855 flags = &curbuf->b_bkc_flags;
5856 }
5857
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005858 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
5859 /* make the local value empty: use the global value */
5860 *flags = 0;
5861 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00005862 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005863 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
5864 errmsg = e_invarg;
5865 if ((((int)*flags & BKC_AUTO) != 0)
5866 + (((int)*flags & BKC_YES) != 0)
5867 + (((int)*flags & BKC_NO) != 0) != 1)
5868 {
5869 /* Must have exactly one of "auto", "yes" and "no". */
5870 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
5871 errmsg = e_invarg;
5872 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005873 }
5874 }
5875
5876 /* 'backupext' and 'patchmode' */
5877 else if (varp == &p_bex || varp == &p_pm)
5878 {
5879 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
5880 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
5881 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
5882 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02005883#ifdef FEAT_LINEBREAK
5884 /* 'breakindentopt' */
5885 else if (varp == &curwin->w_p_briopt)
5886 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005887 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02005888 errmsg = e_invarg;
5889 }
5890#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005891
5892 /*
5893 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[]
5894 * If the new option is invalid, use old value. 'lisp' option: refill
5895 * chartab[] for '-' char
5896 */
5897 else if ( varp == &p_isi
5898 || varp == &(curbuf->b_p_isk)
5899 || varp == &p_isp
5900 || varp == &p_isf)
5901 {
5902 if (init_chartab() == FAIL)
5903 {
5904 did_chartab = TRUE; /* need to restore it below */
5905 errmsg = e_invarg; /* error in value */
5906 }
5907 }
5908
5909 /* 'helpfile' */
5910 else if (varp == &p_hf)
5911 {
5912 /* May compute new values for $VIM and $VIMRUNTIME */
5913 if (didset_vim)
5914 {
5915 vim_setenv((char_u *)"VIM", (char_u *)"");
5916 didset_vim = FALSE;
5917 }
5918 if (didset_vimruntime)
5919 {
5920 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
5921 didset_vimruntime = FALSE;
5922 }
5923 }
5924
Bram Moolenaar1a384422010-07-14 19:53:30 +02005925#ifdef FEAT_SYN_HL
5926 /* 'colorcolumn' */
5927 else if (varp == &curwin->w_p_cc)
5928 errmsg = check_colorcolumn(curwin);
5929#endif
5930
Bram Moolenaar071d4272004-06-13 20:20:40 +00005931#ifdef FEAT_MULTI_LANG
5932 /* 'helplang' */
5933 else if (varp == &p_hlg)
5934 {
5935 /* Check for "", "ab", "ab,cd", etc. */
5936 for (s = p_hlg; *s != NUL; s += 3)
5937 {
5938 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
5939 {
5940 errmsg = e_invarg;
5941 break;
5942 }
5943 if (s[2] == NUL)
5944 break;
5945 }
5946 }
5947#endif
5948
5949 /* 'highlight' */
5950 else if (varp == &p_hl)
5951 {
5952 if (highlight_changed() == FAIL)
5953 errmsg = e_invarg; /* invalid flags */
5954 }
5955
5956 /* 'nrformats' */
5957 else if (gvarp == &p_nf)
5958 {
5959 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
5960 errmsg = e_invarg;
5961 }
5962
5963#ifdef FEAT_SESSION
5964 /* 'sessionoptions' */
5965 else if (varp == &p_ssop)
5966 {
5967 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
5968 errmsg = e_invarg;
5969 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
5970 {
5971 /* Don't allow both "sesdir" and "curdir". */
5972 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
5973 errmsg = e_invarg;
5974 }
5975 }
5976 /* 'viewoptions' */
5977 else if (varp == &p_vop)
5978 {
5979 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
5980 errmsg = e_invarg;
5981 }
5982#endif
5983
5984 /* 'scrollopt' */
5985#ifdef FEAT_SCROLLBIND
5986 else if (varp == &p_sbo)
5987 {
5988 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
5989 errmsg = e_invarg;
5990 }
5991#endif
5992
5993 /* 'ambiwidth' */
5994#ifdef FEAT_MBYTE
5995 else if (varp == &p_ambw)
5996 {
5997 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
5998 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02005999 else if (set_chars_option(&p_lcs) != NULL)
6000 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
6001# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6002 else if (set_chars_option(&p_fcs) != NULL)
6003 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
6004# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006005 }
6006#endif
6007
6008 /* 'background' */
6009 else if (varp == &p_bg)
6010 {
6011 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
6012 {
6013#ifdef FEAT_EVAL
6014 int dark = (*p_bg == 'd');
6015#endif
6016
6017 init_highlight(FALSE, FALSE);
6018
6019#ifdef FEAT_EVAL
6020 if (dark != (*p_bg == 'd')
6021 && get_var_value((char_u *)"g:colors_name") != NULL)
6022 {
6023 /* The color scheme must have set 'background' back to another
6024 * value, that's not what we want here. Disable the color
6025 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00006026 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006027 free_string_option(p_bg);
6028 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
6029 check_string_option(&p_bg);
6030 init_highlight(FALSE, FALSE);
6031 }
6032#endif
6033 }
6034 else
6035 errmsg = e_invarg;
6036 }
6037
6038 /* 'wildmode' */
6039 else if (varp == &p_wim)
6040 {
6041 if (check_opt_wim() == FAIL)
6042 errmsg = e_invarg;
6043 }
6044
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006045#ifdef FEAT_CMDL_COMPL
6046 /* 'wildoptions' */
6047 else if (varp == &p_wop)
6048 {
6049 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6050 errmsg = e_invarg;
6051 }
6052#endif
6053
Bram Moolenaar071d4272004-06-13 20:20:40 +00006054#ifdef FEAT_WAK
6055 /* 'winaltkeys' */
6056 else if (varp == &p_wak)
6057 {
6058 if (*p_wak == NUL
6059 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6060 errmsg = e_invarg;
6061# ifdef FEAT_MENU
6062# ifdef FEAT_GUI_MOTIF
6063 else if (gui.in_use)
6064 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6065# else
6066# ifdef FEAT_GUI_GTK
6067 else if (gui.in_use)
6068 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6069# endif
6070# endif
6071# endif
6072 }
6073#endif
6074
6075#ifdef FEAT_AUTOCMD
6076 /* 'eventignore' */
6077 else if (varp == &p_ei)
6078 {
6079 if (check_ei() == FAIL)
6080 errmsg = e_invarg;
6081 }
6082#endif
6083
6084#ifdef FEAT_MBYTE
6085 /* 'encoding' and 'fileencoding' */
6086 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc)
6087 {
6088 if (gvarp == &p_fenc)
6089 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006090 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006091 errmsg = e_modifiable;
6092 else if (vim_strchr(*varp, ',') != NULL)
6093 /* No comma allowed in 'fileencoding'; catches confusing it
6094 * with 'fileencodings'. */
6095 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006096 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006097 {
6098# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006099 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006100 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006101# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006102 /* Add 'fileencoding' to the swap file. */
6103 ml_setflags(curbuf);
6104 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006105 }
6106 if (errmsg == NULL)
6107 {
6108 /* canonize the value, so that STRCMP() can be used on it */
6109 p = enc_canonize(*varp);
6110 if (p != NULL)
6111 {
6112 vim_free(*varp);
6113 *varp = p;
6114 }
6115 if (varp == &p_enc)
6116 {
6117 errmsg = mb_init();
6118# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006119 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006120# endif
6121 }
6122 }
6123
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006124# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006125 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6126 {
6127 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6128 if (STRCMP(p_tenc, "utf-8") != 0)
6129 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6130 }
6131# endif
6132
6133 if (errmsg == NULL)
6134 {
6135# ifdef FEAT_KEYMAP
6136 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6137 * (with another encoding). */
6138 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6139 (void)keymap_init();
6140# endif
6141
6142 /* When 'termencoding' is not empty and 'encoding' changes or when
6143 * 'termencoding' changes, need to setup for keyboard input and
6144 * display output conversion. */
6145 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6146 {
6147 convert_setup(&input_conv, p_tenc, p_enc);
6148 convert_setup(&output_conv, p_enc, p_tenc);
6149 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006150
6151# if defined(WIN3264) && defined(FEAT_MBYTE)
6152 /* $HOME may have characters in active code page. */
6153 if (varp == &p_enc)
6154 init_homedir();
6155# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006156 }
6157 }
6158#endif
6159
6160#if defined(FEAT_POSTSCRIPT)
6161 else if (varp == &p_penc)
6162 {
6163 /* Canonize printencoding if VIM standard one */
6164 p = enc_canonize(p_penc);
6165 if (p != NULL)
6166 {
6167 vim_free(p_penc);
6168 p_penc = p;
6169 }
6170 else
6171 {
6172 /* Ensure lower case and '-' for '_' */
6173 for (s = p_penc; *s != NUL; s++)
6174 {
6175 if (*s == '_')
6176 *s = '-';
6177 else
6178 *s = TOLOWER_ASC(*s);
6179 }
6180 }
6181 }
6182#endif
6183
Bram Moolenaar9372a112005-12-06 19:59:18 +00006184#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006185 else if (varp == &p_imak)
6186 {
6187 if (gui.in_use && !im_xim_isvalid_imactivate())
6188 errmsg = e_invarg;
6189 }
6190#endif
6191
6192#ifdef FEAT_KEYMAP
6193 else if (varp == &curbuf->b_p_keymap)
6194 {
6195 /* load or unload key mapping tables */
6196 errmsg = keymap_init();
6197
Bram Moolenaarfab06232009-03-04 03:13:35 +00006198 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006199 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006200 if (*curbuf->b_p_keymap != NUL)
6201 {
6202 /* Installed a new keymap, switch on using it. */
6203 curbuf->b_p_iminsert = B_IMODE_LMAP;
6204 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6205 curbuf->b_p_imsearch = B_IMODE_LMAP;
6206 }
6207 else
6208 {
6209 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6210 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6211 curbuf->b_p_iminsert = B_IMODE_NONE;
6212 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6213 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6214 }
6215 if ((opt_flags & OPT_LOCAL) == 0)
6216 {
6217 set_iminsert_global();
6218 set_imsearch_global();
6219 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006220# ifdef FEAT_WINDOWS
6221 status_redraw_curbuf();
6222# endif
6223 }
6224 }
6225#endif
6226
6227 /* 'fileformat' */
6228 else if (gvarp == &p_ff)
6229 {
6230 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6231 errmsg = e_modifiable;
6232 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6233 errmsg = e_invarg;
6234 else
6235 {
6236 /* may also change 'textmode' */
6237 if (get_fileformat(curbuf) == EOL_DOS)
6238 curbuf->b_p_tx = TRUE;
6239 else
6240 curbuf->b_p_tx = FALSE;
6241#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006242 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006243#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006244 /* update flag in swap file */
6245 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006246 /* Redraw needed when switching to/from "mac": a CR in the text
6247 * will be displayed differently. */
6248 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6249 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006250 }
6251 }
6252
6253 /* 'fileformats' */
6254 else if (varp == &p_ffs)
6255 {
6256 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6257 errmsg = e_invarg;
6258 else
6259 {
6260 /* also change 'textauto' */
6261 if (*p_ffs == NUL)
6262 p_ta = FALSE;
6263 else
6264 p_ta = TRUE;
6265 }
6266 }
6267
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006268#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006269 /* 'cryptkey' */
6270 else if (gvarp == &p_key)
6271 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006272# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006273 /* Make sure the ":set" command doesn't show the new value in the
6274 * history. */
6275 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006276# endif
6277 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6278 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006279 ml_set_crypt_key(curbuf, oldval,
6280 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006281 }
6282
6283 else if (gvarp == &p_cm)
6284 {
6285 if (opt_flags & OPT_LOCAL)
6286 p = curbuf->b_p_cm;
6287 else
6288 p = p_cm;
6289 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6290 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006291 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006292 errmsg = e_invarg;
6293 else
6294 {
6295 /* When setting the global value to empty, make it "zip". */
6296 if (*p_cm == NUL)
6297 {
6298 if (new_value_alloced)
6299 free_string_option(p_cm);
6300 p_cm = vim_strsave((char_u *)"zip");
6301 new_value_alloced = TRUE;
6302 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006303 /* When using ":set cm=name" the local value is going to be empty.
6304 * Do that here, otherwise the crypt functions will still use the
6305 * local value. */
6306 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6307 {
6308 free_string_option(curbuf->b_p_cm);
6309 curbuf->b_p_cm = empty_option;
6310 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006311
6312 /* Need to update the swapfile when the effective method changed.
6313 * Set "s" to the effective old value, "p" to the effective new
6314 * method and compare. */
6315 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6316 s = p_cm; /* was previously using the global value */
6317 else
6318 s = oldval;
6319 if (*curbuf->b_p_cm == NUL)
6320 p = p_cm; /* is now using the global value */
6321 else
6322 p = curbuf->b_p_cm;
6323 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006324 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006325
6326 /* If the global value changes need to update the swapfile for all
6327 * buffers using that value. */
6328 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6329 {
6330 buf_T *buf;
6331
6332 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
6333 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006334 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006335 }
6336 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006337 }
6338#endif
6339
6340 /* 'matchpairs' */
6341 else if (gvarp == &p_mps)
6342 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006343#ifdef FEAT_MBYTE
6344 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006345 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006346 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006347 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006348 int x2 = -1;
6349 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006350
6351 if (*p != NUL)
6352 p += mb_ptr2len(p);
6353 if (*p != NUL)
6354 x2 = *p++;
6355 if (*p != NUL)
6356 {
6357 x3 = mb_ptr2char(p);
6358 p += mb_ptr2len(p);
6359 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006360 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006361 {
6362 errmsg = e_invarg;
6363 break;
6364 }
6365 if (*p == NUL)
6366 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006367 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006368 }
6369 else
6370#endif
6371 {
6372 /* Check for "x:y,x:y" */
6373 for (p = *varp; *p != NUL; p += 4)
6374 {
6375 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6376 {
6377 errmsg = e_invarg;
6378 break;
6379 }
6380 if (p[3] == NUL)
6381 break;
6382 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006383 }
6384 }
6385
6386#ifdef FEAT_COMMENTS
6387 /* 'comments' */
6388 else if (gvarp == &p_com)
6389 {
6390 for (s = *varp; *s; )
6391 {
6392 while (*s && *s != ':')
6393 {
6394 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6395 && !VIM_ISDIGIT(*s) && *s != '-')
6396 {
6397 errmsg = illegal_char(errbuf, *s);
6398 break;
6399 }
6400 ++s;
6401 }
6402 if (*s++ == NUL)
6403 errmsg = (char_u *)N_("E524: Missing colon");
6404 else if (*s == ',' || *s == NUL)
6405 errmsg = (char_u *)N_("E525: Zero length string");
6406 if (errmsg != NULL)
6407 break;
6408 while (*s && *s != ',')
6409 {
6410 if (*s == '\\' && s[1] != NUL)
6411 ++s;
6412 ++s;
6413 }
6414 s = skip_to_option_part(s);
6415 }
6416 }
6417#endif
6418
6419 /* 'listchars' */
6420 else if (varp == &p_lcs)
6421 {
6422 errmsg = set_chars_option(varp);
6423 }
6424
6425#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6426 /* 'fillchars' */
6427 else if (varp == &p_fcs)
6428 {
6429 errmsg = set_chars_option(varp);
6430 }
6431#endif
6432
6433#ifdef FEAT_CMDWIN
6434 /* 'cedit' */
6435 else if (varp == &p_cedit)
6436 {
6437 errmsg = check_cedit();
6438 }
6439#endif
6440
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006441 /* 'verbosefile' */
6442 else if (varp == &p_vfile)
6443 {
6444 verbose_stop();
6445 if (*p_vfile != NUL && verbose_open() == FAIL)
6446 errmsg = e_invarg;
6447 }
6448
Bram Moolenaar071d4272004-06-13 20:20:40 +00006449#ifdef FEAT_VIMINFO
6450 /* 'viminfo' */
6451 else if (varp == &p_viminfo)
6452 {
6453 for (s = p_viminfo; *s;)
6454 {
6455 /* Check it's a valid character */
6456 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6457 {
6458 errmsg = illegal_char(errbuf, *s);
6459 break;
6460 }
6461 if (*s == 'n') /* name is always last one */
6462 {
6463 break;
6464 }
6465 else if (*s == 'r') /* skip until next ',' */
6466 {
6467 while (*++s && *s != ',')
6468 ;
6469 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006470 else if (*s == '%')
6471 {
6472 /* optional number */
6473 while (vim_isdigit(*++s))
6474 ;
6475 }
6476 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006477 ++s; /* no extra chars */
6478 else /* must have a number */
6479 {
6480 while (vim_isdigit(*++s))
6481 ;
6482
6483 if (!VIM_ISDIGIT(*(s - 1)))
6484 {
6485 if (errbuf != NULL)
6486 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006487 sprintf((char *)errbuf,
6488 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006489 transchar_byte(*(s - 1)));
6490 errmsg = errbuf;
6491 }
6492 else
6493 errmsg = (char_u *)"";
6494 break;
6495 }
6496 }
6497 if (*s == ',')
6498 ++s;
6499 else if (*s)
6500 {
6501 if (errbuf != NULL)
6502 errmsg = (char_u *)N_("E527: Missing comma");
6503 else
6504 errmsg = (char_u *)"";
6505 break;
6506 }
6507 }
6508 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6509 errmsg = (char_u *)N_("E528: Must specify a ' value");
6510 }
6511#endif /* FEAT_VIMINFO */
6512
6513 /* terminal options */
6514 else if (istermoption(&options[opt_idx]) && full_screen)
6515 {
6516 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6517 if (varp == &T_CCO)
6518 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006519 int colors = atoi((char *)T_CCO);
6520
6521 /* Only reinitialize colors if t_Co value has really changed to
6522 * avoid expensive reload of colorscheme if t_Co is set to the
6523 * same value multiple times. */
6524 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006525 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006526 t_colors = colors;
6527 if (t_colors <= 1)
6528 {
6529 if (new_value_alloced)
6530 vim_free(T_CCO);
6531 T_CCO = empty_option;
6532 }
6533 /* We now have a different color setup, initialize it again. */
6534 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006535 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006536 }
6537 ttest(FALSE);
6538 if (varp == &T_ME)
6539 {
6540 out_str(T_ME);
6541 redraw_later(CLEAR);
6542#if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32))
6543 /* Since t_me has been set, this probably means that the user
6544 * wants to use this as default colors. Need to reset default
6545 * background/foreground colors. */
6546 mch_set_normal_colors();
6547#endif
6548 }
6549 }
6550
6551#ifdef FEAT_LINEBREAK
6552 /* 'showbreak' */
6553 else if (varp == &p_sbr)
6554 {
6555 for (s = p_sbr; *s; )
6556 {
6557 if (ptr2cells(s) != 1)
6558 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006559 mb_ptr_adv(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006560 }
6561 }
6562#endif
6563
6564#ifdef FEAT_GUI
6565 /* 'guifont' */
6566 else if (varp == &p_guifont)
6567 {
6568 if (gui.in_use)
6569 {
6570 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006571# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006572 /*
6573 * Put up a font dialog and let the user select a new value.
6574 * If this is cancelled go back to the old value but don't
6575 * give an error message.
6576 */
6577 if (STRCMP(p, "*") == 0)
6578 {
6579 p = gui_mch_font_dialog(oldval);
6580
6581 if (new_value_alloced)
6582 free_string_option(p_guifont);
6583
6584 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6585 new_value_alloced = TRUE;
6586 }
6587# endif
6588 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6589 {
6590# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6591 if (STRCMP(p_guifont, "*") == 0)
6592 {
6593 /* Dialog was cancelled: Keep the old value without giving
6594 * an error message. */
6595 if (new_value_alloced)
6596 free_string_option(p_guifont);
6597 p_guifont = vim_strsave(oldval);
6598 new_value_alloced = TRUE;
6599 }
6600 else
6601# endif
6602 errmsg = (char_u *)N_("E596: Invalid font(s)");
6603 }
6604 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006605 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006606 }
6607# ifdef FEAT_XFONTSET
6608 else if (varp == &p_guifontset)
6609 {
6610 if (STRCMP(p_guifontset, "*") == 0)
6611 errmsg = (char_u *)N_("E597: can't select fontset");
6612 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6613 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006614 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006615 }
6616# endif
6617# ifdef FEAT_MBYTE
6618 else if (varp == &p_guifontwide)
6619 {
6620 if (STRCMP(p_guifontwide, "*") == 0)
6621 errmsg = (char_u *)N_("E533: can't select wide font");
6622 else if (gui_get_wide_font() == FAIL)
6623 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006624 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006625 }
6626# endif
6627#endif
6628
6629#ifdef CURSOR_SHAPE
6630 /* 'guicursor' */
6631 else if (varp == &p_guicursor)
6632 errmsg = parse_shape_opt(SHAPE_CURSOR);
6633#endif
6634
6635#ifdef FEAT_MOUSESHAPE
6636 /* 'mouseshape' */
6637 else if (varp == &p_mouseshape)
6638 {
6639 errmsg = parse_shape_opt(SHAPE_MOUSE);
6640 update_mouseshape(-1);
6641 }
6642#endif
6643
6644#ifdef FEAT_PRINTER
6645 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006646 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006647# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006648 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006649 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006650# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006651#endif
6652
6653#ifdef FEAT_LANGMAP
6654 /* 'langmap' */
6655 else if (varp == &p_langmap)
6656 langmap_set();
6657#endif
6658
6659#ifdef FEAT_LINEBREAK
6660 /* 'breakat' */
6661 else if (varp == &p_breakat)
6662 fill_breakat_flags();
6663#endif
6664
6665#ifdef FEAT_TITLE
6666 /* 'titlestring' and 'iconstring' */
6667 else if (varp == &p_titlestring || varp == &p_iconstring)
6668 {
6669# ifdef FEAT_STL_OPT
6670 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6671
6672 /* NULL => statusline syntax */
6673 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6674 stl_syntax |= flagval;
6675 else
6676 stl_syntax &= ~flagval;
6677# endif
6678 did_set_title(varp == &p_iconstring);
6679
6680 }
6681#endif
6682
6683#ifdef FEAT_GUI
6684 /* 'guioptions' */
6685 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006686 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006687 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006688 redraw_gui_only = TRUE;
6689 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006690#endif
6691
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006692#if defined(FEAT_GUI_TABLINE)
6693 /* 'guitablabel' */
6694 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006695 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006696 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006697 redraw_gui_only = TRUE;
6698 }
6699 /* 'guitabtooltip' */
6700 else if (varp == &p_gtt)
6701 {
6702 redraw_gui_only = TRUE;
6703 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006704#endif
6705
Bram Moolenaar071d4272004-06-13 20:20:40 +00006706#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6707 /* 'ttymouse' */
6708 else if (varp == &p_ttym)
6709 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006710 /* Switch the mouse off before changing the escape sequences used for
6711 * that. */
6712 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006713 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6714 errmsg = e_invarg;
6715 else
6716 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006717 if (termcap_active)
6718 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006719 }
6720#endif
6721
Bram Moolenaar071d4272004-06-13 20:20:40 +00006722 /* 'selection' */
6723 else if (varp == &p_sel)
6724 {
6725 if (*p_sel == NUL
6726 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6727 errmsg = e_invarg;
6728 }
6729
6730 /* 'selectmode' */
6731 else if (varp == &p_slm)
6732 {
6733 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6734 errmsg = e_invarg;
6735 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006736
6737#ifdef FEAT_BROWSE
6738 /* 'browsedir' */
6739 else if (varp == &p_bsdir)
6740 {
6741 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
6742 && !mch_isdir(p_bsdir))
6743 errmsg = e_invarg;
6744 }
6745#endif
6746
Bram Moolenaar071d4272004-06-13 20:20:40 +00006747 /* 'keymodel' */
6748 else if (varp == &p_km)
6749 {
6750 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
6751 errmsg = e_invarg;
6752 else
6753 {
6754 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
6755 km_startsel = (vim_strchr(p_km, 'a') != NULL);
6756 }
6757 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006758
6759 /* 'mousemodel' */
6760 else if (varp == &p_mousem)
6761 {
6762 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
6763 errmsg = e_invarg;
6764#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
6765 else if (*p_mousem != *oldval)
6766 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
6767 * to create or delete the popup menus. */
6768 gui_motif_update_mousemodel(root_menu);
6769#endif
6770 }
6771
6772 /* 'switchbuf' */
6773 else if (varp == &p_swb)
6774 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00006775 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006776 errmsg = e_invarg;
6777 }
6778
6779 /* 'debug' */
6780 else if (varp == &p_debug)
6781 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00006782 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006783 errmsg = e_invarg;
6784 }
6785
6786 /* 'display' */
6787 else if (varp == &p_dy)
6788 {
6789 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
6790 errmsg = e_invarg;
6791 else
6792 (void)init_chartab();
6793
6794 }
6795
6796#ifdef FEAT_VERTSPLIT
6797 /* 'eadirection' */
6798 else if (varp == &p_ead)
6799 {
6800 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
6801 errmsg = e_invarg;
6802 }
6803#endif
6804
6805#ifdef FEAT_CLIPBOARD
6806 /* 'clipboard' */
6807 else if (varp == &p_cb)
6808 errmsg = check_clipboard_option();
6809#endif
6810
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00006811#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006812 /* When 'spelllang' or 'spellfile' is set and there is a window for this
6813 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006814 else if (varp == &(curwin->w_s->b_p_spl)
6815 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00006816 {
Bram Moolenaare68c25c2015-08-25 15:39:55 +02006817 errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf));
Bram Moolenaar217ad922005-03-20 22:37:15 +00006818 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006819 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006820 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006821 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006822 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006823 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006824 /* 'spellsuggest' */
6825 else if (varp == &p_sps)
6826 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00006827 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006828 errmsg = e_invarg;
6829 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00006830 /* 'mkspellmem' */
6831 else if (varp == &p_msm)
6832 {
6833 if (spell_check_msm() != OK)
6834 errmsg = e_invarg;
6835 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006836#endif
6837
Bram Moolenaar071d4272004-06-13 20:20:40 +00006838#ifdef FEAT_QUICKFIX
6839 /* When 'bufhidden' is set, check for valid value. */
6840 else if (gvarp == &p_bh)
6841 {
6842 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
6843 errmsg = e_invarg;
6844 }
6845
6846 /* When 'buftype' is set, check for valid value. */
6847 else if (gvarp == &p_bt)
6848 {
6849 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
6850 errmsg = e_invarg;
6851 else
6852 {
6853# ifdef FEAT_WINDOWS
6854 if (curwin->w_status_height)
6855 {
6856 curwin->w_redr_status = TRUE;
6857 redraw_later(VALID);
6858 }
6859# endif
6860 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar5075aad2010-01-27 15:58:13 +01006861# ifdef FEAT_TITLE
6862 redraw_titles();
6863# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006864 }
6865 }
6866#endif
6867
6868#ifdef FEAT_STL_OPT
6869 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006870 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006871 {
6872 int wid;
6873
6874 if (varp == &p_ruf) /* reset ru_wid first */
6875 ru_wid = 0;
6876 s = *varp;
6877 if (varp == &p_ruf && *s == '%')
6878 {
6879 /* set ru_wid if 'ruf' starts with "%99(" */
6880 if (*++s == '-') /* ignore a '-' */
6881 s++;
6882 wid = getdigits(&s);
6883 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
6884 ru_wid = wid;
6885 else
6886 errmsg = check_stl_option(p_ruf);
6887 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00006888 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00006889 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006890 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006891 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006892 comp_col();
6893 }
6894#endif
6895
6896#ifdef FEAT_INS_EXPAND
6897 /* check if it is a valid value for 'complete' -- Acevedo */
6898 else if (gvarp == &p_cpt)
6899 {
6900 for (s = *varp; *s;)
6901 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02006902 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006903 s++;
6904 if (!*s)
6905 break;
6906 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
6907 {
6908 errmsg = illegal_char(errbuf, *s);
6909 break;
6910 }
6911 if (*++s != NUL && *s != ',' && *s != ' ')
6912 {
6913 if (s[-1] == 'k' || s[-1] == 's')
6914 {
6915 /* skip optional filename after 'k' and 's' */
6916 while (*s && *s != ',' && *s != ' ')
6917 {
6918 if (*s == '\\')
6919 ++s;
6920 ++s;
6921 }
6922 }
6923 else
6924 {
6925 if (errbuf != NULL)
6926 {
6927 sprintf((char *)errbuf,
6928 _("E535: Illegal character after <%c>"),
6929 *--s);
6930 errmsg = errbuf;
6931 }
6932 else
6933 errmsg = (char_u *)"";
6934 break;
6935 }
6936 }
6937 }
6938 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00006939
6940 /* 'completeopt' */
6941 else if (varp == &p_cot)
6942 {
6943 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
6944 errmsg = e_invarg;
6945 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006946#endif /* FEAT_INS_EXPAND */
6947
6948
6949#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
6950 else if (varp == &p_toolbar)
6951 {
6952 if (opt_strings_flags(p_toolbar, p_toolbar_values,
6953 &toolbar_flags, TRUE) != OK)
6954 errmsg = e_invarg;
6955 else
6956 {
6957 out_flush();
6958 gui_mch_show_toolbar((toolbar_flags &
6959 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6960 }
6961 }
6962#endif
6963
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006964#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006965 /* 'toolbariconsize': GTK+ 2 only */
6966 else if (varp == &p_tbis)
6967 {
6968 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
6969 errmsg = e_invarg;
6970 else
6971 {
6972 out_flush();
6973 gui_mch_show_toolbar((toolbar_flags &
6974 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6975 }
6976 }
6977#endif
6978
6979 /* 'pastetoggle': translate key codes like in a mapping */
6980 else if (varp == &p_pt)
6981 {
6982 if (*p_pt)
6983 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00006984 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006985 if (p != NULL)
6986 {
6987 if (new_value_alloced)
6988 free_string_option(p_pt);
6989 p_pt = p;
6990 new_value_alloced = TRUE;
6991 }
6992 }
6993 }
6994
6995 /* 'backspace' */
6996 else if (varp == &p_bs)
6997 {
6998 if (VIM_ISDIGIT(*p_bs))
6999 {
7000 if (*p_bs >'2' || p_bs[1] != NUL)
7001 errmsg = e_invarg;
7002 }
7003 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
7004 errmsg = e_invarg;
7005 }
Bram Moolenaar165bc692015-07-21 17:53:25 +02007006 else if (varp == &p_bo)
7007 {
7008 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK)
7009 errmsg = e_invarg;
7010 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007011
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007012#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007013 /* 'casemap' */
7014 else if (varp == &p_cmp)
7015 {
7016 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
7017 errmsg = e_invarg;
7018 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007019#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007020
7021#ifdef FEAT_DIFF
7022 /* 'diffopt' */
7023 else if (varp == &p_dip)
7024 {
7025 if (diffopt_changed() == FAIL)
7026 errmsg = e_invarg;
7027 }
7028#endif
7029
7030#ifdef FEAT_FOLDING
7031 /* 'foldmethod' */
7032 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7033 {
7034 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7035 || *curwin->w_p_fdm == NUL)
7036 errmsg = e_invarg;
7037 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007038 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007039 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007040 if (foldmethodIsDiff(curwin))
7041 newFoldLevel();
7042 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007043 }
7044# ifdef FEAT_EVAL
7045 /* 'foldexpr' */
7046 else if (varp == &curwin->w_p_fde)
7047 {
7048 if (foldmethodIsExpr(curwin))
7049 foldUpdateAll(curwin);
7050 }
7051# endif
7052 /* 'foldmarker' */
7053 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7054 {
7055 p = vim_strchr(*varp, ',');
7056 if (p == NULL)
7057 errmsg = (char_u *)N_("E536: comma required");
7058 else if (p == *varp || p[1] == NUL)
7059 errmsg = e_invarg;
7060 else if (foldmethodIsMarker(curwin))
7061 foldUpdateAll(curwin);
7062 }
7063 /* 'commentstring' */
7064 else if (gvarp == &p_cms)
7065 {
7066 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7067 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7068 }
7069 /* 'foldopen' */
7070 else if (varp == &p_fdo)
7071 {
7072 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7073 errmsg = e_invarg;
7074 }
7075 /* 'foldclose' */
7076 else if (varp == &p_fcl)
7077 {
7078 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7079 errmsg = e_invarg;
7080 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007081 /* 'foldignore' */
7082 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7083 {
7084 if (foldmethodIsIndent(curwin))
7085 foldUpdateAll(curwin);
7086 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007087#endif
7088
7089#ifdef FEAT_VIRTUALEDIT
7090 /* 'virtualedit' */
7091 else if (varp == &p_ve)
7092 {
7093 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7094 errmsg = e_invarg;
7095 else if (STRCMP(p_ve, oldval) != 0)
7096 {
7097 /* Recompute cursor position in case the new 've' setting
7098 * changes something. */
7099 validate_virtcol();
7100 coladvance(curwin->w_virtcol);
7101 }
7102 }
7103#endif
7104
7105#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7106 else if (varp == &p_csqf)
7107 {
7108 if (p_csqf != NULL)
7109 {
7110 p = p_csqf;
7111 while (*p != NUL)
7112 {
7113 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7114 || p[1] == NUL
7115 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7116 || (p[2] != NUL && p[2] != ','))
7117 {
7118 errmsg = e_invarg;
7119 break;
7120 }
7121 else if (p[2] == NUL)
7122 break;
7123 else
7124 p += 3;
7125 }
7126 }
7127 }
7128#endif
7129
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007130#ifdef FEAT_CINDENT
7131 /* 'cinoptions' */
7132 else if (gvarp == &p_cino)
7133 {
7134 /* TODO: recognize errors */
7135 parse_cino(curbuf);
7136 }
7137#endif
7138
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007139#if defined(FEAT_RENDER_OPTIONS)
7140 else if (varp == &p_rop && gui.in_use)
7141 {
7142 if (!gui_mch_set_rendering_options(p_rop))
7143 errmsg = e_invarg;
7144 }
7145#endif
7146
Bram Moolenaar071d4272004-06-13 20:20:40 +00007147 /* Options that are a list of flags. */
7148 else
7149 {
7150 p = NULL;
7151 if (varp == &p_ww)
7152 p = (char_u *)WW_ALL;
7153 if (varp == &p_shm)
7154 p = (char_u *)SHM_ALL;
7155 else if (varp == &(p_cpo))
7156 p = (char_u *)CPO_ALL;
7157 else if (varp == &(curbuf->b_p_fo))
7158 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007159#ifdef FEAT_CONCEAL
7160 else if (varp == &curwin->w_p_cocu)
7161 p = (char_u *)COCU_ALL;
7162#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007163 else if (varp == &p_mouse)
7164 {
7165#ifdef FEAT_MOUSE
7166 p = (char_u *)MOUSE_ALL;
7167#else
7168 if (*p_mouse != NUL)
7169 errmsg = (char_u *)N_("E538: No mouse support");
7170#endif
7171 }
7172#if defined(FEAT_GUI)
7173 else if (varp == &p_go)
7174 p = (char_u *)GO_ALL;
7175#endif
7176 if (p != NULL)
7177 {
7178 for (s = *varp; *s; ++s)
7179 if (vim_strchr(p, *s) == NULL)
7180 {
7181 errmsg = illegal_char(errbuf, *s);
7182 break;
7183 }
7184 }
7185 }
7186
7187 /*
7188 * If error detected, restore the previous value.
7189 */
7190 if (errmsg != NULL)
7191 {
7192 if (new_value_alloced)
7193 free_string_option(*varp);
7194 *varp = oldval;
7195 /*
7196 * When resetting some values, need to act on it.
7197 */
7198 if (did_chartab)
7199 (void)init_chartab();
7200 if (varp == &p_hl)
7201 (void)highlight_changed();
7202 }
7203 else
7204 {
7205#ifdef FEAT_EVAL
7206 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007207 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007208#endif
7209 /*
7210 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007211 * Use "free_oldval", because recursiveness may change the flags under
7212 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007213 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007214 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007215 free_string_option(oldval);
7216 if (new_value_alloced)
7217 options[opt_idx].flags |= P_ALLOCED;
7218 else
7219 options[opt_idx].flags &= ~P_ALLOCED;
7220
7221 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007222 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007223 {
7224 /* global option with local value set to use global value; free
7225 * the local value and make it empty */
7226 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7227 free_string_option(*(char_u **)p);
7228 *(char_u **)p = empty_option;
7229 }
7230
7231 /* May set global value for local option. */
7232 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7233 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007234
7235#ifdef FEAT_AUTOCMD
7236 /*
7237 * Trigger the autocommand only after setting the flags.
7238 */
7239# ifdef FEAT_SYN_HL
7240 /* When 'syntax' is set, load the syntax of that name */
7241 if (varp == &(curbuf->b_p_syn))
7242 {
7243 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7244 curbuf->b_fname, TRUE, curbuf);
7245 }
7246# endif
7247 else if (varp == &(curbuf->b_p_ft))
7248 {
7249 /* 'filetype' is set, trigger the FileType autocommand */
7250 did_filetype = TRUE;
7251 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
7252 curbuf->b_fname, TRUE, curbuf);
7253 }
7254#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007255#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007256 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007257 {
7258 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007259 char_u *q = curwin->w_s->b_p_spl;
7260
7261 /* Skip the first name if it is "cjk". */
7262 if (STRNCMP(q, "cjk,", 4) == 0)
7263 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007264
7265 /*
7266 * Source the spell/LANG.vim in 'runtimepath'.
7267 * They could set 'spellcapcheck' depending on the language.
7268 * Use the first name in 'spelllang' up to '_region' or
7269 * '.encoding'.
7270 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007271 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007272 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7273 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007274 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007275 source_runtime(fname, TRUE);
7276 }
7277#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007278 }
7279
7280#ifdef FEAT_MOUSE
7281 if (varp == &p_mouse)
7282 {
7283# ifdef FEAT_MOUSE_TTY
7284 if (*p_mouse == NUL)
7285 mch_setmouse(FALSE); /* switch mouse off */
7286 else
7287# endif
7288 setmouse(); /* in case 'mouse' changed */
7289 }
7290#endif
7291
Bram Moolenaar913077c2012-03-28 19:59:04 +02007292 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007293 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007294 curwin->w_set_curswant = TRUE;
7295
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007296#ifdef FEAT_GUI
7297 /* check redraw when it's not a GUI option or the GUI is active. */
7298 if (!redraw_gui_only || gui.in_use)
7299#endif
7300 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007301
7302 return errmsg;
7303}
7304
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007305#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007306/*
7307 * Simple int comparison function for use with qsort()
7308 */
7309 static int
7310int_cmp(a, b)
7311 const void *a;
7312 const void *b;
7313{
7314 return *(const int *)a - *(const int *)b;
7315}
7316
7317/*
7318 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7319 * Returns error message, NULL if it's OK.
7320 */
7321 char_u *
7322check_colorcolumn(wp)
7323 win_T *wp;
7324{
7325 char_u *s;
7326 int col;
7327 int count = 0;
7328 int color_cols[256];
7329 int i;
7330 int j = 0;
7331
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007332 if (wp->w_buffer == NULL)
7333 return NULL; /* buffer was closed */
7334
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007335 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007336 {
7337 if (*s == '-' || *s == '+')
7338 {
7339 /* -N and +N: add to 'textwidth' */
7340 col = (*s == '-') ? -1 : 1;
7341 ++s;
7342 if (!VIM_ISDIGIT(*s))
7343 return e_invarg;
7344 col = col * getdigits(&s);
7345 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007346 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007347 col += wp->w_buffer->b_p_tw;
7348 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007349 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007350 }
7351 else if (VIM_ISDIGIT(*s))
7352 col = getdigits(&s);
7353 else
7354 return e_invarg;
7355 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007356skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007357 if (*s == NUL)
7358 break;
7359 if (*s != ',')
7360 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007361 if (*++s == NUL)
7362 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007363 }
7364
7365 vim_free(wp->w_p_cc_cols);
7366 if (count == 0)
7367 wp->w_p_cc_cols = NULL;
7368 else
7369 {
7370 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7371 if (wp->w_p_cc_cols != NULL)
7372 {
7373 /* sort the columns for faster usage on screen redraw inside
7374 * win_line() */
7375 qsort(color_cols, count, sizeof(int), int_cmp);
7376
7377 for (i = 0; i < count; ++i)
7378 /* skip duplicates */
7379 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7380 wp->w_p_cc_cols[j++] = color_cols[i];
7381 wp->w_p_cc_cols[j] = -1; /* end marker */
7382 }
7383 }
7384
7385 return NULL; /* no error */
7386}
7387#endif
7388
Bram Moolenaar071d4272004-06-13 20:20:40 +00007389/*
7390 * Handle setting 'listchars' or 'fillchars'.
7391 * Returns error message, NULL if it's OK.
7392 */
7393 static char_u *
7394set_chars_option(varp)
7395 char_u **varp;
7396{
7397 int round, i, len, entries;
7398 char_u *p, *s;
7399 int c1, c2 = 0;
7400 struct charstab
7401 {
7402 int *cp;
7403 char *name;
7404 };
7405#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7406 static struct charstab filltab[] =
7407 {
7408 {&fill_stl, "stl"},
7409 {&fill_stlnc, "stlnc"},
7410 {&fill_vert, "vert"},
7411 {&fill_fold, "fold"},
7412 {&fill_diff, "diff"},
7413 };
7414#endif
7415 static struct charstab lcstab[] =
7416 {
7417 {&lcs_eol, "eol"},
7418 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007419 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007420 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007421 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007422 {&lcs_tab2, "tab"},
7423 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007424#ifdef FEAT_CONCEAL
7425 {&lcs_conceal, "conceal"},
7426#else
7427 {NULL, "conceal"},
7428#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007429 };
7430 struct charstab *tab;
7431
7432#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7433 if (varp == &p_lcs)
7434#endif
7435 {
7436 tab = lcstab;
7437 entries = sizeof(lcstab) / sizeof(struct charstab);
7438 }
7439#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7440 else
7441 {
7442 tab = filltab;
7443 entries = sizeof(filltab) / sizeof(struct charstab);
7444 }
7445#endif
7446
7447 /* first round: check for valid value, second round: assign values */
7448 for (round = 0; round <= 1; ++round)
7449 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007450 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007451 {
7452 /* After checking that the value is valid: set defaults: space for
7453 * 'fillchars', NUL for 'listchars' */
7454 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007455 if (tab[i].cp != NULL)
7456 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007457 if (varp == &p_lcs)
7458 lcs_tab1 = NUL;
7459#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7460 else
7461 fill_diff = '-';
7462#endif
7463 }
7464 p = *varp;
7465 while (*p)
7466 {
7467 for (i = 0; i < entries; ++i)
7468 {
7469 len = (int)STRLEN(tab[i].name);
7470 if (STRNCMP(p, tab[i].name, len) == 0
7471 && p[len] == ':'
7472 && p[len + 1] != NUL)
7473 {
7474 s = p + len + 1;
7475#ifdef FEAT_MBYTE
7476 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007477 if (mb_char2cells(c1) > 1)
7478 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007479#else
7480 c1 = *s++;
7481#endif
7482 if (tab[i].cp == &lcs_tab2)
7483 {
7484 if (*s == NUL)
7485 continue;
7486#ifdef FEAT_MBYTE
7487 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007488 if (mb_char2cells(c2) > 1)
7489 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007490#else
7491 c2 = *s++;
7492#endif
7493 }
7494 if (*s == ',' || *s == NUL)
7495 {
7496 if (round)
7497 {
7498 if (tab[i].cp == &lcs_tab2)
7499 {
7500 lcs_tab1 = c1;
7501 lcs_tab2 = c2;
7502 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007503 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007504 *(tab[i].cp) = c1;
7505
7506 }
7507 p = s;
7508 break;
7509 }
7510 }
7511 }
7512
7513 if (i == entries)
7514 return e_invarg;
7515 if (*p == ',')
7516 ++p;
7517 }
7518 }
7519
7520 return NULL; /* no error */
7521}
7522
7523#ifdef FEAT_STL_OPT
7524/*
7525 * Check validity of options with the 'statusline' format.
7526 * Return error message or NULL.
7527 */
7528 char_u *
7529check_stl_option(s)
7530 char_u *s;
7531{
7532 int itemcnt = 0;
7533 int groupdepth = 0;
7534 static char_u errbuf[80];
7535
7536 while (*s && itemcnt < STL_MAX_ITEM)
7537 {
7538 /* Check for valid keys after % sequences */
7539 while (*s && *s != '%')
7540 s++;
7541 if (!*s)
7542 break;
7543 s++;
7544 if (*s != '%' && *s != ')')
7545 ++itemcnt;
7546 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7547 {
7548 s++;
7549 continue;
7550 }
7551 if (*s == ')')
7552 {
7553 s++;
7554 if (--groupdepth < 0)
7555 break;
7556 continue;
7557 }
7558 if (*s == '-')
7559 s++;
7560 while (VIM_ISDIGIT(*s))
7561 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007562 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007563 continue;
7564 if (*s == '.')
7565 {
7566 s++;
7567 while (*s && VIM_ISDIGIT(*s))
7568 s++;
7569 }
7570 if (*s == '(')
7571 {
7572 groupdepth++;
7573 continue;
7574 }
7575 if (vim_strchr(STL_ALL, *s) == NULL)
7576 {
7577 return illegal_char(errbuf, *s);
7578 }
7579 if (*s == '{')
7580 {
7581 s++;
7582 while (*s != '}' && *s)
7583 s++;
7584 if (*s != '}')
7585 return (char_u *)N_("E540: Unclosed expression sequence");
7586 }
7587 }
7588 if (itemcnt >= STL_MAX_ITEM)
7589 return (char_u *)N_("E541: too many items");
7590 if (groupdepth != 0)
7591 return (char_u *)N_("E542: unbalanced groups");
7592 return NULL;
7593}
7594#endif
7595
7596#ifdef FEAT_CLIPBOARD
7597/*
7598 * Extract the items in the 'clipboard' option and set global values.
7599 */
7600 static char_u *
7601check_clipboard_option()
7602{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007603 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007604 int new_autoselect_star = FALSE;
7605 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007606 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007607 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007608 regprog_T *new_exclude_prog = NULL;
7609 char_u *errmsg = NULL;
7610 char_u *p;
7611
7612 for (p = p_cb; *p != NUL; )
7613 {
7614 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7615 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007616 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007617 p += 7;
7618 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007619 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007620 && (p[11] == ',' || p[11] == NUL))
7621 {
7622 new_unnamed |= CLIP_UNNAMED_PLUS;
7623 p += 11;
7624 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007625 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007626 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007627 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007628 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007629 p += 10;
7630 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007631 else if (STRNCMP(p, "autoselectplus", 14) == 0
7632 && (p[14] == ',' || p[14] == NUL))
7633 {
7634 new_autoselect_plus = TRUE;
7635 p += 14;
7636 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007637 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007638 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007639 {
7640 new_autoselectml = TRUE;
7641 p += 12;
7642 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007643 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7644 {
7645 new_html = TRUE;
7646 p += 4;
7647 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007648 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7649 {
7650 p += 8;
7651 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7652 if (new_exclude_prog == NULL)
7653 errmsg = e_invarg;
7654 break;
7655 }
7656 else
7657 {
7658 errmsg = e_invarg;
7659 break;
7660 }
7661 if (*p == ',')
7662 ++p;
7663 }
7664 if (errmsg == NULL)
7665 {
7666 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007667 clip_autoselect_star = new_autoselect_star;
7668 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007669 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007670 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02007671 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007672 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02007673#ifdef FEAT_GUI_GTK
7674 if (gui.in_use)
7675 {
7676 gui_gtk_set_selection_targets();
7677 gui_gtk_set_dnd_targets();
7678 }
7679#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007680 }
7681 else
Bram Moolenaar473de612013-06-08 18:19:48 +02007682 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007683
7684 return errmsg;
7685}
7686#endif
7687
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007688#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007689 static char_u *
7690did_set_spell_option(is_spellfile)
7691 int is_spellfile;
7692{
7693 char_u *errmsg = NULL;
7694 win_T *wp;
7695 int l;
7696
7697 if (is_spellfile)
7698 {
7699 l = (int)STRLEN(curwin->w_s->b_p_spf);
7700 if (l > 0 && (l < 4
7701 || STRCMP(curwin->w_s->b_p_spf + l - 4, ".add") != 0))
7702 errmsg = e_invarg;
7703 }
7704
7705 if (errmsg == NULL)
7706 {
7707 FOR_ALL_WINDOWS(wp)
7708 if (wp->w_buffer == curbuf && wp->w_p_spell)
7709 {
7710 errmsg = did_set_spelllang(wp);
7711# ifdef FEAT_WINDOWS
7712 break;
7713# endif
7714 }
7715 }
7716 return errmsg;
7717}
7718
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007719/*
7720 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
7721 * Return error message when failed, NULL when OK.
7722 */
7723 static char_u *
Bram Moolenaar860cae12010-06-05 23:22:07 +02007724compile_cap_prog(synblock)
7725 synblock_T *synblock;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007726{
Bram Moolenaar860cae12010-06-05 23:22:07 +02007727 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007728 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007729
Bram Moolenaar860cae12010-06-05 23:22:07 +02007730 if (*synblock->b_p_spc == NUL)
7731 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007732 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007733 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007734 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007735 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007736 if (re != NULL)
7737 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007738 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02007739 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02007740 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007741 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007742 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007743 return e_invarg;
7744 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007745 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007746 }
7747
Bram Moolenaar473de612013-06-08 18:19:48 +02007748 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007749 return NULL;
7750}
7751#endif
7752
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007753#if defined(FEAT_EVAL) || defined(PROTO)
7754/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007755 * Set the scriptID for an option, taking care of setting the buffer- or
7756 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007757 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007758 static void
7759set_option_scriptID_idx(opt_idx, opt_flags, id)
7760 int opt_idx;
7761 int opt_flags;
7762 int id;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007763{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007764 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
7765 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007766
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007767 /* Remember where the option was set. For local options need to do that
7768 * in the buffer or window structure. */
7769 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007770 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007771 if (both || (opt_flags & OPT_LOCAL))
7772 {
7773 if (indir & PV_BUF)
7774 curbuf->b_p_scriptID[indir & PV_MASK] = id;
7775 else if (indir & PV_WIN)
7776 curwin->w_p_scriptID[indir & PV_MASK] = id;
7777 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007778}
7779#endif
7780
Bram Moolenaar071d4272004-06-13 20:20:40 +00007781/*
7782 * Set the value of a boolean option, and take care of side effects.
7783 * Returns NULL for success, or an error message for an error.
7784 */
7785 static char_u *
7786set_bool_option(opt_idx, varp, value, opt_flags)
7787 int opt_idx; /* index in options[] table */
7788 char_u *varp; /* pointer to the option variable */
7789 int value; /* new value */
7790 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
7791{
7792 int old_value = *(int *)varp;
7793
Bram Moolenaar071d4272004-06-13 20:20:40 +00007794 /* Disallow changing some options from secure mode */
7795 if ((secure
7796#ifdef HAVE_SANDBOX
7797 || sandbox != 0
7798#endif
7799 ) && (options[opt_idx].flags & P_SECURE))
7800 return e_secure;
7801
7802 *(int *)varp = value; /* set the new value */
7803#ifdef FEAT_EVAL
7804 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007805 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007806#endif
7807
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00007808#ifdef FEAT_GUI
7809 need_mouse_correct = TRUE;
7810#endif
7811
Bram Moolenaar071d4272004-06-13 20:20:40 +00007812 /* May set global value for local option. */
7813 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
7814 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
7815
7816 /*
7817 * Handle side effects of changing a bool option.
7818 */
7819
7820 /* 'compatible' */
7821 if ((int *)varp == &p_cp)
7822 {
7823 compatible_set();
7824 }
7825
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007826#ifdef FEAT_PERSISTENT_UNDO
7827 /* 'undofile' */
7828 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
7829 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007830 /* Only take action when the option was set. When reset we do not
7831 * delete the undo file, the option may be set again without making
7832 * any changes in between. */
7833 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007834 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007835 char_u hash[UNDO_HASH_SIZE];
7836 buf_T *save_curbuf = curbuf;
7837
7838 for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007839 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007840 /* When 'undofile' is set globally: for every buffer, otherwise
7841 * only for the current buffer: Try to read in the undofile,
7842 * if one exists, the buffer wasn't changed and the buffer was
7843 * loaded */
7844 if ((curbuf == save_curbuf
7845 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
7846 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
7847 {
7848 u_compute_hash(hash);
7849 u_read_undo(NULL, hash, curbuf->b_fname);
7850 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007851 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007852 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007853 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007854 }
7855#endif
7856
Bram Moolenaar071d4272004-06-13 20:20:40 +00007857 else if ((int *)varp == &curbuf->b_p_ro)
7858 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007859 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007860 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
7861 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007862
7863 /* when 'readonly' is set may give W10 again */
7864 if (curbuf->b_p_ro)
7865 curbuf->b_did_warn = FALSE;
7866
Bram Moolenaar071d4272004-06-13 20:20:40 +00007867#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007868 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007869#endif
7870 }
7871
Bram Moolenaar9c449722010-07-20 18:44:27 +02007872#ifdef FEAT_GUI
7873 else if ((int *)varp == &p_mh)
7874 {
7875 if (!p_mh)
7876 gui_mch_mousehide(FALSE);
7877 }
7878#endif
7879
Bram Moolenaara539df02010-08-01 14:35:05 +02007880#ifdef FEAT_TITLE
7881 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007882 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007883 {
7884 redraw_titles();
7885 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007886 /* when 'endofline' is changed, redraw the window title */
7887 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007888 {
7889 redraw_titles();
7890 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02007891 /* when 'fixeol' is changed, redraw the window title */
7892 else if ((int *)varp == &curbuf->b_p_fixeol)
7893 {
7894 redraw_titles();
7895 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007896# ifdef FEAT_MBYTE
7897 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00007898 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007899 {
7900 redraw_titles();
7901 }
7902# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007903#endif
7904
7905 /* when 'bin' is set also set some other options */
7906 else if ((int *)varp == &curbuf->b_p_bin)
7907 {
7908 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
7909#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007910 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007911#endif
7912 }
7913
7914#ifdef FEAT_AUTOCMD
7915 /* when 'buflisted' changes, trigger autocommands */
7916 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
7917 {
7918 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
7919 NULL, NULL, TRUE, curbuf);
7920 }
7921#endif
7922
7923 /* when 'swf' is set, create swapfile, when reset remove swapfile */
7924 else if ((int *)varp == &curbuf->b_p_swf)
7925 {
7926 if (curbuf->b_p_swf && p_uc)
7927 ml_open_file(curbuf); /* create the swap file */
7928 else
Bram Moolenaard55de222007-05-06 13:38:48 +00007929 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
7930 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007931 mf_close_file(curbuf, TRUE); /* remove the swap file */
7932 }
7933
7934 /* when 'terse' is set change 'shortmess' */
7935 else if ((int *)varp == &p_terse)
7936 {
7937 char_u *p;
7938
7939 p = vim_strchr(p_shm, SHM_SEARCH);
7940
7941 /* insert 's' in p_shm */
7942 if (p_terse && p == NULL)
7943 {
7944 STRCPY(IObuff, p_shm);
7945 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007946 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007947 }
7948 /* remove 's' from p_shm */
7949 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007950 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007951 }
7952
7953 /* when 'paste' is set or reset also change other options */
7954 else if ((int *)varp == &p_paste)
7955 {
7956 paste_option_changed();
7957 }
7958
7959 /* when 'insertmode' is set from an autocommand need to do work here */
7960 else if ((int *)varp == &p_im)
7961 {
7962 if (p_im)
7963 {
7964 if ((State & INSERT) == 0)
7965 need_start_insertmode = TRUE;
7966 stop_insert_mode = FALSE;
7967 }
7968 else
7969 {
7970 need_start_insertmode = FALSE;
7971 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00007972 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007973 clear_cmdline = TRUE; /* remove "(insert)" */
7974 restart_edit = 0;
7975 }
7976 }
7977
7978 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
7979 else if ((int *)varp == &p_ic && p_hls)
7980 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007981 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007982 }
7983
7984#ifdef FEAT_SEARCH_EXTRA
7985 /* when 'hlsearch' is set or reset: reset no_hlsearch */
7986 else if ((int *)varp == &p_hls)
7987 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01007988 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007989 }
7990#endif
7991
7992#ifdef FEAT_SCROLLBIND
7993 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
7994 * at the end of normal_cmd() */
7995 else if ((int *)varp == &curwin->w_p_scb)
7996 {
7997 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02007998 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007999 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02008000 curwin->w_scbind_pos = curwin->w_topline;
8001 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008002 }
8003#endif
8004
8005#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
8006 /* There can be only one window with 'previewwindow' set. */
8007 else if ((int *)varp == &curwin->w_p_pvw)
8008 {
8009 if (curwin->w_p_pvw)
8010 {
8011 win_T *win;
8012
8013 for (win = firstwin; win != NULL; win = win->w_next)
8014 if (win->w_p_pvw && win != curwin)
8015 {
8016 curwin->w_p_pvw = FALSE;
8017 return (char_u *)N_("E590: A preview window already exists");
8018 }
8019 }
8020 }
8021#endif
8022
8023 /* when 'textmode' is set or reset also change 'fileformat' */
8024 else if ((int *)varp == &curbuf->b_p_tx)
8025 {
8026 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
8027 }
8028
8029 /* when 'textauto' is set or reset also change 'fileformats' */
8030 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008031 set_string_option_direct((char_u *)"ffs", -1,
8032 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008033 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008034
8035 /*
8036 * When 'lisp' option changes include/exclude '-' in
8037 * keyword characters.
8038 */
8039#ifdef FEAT_LISP
8040 else if (varp == (char_u *)&(curbuf->b_p_lisp))
8041 {
8042 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
8043 }
8044#endif
8045
8046#ifdef FEAT_TITLE
8047 /* when 'title' changed, may need to change the title; same for 'icon' */
8048 else if ((int *)varp == &p_title)
8049 {
8050 did_set_title(FALSE);
8051 }
8052
8053 else if ((int *)varp == &p_icon)
8054 {
8055 did_set_title(TRUE);
8056 }
8057#endif
8058
8059 else if ((int *)varp == &curbuf->b_changed)
8060 {
8061 if (!value)
8062 save_file_ff(curbuf); /* Buffer is unchanged */
8063#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008064 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008065#endif
8066#ifdef FEAT_AUTOCMD
8067 modified_was_set = value;
8068#endif
8069 }
8070
8071#ifdef BACKSLASH_IN_FILENAME
8072 else if ((int *)varp == &p_ssl)
8073 {
8074 if (p_ssl)
8075 {
8076 psepc = '/';
8077 psepcN = '\\';
8078 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008079 }
8080 else
8081 {
8082 psepc = '\\';
8083 psepcN = '/';
8084 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008085 }
8086
8087 /* need to adjust the file name arguments and buffer names. */
8088 buflist_slash_adjust();
8089 alist_slash_adjust();
8090# ifdef FEAT_EVAL
8091 scriptnames_slash_adjust();
8092# endif
8093 }
8094#endif
8095
8096 /* If 'wrap' is set, set w_leftcol to zero. */
8097 else if ((int *)varp == &curwin->w_p_wrap)
8098 {
8099 if (curwin->w_p_wrap)
8100 curwin->w_leftcol = 0;
8101 }
8102
8103#ifdef FEAT_WINDOWS
8104 else if ((int *)varp == &p_ea)
8105 {
8106 if (p_ea && !old_value)
8107 win_equal(curwin, FALSE, 0);
8108 }
8109#endif
8110
8111 else if ((int *)varp == &p_wiv)
8112 {
8113 /*
8114 * When 'weirdinvert' changed, set/reset 't_xs'.
8115 * Then set 'weirdinvert' according to value of 't_xs'.
8116 */
8117 if (p_wiv && !old_value)
8118 T_XS = (char_u *)"y";
8119 else if (!p_wiv && old_value)
8120 T_XS = empty_option;
8121 p_wiv = (*T_XS != NUL);
8122 }
8123
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00008124#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00008125 else if ((int *)varp == &p_beval)
8126 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008127 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008128 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008129 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008130 gui_mch_disable_beval_area(balloonEval);
8131 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008132#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008133
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008134#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008135 else if ((int *)varp == &p_acd)
8136 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008137 /* Change directories when the 'acd' option is set now. */
8138 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008139 }
8140#endif
8141
8142#ifdef FEAT_DIFF
8143 /* 'diff' */
8144 else if ((int *)varp == &curwin->w_p_diff)
8145 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008146 /* May add or remove the buffer from the list of diff buffers. */
8147 diff_buf_adjust(curwin);
8148# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008149 if (foldmethodIsDiff(curwin))
8150 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008151# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008152 }
8153#endif
8154
8155#ifdef USE_IM_CONTROL
8156 /* 'imdisable' */
8157 else if ((int *)varp == &p_imdisable)
8158 {
8159 /* Only de-activate it here, it will be enabled when changing mode. */
8160 if (p_imdisable)
8161 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008162 else if (State & INSERT)
8163 /* When the option is set from an autocommand, it may need to take
8164 * effect right away. */
8165 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008166 }
8167#endif
8168
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008169#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008170 /* 'spell' */
8171 else if ((int *)varp == &curwin->w_p_spell)
8172 {
8173 if (curwin->w_p_spell)
8174 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008175 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008176 if (errmsg != NULL)
8177 EMSG(_(errmsg));
8178 }
8179 }
8180#endif
8181
Bram Moolenaar071d4272004-06-13 20:20:40 +00008182#ifdef FEAT_FKMAP
8183 else if ((int *)varp == &p_altkeymap)
8184 {
8185 if (old_value != p_altkeymap)
8186 {
8187 if (!p_altkeymap)
8188 {
8189 p_hkmap = p_fkmap;
8190 p_fkmap = 0;
8191 }
8192 else
8193 {
8194 p_fkmap = p_hkmap;
8195 p_hkmap = 0;
8196 }
8197 (void)init_chartab();
8198 }
8199 }
8200
8201 /*
8202 * In case some second language keymapping options have changed, check
8203 * and correct the setting in a consistent way.
8204 */
8205
8206 /*
8207 * If hkmap or fkmap are set, reset Arabic keymapping.
8208 */
8209 if ((p_hkmap || p_fkmap) && p_altkeymap)
8210 {
8211 p_altkeymap = p_fkmap;
8212# ifdef FEAT_ARABIC
8213 curwin->w_p_arab = FALSE;
8214# endif
8215 (void)init_chartab();
8216 }
8217
8218 /*
8219 * If hkmap set, reset Farsi keymapping.
8220 */
8221 if (p_hkmap && p_altkeymap)
8222 {
8223 p_altkeymap = 0;
8224 p_fkmap = 0;
8225# ifdef FEAT_ARABIC
8226 curwin->w_p_arab = FALSE;
8227# endif
8228 (void)init_chartab();
8229 }
8230
8231 /*
8232 * If fkmap set, reset Hebrew keymapping.
8233 */
8234 if (p_fkmap && !p_altkeymap)
8235 {
8236 p_altkeymap = 1;
8237 p_hkmap = 0;
8238# ifdef FEAT_ARABIC
8239 curwin->w_p_arab = FALSE;
8240# endif
8241 (void)init_chartab();
8242 }
8243#endif
8244
8245#ifdef FEAT_ARABIC
8246 if ((int *)varp == &curwin->w_p_arab)
8247 {
8248 if (curwin->w_p_arab)
8249 {
8250 /*
8251 * 'arabic' is set, handle various sub-settings.
8252 */
8253 if (!p_tbidi)
8254 {
8255 /* set rightleft mode */
8256 if (!curwin->w_p_rl)
8257 {
8258 curwin->w_p_rl = TRUE;
8259 changed_window_setting();
8260 }
8261
8262 /* Enable Arabic shaping (major part of what Arabic requires) */
8263 if (!p_arshape)
8264 {
8265 p_arshape = TRUE;
8266 redraw_later_clear();
8267 }
8268 }
8269
8270 /* Arabic requires a utf-8 encoding, inform the user if its not
8271 * set. */
8272 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008273 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008274 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8275
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008276 msg_source(hl_attr(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008277 MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
8278#ifdef FEAT_EVAL
8279 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8280#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008281 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008282
8283# ifdef FEAT_MBYTE
8284 /* set 'delcombine' */
8285 p_deco = TRUE;
8286# endif
8287
8288# ifdef FEAT_KEYMAP
8289 /* Force-set the necessary keymap for arabic */
8290 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8291 OPT_LOCAL);
8292# endif
8293# ifdef FEAT_FKMAP
8294 p_altkeymap = 0;
8295 p_hkmap = 0;
8296 p_fkmap = 0;
8297 (void)init_chartab();
8298# endif
8299 }
8300 else
8301 {
8302 /*
8303 * 'arabic' is reset, handle various sub-settings.
8304 */
8305 if (!p_tbidi)
8306 {
8307 /* reset rightleft mode */
8308 if (curwin->w_p_rl)
8309 {
8310 curwin->w_p_rl = FALSE;
8311 changed_window_setting();
8312 }
8313
8314 /* 'arabicshape' isn't reset, it is a global option and
8315 * another window may still need it "on". */
8316 }
8317
8318 /* 'delcombine' isn't reset, it is a global option and another
8319 * window may still want it "on". */
8320
8321# ifdef FEAT_KEYMAP
8322 /* Revert to the default keymap */
8323 curbuf->b_p_iminsert = B_IMODE_NONE;
8324 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8325# endif
8326 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008327 }
8328
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008329#endif
8330
Bram Moolenaar071d4272004-06-13 20:20:40 +00008331 /*
8332 * End of handling side effects for bool options.
8333 */
8334
Bram Moolenaar53744302015-07-17 17:38:22 +02008335 /* after handling side effects, call autocommand */
8336
Bram Moolenaar071d4272004-06-13 20:20:40 +00008337 options[opt_idx].flags |= P_WAS_SET;
8338
Bram Moolenaar53744302015-07-17 17:38:22 +02008339#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8340 if (!starting)
8341 {
8342 char_u buf_old[2], buf_new[2], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008343 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8344 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8345 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008346 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8347 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8348 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8349 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8350 reset_v_option_vars();
8351 }
8352#endif
8353
Bram Moolenaar071d4272004-06-13 20:20:40 +00008354 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008355 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008356 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008357 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008358 check_redraw(options[opt_idx].flags);
8359
8360 return NULL;
8361}
8362
8363/*
8364 * Set the value of a number option, and take care of side effects.
8365 * Returns NULL for success, or an error message for an error.
8366 */
8367 static char_u *
Bram Moolenaar555b2802005-05-19 21:08:39 +00008368set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008369 int opt_idx; /* index in options[] table */
8370 char_u *varp; /* pointer to the option variable */
8371 long value; /* new value */
8372 char_u *errbuf; /* buffer for error messages */
Bram Moolenaar555b2802005-05-19 21:08:39 +00008373 size_t errbuflen; /* length of "errbuf" */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008374 int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and
8375 OPT_MODELINE */
8376{
8377 char_u *errmsg = NULL;
8378 long old_value = *(long *)varp;
8379 long old_Rows = Rows; /* remember old Rows */
8380 long old_Columns = Columns; /* remember old Columns */
8381 long *pp = (long *)varp;
8382
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008383 /* Disallow changing some options from secure mode. */
8384 if ((secure
8385#ifdef HAVE_SANDBOX
8386 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008387#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008388 ) && (options[opt_idx].flags & P_SECURE))
8389 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008390
8391 *pp = value;
8392#ifdef FEAT_EVAL
8393 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008394 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008395#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008396#ifdef FEAT_GUI
8397 need_mouse_correct = TRUE;
8398#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008399
Bram Moolenaar14f24742012-08-08 18:01:05 +02008400 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008401 {
8402 errmsg = e_positive;
8403 curbuf->b_p_sw = curbuf->b_p_ts;
8404 }
8405
8406 /*
8407 * Number options that need some action when changed
8408 */
8409#ifdef FEAT_WINDOWS
8410 if (pp == &p_wh || pp == &p_hh)
8411 {
8412 if (p_wh < 1)
8413 {
8414 errmsg = e_positive;
8415 p_wh = 1;
8416 }
8417 if (p_wmh > p_wh)
8418 {
8419 errmsg = e_winheight;
8420 p_wh = p_wmh;
8421 }
8422 if (p_hh < 0)
8423 {
8424 errmsg = e_positive;
8425 p_hh = 0;
8426 }
8427
8428 /* Change window height NOW */
8429 if (lastwin != firstwin)
8430 {
8431 if (pp == &p_wh && curwin->w_height < p_wh)
8432 win_setheight((int)p_wh);
8433 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8434 win_setheight((int)p_hh);
8435 }
8436 }
8437
8438 /* 'winminheight' */
8439 else if (pp == &p_wmh)
8440 {
8441 if (p_wmh < 0)
8442 {
8443 errmsg = e_positive;
8444 p_wmh = 0;
8445 }
8446 if (p_wmh > p_wh)
8447 {
8448 errmsg = e_winheight;
8449 p_wmh = p_wh;
8450 }
8451 win_setminheight();
8452 }
8453
8454# ifdef FEAT_VERTSPLIT
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008455 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008456 {
8457 if (p_wiw < 1)
8458 {
8459 errmsg = e_positive;
8460 p_wiw = 1;
8461 }
8462 if (p_wmw > p_wiw)
8463 {
8464 errmsg = e_winwidth;
8465 p_wiw = p_wmw;
8466 }
8467
8468 /* Change window width NOW */
8469 if (lastwin != firstwin && curwin->w_width < p_wiw)
8470 win_setwidth((int)p_wiw);
8471 }
8472
8473 /* 'winminwidth' */
8474 else if (pp == &p_wmw)
8475 {
8476 if (p_wmw < 0)
8477 {
8478 errmsg = e_positive;
8479 p_wmw = 0;
8480 }
8481 if (p_wmw > p_wiw)
8482 {
8483 errmsg = e_winwidth;
8484 p_wmw = p_wiw;
8485 }
8486 win_setminheight();
8487 }
8488# endif
8489
8490#endif
8491
8492#ifdef FEAT_WINDOWS
8493 /* (re)set last window status line */
8494 else if (pp == &p_ls)
8495 {
8496 last_status(FALSE);
8497 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008498
8499 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008500 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008501 {
8502 shell_new_rows(); /* recompute window positions and heights */
8503 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008504#endif
8505
8506#ifdef FEAT_GUI
8507 else if (pp == &p_linespace)
8508 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008509 /* Recompute gui.char_height and resize the Vim window to keep the
8510 * same number of lines. */
8511 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008512 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008513 }
8514#endif
8515
8516#ifdef FEAT_FOLDING
8517 /* 'foldlevel' */
8518 else if (pp == &curwin->w_p_fdl)
8519 {
8520 if (curwin->w_p_fdl < 0)
8521 curwin->w_p_fdl = 0;
8522 newFoldLevel();
8523 }
8524
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008525 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008526 else if (pp == &curwin->w_p_fml)
8527 {
8528 foldUpdateAll(curwin);
8529 }
8530
8531 /* 'foldnestmax' */
8532 else if (pp == &curwin->w_p_fdn)
8533 {
8534 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8535 foldUpdateAll(curwin);
8536 }
8537
8538 /* 'foldcolumn' */
8539 else if (pp == &curwin->w_p_fdc)
8540 {
8541 if (curwin->w_p_fdc < 0)
8542 {
8543 errmsg = e_positive;
8544 curwin->w_p_fdc = 0;
8545 }
8546 else if (curwin->w_p_fdc > 12)
8547 {
8548 errmsg = e_invarg;
8549 curwin->w_p_fdc = 12;
8550 }
8551 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008552#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008553
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008554#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008555 /* 'shiftwidth' or 'tabstop' */
8556 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8557 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008558# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008559 if (foldmethodIsIndent(curwin))
8560 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008561# endif
8562# ifdef FEAT_CINDENT
8563 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8564 * parse 'cinoptions'. */
8565 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8566 parse_cino(curbuf);
8567# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008568 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008569#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008570
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008571#ifdef FEAT_MBYTE
8572 /* 'maxcombine' */
8573 else if (pp == &p_mco)
8574 {
8575 if (p_mco > MAX_MCO)
8576 p_mco = MAX_MCO;
8577 else if (p_mco < 0)
8578 p_mco = 0;
8579 screenclear(); /* will re-allocate the screen */
8580 }
8581#endif
8582
Bram Moolenaar071d4272004-06-13 20:20:40 +00008583 else if (pp == &curbuf->b_p_iminsert)
8584 {
8585 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8586 {
8587 errmsg = e_invarg;
8588 curbuf->b_p_iminsert = B_IMODE_NONE;
8589 }
8590 p_iminsert = curbuf->b_p_iminsert;
8591 if (termcap_active) /* don't do this in the alternate screen */
8592 showmode();
8593#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8594 /* Show/unshow value of 'keymap' in status lines. */
8595 status_redraw_curbuf();
8596#endif
8597 }
8598
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008599 else if (pp == &p_window)
8600 {
8601 if (p_window < 1)
8602 p_window = 1;
8603 else if (p_window >= Rows)
8604 p_window = Rows - 1;
8605 }
8606
Bram Moolenaar071d4272004-06-13 20:20:40 +00008607 else if (pp == &curbuf->b_p_imsearch)
8608 {
8609 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8610 {
8611 errmsg = e_invarg;
8612 curbuf->b_p_imsearch = B_IMODE_NONE;
8613 }
8614 p_imsearch = curbuf->b_p_imsearch;
8615 }
8616
8617#ifdef FEAT_TITLE
8618 /* if 'titlelen' has changed, redraw the title */
8619 else if (pp == &p_titlelen)
8620 {
8621 if (p_titlelen < 0)
8622 {
8623 errmsg = e_positive;
8624 p_titlelen = 85;
8625 }
8626 if (starting != NO_SCREEN && old_value != p_titlelen)
8627 need_maketitle = TRUE;
8628 }
8629#endif
8630
8631 /* if p_ch changed value, change the command line height */
8632 else if (pp == &p_ch)
8633 {
8634 if (p_ch < 1)
8635 {
8636 errmsg = e_positive;
8637 p_ch = 1;
8638 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008639 if (p_ch > Rows - min_rows() + 1)
8640 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008641
8642 /* Only compute the new window layout when startup has been
8643 * completed. Otherwise the frame sizes may be wrong. */
8644 if (p_ch != old_value && full_screen
8645#ifdef FEAT_GUI
8646 && !gui.starting
8647#endif
8648 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008649 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008650 }
8651
8652 /* when 'updatecount' changes from zero to non-zero, open swap files */
8653 else if (pp == &p_uc)
8654 {
8655 if (p_uc < 0)
8656 {
8657 errmsg = e_positive;
8658 p_uc = 100;
8659 }
8660 if (p_uc && !old_value)
8661 ml_open_files();
8662 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008663#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008664 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008665 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008666 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008667 {
8668 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008669 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008670 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008671 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008672 {
8673 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008674 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008675 }
8676 }
8677#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008678#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008679 else if (pp == &p_mzq)
8680 mzvim_reset_timer();
8681#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008682
8683 /* sync undo before 'undolevels' changes */
8684 else if (pp == &p_ul)
8685 {
8686 /* use the old value, otherwise u_sync() may not work properly */
8687 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00008688 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008689 p_ul = value;
8690 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01008691 else if (pp == &curbuf->b_p_ul)
8692 {
8693 /* use the old value, otherwise u_sync() may not work properly */
8694 curbuf->b_p_ul = old_value;
8695 u_sync(TRUE);
8696 curbuf->b_p_ul = value;
8697 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008698
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008699#ifdef FEAT_LINEBREAK
8700 /* 'numberwidth' must be positive */
8701 else if (pp == &curwin->w_p_nuw)
8702 {
8703 if (curwin->w_p_nuw < 1)
8704 {
8705 errmsg = e_positive;
8706 curwin->w_p_nuw = 1;
8707 }
8708 if (curwin->w_p_nuw > 10)
8709 {
8710 errmsg = e_invarg;
8711 curwin->w_p_nuw = 10;
8712 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02008713 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008714 }
8715#endif
8716
Bram Moolenaar1a384422010-07-14 19:53:30 +02008717 else if (pp == &curbuf->b_p_tw)
8718 {
8719 if (curbuf->b_p_tw < 0)
8720 {
8721 errmsg = e_positive;
8722 curbuf->b_p_tw = 0;
8723 }
8724#ifdef FEAT_SYN_HL
8725# ifdef FEAT_WINDOWS
8726 {
8727 win_T *wp;
8728 tabpage_T *tp;
8729
8730 FOR_ALL_TAB_WINDOWS(tp, wp)
8731 check_colorcolumn(wp);
8732 }
8733# else
8734 check_colorcolumn(curwin);
8735# endif
8736#endif
8737 }
8738
Bram Moolenaar071d4272004-06-13 20:20:40 +00008739 /*
8740 * Check the bounds for numeric options here
8741 */
8742 if (Rows < min_rows() && full_screen)
8743 {
8744 if (errbuf != NULL)
8745 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008746 vim_snprintf((char *)errbuf, errbuflen,
8747 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00008748 errmsg = errbuf;
8749 }
8750 Rows = min_rows();
8751 }
8752 if (Columns < MIN_COLUMNS && full_screen)
8753 {
8754 if (errbuf != NULL)
8755 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008756 vim_snprintf((char *)errbuf, errbuflen,
8757 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008758 errmsg = errbuf;
8759 }
8760 Columns = MIN_COLUMNS;
8761 }
Bram Moolenaare057d402013-06-30 17:51:51 +02008762 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008763
8764#ifdef DJGPP
8765 /* avoid a crash by checking for a too large value of 'columns' */
8766 if (old_Columns != Columns && full_screen && term_console)
8767 mch_check_columns();
8768#endif
8769
8770 /*
8771 * If the screen (shell) height has been changed, assume it is the
8772 * physical screenheight.
8773 */
8774 if (old_Rows != Rows || old_Columns != Columns)
8775 {
8776 /* Changing the screen size is not allowed while updating the screen. */
8777 if (updating_screen)
8778 *pp = old_value;
8779 else if (full_screen
8780#ifdef FEAT_GUI
8781 && !gui.starting
8782#endif
8783 )
8784 set_shellsize((int)Columns, (int)Rows, TRUE);
8785 else
8786 {
8787 /* Postpone the resizing; check the size and cmdline position for
8788 * messages. */
8789 check_shellsize();
8790 if (cmdline_row > Rows - p_ch && Rows > p_ch)
8791 cmdline_row = Rows - p_ch;
8792 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00008793 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008794 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008795 }
8796
Bram Moolenaar071d4272004-06-13 20:20:40 +00008797 if (curbuf->b_p_ts <= 0)
8798 {
8799 errmsg = e_positive;
8800 curbuf->b_p_ts = 8;
8801 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008802 if (p_tm < 0)
8803 {
8804 errmsg = e_positive;
8805 p_tm = 0;
8806 }
8807 if ((curwin->w_p_scr <= 0
8808 || (curwin->w_p_scr > curwin->w_height
8809 && curwin->w_height > 0))
8810 && full_screen)
8811 {
8812 if (pp == &(curwin->w_p_scr))
8813 {
8814 if (curwin->w_p_scr != 0)
8815 errmsg = e_scroll;
8816 win_comp_scroll(curwin);
8817 }
8818 /* If 'scroll' became invalid because of a side effect silently adjust
8819 * it. */
8820 else if (curwin->w_p_scr <= 0)
8821 curwin->w_p_scr = 1;
8822 else /* curwin->w_p_scr > curwin->w_height */
8823 curwin->w_p_scr = curwin->w_height;
8824 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00008825 if (p_hi < 0)
8826 {
8827 errmsg = e_positive;
8828 p_hi = 0;
8829 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02008830 else if (p_hi > 10000)
8831 {
8832 errmsg = e_invarg;
8833 p_hi = 10000;
8834 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02008835 if (p_re < 0 || p_re > 2)
8836 {
8837 errmsg = e_invarg;
8838 p_re = 0;
8839 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008840 if (p_report < 0)
8841 {
8842 errmsg = e_positive;
8843 p_report = 1;
8844 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00008845 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008846 {
8847 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
8848 p_sj = Rows / 2;
8849 else
8850 {
8851 errmsg = e_scroll;
8852 p_sj = 1;
8853 }
8854 }
8855 if (p_so < 0 && full_screen)
8856 {
8857 errmsg = e_scroll;
8858 p_so = 0;
8859 }
8860 if (p_siso < 0 && full_screen)
8861 {
8862 errmsg = e_positive;
8863 p_siso = 0;
8864 }
8865#ifdef FEAT_CMDWIN
8866 if (p_cwh < 1)
8867 {
8868 errmsg = e_positive;
8869 p_cwh = 1;
8870 }
8871#endif
8872 if (p_ut < 0)
8873 {
8874 errmsg = e_positive;
8875 p_ut = 2000;
8876 }
8877 if (p_ss < 0)
8878 {
8879 errmsg = e_positive;
8880 p_ss = 0;
8881 }
8882
8883 /* May set global value for local option. */
8884 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8885 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
8886
8887 options[opt_idx].flags |= P_WAS_SET;
8888
Bram Moolenaar53744302015-07-17 17:38:22 +02008889#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8890 if (!starting && errmsg == NULL)
8891 {
8892 char_u buf_old[11], buf_new[11], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008893 vim_snprintf((char *)buf_old, 10, "%ld", old_value);
8894 vim_snprintf((char *)buf_new, 10, "%ld", value);
8895 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008896 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8897 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8898 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8899 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8900 reset_v_option_vars();
8901 }
8902#endif
8903
Bram Moolenaar071d4272004-06-13 20:20:40 +00008904 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008905 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008906 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008907 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008908 check_redraw(options[opt_idx].flags);
8909
8910 return errmsg;
8911}
8912
8913/*
8914 * Called after an option changed: check if something needs to be redrawn.
8915 */
8916 static void
8917check_redraw(flags)
8918 long_u flags;
8919{
8920 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008921 int doclear = (flags & P_RCLR) == P_RCLR;
8922 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008923
8924#ifdef FEAT_WINDOWS
8925 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
8926 status_redraw_all();
8927#endif
8928
8929 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
8930 changed_window_setting();
8931 if (flags & P_RBUF)
8932 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008933 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008934 redraw_all_later(CLEAR);
8935 else if (all)
8936 redraw_all_later(NOT_VALID);
8937}
8938
8939/*
8940 * Find index for option 'arg'.
8941 * Return -1 if not found.
8942 */
8943 static int
8944findoption(arg)
8945 char_u *arg;
8946{
8947 int opt_idx;
8948 char *s, *p;
8949 static short quick_tab[27] = {0, 0}; /* quick access table */
8950 int is_term_opt;
8951
8952 /*
8953 * For first call: Initialize the quick-access table.
8954 * It contains the index for the first option that starts with a certain
8955 * letter. There are 26 letters, plus the first "t_" option.
8956 */
8957 if (quick_tab[1] == 0)
8958 {
8959 p = options[0].fullname;
8960 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8961 {
8962 if (s[0] != p[0])
8963 {
8964 if (s[0] == 't' && s[1] == '_')
8965 quick_tab[26] = opt_idx;
8966 else
8967 quick_tab[CharOrdLow(s[0])] = opt_idx;
8968 }
8969 p = s;
8970 }
8971 }
8972
8973 /*
8974 * Check for name starting with an illegal character.
8975 */
8976#ifdef EBCDIC
8977 if (!islower(arg[0]))
8978#else
8979 if (arg[0] < 'a' || arg[0] > 'z')
8980#endif
8981 return -1;
8982
8983 is_term_opt = (arg[0] == 't' && arg[1] == '_');
8984 if (is_term_opt)
8985 opt_idx = quick_tab[26];
8986 else
8987 opt_idx = quick_tab[CharOrdLow(arg[0])];
8988 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8989 {
8990 if (STRCMP(arg, s) == 0) /* match full name */
8991 break;
8992 }
8993 if (s == NULL && !is_term_opt)
8994 {
8995 opt_idx = quick_tab[CharOrdLow(arg[0])];
8996 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
8997 {
8998 s = options[opt_idx].shortname;
8999 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
9000 break;
9001 s = NULL;
9002 }
9003 }
9004 if (s == NULL)
9005 opt_idx = -1;
9006 return opt_idx;
9007}
9008
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009009#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009010/*
9011 * Get the value for an option.
9012 *
9013 * Returns:
9014 * Number or Toggle option: 1, *numval gets value.
9015 * String option: 0, *stringval gets allocated string.
9016 * Hidden Number or Toggle option: -1.
9017 * hidden String option: -2.
9018 * unknown option: -3.
9019 */
9020 int
9021get_option_value(name, numval, stringval, opt_flags)
9022 char_u *name;
9023 long *numval;
Bram Moolenaar370df582010-06-22 05:16:38 +02009024 char_u **stringval; /* NULL when only checking existence */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009025 int opt_flags;
9026{
9027 int opt_idx;
9028 char_u *varp;
9029
9030 opt_idx = findoption(name);
9031 if (opt_idx < 0) /* unknown option */
9032 return -3;
9033
9034 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
9035
9036 if (options[opt_idx].flags & P_STRING)
9037 {
9038 if (varp == NULL) /* hidden option */
9039 return -2;
9040 if (stringval != NULL)
9041 {
9042#ifdef FEAT_CRYPT
9043 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00009044 if ((char_u **)varp == &curbuf->b_p_key
9045 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009046 *stringval = vim_strsave((char_u *)"*****");
9047 else
9048#endif
9049 *stringval = vim_strsave(*(char_u **)(varp));
9050 }
9051 return 0;
9052 }
9053
9054 if (varp == NULL) /* hidden option */
9055 return -1;
9056 if (options[opt_idx].flags & P_NUM)
9057 *numval = *(long *)varp;
9058 else
9059 {
9060 /* Special case: 'modified' is b_changed, but we also want to consider
9061 * it set when 'ff' or 'fenc' changed. */
9062 if ((int *)varp == &curbuf->b_changed)
9063 *numval = curbufIsChanged();
9064 else
9065 *numval = *(int *)varp;
9066 }
9067 return 1;
9068}
9069#endif
9070
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009071#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009072/*
9073 * Returns the option attributes and its value. Unlike the above function it
9074 * will return either global value or local value of the option depending on
9075 * what was requested, but it will never return global value if it was
9076 * requested to return local one and vice versa. Neither it will return
9077 * buffer-local value if it was requested to return window-local one.
9078 *
9079 * Pretends that option is absent if it is not present in the requested scope
9080 * (i.e. has no global, window-local or buffer-local value depending on
9081 * opt_type). Uses
9082 *
9083 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009084 * 0 hidden or unknown option, also option that does not have requested
9085 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009086 * see SOPT_* in vim.h for other flags
9087 *
9088 * Possible opt_type values: see SREQ_* in vim.h
9089 */
9090 int
9091get_option_value_strict(name, numval, stringval, opt_type, from)
9092 char_u *name;
9093 long *numval;
9094 char_u **stringval; /* NULL when only obtaining attributes */
9095 int opt_type;
9096 void *from;
9097{
9098 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009099 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009100 struct vimoption *p;
9101 int r = 0;
9102
9103 opt_idx = findoption(name);
9104 if (opt_idx < 0)
9105 return 0;
9106
9107 p = &(options[opt_idx]);
9108
9109 /* Hidden option */
9110 if (p->var == NULL)
9111 return 0;
9112
9113 if (p->flags & P_BOOL)
9114 r |= SOPT_BOOL;
9115 else if (p->flags & P_NUM)
9116 r |= SOPT_NUM;
9117 else if (p->flags & P_STRING)
9118 r |= SOPT_STRING;
9119
9120 if (p->indir == PV_NONE)
9121 {
9122 if (opt_type == SREQ_GLOBAL)
9123 r |= SOPT_GLOBAL;
9124 else
9125 return 0; /* Did not request global-only option */
9126 }
9127 else
9128 {
9129 if (p->indir & PV_BOTH)
9130 r |= SOPT_GLOBAL;
9131 else if (opt_type == SREQ_GLOBAL)
9132 return 0; /* Requested global option */
9133
9134 if (p->indir & PV_WIN)
9135 {
9136 if (opt_type == SREQ_BUF)
9137 return 0; /* Did not request window-local option */
9138 else
9139 r |= SOPT_WIN;
9140 }
9141 else if (p->indir & PV_BUF)
9142 {
9143 if (opt_type == SREQ_WIN)
9144 return 0; /* Did not request buffer-local option */
9145 else
9146 r |= SOPT_BUF;
9147 }
9148 }
9149
9150 if (stringval == NULL)
9151 return r;
9152
9153 if (opt_type == SREQ_GLOBAL)
9154 varp = p->var;
9155 else
9156 {
9157 if (opt_type == SREQ_BUF)
9158 {
9159 /* Special case: 'modified' is b_changed, but we also want to
9160 * consider it set when 'ff' or 'fenc' changed. */
9161 if (p->indir == PV_MOD)
9162 {
9163 *numval = bufIsChanged((buf_T *) from);
9164 varp = NULL;
9165 }
9166#ifdef FEAT_CRYPT
9167 else if (p->indir == PV_KEY)
9168 {
9169 /* never return the value of the crypt key */
9170 *stringval = NULL;
9171 varp = NULL;
9172 }
9173#endif
9174 else
9175 {
9176 aco_save_T aco;
9177 aucmd_prepbuf(&aco, (buf_T *) from);
9178 varp = get_varp(p);
9179 aucmd_restbuf(&aco);
9180 }
9181 }
9182 else if (opt_type == SREQ_WIN)
9183 {
9184 win_T *save_curwin;
9185 save_curwin = curwin;
9186 curwin = (win_T *) from;
9187 curbuf = curwin->w_buffer;
9188 varp = get_varp(p);
9189 curwin = save_curwin;
9190 curbuf = curwin->w_buffer;
9191 }
9192 if (varp == p->var)
9193 return (r | SOPT_UNSET);
9194 }
9195
9196 if (varp != NULL)
9197 {
9198 if (p->flags & P_STRING)
9199 *stringval = vim_strsave(*(char_u **)(varp));
9200 else if (p->flags & P_NUM)
9201 *numval = *(long *) varp;
9202 else
9203 *numval = *(int *)varp;
9204 }
9205
9206 return r;
9207}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009208
9209/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009210 * Iterate over options. First argument is a pointer to a pointer to a
9211 * structure inside options[] array, second is option type like in the above
9212 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009213 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009214 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009215 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009216 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009217 * first argument to NULL.
9218 *
9219 * Returns full option name for current option on each call.
9220 */
9221 char_u *
9222option_iter_next(option, opt_type)
9223 void **option;
9224 int opt_type;
9225{
9226 struct vimoption *ret = NULL;
9227 do
9228 {
9229 if (*option == NULL)
9230 *option = (void *) options;
9231 else if (((struct vimoption *) (*option))->fullname == NULL)
9232 {
9233 *option = NULL;
9234 return NULL;
9235 }
9236 else
9237 *option = (void *) (((struct vimoption *) (*option)) + 1);
9238
9239 ret = ((struct vimoption *) (*option));
9240
9241 /* Hidden option */
9242 if (ret->var == NULL)
9243 {
9244 ret = NULL;
9245 continue;
9246 }
9247
9248 switch (opt_type)
9249 {
9250 case SREQ_GLOBAL:
9251 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9252 ret = NULL;
9253 break;
9254 case SREQ_BUF:
9255 if (!(ret->indir & PV_BUF))
9256 ret = NULL;
9257 break;
9258 case SREQ_WIN:
9259 if (!(ret->indir & PV_WIN))
9260 ret = NULL;
9261 break;
9262 default:
9263 EMSG2(_(e_intern2), "option_iter_next()");
9264 return NULL;
9265 }
9266 }
9267 while (ret == NULL);
9268
9269 return (char_u *)ret->fullname;
9270}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009271#endif
9272
Bram Moolenaar071d4272004-06-13 20:20:40 +00009273/*
9274 * Set the value of option "name".
9275 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009276 *
9277 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009278 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009279 char_u *
Bram Moolenaar071d4272004-06-13 20:20:40 +00009280set_option_value(name, number, string, opt_flags)
9281 char_u *name;
9282 long number;
9283 char_u *string;
9284 int opt_flags; /* OPT_LOCAL or 0 (both) */
9285{
9286 int opt_idx;
9287 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009288 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009289
9290 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009291 if (opt_idx < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009292 EMSG2(_("E355: Unknown option: %s"), name);
9293 else
9294 {
9295 flags = options[opt_idx].flags;
9296#ifdef HAVE_SANDBOX
9297 /* Disallow changing some options in the sandbox */
9298 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009299 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009300 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009301 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009302 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009303#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009304 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009305 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009306 else
9307 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009308 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009309 if (varp != NULL) /* hidden option is not changed */
9310 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009311 if (number == 0 && string != NULL)
9312 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009313 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009314
9315 /* Either we are given a string or we are setting option
9316 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009317 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009318 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009319 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009320 {
9321 /* There's another character after zeros or the string
9322 * is empty. In both cases, we are trying to set a
9323 * num option using a string. */
9324 EMSG3(_("E521: Number required: &%s = '%s'"),
9325 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009326 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009327
9328 }
9329 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009330 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009331 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009332 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009333 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009334 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009335 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009336 }
9337 }
9338 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009339 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009340}
9341
9342/*
9343 * Get the terminal code for a terminal option.
9344 * Returns NULL when not found.
9345 */
9346 char_u *
9347get_term_code(tname)
9348 char_u *tname;
9349{
9350 int opt_idx;
9351 char_u *varp;
9352
9353 if (tname[0] != 't' || tname[1] != '_' ||
9354 tname[2] == NUL || tname[3] == NUL)
9355 return NULL;
9356 if ((opt_idx = findoption(tname)) >= 0)
9357 {
9358 varp = get_varp(&(options[opt_idx]));
9359 if (varp != NULL)
9360 varp = *(char_u **)(varp);
9361 return varp;
9362 }
9363 return find_termcode(tname + 2);
9364}
9365
9366 char_u *
9367get_highlight_default()
9368{
9369 int i;
9370
9371 i = findoption((char_u *)"hl");
9372 if (i >= 0)
9373 return options[i].def_val[VI_DEFAULT];
9374 return (char_u *)NULL;
9375}
9376
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009377#if defined(FEAT_MBYTE) || defined(PROTO)
9378 char_u *
9379get_encoding_default()
9380{
9381 int i;
9382
9383 i = findoption((char_u *)"enc");
9384 if (i >= 0)
9385 return options[i].def_val[VI_DEFAULT];
9386 return (char_u *)NULL;
9387}
9388#endif
9389
Bram Moolenaar071d4272004-06-13 20:20:40 +00009390/*
9391 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9392 */
9393 static int
9394find_key_option(arg)
9395 char_u *arg;
9396{
9397 int key;
9398 int modifiers;
9399
9400 /*
9401 * Don't use get_special_key_code() for t_xx, we don't want it to call
9402 * add_termcap_entry().
9403 */
9404 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9405 key = TERMCAP2KEY(arg[2], arg[3]);
9406 else
9407 {
9408 --arg; /* put arg at the '<' */
9409 modifiers = 0;
Bram Moolenaar2a8ced02008-12-24 11:54:31 +00009410 key = find_special_key(&arg, &modifiers, TRUE, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009411 if (modifiers) /* can't handle modifiers here */
9412 key = 0;
9413 }
9414 return key;
9415}
9416
9417/*
9418 * if 'all' == 0: show changed options
9419 * if 'all' == 1: show all normal options
9420 * if 'all' == 2: show all terminal options
9421 */
9422 static void
9423showoptions(all, opt_flags)
9424 int all;
9425 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
9426{
9427 struct vimoption *p;
9428 int col;
9429 int isterm;
9430 char_u *varp;
9431 struct vimoption **items;
9432 int item_count;
9433 int run;
9434 int row, rows;
9435 int cols;
9436 int i;
9437 int len;
9438
9439#define INC 20
9440#define GAP 3
9441
9442 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9443 PARAM_COUNT));
9444 if (items == NULL)
9445 return;
9446
9447 /* Highlight title */
9448 if (all == 2)
9449 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9450 else if (opt_flags & OPT_GLOBAL)
9451 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9452 else if (opt_flags & OPT_LOCAL)
9453 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9454 else
9455 MSG_PUTS_TITLE(_("\n--- Options ---"));
9456
9457 /*
9458 * do the loop two times:
9459 * 1. display the short items
9460 * 2. display the long items (only strings and numbers)
9461 */
9462 for (run = 1; run <= 2 && !got_int; ++run)
9463 {
9464 /*
9465 * collect the items in items[]
9466 */
9467 item_count = 0;
9468 for (p = &options[0]; p->fullname != NULL; p++)
9469 {
9470 varp = NULL;
9471 isterm = istermoption(p);
9472 if (opt_flags != 0)
9473 {
9474 if (p->indir != PV_NONE && !isterm)
9475 varp = get_varp_scope(p, opt_flags);
9476 }
9477 else
9478 varp = get_varp(p);
9479 if (varp != NULL
9480 && ((all == 2 && isterm)
9481 || (all == 1 && !isterm)
9482 || (all == 0 && !optval_default(p, varp))))
9483 {
9484 if (p->flags & P_BOOL)
9485 len = 1; /* a toggle option fits always */
9486 else
9487 {
9488 option_value2string(p, opt_flags);
9489 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9490 }
9491 if ((len <= INC - GAP && run == 1) ||
9492 (len > INC - GAP && run == 2))
9493 items[item_count++] = p;
9494 }
9495 }
9496
9497 /*
9498 * display the items
9499 */
9500 if (run == 1)
9501 {
9502 cols = (Columns + GAP - 3) / INC;
9503 if (cols == 0)
9504 cols = 1;
9505 rows = (item_count + cols - 1) / cols;
9506 }
9507 else /* run == 2 */
9508 rows = item_count;
9509 for (row = 0; row < rows && !got_int; ++row)
9510 {
9511 msg_putchar('\n'); /* go to next line */
9512 if (got_int) /* 'q' typed in more */
9513 break;
9514 col = 0;
9515 for (i = row; i < item_count; i += rows)
9516 {
9517 msg_col = col; /* make columns */
9518 showoneopt(items[i], opt_flags);
9519 col += INC;
9520 }
9521 out_flush();
9522 ui_breakcheck();
9523 }
9524 }
9525 vim_free(items);
9526}
9527
9528/*
9529 * Return TRUE if option "p" has its default value.
9530 */
9531 static int
9532optval_default(p, varp)
9533 struct vimoption *p;
9534 char_u *varp;
9535{
9536 int dvi;
9537
9538 if (varp == NULL)
9539 return TRUE; /* hidden option is always at default */
9540 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9541 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009542 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009543 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009544 /* the cast to long is required for Manx C, long_i is
9545 * needed for MSVC */
9546 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009547 /* P_STRING */
9548 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9549}
9550
9551/*
9552 * showoneopt: show the value of one option
9553 * must not be called with a hidden option!
9554 */
9555 static void
9556showoneopt(p, opt_flags)
9557 struct vimoption *p;
9558 int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */
9559{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009560 char_u *varp;
9561 int save_silent = silent_mode;
9562
9563 silent_mode = FALSE;
9564 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009565
9566 varp = get_varp_scope(p, opt_flags);
9567
9568 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9569 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9570 ? !curbufIsChanged() : !*(int *)varp))
9571 MSG_PUTS("no");
9572 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9573 MSG_PUTS("--");
9574 else
9575 MSG_PUTS(" ");
9576 MSG_PUTS(p->fullname);
9577 if (!(p->flags & P_BOOL))
9578 {
9579 msg_putchar('=');
9580 /* put value string in NameBuff */
9581 option_value2string(p, opt_flags);
9582 msg_outtrans(NameBuff);
9583 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009584
9585 silent_mode = save_silent;
9586 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009587}
9588
9589/*
9590 * Write modified options as ":set" commands to a file.
9591 *
9592 * There are three values for "opt_flags":
9593 * OPT_GLOBAL: Write global option values and fresh values of
9594 * buffer-local options (used for start of a session
9595 * file).
9596 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
9597 * curwin (used for a vimrc file).
9598 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
9599 * and local values for window-local options of
9600 * curwin. Local values are also written when at the
9601 * default value, because a modeline or autocommand
9602 * may have set them when doing ":edit file" and the
9603 * user has set them back at the default or fresh
9604 * value.
9605 * When "local_only" is TRUE, don't write fresh
9606 * values, only local values (for ":mkview").
9607 * (fresh value = value used for a new buffer or window for a local option).
9608 *
9609 * Return FAIL on error, OK otherwise.
9610 */
9611 int
9612makeset(fd, opt_flags, local_only)
9613 FILE *fd;
9614 int opt_flags;
9615 int local_only;
9616{
9617 struct vimoption *p;
9618 char_u *varp; /* currently used value */
9619 char_u *varp_fresh; /* local value */
9620 char_u *varp_local = NULL; /* fresh value */
9621 char *cmd;
9622 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009623 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009624
9625 /*
9626 * The options that don't have a default (terminal name, columns, lines)
9627 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009628 * Do the loop over "options[]" twice: once for options with the
9629 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009630 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009631 for (pri = 1; pri >= 0; --pri)
9632 {
9633 for (p = &options[0]; !istermoption(p); p++)
9634 if (!(p->flags & P_NO_MKRC)
9635 && !istermoption(p)
9636 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009637 {
9638 /* skip global option when only doing locals */
9639 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
9640 continue;
9641
9642 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
9643 * file, they are always buffer-specific. */
9644 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
9645 continue;
9646
9647 /* Global values are only written when not at the default value. */
9648 varp = get_varp_scope(p, opt_flags);
9649 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
9650 continue;
9651
9652 round = 2;
9653 if (p->indir != PV_NONE)
9654 {
9655 if (p->var == VAR_WIN)
9656 {
9657 /* skip window-local option when only doing globals */
9658 if (!(opt_flags & OPT_LOCAL))
9659 continue;
9660 /* When fresh value of window-local option is not at the
9661 * default, need to write it too. */
9662 if (!(opt_flags & OPT_GLOBAL) && !local_only)
9663 {
9664 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
9665 if (!optval_default(p, varp_fresh))
9666 {
9667 round = 1;
9668 varp_local = varp;
9669 varp = varp_fresh;
9670 }
9671 }
9672 }
9673 }
9674
9675 /* Round 1: fresh value for window-local options.
9676 * Round 2: other values */
9677 for ( ; round <= 2; varp = varp_local, ++round)
9678 {
9679 if (round == 1 || (opt_flags & OPT_GLOBAL))
9680 cmd = "set";
9681 else
9682 cmd = "setlocal";
9683
9684 if (p->flags & P_BOOL)
9685 {
9686 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
9687 return FAIL;
9688 }
9689 else if (p->flags & P_NUM)
9690 {
9691 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
9692 return FAIL;
9693 }
9694 else /* P_STRING */
9695 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009696#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9697 int do_endif = FALSE;
9698
Bram Moolenaar071d4272004-06-13 20:20:40 +00009699 /* Don't set 'syntax' and 'filetype' again if the value is
9700 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009701 if (
9702# if defined(FEAT_SYN_HL)
9703 p->indir == PV_SYN
9704# if defined(FEAT_AUTOCMD)
9705 ||
9706# endif
9707# endif
9708# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009709 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009710# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009711 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00009712 {
9713 if (fprintf(fd, "if &%s != '%s'", p->fullname,
9714 *(char_u **)(varp)) < 0
9715 || put_eol(fd) < 0)
9716 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009717 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009718 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009719#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009720 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
9721 (p->flags & P_EXPAND) != 0) == FAIL)
9722 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009723#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9724 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009725 {
9726 if (put_line(fd, "endif") == FAIL)
9727 return FAIL;
9728 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009729#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009730 }
9731 }
9732 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009733 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009734 return OK;
9735}
9736
9737#if defined(FEAT_FOLDING) || defined(PROTO)
9738/*
9739 * Generate set commands for the local fold options only. Used when
9740 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
9741 */
9742 int
9743makefoldset(fd)
9744 FILE *fd;
9745{
9746 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
9747# ifdef FEAT_EVAL
9748 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
9749 == FAIL
9750# endif
9751 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
9752 == FAIL
9753 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
9754 == FAIL
9755 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
9756 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
9757 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
9758 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
9759 )
9760 return FAIL;
9761
9762 return OK;
9763}
9764#endif
9765
9766 static int
9767put_setstring(fd, cmd, name, valuep, expand)
9768 FILE *fd;
9769 char *cmd;
9770 char *name;
9771 char_u **valuep;
9772 int expand;
9773{
9774 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009775 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009776
9777 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9778 return FAIL;
9779 if (*valuep != NULL)
9780 {
9781 /* Output 'pastetoggle' as key names. For other
9782 * options some characters have to be escaped with
9783 * CTRL-V or backslash */
9784 if (valuep == &p_pt)
9785 {
9786 s = *valuep;
9787 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +00009788 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009789 return FAIL;
9790 }
9791 else if (expand)
9792 {
Bram Moolenaarf8441472011-04-28 17:24:58 +02009793 buf = alloc(MAXPATHL);
9794 if (buf == NULL)
9795 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009796 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
9797 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +02009798 {
9799 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009800 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009801 }
9802 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009803 }
9804 else if (put_escstr(fd, *valuep, 2) == FAIL)
9805 return FAIL;
9806 }
9807 if (put_eol(fd) < 0)
9808 return FAIL;
9809 return OK;
9810}
9811
9812 static int
9813put_setnum(fd, cmd, name, valuep)
9814 FILE *fd;
9815 char *cmd;
9816 char *name;
9817 long *valuep;
9818{
9819 long wc;
9820
9821 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9822 return FAIL;
9823 if (wc_use_keyname((char_u *)valuep, &wc))
9824 {
9825 /* print 'wildchar' and 'wildcharm' as a key name */
9826 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
9827 return FAIL;
9828 }
9829 else if (fprintf(fd, "%ld", *valuep) < 0)
9830 return FAIL;
9831 if (put_eol(fd) < 0)
9832 return FAIL;
9833 return OK;
9834}
9835
9836 static int
9837put_setbool(fd, cmd, name, value)
9838 FILE *fd;
9839 char *cmd;
9840 char *name;
9841 int value;
9842{
Bram Moolenaar893de922007-10-02 18:40:57 +00009843 if (value < 0) /* global/local option using global value */
9844 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009845 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
9846 || put_eol(fd) < 0)
9847 return FAIL;
9848 return OK;
9849}
9850
9851/*
9852 * Clear all the terminal options.
9853 * If the option has been allocated, free the memory.
9854 * Terminal options are never hidden or indirect.
9855 */
9856 void
9857clear_termoptions()
9858{
Bram Moolenaar071d4272004-06-13 20:20:40 +00009859 /*
9860 * Reset a few things before clearing the old options. This may cause
9861 * outputting a few things that the terminal doesn't understand, but the
9862 * screen will be cleared later, so this is OK.
9863 */
9864#ifdef FEAT_MOUSE_TTY
9865 mch_setmouse(FALSE); /* switch mouse off */
9866#endif
9867#ifdef FEAT_TITLE
9868 mch_restore_title(3); /* restore window titles */
9869#endif
9870#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
9871 /* When starting the GUI close the display opened for the clipboard.
9872 * After restoring the title, because that will need the display. */
9873 if (gui.starting)
9874 clear_xterm_clip();
9875#endif
9876#ifdef WIN3264
9877 /*
9878 * Check if this is allowed now.
9879 */
9880 if (can_end_termcap_mode(FALSE) == TRUE)
9881#endif
9882 stoptermcap(); /* stop termcap mode */
9883
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00009884 free_termoptions();
9885}
9886
9887 void
9888free_termoptions()
9889{
9890 struct vimoption *p;
9891
Bram Moolenaar071d4272004-06-13 20:20:40 +00009892 for (p = &options[0]; p->fullname != NULL; p++)
9893 if (istermoption(p))
9894 {
9895 if (p->flags & P_ALLOCED)
9896 free_string_option(*(char_u **)(p->var));
9897 if (p->flags & P_DEF_ALLOCED)
9898 free_string_option(p->def_val[VI_DEFAULT]);
9899 *(char_u **)(p->var) = empty_option;
9900 p->def_val[VI_DEFAULT] = empty_option;
9901 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
9902 }
9903 clear_termcodes();
9904}
9905
9906/*
Bram Moolenaar363cb672009-07-22 12:28:17 +00009907 * Free the string for one term option, if it was allocated.
9908 * Set the string to empty_option and clear allocated flag.
9909 * "var" points to the option value.
9910 */
9911 void
9912free_one_termoption(var)
9913 char_u *var;
9914{
9915 struct vimoption *p;
9916
9917 for (p = &options[0]; p->fullname != NULL; p++)
9918 if (p->var == var)
9919 {
9920 if (p->flags & P_ALLOCED)
9921 free_string_option(*(char_u **)(p->var));
9922 *(char_u **)(p->var) = empty_option;
9923 p->flags &= ~P_ALLOCED;
9924 break;
9925 }
9926}
9927
9928/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00009929 * Set the terminal option defaults to the current value.
9930 * Used after setting the terminal name.
9931 */
9932 void
9933set_term_defaults()
9934{
9935 struct vimoption *p;
9936
9937 for (p = &options[0]; p->fullname != NULL; p++)
9938 {
9939 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
9940 {
9941 if (p->flags & P_DEF_ALLOCED)
9942 {
9943 free_string_option(p->def_val[VI_DEFAULT]);
9944 p->flags &= ~P_DEF_ALLOCED;
9945 }
9946 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
9947 if (p->flags & P_ALLOCED)
9948 {
9949 p->flags |= P_DEF_ALLOCED;
9950 p->flags &= ~P_ALLOCED; /* don't free the value now */
9951 }
9952 }
9953 }
9954}
9955
9956/*
9957 * return TRUE if 'p' starts with 't_'
9958 */
9959 static int
9960istermoption(p)
9961 struct vimoption *p;
9962{
9963 return (p->fullname[0] == 't' && p->fullname[1] == '_');
9964}
9965
9966/*
9967 * Compute columns for ruler and shown command. 'sc_col' is also used to
9968 * decide what the maximum length of a message on the status line can be.
9969 * If there is a status line for the last window, 'sc_col' is independent
9970 * of 'ru_col'.
9971 */
9972
9973#define COL_RULER 17 /* columns needed by standard ruler */
9974
9975 void
9976comp_col()
9977{
9978#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
9979 int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin));
9980
9981 sc_col = 0;
9982 ru_col = 0;
9983 if (p_ru)
9984 {
9985#ifdef FEAT_STL_OPT
9986 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
9987#else
9988 ru_col = COL_RULER + 1;
9989#endif
9990 /* no last status line, adjust sc_col */
9991 if (!last_has_status)
9992 sc_col = ru_col;
9993 }
9994 if (p_sc)
9995 {
9996 sc_col += SHOWCMD_COLS;
9997 if (!p_ru || last_has_status) /* no need for separating space */
9998 ++sc_col;
9999 }
10000 sc_col = Columns - sc_col;
10001 ru_col = Columns - ru_col;
10002 if (sc_col <= 0) /* screen too narrow, will become a mess */
10003 sc_col = 1;
10004 if (ru_col <= 0)
10005 ru_col = 1;
10006#else
10007 sc_col = Columns;
10008 ru_col = Columns;
10009#endif
10010}
10011
10012/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010013 * Unset local option value, similar to ":set opt<".
10014 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010015 void
10016unset_global_local_option(name, from)
10017 char_u *name;
10018 void *from;
10019{
10020 struct vimoption *p;
10021 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010022 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010023
10024 opt_idx = findoption(name);
Bram Moolenaarbd8539a2015-08-11 18:53:03 +020010025 if (opt_idx < 0)
10026 return;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010027 p = &(options[opt_idx]);
10028
10029 switch ((int)p->indir)
10030 {
10031 /* global option with local value: use local value if it's been set */
10032 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010033 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010034 break;
10035 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010036 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010037 break;
10038 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010039 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010040 break;
10041 case PV_AR:
10042 buf->b_p_ar = -1;
10043 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010044 case PV_BKC:
10045 clear_string_option(&buf->b_p_bkc);
10046 buf->b_bkc_flags = 0;
10047 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010048 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010049 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010050 break;
10051#ifdef FEAT_FIND_ID
10052 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010053 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010054 break;
10055 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010056 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010057 break;
10058#endif
10059#ifdef FEAT_INS_EXPAND
10060 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010061 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010062 break;
10063 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010064 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010065 break;
10066#endif
10067#ifdef FEAT_QUICKFIX
10068 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010069 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010070 break;
10071 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010072 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010073 break;
10074 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010075 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010076 break;
10077#endif
10078#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10079 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010080 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010081 break;
10082#endif
10083#if defined(FEAT_CRYPT)
10084 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010085 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010086 break;
10087#endif
10088#ifdef FEAT_STL_OPT
10089 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010090 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010091 break;
10092#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010093 case PV_UL:
10094 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10095 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010096#ifdef FEAT_LISP
10097 case PV_LW:
10098 clear_string_option(&buf->b_p_lw);
10099 break;
10100#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010101 }
10102}
10103
10104/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010105 * Get pointer to option variable, depending on local or global scope.
10106 */
10107 static char_u *
10108get_varp_scope(p, opt_flags)
10109 struct vimoption *p;
10110 int opt_flags;
10111{
10112 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10113 {
10114 if (p->var == VAR_WIN)
10115 return (char_u *)GLOBAL_WO(get_varp(p));
10116 return p->var;
10117 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010118 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010119 {
10120 switch ((int)p->indir)
10121 {
10122#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010123 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10124 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10125 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010126#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010127 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10128 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10129 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010130 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010131 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010132#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010133 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10134 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010135#endif
10136#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010137 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10138 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010139#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010140#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10141 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10142#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010143#if defined(FEAT_CRYPT)
10144 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10145#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010146#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010147 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010148#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010149 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010150#ifdef FEAT_LISP
10151 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10152#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010153 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010154 }
10155 return NULL; /* "cannot happen" */
10156 }
10157 return get_varp(p);
10158}
10159
10160/*
10161 * Get pointer to option variable.
10162 */
10163 static char_u *
10164get_varp(p)
10165 struct vimoption *p;
10166{
10167 /* hidden option, always return NULL */
10168 if (p->var == NULL)
10169 return NULL;
10170
10171 switch ((int)p->indir)
10172 {
10173 case PV_NONE: return p->var;
10174
10175 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010176 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010177 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010178 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010179 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010180 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010181 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010182 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010183 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010184 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010185 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010186 case PV_BKC: return *curbuf->b_p_bkc != NUL
10187 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010188#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010189 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010190 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010191 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010192 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10193#endif
10194#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010195 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010196 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010197 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010198 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10199#endif
10200#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010201 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010202 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010203 case PV_GP: return *curbuf->b_p_gp != NUL
10204 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10205 case PV_MP: return *curbuf->b_p_mp != NUL
10206 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010207#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010208#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10209 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10210 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10211#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010212#if defined(FEAT_CRYPT)
10213 case PV_CM: return *curbuf->b_p_cm != NUL
10214 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10215#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010216#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010217 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010218 ? (char_u *)&(curwin->w_p_stl) : p->var;
10219#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010220 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10221 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010222#ifdef FEAT_LISP
10223 case PV_LW: return *curbuf->b_p_lw != NUL
10224 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10225#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010226
10227#ifdef FEAT_ARABIC
10228 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10229#endif
10230 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010231#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010232 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10233#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010234#ifdef FEAT_SYN_HL
10235 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10236 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010237 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010238#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010239#ifdef FEAT_DIFF
10240 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10241#endif
10242#ifdef FEAT_FOLDING
10243 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10244 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10245 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10246 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10247 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10248 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10249 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10250# ifdef FEAT_EVAL
10251 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10252 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10253# endif
10254 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10255#endif
10256 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010257 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010258#ifdef FEAT_LINEBREAK
10259 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10260#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010261#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010262 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
10263#endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010264#ifdef FEAT_VERTSPLIT
10265 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10266#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010267#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10268 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10269#endif
10270#ifdef FEAT_RIGHTLEFT
10271 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10272 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10273#endif
10274 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10275 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10276#ifdef FEAT_LINEBREAK
10277 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010278 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10279 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010280#endif
10281#ifdef FEAT_SCROLLBIND
10282 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10283#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010284#ifdef FEAT_CURSORBIND
10285 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10286#endif
10287#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010288 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10289 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010290#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010291
10292 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10293 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10294#ifdef FEAT_MBYTE
10295 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10296#endif
10297#if defined(FEAT_QUICKFIX)
10298 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10299 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
10300#endif
10301 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10302 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10303#ifdef FEAT_CINDENT
10304 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10305 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10306 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10307#endif
10308#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10309 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10310#endif
10311#ifdef FEAT_COMMENTS
10312 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10313#endif
10314#ifdef FEAT_FOLDING
10315 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10316#endif
10317#ifdef FEAT_INS_EXPAND
10318 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10319#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010320#ifdef FEAT_COMPL_FUNC
10321 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010322 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010323#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010324 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010325 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010326 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10327#ifdef FEAT_MBYTE
10328 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10329#endif
10330 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10331#ifdef FEAT_AUTOCMD
10332 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10333#endif
10334 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010335 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010336 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10337 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10338 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10339 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10340#ifdef FEAT_FIND_ID
10341# ifdef FEAT_EVAL
10342 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10343# endif
10344#endif
10345#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10346 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10347 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10348#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010349#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010350 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10351#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010352#ifdef FEAT_CRYPT
10353 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10354#endif
10355#ifdef FEAT_LISP
10356 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10357#endif
10358 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10359 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10360 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10361 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10362 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010363 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010364#ifdef FEAT_TEXTOBJ
10365 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10366#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010367 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10368#ifdef FEAT_SMARTINDENT
10369 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10370#endif
10371#ifndef SHORT_FNAME
10372 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
10373#endif
10374 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10375#ifdef FEAT_SEARCHPATH
10376 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10377#endif
10378 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10379#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010380 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010381 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10382#endif
10383#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010384 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10385 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10386 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010387#endif
10388 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10389 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10390 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10391 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010392#ifdef FEAT_PERSISTENT_UNDO
10393 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10394#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010395 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10396#ifdef FEAT_KEYMAP
10397 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10398#endif
10399 default: EMSG(_("E356: get_varp ERROR"));
10400 }
10401 /* always return a valid pointer to avoid a crash! */
10402 return (char_u *)&(curbuf->b_p_wm);
10403}
10404
10405/*
10406 * Get the value of 'equalprg', either the buffer-local one or the global one.
10407 */
10408 char_u *
10409get_equalprg()
10410{
10411 if (*curbuf->b_p_ep == NUL)
10412 return p_ep;
10413 return curbuf->b_p_ep;
10414}
10415
10416#if defined(FEAT_WINDOWS) || defined(PROTO)
10417/*
10418 * Copy options from one window to another.
10419 * Used when splitting a window.
10420 */
10421 void
10422win_copy_options(wp_from, wp_to)
10423 win_T *wp_from;
10424 win_T *wp_to;
10425{
10426 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10427 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10428# ifdef FEAT_RIGHTLEFT
10429# ifdef FEAT_FKMAP
10430 /* Is this right? */
10431 wp_to->w_farsi = wp_from->w_farsi;
10432# endif
10433# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020010434#if defined(FEAT_LINEBREAK)
10435 briopt_check(wp_to);
10436#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010437}
10438#endif
10439
10440/*
10441 * Copy the options from one winopt_T to another.
10442 * Doesn't free the old option values in "to", use clear_winopt() for that.
10443 * The 'scroll' option is not copied, because it depends on the window height.
10444 * The 'previewwindow' option is reset, there can be only one preview window.
10445 */
10446 void
10447copy_winopt(from, to)
10448 winopt_T *from;
10449 winopt_T *to;
10450{
10451#ifdef FEAT_ARABIC
10452 to->wo_arab = from->wo_arab;
10453#endif
10454 to->wo_list = from->wo_list;
10455 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010456 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010457#ifdef FEAT_LINEBREAK
10458 to->wo_nuw = from->wo_nuw;
10459#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010460#ifdef FEAT_RIGHTLEFT
10461 to->wo_rl = from->wo_rl;
10462 to->wo_rlc = vim_strsave(from->wo_rlc);
10463#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010464#ifdef FEAT_STL_OPT
10465 to->wo_stl = vim_strsave(from->wo_stl);
10466#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010467 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010468#ifdef FEAT_DIFF
10469 to->wo_wrap_save = from->wo_wrap_save;
10470#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010471#ifdef FEAT_LINEBREAK
10472 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020010473 to->wo_bri = from->wo_bri;
10474 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010475#endif
10476#ifdef FEAT_SCROLLBIND
10477 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010478 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010479#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010480#ifdef FEAT_CURSORBIND
10481 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010482 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010483#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010484#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010485 to->wo_spell = from->wo_spell;
10486#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010487#ifdef FEAT_SYN_HL
10488 to->wo_cuc = from->wo_cuc;
10489 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010490 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010491#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010492#ifdef FEAT_DIFF
10493 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010494 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010495#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010496#ifdef FEAT_CONCEAL
10497 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010498 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010499#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010500#ifdef FEAT_FOLDING
10501 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010502 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010503 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010504 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010505 to->wo_fdi = vim_strsave(from->wo_fdi);
10506 to->wo_fml = from->wo_fml;
10507 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010508 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010509 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010510 to->wo_fdm_save = from->wo_diff_saved
10511 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010512 to->wo_fdn = from->wo_fdn;
10513# ifdef FEAT_EVAL
10514 to->wo_fde = vim_strsave(from->wo_fde);
10515 to->wo_fdt = vim_strsave(from->wo_fdt);
10516# endif
10517 to->wo_fmr = vim_strsave(from->wo_fmr);
10518#endif
10519 check_winopt(to); /* don't want NULL pointers */
10520}
10521
10522/*
10523 * Check string options in a window for a NULL value.
10524 */
10525 void
10526check_win_options(win)
10527 win_T *win;
10528{
10529 check_winopt(&win->w_onebuf_opt);
10530 check_winopt(&win->w_allbuf_opt);
10531}
10532
10533/*
10534 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10535 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020010536 static void
Bram Moolenaar071d4272004-06-13 20:20:40 +000010537check_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010538 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010539{
10540#ifdef FEAT_FOLDING
10541 check_string_option(&wop->wo_fdi);
10542 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010543 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010544# ifdef FEAT_EVAL
10545 check_string_option(&wop->wo_fde);
10546 check_string_option(&wop->wo_fdt);
10547# endif
10548 check_string_option(&wop->wo_fmr);
10549#endif
10550#ifdef FEAT_RIGHTLEFT
10551 check_string_option(&wop->wo_rlc);
10552#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010553#ifdef FEAT_STL_OPT
10554 check_string_option(&wop->wo_stl);
10555#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010556#ifdef FEAT_SYN_HL
10557 check_string_option(&wop->wo_cc);
10558#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010559#ifdef FEAT_CONCEAL
10560 check_string_option(&wop->wo_cocu);
10561#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010562#ifdef FEAT_LINEBREAK
10563 check_string_option(&wop->wo_briopt);
10564#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010565}
10566
10567/*
10568 * Free the allocated memory inside a winopt_T.
10569 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010570 void
10571clear_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010572 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010573{
10574#ifdef FEAT_FOLDING
10575 clear_string_option(&wop->wo_fdi);
10576 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010577 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010578# ifdef FEAT_EVAL
10579 clear_string_option(&wop->wo_fde);
10580 clear_string_option(&wop->wo_fdt);
10581# endif
10582 clear_string_option(&wop->wo_fmr);
10583#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010584#ifdef FEAT_LINEBREAK
10585 clear_string_option(&wop->wo_briopt);
10586#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010587#ifdef FEAT_RIGHTLEFT
10588 clear_string_option(&wop->wo_rlc);
10589#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010590#ifdef FEAT_STL_OPT
10591 clear_string_option(&wop->wo_stl);
10592#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010593#ifdef FEAT_SYN_HL
10594 clear_string_option(&wop->wo_cc);
10595#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010596#ifdef FEAT_CONCEAL
10597 clear_string_option(&wop->wo_cocu);
10598#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010599}
10600
10601/*
10602 * Copy global option values to local options for one buffer.
10603 * Used when creating a new buffer and sometimes when entering a buffer.
10604 * flags:
10605 * BCO_ENTER We will enter the buf buffer.
10606 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
10607 * appropriate.
10608 * BCO_NOHELP Don't copy the values to a help buffer.
10609 */
10610 void
10611buf_copy_options(buf, flags)
10612 buf_T *buf;
10613 int flags;
10614{
10615 int should_copy = TRUE;
10616 char_u *save_p_isk = NULL; /* init for GCC */
10617 int dont_do_help;
10618 int did_isk = FALSE;
10619
10620 /*
Bram Moolenaar1a384422010-07-14 19:53:30 +020010621 * Don't do anything if the buffer is invalid.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010622 */
10623 if (buf == NULL || !buf_valid(buf))
10624 return;
10625
10626 /*
10627 * Skip this when the option defaults have not been set yet. Happens when
10628 * main() allocates the first buffer.
10629 */
10630 if (p_cpo != NULL)
10631 {
10632 /*
10633 * Always copy when entering and 'cpo' contains 'S'.
10634 * Don't copy when already initialized.
10635 * Don't copy when 'cpo' contains 's' and not entering.
10636 * 'S' BCO_ENTER initialized 's' should_copy
10637 * yes yes X X TRUE
10638 * yes no yes X FALSE
10639 * no X yes X FALSE
10640 * X no no yes FALSE
10641 * X no no no TRUE
10642 * no yes no X TRUE
10643 */
10644 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
10645 && (buf->b_p_initialized
10646 || (!(flags & BCO_ENTER)
10647 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
10648 should_copy = FALSE;
10649
10650 if (should_copy || (flags & BCO_ALWAYS))
10651 {
10652 /* Don't copy the options specific to a help buffer when
10653 * BCO_NOHELP is given or the options were initialized already
10654 * (jumping back to a help file with CTRL-T or CTRL-O) */
10655 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
10656 || buf->b_p_initialized;
10657 if (dont_do_help) /* don't free b_p_isk */
10658 {
10659 save_p_isk = buf->b_p_isk;
10660 buf->b_p_isk = NULL;
10661 }
10662 /*
10663 * Always free the allocated strings.
10664 * If not already initialized, set 'readonly' and copy 'fileformat'.
10665 */
10666 if (!buf->b_p_initialized)
10667 {
10668 free_buf_options(buf, TRUE);
10669 buf->b_p_ro = FALSE; /* don't copy readonly */
10670 buf->b_p_tx = p_tx;
10671#ifdef FEAT_MBYTE
10672 buf->b_p_fenc = vim_strsave(p_fenc);
10673#endif
10674 buf->b_p_ff = vim_strsave(p_ff);
10675#if defined(FEAT_QUICKFIX)
10676 buf->b_p_bh = empty_option;
10677 buf->b_p_bt = empty_option;
10678#endif
10679 }
10680 else
10681 free_buf_options(buf, FALSE);
10682
10683 buf->b_p_ai = p_ai;
10684 buf->b_p_ai_nopaste = p_ai_nopaste;
10685 buf->b_p_sw = p_sw;
10686 buf->b_p_tw = p_tw;
10687 buf->b_p_tw_nopaste = p_tw_nopaste;
10688 buf->b_p_tw_nobin = p_tw_nobin;
10689 buf->b_p_wm = p_wm;
10690 buf->b_p_wm_nopaste = p_wm_nopaste;
10691 buf->b_p_wm_nobin = p_wm_nobin;
10692 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000010693#ifdef FEAT_MBYTE
10694 buf->b_p_bomb = p_bomb;
10695#endif
Bram Moolenaarb388be02015-07-22 22:19:38 +020010696 buf->b_p_fixeol = p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010697 buf->b_p_et = p_et;
10698 buf->b_p_et_nobin = p_et_nobin;
10699 buf->b_p_ml = p_ml;
10700 buf->b_p_ml_nobin = p_ml_nobin;
10701 buf->b_p_inf = p_inf;
10702 buf->b_p_swf = p_swf;
10703#ifdef FEAT_INS_EXPAND
10704 buf->b_p_cpt = vim_strsave(p_cpt);
10705#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010706#ifdef FEAT_COMPL_FUNC
10707 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010708 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010709#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010710 buf->b_p_sts = p_sts;
10711 buf->b_p_sts_nopaste = p_sts_nopaste;
10712#ifndef SHORT_FNAME
10713 buf->b_p_sn = p_sn;
10714#endif
10715#ifdef FEAT_COMMENTS
10716 buf->b_p_com = vim_strsave(p_com);
10717#endif
10718#ifdef FEAT_FOLDING
10719 buf->b_p_cms = vim_strsave(p_cms);
10720#endif
10721 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010722 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010723 buf->b_p_nf = vim_strsave(p_nf);
10724 buf->b_p_mps = vim_strsave(p_mps);
10725#ifdef FEAT_SMARTINDENT
10726 buf->b_p_si = p_si;
10727#endif
10728 buf->b_p_ci = p_ci;
10729#ifdef FEAT_CINDENT
10730 buf->b_p_cin = p_cin;
10731 buf->b_p_cink = vim_strsave(p_cink);
10732 buf->b_p_cino = vim_strsave(p_cino);
10733#endif
10734#ifdef FEAT_AUTOCMD
10735 /* Don't copy 'filetype', it must be detected */
10736 buf->b_p_ft = empty_option;
10737#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010738 buf->b_p_pi = p_pi;
10739#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10740 buf->b_p_cinw = vim_strsave(p_cinw);
10741#endif
10742#ifdef FEAT_LISP
10743 buf->b_p_lisp = p_lisp;
10744#endif
10745#ifdef FEAT_SYN_HL
10746 /* Don't copy 'syntax', it must be set */
10747 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010748 buf->b_p_smc = p_smc;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010749#endif
10750#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020010751 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010752 (void)compile_cap_prog(&buf->b_s);
10753 buf->b_s.b_p_spf = vim_strsave(p_spf);
10754 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010755#endif
10756#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10757 buf->b_p_inde = vim_strsave(p_inde);
10758 buf->b_p_indk = vim_strsave(p_indk);
10759#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010760#if defined(FEAT_EVAL)
10761 buf->b_p_fex = vim_strsave(p_fex);
10762#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010763#ifdef FEAT_CRYPT
10764 buf->b_p_key = vim_strsave(p_key);
10765#endif
10766#ifdef FEAT_SEARCHPATH
10767 buf->b_p_sua = vim_strsave(p_sua);
10768#endif
10769#ifdef FEAT_KEYMAP
10770 buf->b_p_keymap = vim_strsave(p_keymap);
10771 buf->b_kmap_state |= KEYMAP_INIT;
10772#endif
10773 /* This isn't really an option, but copying the langmap and IME
10774 * state from the current buffer is better than resetting it. */
10775 buf->b_p_iminsert = p_iminsert;
10776 buf->b_p_imsearch = p_imsearch;
10777
10778 /* options that are normally global but also have a local value
10779 * are not copied, start using the global value */
10780 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010781 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010782 buf->b_p_bkc = empty_option;
10783 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010784#ifdef FEAT_QUICKFIX
10785 buf->b_p_gp = empty_option;
10786 buf->b_p_mp = empty_option;
10787 buf->b_p_efm = empty_option;
10788#endif
10789 buf->b_p_ep = empty_option;
10790 buf->b_p_kp = empty_option;
10791 buf->b_p_path = empty_option;
10792 buf->b_p_tags = empty_option;
10793#ifdef FEAT_FIND_ID
10794 buf->b_p_def = empty_option;
10795 buf->b_p_inc = empty_option;
10796# ifdef FEAT_EVAL
10797 buf->b_p_inex = vim_strsave(p_inex);
10798# endif
10799#endif
10800#ifdef FEAT_INS_EXPAND
10801 buf->b_p_dict = empty_option;
10802 buf->b_p_tsr = empty_option;
10803#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010804#ifdef FEAT_TEXTOBJ
10805 buf->b_p_qe = vim_strsave(p_qe);
10806#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010807#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10808 buf->b_p_bexpr = empty_option;
10809#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010810#if defined(FEAT_CRYPT)
10811 buf->b_p_cm = empty_option;
10812#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010813#ifdef FEAT_PERSISTENT_UNDO
10814 buf->b_p_udf = p_udf;
10815#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010816#ifdef FEAT_LISP
10817 buf->b_p_lw = empty_option;
10818#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010819
10820 /*
10821 * Don't copy the options set by ex_help(), use the saved values,
10822 * when going from a help buffer to a non-help buffer.
10823 * Don't touch these at all when BCO_NOHELP is used and going from
10824 * or to a help buffer.
10825 */
10826 if (dont_do_help)
10827 buf->b_p_isk = save_p_isk;
10828 else
10829 {
10830 buf->b_p_isk = vim_strsave(p_isk);
10831 did_isk = TRUE;
10832 buf->b_p_ts = p_ts;
10833 buf->b_help = FALSE;
10834#ifdef FEAT_QUICKFIX
10835 if (buf->b_p_bt[0] == 'h')
10836 clear_string_option(&buf->b_p_bt);
10837#endif
10838 buf->b_p_ma = p_ma;
10839 }
10840 }
10841
10842 /*
10843 * When the options should be copied (ignoring BCO_ALWAYS), set the
10844 * flag that indicates that the options have been initialized.
10845 */
10846 if (should_copy)
10847 buf->b_p_initialized = TRUE;
10848 }
10849
10850 check_buf_options(buf); /* make sure we don't have NULLs */
10851 if (did_isk)
10852 (void)buf_init_chartab(buf, FALSE);
10853}
10854
10855/*
10856 * Reset the 'modifiable' option and its default value.
10857 */
10858 void
10859reset_modifiable()
10860{
10861 int opt_idx;
10862
10863 curbuf->b_p_ma = FALSE;
10864 p_ma = FALSE;
10865 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000010866 if (opt_idx >= 0)
10867 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010868}
10869
10870/*
10871 * Set the global value for 'iminsert' to the local value.
10872 */
10873 void
10874set_iminsert_global()
10875{
10876 p_iminsert = curbuf->b_p_iminsert;
10877}
10878
10879/*
10880 * Set the global value for 'imsearch' to the local value.
10881 */
10882 void
10883set_imsearch_global()
10884{
10885 p_imsearch = curbuf->b_p_imsearch;
10886}
10887
10888#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
10889static int expand_option_idx = -1;
10890static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
10891static int expand_option_flags = 0;
10892
10893 void
10894set_context_in_set_cmd(xp, arg, opt_flags)
10895 expand_T *xp;
10896 char_u *arg;
10897 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
10898{
10899 int nextchar;
10900 long_u flags = 0; /* init for GCC */
10901 int opt_idx = 0; /* init for GCC */
10902 char_u *p;
10903 char_u *s;
10904 int is_term_option = FALSE;
10905 int key;
10906
10907 expand_option_flags = opt_flags;
10908
10909 xp->xp_context = EXPAND_SETTINGS;
10910 if (*arg == NUL)
10911 {
10912 xp->xp_pattern = arg;
10913 return;
10914 }
10915 p = arg + STRLEN(arg) - 1;
10916 if (*p == ' ' && *(p - 1) != '\\')
10917 {
10918 xp->xp_pattern = p + 1;
10919 return;
10920 }
10921 while (p > arg)
10922 {
10923 s = p;
10924 /* count number of backslashes before ' ' or ',' */
10925 if (*p == ' ' || *p == ',')
10926 {
10927 while (s > arg && *(s - 1) == '\\')
10928 --s;
10929 }
10930 /* break at a space with an even number of backslashes */
10931 if (*p == ' ' && ((p - s) & 1) == 0)
10932 {
10933 ++p;
10934 break;
10935 }
10936 --p;
10937 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000010938 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010939 {
10940 xp->xp_context = EXPAND_BOOL_SETTINGS;
10941 p += 2;
10942 }
10943 if (STRNCMP(p, "inv", 3) == 0)
10944 {
10945 xp->xp_context = EXPAND_BOOL_SETTINGS;
10946 p += 3;
10947 }
10948 xp->xp_pattern = arg = p;
10949 if (*arg == '<')
10950 {
10951 while (*p != '>')
10952 if (*p++ == NUL) /* expand terminal option name */
10953 return;
10954 key = get_special_key_code(arg + 1);
10955 if (key == 0) /* unknown name */
10956 {
10957 xp->xp_context = EXPAND_NOTHING;
10958 return;
10959 }
10960 nextchar = *++p;
10961 is_term_option = TRUE;
10962 expand_option_name[2] = KEY2TERMCAP0(key);
10963 expand_option_name[3] = KEY2TERMCAP1(key);
10964 }
10965 else
10966 {
10967 if (p[0] == 't' && p[1] == '_')
10968 {
10969 p += 2;
10970 if (*p != NUL)
10971 ++p;
10972 if (*p == NUL)
10973 return; /* expand option name */
10974 nextchar = *++p;
10975 is_term_option = TRUE;
10976 expand_option_name[2] = p[-2];
10977 expand_option_name[3] = p[-1];
10978 }
10979 else
10980 {
10981 /* Allow * wildcard */
10982 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
10983 p++;
10984 if (*p == NUL)
10985 return;
10986 nextchar = *p;
10987 *p = NUL;
10988 opt_idx = findoption(arg);
10989 *p = nextchar;
10990 if (opt_idx == -1 || options[opt_idx].var == NULL)
10991 {
10992 xp->xp_context = EXPAND_NOTHING;
10993 return;
10994 }
10995 flags = options[opt_idx].flags;
10996 if (flags & P_BOOL)
10997 {
10998 xp->xp_context = EXPAND_NOTHING;
10999 return;
11000 }
11001 }
11002 }
11003 /* handle "-=" and "+=" */
11004 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
11005 {
11006 ++p;
11007 nextchar = '=';
11008 }
11009 if ((nextchar != '=' && nextchar != ':')
11010 || xp->xp_context == EXPAND_BOOL_SETTINGS)
11011 {
11012 xp->xp_context = EXPAND_UNSUCCESSFUL;
11013 return;
11014 }
11015 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
11016 {
11017 xp->xp_context = EXPAND_OLD_SETTING;
11018 if (is_term_option)
11019 expand_option_idx = -1;
11020 else
11021 expand_option_idx = opt_idx;
11022 xp->xp_pattern = p + 1;
11023 return;
11024 }
11025 xp->xp_context = EXPAND_NOTHING;
11026 if (is_term_option || (flags & P_NUM))
11027 return;
11028
11029 xp->xp_pattern = p + 1;
11030
11031 if (flags & P_EXPAND)
11032 {
11033 p = options[opt_idx].var;
11034 if (p == (char_u *)&p_bdir
11035 || p == (char_u *)&p_dir
11036 || p == (char_u *)&p_path
11037 || p == (char_u *)&p_rtp
11038#ifdef FEAT_SEARCHPATH
11039 || p == (char_u *)&p_cdpath
11040#endif
11041#ifdef FEAT_SESSION
11042 || p == (char_u *)&p_vdir
11043#endif
11044 )
11045 {
11046 xp->xp_context = EXPAND_DIRECTORIES;
11047 if (p == (char_u *)&p_path
11048#ifdef FEAT_SEARCHPATH
11049 || p == (char_u *)&p_cdpath
11050#endif
11051 )
11052 xp->xp_backslash = XP_BS_THREE;
11053 else
11054 xp->xp_backslash = XP_BS_ONE;
11055 }
11056 else
11057 {
11058 xp->xp_context = EXPAND_FILES;
11059 /* for 'tags' need three backslashes for a space */
11060 if (p == (char_u *)&p_tags)
11061 xp->xp_backslash = XP_BS_THREE;
11062 else
11063 xp->xp_backslash = XP_BS_ONE;
11064 }
11065 }
11066
11067 /* For an option that is a list of file names, find the start of the
11068 * last file name. */
11069 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11070 {
11071 /* count number of backslashes before ' ' or ',' */
11072 if (*p == ' ' || *p == ',')
11073 {
11074 s = p;
11075 while (s > xp->xp_pattern && *(s - 1) == '\\')
11076 --s;
11077 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11078 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11079 {
11080 xp->xp_pattern = p + 1;
11081 break;
11082 }
11083 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011084
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011085#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011086 /* for 'spellsuggest' start at "file:" */
11087 if (options[opt_idx].var == (char_u *)&p_sps
11088 && STRNCMP(p, "file:", 5) == 0)
11089 {
11090 xp->xp_pattern = p + 5;
11091 break;
11092 }
11093#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011094 }
11095
11096 return;
11097}
11098
11099 int
11100ExpandSettings(xp, regmatch, num_file, file)
11101 expand_T *xp;
11102 regmatch_T *regmatch;
11103 int *num_file;
11104 char_u ***file;
11105{
11106 int num_normal = 0; /* Nr of matching non-term-code settings */
11107 int num_term = 0; /* Nr of matching terminal code settings */
11108 int opt_idx;
11109 int match;
11110 int count = 0;
11111 char_u *str;
11112 int loop;
11113 int is_term_opt;
11114 char_u name_buf[MAX_KEY_NAME_LEN];
11115 static char *(names[]) = {"all", "termcap"};
11116 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11117
11118 /* do this loop twice:
11119 * loop == 0: count the number of matching options
11120 * loop == 1: copy the matching options into allocated memory
11121 */
11122 for (loop = 0; loop <= 1; ++loop)
11123 {
11124 regmatch->rm_ic = ic;
11125 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11126 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011127 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11128 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011129 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11130 {
11131 if (loop == 0)
11132 num_normal++;
11133 else
11134 (*file)[count++] = vim_strsave((char_u *)names[match]);
11135 }
11136 }
11137 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11138 opt_idx++)
11139 {
11140 if (options[opt_idx].var == NULL)
11141 continue;
11142 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11143 && !(options[opt_idx].flags & P_BOOL))
11144 continue;
11145 is_term_opt = istermoption(&options[opt_idx]);
11146 if (is_term_opt && num_normal > 0)
11147 continue;
11148 match = FALSE;
11149 if (vim_regexec(regmatch, str, (colnr_T)0)
11150 || (options[opt_idx].shortname != NULL
11151 && vim_regexec(regmatch,
11152 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11153 match = TRUE;
11154 else if (is_term_opt)
11155 {
11156 name_buf[0] = '<';
11157 name_buf[1] = 't';
11158 name_buf[2] = '_';
11159 name_buf[3] = str[2];
11160 name_buf[4] = str[3];
11161 name_buf[5] = '>';
11162 name_buf[6] = NUL;
11163 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11164 {
11165 match = TRUE;
11166 str = name_buf;
11167 }
11168 }
11169 if (match)
11170 {
11171 if (loop == 0)
11172 {
11173 if (is_term_opt)
11174 num_term++;
11175 else
11176 num_normal++;
11177 }
11178 else
11179 (*file)[count++] = vim_strsave(str);
11180 }
11181 }
11182 /*
11183 * Check terminal key codes, these are not in the option table
11184 */
11185 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11186 {
11187 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11188 {
11189 if (!isprint(str[0]) || !isprint(str[1]))
11190 continue;
11191
11192 name_buf[0] = 't';
11193 name_buf[1] = '_';
11194 name_buf[2] = str[0];
11195 name_buf[3] = str[1];
11196 name_buf[4] = NUL;
11197
11198 match = FALSE;
11199 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11200 match = TRUE;
11201 else
11202 {
11203 name_buf[0] = '<';
11204 name_buf[1] = 't';
11205 name_buf[2] = '_';
11206 name_buf[3] = str[0];
11207 name_buf[4] = str[1];
11208 name_buf[5] = '>';
11209 name_buf[6] = NUL;
11210
11211 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11212 match = TRUE;
11213 }
11214 if (match)
11215 {
11216 if (loop == 0)
11217 num_term++;
11218 else
11219 (*file)[count++] = vim_strsave(name_buf);
11220 }
11221 }
11222
11223 /*
11224 * Check special key names.
11225 */
11226 regmatch->rm_ic = TRUE; /* ignore case here */
11227 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11228 {
11229 name_buf[0] = '<';
11230 STRCPY(name_buf + 1, str);
11231 STRCAT(name_buf, ">");
11232
11233 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11234 {
11235 if (loop == 0)
11236 num_term++;
11237 else
11238 (*file)[count++] = vim_strsave(name_buf);
11239 }
11240 }
11241 }
11242 if (loop == 0)
11243 {
11244 if (num_normal > 0)
11245 *num_file = num_normal;
11246 else if (num_term > 0)
11247 *num_file = num_term;
11248 else
11249 return OK;
11250 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11251 if (*file == NULL)
11252 {
11253 *file = (char_u **)"";
11254 return FAIL;
11255 }
11256 }
11257 }
11258 return OK;
11259}
11260
11261 int
11262ExpandOldSetting(num_file, file)
11263 int *num_file;
11264 char_u ***file;
11265{
11266 char_u *var = NULL; /* init for GCC */
11267 char_u *buf;
11268
11269 *num_file = 0;
11270 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11271 if (*file == NULL)
11272 return FAIL;
11273
11274 /*
11275 * For a terminal key code expand_option_idx is < 0.
11276 */
11277 if (expand_option_idx < 0)
11278 {
11279 var = find_termcode(expand_option_name + 2);
11280 if (var == NULL)
11281 expand_option_idx = findoption(expand_option_name);
11282 }
11283
11284 if (expand_option_idx >= 0)
11285 {
11286 /* put string of option value in NameBuff */
11287 option_value2string(&options[expand_option_idx], expand_option_flags);
11288 var = NameBuff;
11289 }
11290 else if (var == NULL)
11291 var = (char_u *)"";
11292
11293 /* A backslash is required before some characters. This is the reverse of
11294 * what happens in do_set(). */
11295 buf = vim_strsave_escaped(var, escape_chars);
11296
11297 if (buf == NULL)
11298 {
11299 vim_free(*file);
11300 *file = NULL;
11301 return FAIL;
11302 }
11303
11304#ifdef BACKSLASH_IN_FILENAME
11305 /* For MS-Windows et al. we don't double backslashes at the start and
11306 * before a file name character. */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011307 for (var = buf; *var != NUL; mb_ptr_adv(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011308 if (var[0] == '\\' && var[1] == '\\'
11309 && expand_option_idx >= 0
11310 && (options[expand_option_idx].flags & P_EXPAND)
11311 && vim_isfilec(var[2])
11312 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011313 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011314#endif
11315
11316 *file[0] = buf;
11317 *num_file = 1;
11318 return OK;
11319}
11320#endif
11321
11322/*
11323 * Get the value for the numeric or string option *opp in a nice format into
11324 * NameBuff[]. Must not be called with a hidden option!
11325 */
11326 static void
11327option_value2string(opp, opt_flags)
11328 struct vimoption *opp;
11329 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
11330{
11331 char_u *varp;
11332
11333 varp = get_varp_scope(opp, opt_flags);
11334
11335 if (opp->flags & P_NUM)
11336 {
11337 long wc = 0;
11338
11339 if (wc_use_keyname(varp, &wc))
11340 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11341 else if (wc != 0)
11342 STRCPY(NameBuff, transchar((int)wc));
11343 else
11344 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11345 }
11346 else /* P_STRING */
11347 {
11348 varp = *(char_u **)(varp);
11349 if (varp == NULL) /* just in case */
11350 NameBuff[0] = NUL;
11351#ifdef FEAT_CRYPT
11352 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011353 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011354 STRCPY(NameBuff, "*****");
11355#endif
11356 else if (opp->flags & P_EXPAND)
11357 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11358 /* Translate 'pastetoggle' into special key names */
11359 else if ((char_u **)opp->var == &p_pt)
11360 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11361 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011362 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011363 }
11364}
11365
11366/*
11367 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11368 * printed as a keyname.
11369 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11370 */
11371 static int
11372wc_use_keyname(varp, wcp)
11373 char_u *varp;
11374 long *wcp;
11375{
11376 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11377 {
11378 *wcp = *(long *)varp;
11379 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11380 return TRUE;
11381 }
11382 return FALSE;
11383}
11384
Bram Moolenaar01615492015-02-03 13:00:38 +010011385#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011386/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011387 * Any character has an equivalent 'langmap' character. This is used for
11388 * keyboards that have a special language mode that sends characters above
11389 * 128 (although other characters can be translated too). The "to" field is a
11390 * Vim command character. This avoids having to switch the keyboard back to
11391 * ASCII mode when leaving Insert mode.
11392 *
11393 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11394 * commands.
11395 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11396 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11397 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011398 */
Bram Moolenaar01615492015-02-03 13:00:38 +010011399# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011400/*
11401 * With multi-byte support use growarray for 'langmap' chars >= 256
11402 */
11403typedef struct
11404{
11405 int from;
11406 int to;
11407} langmap_entry_T;
11408
11409static garray_T langmap_mapga;
11410static void langmap_set_entry __ARGS((int from, int to));
Bram Moolenaar071d4272004-06-13 20:20:40 +000011411
11412/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011413 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11414 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011415 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011416 static void
11417langmap_set_entry(from, to)
11418 int from;
11419 int to;
11420{
11421 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011422 int a = 0;
11423 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011424
11425 /* Do a binary search for an existing entry. */
11426 while (a != b)
11427 {
11428 int i = (a + b) / 2;
11429 int d = entries[i].from - from;
11430
11431 if (d == 0)
11432 {
11433 entries[i].to = to;
11434 return;
11435 }
11436 if (d < 0)
11437 a = i + 1;
11438 else
11439 b = i;
11440 }
11441
11442 if (ga_grow(&langmap_mapga, 1) != OK)
11443 return; /* out of memory */
11444
11445 /* insert new entry at position "a" */
11446 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11447 mch_memmove(entries + 1, entries,
11448 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11449 ++langmap_mapga.ga_len;
11450 entries[0].from = from;
11451 entries[0].to = to;
11452}
11453
11454/*
11455 * Apply 'langmap' to multi-byte character "c" and return the result.
11456 */
11457 int
11458langmap_adjust_mb(c)
11459 int c;
11460{
11461 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11462 int a = 0;
11463 int b = langmap_mapga.ga_len;
11464
11465 while (a != b)
11466 {
11467 int i = (a + b) / 2;
11468 int d = entries[i].from - c;
11469
11470 if (d == 0)
11471 return entries[i].to; /* found matching entry */
11472 if (d < 0)
11473 a = i + 1;
11474 else
11475 b = i;
11476 }
11477 return c; /* no entry found, return "c" unmodified */
11478}
11479# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011480
11481 static void
11482langmap_init()
11483{
11484 int i;
11485
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011486 for (i = 0; i < 256; i++)
11487 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11488# ifdef FEAT_MBYTE
11489 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11490# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011491}
11492
11493/*
11494 * Called when langmap option is set; the language map can be
11495 * changed at any time!
11496 */
11497 static void
11498langmap_set()
11499{
11500 char_u *p;
11501 char_u *p2;
11502 int from, to;
11503
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011504#ifdef FEAT_MBYTE
11505 ga_clear(&langmap_mapga); /* clear the previous map first */
11506#endif
11507 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011508
11509 for (p = p_langmap; p[0] != NUL; )
11510 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011511 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
11512 mb_ptr_adv(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011513 {
11514 if (p2[0] == '\\' && p2[1] != NUL)
11515 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011516 }
11517 if (p2[0] == ';')
11518 ++p2; /* abcd;ABCD form, p2 points to A */
11519 else
11520 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11521 while (p[0])
11522 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011523 if (p[0] == ',')
11524 {
11525 ++p;
11526 break;
11527 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011528 if (p[0] == '\\' && p[1] != NUL)
11529 ++p;
11530#ifdef FEAT_MBYTE
11531 from = (*mb_ptr2char)(p);
11532#else
11533 from = p[0];
11534#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011535 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011536 if (p2 == NULL)
11537 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011538 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011539 if (p[0] != ',')
11540 {
11541 if (p[0] == '\\')
11542 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011543#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011544 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011545#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011546 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011547#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011548 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011549 }
11550 else
11551 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011552 if (p2[0] != ',')
11553 {
11554 if (p2[0] == '\\')
11555 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011556#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011557 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011558#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011559 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011560#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011561 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011562 }
11563 if (to == NUL)
11564 {
11565 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
11566 transchar(from));
11567 return;
11568 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011569
11570#ifdef FEAT_MBYTE
11571 if (from >= 256)
11572 langmap_set_entry(from, to);
11573 else
11574#endif
11575 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011576
11577 /* Advance to next pair */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011578 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011579 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011580 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011581 mb_ptr_adv(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011582 if (*p == ';')
11583 {
11584 p = p2;
11585 if (p[0] != NUL)
11586 {
11587 if (p[0] != ',')
11588 {
11589 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
11590 return;
11591 }
11592 ++p;
11593 }
11594 break;
11595 }
11596 }
11597 }
11598 }
11599}
11600#endif
11601
11602/*
11603 * Return TRUE if format option 'x' is in effect.
11604 * Take care of no formatting when 'paste' is set.
11605 */
11606 int
11607has_format_option(x)
11608 int x;
11609{
11610 if (p_paste)
11611 return FALSE;
11612 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
11613}
11614
11615/*
11616 * Return TRUE if "x" is present in 'shortmess' option, or
11617 * 'shortmess' contains 'a' and "x" is present in SHM_A.
11618 */
11619 int
11620shortmess(x)
11621 int x;
11622{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010011623 return p_shm != NULL &&
11624 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000011625 || (vim_strchr(p_shm, 'a') != NULL
11626 && vim_strchr((char_u *)SHM_A, x) != NULL));
11627}
11628
11629/*
11630 * paste_option_changed() - Called after p_paste was set or reset.
11631 */
11632 static void
11633paste_option_changed()
11634{
11635 static int old_p_paste = FALSE;
11636 static int save_sm = 0;
11637#ifdef FEAT_CMDL_INFO
11638 static int save_ru = 0;
11639#endif
11640#ifdef FEAT_RIGHTLEFT
11641 static int save_ri = 0;
11642 static int save_hkmap = 0;
11643#endif
11644 buf_T *buf;
11645
11646 if (p_paste)
11647 {
11648 /*
11649 * Paste switched from off to on.
11650 * Save the current values, so they can be restored later.
11651 */
11652 if (!old_p_paste)
11653 {
11654 /* save options for each buffer */
11655 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11656 {
11657 buf->b_p_tw_nopaste = buf->b_p_tw;
11658 buf->b_p_wm_nopaste = buf->b_p_wm;
11659 buf->b_p_sts_nopaste = buf->b_p_sts;
11660 buf->b_p_ai_nopaste = buf->b_p_ai;
11661 }
11662
11663 /* save global options */
11664 save_sm = p_sm;
11665#ifdef FEAT_CMDL_INFO
11666 save_ru = p_ru;
11667#endif
11668#ifdef FEAT_RIGHTLEFT
11669 save_ri = p_ri;
11670 save_hkmap = p_hkmap;
11671#endif
11672 /* save global values for local buffer options */
11673 p_tw_nopaste = p_tw;
11674 p_wm_nopaste = p_wm;
11675 p_sts_nopaste = p_sts;
11676 p_ai_nopaste = p_ai;
11677 }
11678
11679 /*
11680 * Always set the option values, also when 'paste' is set when it is
11681 * already on.
11682 */
11683 /* set options for each buffer */
11684 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11685 {
11686 buf->b_p_tw = 0; /* textwidth is 0 */
11687 buf->b_p_wm = 0; /* wrapmargin is 0 */
11688 buf->b_p_sts = 0; /* softtabstop is 0 */
11689 buf->b_p_ai = 0; /* no auto-indent */
11690 }
11691
11692 /* set global options */
11693 p_sm = 0; /* no showmatch */
11694#ifdef FEAT_CMDL_INFO
11695# ifdef FEAT_WINDOWS
11696 if (p_ru)
11697 status_redraw_all(); /* redraw to remove the ruler */
11698# endif
11699 p_ru = 0; /* no ruler */
11700#endif
11701#ifdef FEAT_RIGHTLEFT
11702 p_ri = 0; /* no reverse insert */
11703 p_hkmap = 0; /* no Hebrew keyboard */
11704#endif
11705 /* set global values for local buffer options */
11706 p_tw = 0;
11707 p_wm = 0;
11708 p_sts = 0;
11709 p_ai = 0;
11710 }
11711
11712 /*
11713 * Paste switched from on to off: Restore saved values.
11714 */
11715 else if (old_p_paste)
11716 {
11717 /* restore options for each buffer */
11718 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11719 {
11720 buf->b_p_tw = buf->b_p_tw_nopaste;
11721 buf->b_p_wm = buf->b_p_wm_nopaste;
11722 buf->b_p_sts = buf->b_p_sts_nopaste;
11723 buf->b_p_ai = buf->b_p_ai_nopaste;
11724 }
11725
11726 /* restore global options */
11727 p_sm = save_sm;
11728#ifdef FEAT_CMDL_INFO
11729# ifdef FEAT_WINDOWS
11730 if (p_ru != save_ru)
11731 status_redraw_all(); /* redraw to draw the ruler */
11732# endif
11733 p_ru = save_ru;
11734#endif
11735#ifdef FEAT_RIGHTLEFT
11736 p_ri = save_ri;
11737 p_hkmap = save_hkmap;
11738#endif
11739 /* set global values for local buffer options */
11740 p_tw = p_tw_nopaste;
11741 p_wm = p_wm_nopaste;
11742 p_sts = p_sts_nopaste;
11743 p_ai = p_ai_nopaste;
11744 }
11745
11746 old_p_paste = p_paste;
11747}
11748
11749/*
11750 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
11751 *
11752 * Reset 'compatible' and set the values for options that didn't get set yet
11753 * to the Vim defaults.
11754 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011755 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011756 */
11757 void
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011758vimrc_found(fname, envname)
11759 char_u *fname;
11760 char_u *envname;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011761{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011762 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000011763 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011764 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011765
11766 if (!option_was_set((char_u *)"cp"))
11767 {
11768 p_cp = FALSE;
11769 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11770 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
11771 set_option_default(opt_idx, OPT_FREE, FALSE);
11772 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020011773 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000011774 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011775
11776 if (fname != NULL)
11777 {
11778 p = vim_getenv(envname, &dofree);
11779 if (p == NULL)
11780 {
11781 /* Set $MYVIMRC to the first vimrc file found. */
11782 p = FullName_save(fname, FALSE);
11783 if (p != NULL)
11784 {
11785 vim_setenv(envname, p);
11786 vim_free(p);
11787 }
11788 }
11789 else if (dofree)
11790 vim_free(p);
11791 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011792}
11793
11794/*
11795 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
11796 */
11797 void
11798change_compatible(on)
11799 int on;
11800{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011801 int opt_idx;
11802
Bram Moolenaar071d4272004-06-13 20:20:40 +000011803 if (p_cp != on)
11804 {
11805 p_cp = on;
11806 compatible_set();
11807 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011808 opt_idx = findoption((char_u *)"cp");
11809 if (opt_idx >= 0)
11810 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011811}
11812
11813/*
11814 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020011815 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011816 */
11817 int
11818option_was_set(name)
11819 char_u *name;
11820{
11821 int idx;
11822
11823 idx = findoption(name);
11824 if (idx < 0) /* unknown option */
11825 return FALSE;
11826 if (options[idx].flags & P_WAS_SET)
11827 return TRUE;
11828 return FALSE;
11829}
11830
11831/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010011832 * Reset the flag indicating option "name" was set.
11833 */
11834 void
11835reset_option_was_set(name)
11836 char_u *name;
11837{
11838 int idx = findoption(name);
11839
11840 if (idx >= 0)
11841 options[idx].flags &= ~P_WAS_SET;
11842}
11843
11844/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011845 * compatible_set() - Called when 'compatible' has been set or unset.
11846 *
11847 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
11848 * flag) to a Vi compatible value.
11849 * When 'compatible' is unset: Set all options that have a different default
11850 * for Vim (without the P_VI_DEF flag) to that default.
11851 */
11852 static void
11853compatible_set()
11854{
11855 int opt_idx;
11856
11857 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11858 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
11859 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
11860 set_option_default(opt_idx, OPT_FREE, p_cp);
11861 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020011862 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000011863}
11864
11865#ifdef FEAT_LINEBREAK
11866
11867# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
11868 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011869 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011870# endif
11871
11872/*
11873 * fill_breakat_flags() -- called when 'breakat' changes value.
11874 */
11875 static void
11876fill_breakat_flags()
11877{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011878 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011879 int i;
11880
11881 for (i = 0; i < 256; i++)
11882 breakat_flags[i] = FALSE;
11883
11884 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011885 for (p = p_breakat; *p; p++)
11886 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011887}
11888
11889# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011890 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011891# endif
11892
11893#endif
11894
11895/*
11896 * Check an option that can be a range of string values.
11897 *
11898 * Return OK for correct value, FAIL otherwise.
11899 * Empty is always OK.
11900 */
11901 static int
11902check_opt_strings(val, values, list)
11903 char_u *val;
11904 char **values;
11905 int list; /* when TRUE: accept a list of values */
11906{
11907 return opt_strings_flags(val, values, NULL, list);
11908}
11909
11910/*
11911 * Handle an option that can be a range of string values.
11912 * Set a flag in "*flagp" for each string present.
11913 *
11914 * Return OK for correct value, FAIL otherwise.
11915 * Empty is always OK.
11916 */
11917 static int
11918opt_strings_flags(val, values, flagp, list)
11919 char_u *val; /* new value */
11920 char **values; /* array of valid string values */
11921 unsigned *flagp;
11922 int list; /* when TRUE: accept a list of values */
11923{
11924 int i;
11925 int len;
11926 unsigned new_flags = 0;
11927
11928 while (*val)
11929 {
11930 for (i = 0; ; ++i)
11931 {
11932 if (values[i] == NULL) /* val not found in values[] */
11933 return FAIL;
11934
11935 len = (int)STRLEN(values[i]);
11936 if (STRNCMP(values[i], val, len) == 0
11937 && ((list && val[len] == ',') || val[len] == NUL))
11938 {
11939 val += len + (val[len] == ',');
11940 new_flags |= (1 << i);
11941 break; /* check next item in val list */
11942 }
11943 }
11944 }
11945 if (flagp != NULL)
11946 *flagp = new_flags;
11947
11948 return OK;
11949}
11950
11951/*
11952 * Read the 'wildmode' option, fill wim_flags[].
11953 */
11954 static int
11955check_opt_wim()
11956{
11957 char_u new_wim_flags[4];
11958 char_u *p;
11959 int i;
11960 int idx = 0;
11961
11962 for (i = 0; i < 4; ++i)
11963 new_wim_flags[i] = 0;
11964
11965 for (p = p_wim; *p; ++p)
11966 {
11967 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
11968 ;
11969 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
11970 return FAIL;
11971 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
11972 new_wim_flags[idx] |= WIM_LONGEST;
11973 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
11974 new_wim_flags[idx] |= WIM_FULL;
11975 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
11976 new_wim_flags[idx] |= WIM_LIST;
11977 else
11978 return FAIL;
11979 p += i;
11980 if (*p == NUL)
11981 break;
11982 if (*p == ',')
11983 {
11984 if (idx == 3)
11985 return FAIL;
11986 ++idx;
11987 }
11988 }
11989
11990 /* fill remaining entries with last flag */
11991 while (idx < 3)
11992 {
11993 new_wim_flags[idx + 1] = new_wim_flags[idx];
11994 ++idx;
11995 }
11996
11997 /* only when there are no errors, wim_flags[] is changed */
11998 for (i = 0; i < 4; ++i)
11999 wim_flags[i] = new_wim_flags[i];
12000 return OK;
12001}
12002
12003/*
12004 * Check if backspacing over something is allowed.
12005 */
12006 int
12007can_bs(what)
12008 int what; /* BS_INDENT, BS_EOL or BS_START */
12009{
12010 switch (*p_bs)
12011 {
12012 case '2': return TRUE;
12013 case '1': return (what != BS_START);
12014 case '0': return FALSE;
12015 }
12016 return vim_strchr(p_bs, what) != NULL;
12017}
12018
12019/*
12020 * Save the current values of 'fileformat' and 'fileencoding', so that we know
12021 * the file must be considered changed when the value is different.
12022 */
12023 void
12024save_file_ff(buf)
12025 buf_T *buf;
12026{
12027 buf->b_start_ffc = *buf->b_p_ff;
12028 buf->b_start_eol = buf->b_p_eol;
12029#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012030 buf->b_start_bomb = buf->b_p_bomb;
12031
Bram Moolenaar071d4272004-06-13 20:20:40 +000012032 /* Only use free/alloc when necessary, they take time. */
12033 if (buf->b_start_fenc == NULL
12034 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
12035 {
12036 vim_free(buf->b_start_fenc);
12037 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
12038 }
12039#endif
12040}
12041
12042/*
12043 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
12044 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012045 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
12046 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012047 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012048 * When "ignore_empty" is true don't consider a new, empty buffer to be
12049 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012050 */
12051 int
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012052file_ff_differs(buf, ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012053 buf_T *buf;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012054 int ignore_empty;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012055{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012056 /* In a buffer that was never loaded the options are not valid. */
12057 if (buf->b_flags & BF_NEVERLOADED)
12058 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012059 if (ignore_empty
12060 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012061 && buf->b_ml.ml_line_count == 1
12062 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12063 return FALSE;
12064 if (buf->b_start_ffc != *buf->b_p_ff)
12065 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012066 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012067 return TRUE;
12068#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012069 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12070 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012071 if (buf->b_start_fenc == NULL)
12072 return (*buf->b_p_fenc != NUL);
12073 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12074#else
12075 return FALSE;
12076#endif
12077}
12078
12079/*
12080 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12081 */
12082 int
12083check_ff_value(p)
12084 char_u *p;
12085{
12086 return check_opt_strings(p, p_ff_values, FALSE);
12087}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012088
12089/*
12090 * Return the effective shiftwidth value for current buffer, using the
12091 * 'tabstop' value when 'shiftwidth' is zero.
12092 */
12093 long
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012094get_sw_value(buf)
12095 buf_T *buf;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012096{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012097 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012098}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012099
12100/*
12101 * Return the effective softtabstop value for the current buffer, using the
12102 * 'tabstop' value when 'softtabstop' is negative.
12103 */
12104 long
12105get_sts_value()
12106{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012107 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012108}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012109
12110/*
12111 * Check matchpairs option for "*initc".
12112 * If there is a match set "*initc" to the matching character and "*findc" to
12113 * the opposite character. Set "*backwards" to the direction.
12114 * When "switchit" is TRUE swap the direction.
12115 */
12116 void
12117find_mps_values(initc, findc, backwards, switchit)
12118 int *initc;
12119 int *findc;
12120 int *backwards;
12121 int switchit;
12122{
12123 char_u *ptr;
12124
12125 ptr = curbuf->b_p_mps;
12126 while (*ptr != NUL)
12127 {
12128#ifdef FEAT_MBYTE
12129 if (has_mbyte)
12130 {
12131 char_u *prev;
12132
12133 if (mb_ptr2char(ptr) == *initc)
12134 {
12135 if (switchit)
12136 {
12137 *findc = *initc;
12138 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12139 *backwards = TRUE;
12140 }
12141 else
12142 {
12143 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12144 *backwards = FALSE;
12145 }
12146 return;
12147 }
12148 prev = ptr;
12149 ptr += mb_ptr2len(ptr) + 1;
12150 if (mb_ptr2char(ptr) == *initc)
12151 {
12152 if (switchit)
12153 {
12154 *findc = *initc;
12155 *initc = mb_ptr2char(prev);
12156 *backwards = FALSE;
12157 }
12158 else
12159 {
12160 *findc = mb_ptr2char(prev);
12161 *backwards = TRUE;
12162 }
12163 return;
12164 }
12165 ptr += mb_ptr2len(ptr);
12166 }
12167 else
12168#endif
12169 {
12170 if (*ptr == *initc)
12171 {
12172 if (switchit)
12173 {
12174 *backwards = TRUE;
12175 *findc = *initc;
12176 *initc = ptr[2];
12177 }
12178 else
12179 {
12180 *backwards = FALSE;
12181 *findc = ptr[2];
12182 }
12183 return;
12184 }
12185 ptr += 2;
12186 if (*ptr == *initc)
12187 {
12188 if (switchit)
12189 {
12190 *backwards = FALSE;
12191 *findc = *initc;
12192 *initc = ptr[-2];
12193 }
12194 else
12195 {
12196 *backwards = TRUE;
12197 *findc = ptr[-2];
12198 }
12199 return;
12200 }
12201 ++ptr;
12202 }
12203 if (*ptr == ',')
12204 ++ptr;
12205 }
12206}
Bram Moolenaar597a4222014-06-25 14:39:50 +020012207
12208#if defined(FEAT_LINEBREAK) || defined(PROTO)
12209/*
12210 * This is called when 'breakindentopt' is changed and when a window is
12211 * initialized.
12212 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012213 static int
12214briopt_check(wp)
12215 win_T *wp;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012216{
12217 char_u *p;
12218 int bri_shift = 0;
12219 long bri_min = 20;
12220 int bri_sbr = FALSE;
12221
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012222 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012223 while (*p != NUL)
12224 {
12225 if (STRNCMP(p, "shift:", 6) == 0
12226 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
12227 {
12228 p += 6;
12229 bri_shift = getdigits(&p);
12230 }
12231 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
12232 {
12233 p += 4;
12234 bri_min = getdigits(&p);
12235 }
12236 else if (STRNCMP(p, "sbr", 3) == 0)
12237 {
12238 p += 3;
12239 bri_sbr = TRUE;
12240 }
12241 if (*p != ',' && *p != NUL)
12242 return FAIL;
12243 if (*p == ',')
12244 ++p;
12245 }
12246
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012247 wp->w_p_brishift = bri_shift;
12248 wp->w_p_brimin = bri_min;
12249 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012250
12251 return OK;
12252}
12253#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012254
12255/*
12256 * Get the local or global value of 'backupcopy'.
12257 */
12258 unsigned int
12259get_bkc_value(buf)
12260 buf_T *buf;
12261{
12262 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
12263}