blob: b5e53efee7027a87d66ae0e453ed3eabb0e2cbec [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
3657 && options[i].var != (char_u *)&p_cm
3658 && options[i].var != (char_u *)&p_key)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003659 set_option_default(i, opt_flags, p_cp);
3660
3661#ifdef FEAT_WINDOWS
3662 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003663 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003664 win_comp_scroll(wp);
3665#else
3666 win_comp_scroll(curwin);
3667#endif
Bram Moolenaar5a4eceb2014-09-09 17:33:07 +02003668#ifdef FEAT_CINDENT
3669 parse_cino(curbuf);
3670#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003671}
3672
3673/*
3674 * Set the Vi-default value of a string option.
3675 * Used for 'sh', 'backupskip' and 'term'.
3676 */
3677 void
3678set_string_default(name, val)
3679 char *name;
3680 char_u *val;
3681{
3682 char_u *p;
3683 int opt_idx;
3684
3685 p = vim_strsave(val);
3686 if (p != NULL) /* we don't want a NULL */
3687 {
3688 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003689 if (opt_idx >= 0)
3690 {
3691 if (options[opt_idx].flags & P_DEF_ALLOCED)
3692 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3693 options[opt_idx].def_val[VI_DEFAULT] = p;
3694 options[opt_idx].flags |= P_DEF_ALLOCED;
3695 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003696 }
3697}
3698
3699/*
3700 * Set the Vi-default value of a number option.
3701 * Used for 'lines' and 'columns'.
3702 */
3703 void
3704set_number_default(name, val)
3705 char *name;
3706 long val;
3707{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003708 int opt_idx;
3709
3710 opt_idx = findoption((char_u *)name);
3711 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003712 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003713}
3714
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003715#if defined(EXITFREE) || defined(PROTO)
3716/*
3717 * Free all options.
3718 */
3719 void
3720free_all_options()
3721{
3722 int i;
3723
3724 for (i = 0; !istermoption(&options[i]); i++)
3725 {
3726 if (options[i].indir == PV_NONE)
3727 {
3728 /* global option: free value and default value. */
3729 if (options[i].flags & P_ALLOCED && options[i].var != NULL)
3730 free_string_option(*(char_u **)options[i].var);
3731 if (options[i].flags & P_DEF_ALLOCED)
3732 free_string_option(options[i].def_val[VI_DEFAULT]);
3733 }
3734 else if (options[i].var != VAR_WIN
3735 && (options[i].flags & P_STRING))
3736 /* buffer-local option: free global value */
3737 free_string_option(*(char_u **)options[i].var);
3738 }
3739}
3740#endif
3741
3742
Bram Moolenaar071d4272004-06-13 20:20:40 +00003743/*
3744 * Initialize the options, part two: After getting Rows and Columns and
3745 * setting 'term'.
3746 */
3747 void
3748set_init_2()
3749{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003750 int idx;
3751
Bram Moolenaar071d4272004-06-13 20:20:40 +00003752 /*
3753 * 'scroll' defaults to half the window height. Note that this default is
3754 * wrong when the window height changes.
3755 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003756 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003757 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003758 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003759 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003760 comp_col();
3761
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003762 /*
3763 * 'window' is only for backwards compatibility with Vi.
3764 * Default is Rows - 1.
3765 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003766 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003767 p_window = Rows - 1;
3768 set_number_default("window", Rows - 1);
3769
Bram Moolenaarf740b292006-02-16 22:11:02 +00003770 /* For DOS console the default is always black. */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003771#if !((defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003772 /*
3773 * If 'background' wasn't set by the user, try guessing the value,
3774 * depending on the terminal name. Only need to check for terminals
3775 * with a dark background, that can handle color.
3776 */
3777 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003778 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3779 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003780 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003781 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003782 /* don't mark it as set, when starting the GUI it may be
3783 * changed again */
3784 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003785 }
3786#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003787
3788#ifdef CURSOR_SHAPE
3789 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3790#endif
3791#ifdef FEAT_MOUSESHAPE
3792 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3793#endif
3794#ifdef FEAT_PRINTER
3795 (void)parse_printoptions(); /* parse 'printoptions' default value */
3796#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003797}
3798
3799/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00003800 * Return "dark" or "light" depending on the kind of terminal.
3801 * This is just guessing! Recognized are:
3802 * "linux" Linux console
3803 * "screen.linux" Linux console with screen
3804 * "cygwin" Cygwin shell
3805 * "putty" Putty program
3806 * We also check the COLORFGBG environment variable, which is set by
3807 * rxvt and derivatives. This variable contains either two or three
3808 * values separated by semicolons; we want the last value in either
3809 * case. If this value is 0-6 or 8, our background is dark.
3810 */
3811 static char_u *
3812term_bg_default()
3813{
Bram Moolenaarf740b292006-02-16 22:11:02 +00003814#if defined(MSDOS) || defined(OS2) || defined(WIN3264)
3815 /* DOS console nearly always black */
3816 return (char_u *)"dark";
3817#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00003818 char_u *p;
3819
Bram Moolenaarf740b292006-02-16 22:11:02 +00003820 if (STRCMP(T_NAME, "linux") == 0
3821 || STRCMP(T_NAME, "screen.linux") == 0
3822 || STRCMP(T_NAME, "cygwin") == 0
3823 || STRCMP(T_NAME, "putty") == 0
3824 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
3825 && (p = vim_strrchr(p, ';')) != NULL
3826 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
3827 && p[2] == NUL))
3828 return (char_u *)"dark";
3829 return (char_u *)"light";
3830#endif
3831}
3832
3833/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00003834 * Initialize the options, part three: After reading the .vimrc
3835 */
3836 void
3837set_init_3()
3838{
3839#if defined(UNIX) || defined(OS2) || defined(WIN3264)
3840/*
3841 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
3842 * This is done after other initializations, where 'shell' might have been
3843 * set, but only if they have not been set before.
3844 */
3845 char_u *p;
3846 int idx_srr;
3847 int do_srr;
3848#ifdef FEAT_QUICKFIX
3849 int idx_sp;
3850 int do_sp;
3851#endif
3852
3853 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003854 if (idx_srr < 0)
3855 do_srr = FALSE;
3856 else
3857 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003858#ifdef FEAT_QUICKFIX
3859 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003860 if (idx_sp < 0)
3861 do_sp = FALSE;
3862 else
3863 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003864#endif
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003865 p = get_isolated_shell_name();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003866 if (p != NULL)
3867 {
3868 /*
3869 * Default for p_sp is "| tee", for p_srr is ">".
3870 * For known shells it is changed here to include stderr.
3871 */
3872 if ( fnamecmp(p, "csh") == 0
3873 || fnamecmp(p, "tcsh") == 0
3874# if defined(OS2) || defined(WIN3264) /* also check with .exe extension */
3875 || fnamecmp(p, "csh.exe") == 0
3876 || fnamecmp(p, "tcsh.exe") == 0
3877# endif
3878 )
3879 {
3880#if defined(FEAT_QUICKFIX)
3881 if (do_sp)
3882 {
3883# ifdef WIN3264
3884 p_sp = (char_u *)">&";
3885# else
3886 p_sp = (char_u *)"|& tee";
3887# endif
3888 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3889 }
3890#endif
3891 if (do_srr)
3892 {
3893 p_srr = (char_u *)">&";
3894 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3895 }
3896 }
3897 else
3898# ifndef OS2 /* Always use bourne shell style redirection if we reach this */
3899 if ( fnamecmp(p, "sh") == 0
3900 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003901 || fnamecmp(p, "mksh") == 0
3902 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003903 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003904 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003905 || fnamecmp(p, "bash") == 0
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003906 || fnamecmp(p, "fish") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003907# ifdef WIN3264
3908 || fnamecmp(p, "cmd") == 0
3909 || fnamecmp(p, "sh.exe") == 0
3910 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003911 || fnamecmp(p, "mksh.exe") == 0
3912 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003913 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003914 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003915 || fnamecmp(p, "bash.exe") == 0
3916 || fnamecmp(p, "cmd.exe") == 0
3917# endif
3918 )
3919# endif
3920 {
3921#if defined(FEAT_QUICKFIX)
3922 if (do_sp)
3923 {
3924# ifdef WIN3264
3925 p_sp = (char_u *)">%s 2>&1";
3926# else
3927 p_sp = (char_u *)"2>&1| tee";
3928# endif
3929 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3930 }
3931#endif
3932 if (do_srr)
3933 {
3934 p_srr = (char_u *)">%s 2>&1";
3935 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3936 }
3937 }
3938 vim_free(p);
3939 }
3940#endif
3941
3942#if defined(MSDOS) || defined(WIN3264) || defined(OS2)
3943 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01003944 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
3945 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003946 * This is done after other initializations, where 'shell' might have been
3947 * set, but only if they have not been set before. Default for p_shcf is
3948 * "/c", for p_shq is "". For "sh" like shells it is changed here to
3949 * "-c" and "\"", but not for DJGPP, because it starts the shell without
3950 * command.com. And for Win32 we need to set p_sxq instead.
3951 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00003952 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003953 {
3954 int idx3;
3955
3956 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003957 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003958 {
3959 p_shcf = (char_u *)"-c";
3960 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3961 }
3962
3963# ifndef DJGPP
3964# ifdef WIN3264
3965 /* Somehow Win32 requires the quotes around the redirection too */
3966 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003967 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003968 {
3969 p_sxq = (char_u *)"\"";
3970 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3971 }
3972# else
3973 idx3 = findoption((char_u *)"shq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003974 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003975 {
3976 p_shq = (char_u *)"\"";
3977 options[idx3].def_val[VI_DEFAULT] = p_shq;
3978 }
3979# endif
3980# endif
3981 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01003982 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
3983 {
3984 int idx3;
3985
3986 /*
3987 * cmd.exe on Windows will strip the first and last double quote given
3988 * on the command line, e.g. most of the time things like:
3989 * cmd /c "my path/to/echo" "my args to echo"
3990 * become:
3991 * my path/to/echo" "my args to echo
3992 * when executed.
3993 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01003994 * To avoid this, set shellxquote to surround the command in
3995 * parenthesis. This appears to make most commands work, without
3996 * breaking commands that worked previously, such as
3997 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01003998 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01003999 idx3 = findoption((char_u *)"sxq");
4000 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4001 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004002 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004003 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4004 }
4005
Bram Moolenaara64ba222012-02-12 23:23:31 +01004006 idx3 = findoption((char_u *)"shcf");
4007 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4008 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004009 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004010 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4011 }
4012 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004013#endif
4014
4015#ifdef FEAT_TITLE
4016 set_title_defaults();
4017#endif
4018}
4019
4020#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4021/*
4022 * When 'helplang' is still at its default value, set it to "lang".
4023 * Only the first two characters of "lang" are used.
4024 */
4025 void
4026set_helplang_default(lang)
4027 char_u *lang;
4028{
4029 int idx;
4030
4031 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4032 return;
4033 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004034 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004035 {
4036 if (options[idx].flags & P_ALLOCED)
4037 free_string_option(p_hlg);
4038 p_hlg = vim_strsave(lang);
4039 if (p_hlg == NULL)
4040 p_hlg = empty_option;
4041 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004042 {
4043 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4044 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4045 {
4046 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4047 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4048 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004049 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004050 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004051 options[idx].flags |= P_ALLOCED;
4052 }
4053}
4054#endif
4055
4056#ifdef FEAT_GUI
4057static char_u *gui_bg_default __ARGS((void));
4058
4059 static char_u *
4060gui_bg_default()
4061{
4062 if (gui_get_lightness(gui.back_pixel) < 127)
4063 return (char_u *)"dark";
4064 return (char_u *)"light";
4065}
4066
4067/*
4068 * Option initializations that can only be done after opening the GUI window.
4069 */
4070 void
4071init_gui_options()
4072{
4073 /* Set the 'background' option according to the lightness of the
4074 * background color, unless the user has set it already. */
4075 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4076 {
4077 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4078 highlight_changed();
4079 }
4080}
4081#endif
4082
4083#ifdef FEAT_TITLE
4084/*
4085 * 'title' and 'icon' only default to true if they have not been set or reset
4086 * in .vimrc and we can read the old value.
4087 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4088 * they can be reset. This reduces startup time when using X on a remote
4089 * machine.
4090 */
4091 void
4092set_title_defaults()
4093{
4094 int idx1;
4095 long val;
4096
4097 /*
4098 * If GUI is (going to be) used, we can always set the window title and
4099 * icon name. Saves a bit of time, because the X11 display server does
4100 * not need to be contacted.
4101 */
4102 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004103 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004104 {
4105#ifdef FEAT_GUI
4106 if (gui.starting || gui.in_use)
4107 val = TRUE;
4108 else
4109#endif
4110 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004111 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004112 p_title = val;
4113 }
4114 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004115 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004116 {
4117#ifdef FEAT_GUI
4118 if (gui.starting || gui.in_use)
4119 val = TRUE;
4120 else
4121#endif
4122 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004123 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004124 p_icon = val;
4125 }
4126}
4127#endif
4128
4129/*
4130 * Parse 'arg' for option settings.
4131 *
4132 * 'arg' may be IObuff, but only when no errors can be present and option
4133 * does not need to be expanded with option_expand().
4134 * "opt_flags":
4135 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004136 * OPT_GLOBAL for ":setglobal"
4137 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004138 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004139 * OPT_WINONLY to only set window-local options
4140 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004141 *
4142 * returns FAIL if an error is detected, OK otherwise
4143 */
4144 int
4145do_set(arg, opt_flags)
4146 char_u *arg; /* option string (may be written to!) */
4147 int opt_flags;
4148{
4149 int opt_idx;
4150 char_u *errmsg;
4151 char_u errbuf[80];
4152 char_u *startarg;
4153 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4154 int nextchar; /* next non-white char after option name */
4155 int afterchar; /* character just after option name */
4156 int len;
4157 int i;
4158 long value;
4159 int key;
4160 long_u flags; /* flags for current option */
4161 char_u *varp = NULL; /* pointer to variable for current option */
4162 int did_show = FALSE; /* already showed one value */
4163 int adding; /* "opt+=arg" */
4164 int prepending; /* "opt^=arg" */
4165 int removing; /* "opt-=arg" */
4166 int cp_val = 0;
4167 char_u key_name[2];
4168
4169 if (*arg == NUL)
4170 {
4171 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004172 did_show = TRUE;
4173 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004174 }
4175
4176 while (*arg != NUL) /* loop to process all options */
4177 {
4178 errmsg = NULL;
4179 startarg = arg; /* remember for error message */
4180
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004181 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4182 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004183 {
4184 /*
4185 * ":set all" show all options.
4186 * ":set all&" set all options to their default value.
4187 */
4188 arg += 3;
4189 if (*arg == '&')
4190 {
4191 ++arg;
4192 /* Only for :set command set global value of local options. */
4193 set_options_default(OPT_FREE | opt_flags);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02004194 didset_options();
4195 didset_options2();
Bram Moolenaarb341dda2015-08-25 12:56:31 +02004196 redraw_all_later(CLEAR);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004197 }
4198 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004199 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004200 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004201 did_show = TRUE;
4202 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004203 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004204 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004205 {
4206 showoptions(2, opt_flags);
4207 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004208 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004209 arg += 7;
4210 }
4211 else
4212 {
4213 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004214 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004215 {
4216 prefix = 0;
4217 arg += 2;
4218 }
4219 else if (STRNCMP(arg, "inv", 3) == 0)
4220 {
4221 prefix = 2;
4222 arg += 3;
4223 }
4224
4225 /* find end of name */
4226 key = 0;
4227 if (*arg == '<')
4228 {
4229 nextchar = 0;
4230 opt_idx = -1;
4231 /* look out for <t_>;> */
4232 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4233 len = 5;
4234 else
4235 {
4236 len = 1;
4237 while (arg[len] != NUL && arg[len] != '>')
4238 ++len;
4239 }
4240 if (arg[len] != '>')
4241 {
4242 errmsg = e_invarg;
4243 goto skip;
4244 }
4245 arg[len] = NUL; /* put NUL after name */
4246 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4247 opt_idx = findoption(arg + 1);
4248 arg[len++] = '>'; /* restore '>' */
4249 if (opt_idx == -1)
4250 key = find_key_option(arg + 1);
4251 }
4252 else
4253 {
4254 len = 0;
4255 /*
4256 * The two characters after "t_" may not be alphanumeric.
4257 */
4258 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4259 len = 4;
4260 else
4261 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4262 ++len;
4263 nextchar = arg[len];
4264 arg[len] = NUL; /* put NUL after name */
4265 opt_idx = findoption(arg);
4266 arg[len] = nextchar; /* restore nextchar */
4267 if (opt_idx == -1)
4268 key = find_key_option(arg);
4269 }
4270
4271 /* remember character after option name */
4272 afterchar = arg[len];
4273
4274 /* skip white space, allow ":set ai ?" */
4275 while (vim_iswhite(arg[len]))
4276 ++len;
4277
4278 adding = FALSE;
4279 prepending = FALSE;
4280 removing = FALSE;
4281 if (arg[len] != NUL && arg[len + 1] == '=')
4282 {
4283 if (arg[len] == '+')
4284 {
4285 adding = TRUE; /* "+=" */
4286 ++len;
4287 }
4288 else if (arg[len] == '^')
4289 {
4290 prepending = TRUE; /* "^=" */
4291 ++len;
4292 }
4293 else if (arg[len] == '-')
4294 {
4295 removing = TRUE; /* "-=" */
4296 ++len;
4297 }
4298 }
4299 nextchar = arg[len];
4300
4301 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4302 {
4303 errmsg = (char_u *)N_("E518: Unknown option");
4304 goto skip;
4305 }
4306
4307 if (opt_idx >= 0)
4308 {
4309 if (options[opt_idx].var == NULL) /* hidden option: skip */
4310 {
4311 /* Only give an error message when requesting the value of
4312 * a hidden option, ignore setting it. */
4313 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4314 && (!(options[opt_idx].flags & P_BOOL)
4315 || nextchar == '?'))
4316 errmsg = (char_u *)N_("E519: Option not supported");
4317 goto skip;
4318 }
4319
4320 flags = options[opt_idx].flags;
4321 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4322 }
4323 else
4324 {
4325 flags = P_STRING;
4326 if (key < 0)
4327 {
4328 key_name[0] = KEY2TERMCAP0(key);
4329 key_name[1] = KEY2TERMCAP1(key);
4330 }
4331 else
4332 {
4333 key_name[0] = KS_KEY;
4334 key_name[1] = (key & 0xff);
4335 }
4336 }
4337
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004338 /* Skip all options that are not window-local (used when showing
4339 * an already loaded buffer in a window). */
4340 if ((opt_flags & OPT_WINONLY)
4341 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4342 goto skip;
4343
Bram Moolenaara3227e22006-03-08 21:32:40 +00004344 /* Skip all options that are window-local (used for :vimgrep). */
4345 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4346 && options[opt_idx].var == VAR_WIN)
4347 goto skip;
4348
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004349 /* Disallow changing some options from modelines. */
4350 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004351 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004352 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004353 {
4354 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4355 goto skip;
4356 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004357#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004358 /* In diff mode some options are overruled. This avoids that
4359 * 'foldmethod' becomes "marker" instead of "diff" and that
4360 * "wrap" gets set. */
4361 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004362 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004363 && (options[opt_idx].indir == PV_FDM
4364 || options[opt_idx].indir == PV_WRAP))
4365 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004366#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004367 }
4368
4369#ifdef HAVE_SANDBOX
4370 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004371 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004372 {
4373 errmsg = (char_u *)_(e_sandbox);
4374 goto skip;
4375 }
4376#endif
4377
4378 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4379 {
4380 arg += len;
4381 cp_val = p_cp;
4382 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4383 {
4384 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4385 {
4386 cp_val = FALSE;
4387 arg += 3;
4388 }
4389 else /* "opt&vi": set to Vi default */
4390 {
4391 cp_val = TRUE;
4392 arg += 2;
4393 }
4394 }
4395 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
4396 && arg[1] != NUL && !vim_iswhite(arg[1]))
4397 {
4398 errmsg = e_trailing;
4399 goto skip;
4400 }
4401 }
4402
4403 /*
4404 * allow '=' and ':' as MSDOS command.com allows only one
4405 * '=' character per "set" command line. grrr. (jw)
4406 */
4407 if (nextchar == '?'
4408 || (prefix == 1
4409 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4410 && !(flags & P_BOOL)))
4411 {
4412 /*
4413 * print value
4414 */
4415 if (did_show)
4416 msg_putchar('\n'); /* cursor below last one */
4417 else
4418 {
4419 gotocmdline(TRUE); /* cursor at status line */
4420 did_show = TRUE; /* remember that we did a line */
4421 }
4422 if (opt_idx >= 0)
4423 {
4424 showoneopt(&options[opt_idx], opt_flags);
4425#ifdef FEAT_EVAL
4426 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004427 {
4428 /* Mention where the option was last set. */
4429 if (varp == options[opt_idx].var)
4430 last_set_msg(options[opt_idx].scriptID);
4431 else if ((int)options[opt_idx].indir & PV_WIN)
4432 last_set_msg(curwin->w_p_scriptID[
4433 (int)options[opt_idx].indir & PV_MASK]);
4434 else if ((int)options[opt_idx].indir & PV_BUF)
4435 last_set_msg(curbuf->b_p_scriptID[
4436 (int)options[opt_idx].indir & PV_MASK]);
4437 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004438#endif
4439 }
4440 else
4441 {
4442 char_u *p;
4443
4444 p = find_termcode(key_name);
4445 if (p == NULL)
4446 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004447 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004448 goto skip;
4449 }
4450 else
4451 (void)show_one_termcode(key_name, p, TRUE);
4452 }
4453 if (nextchar != '?'
4454 && nextchar != NUL && !vim_iswhite(afterchar))
4455 errmsg = e_trailing;
4456 }
4457 else
4458 {
4459 if (flags & P_BOOL) /* boolean */
4460 {
4461 if (nextchar == '=' || nextchar == ':')
4462 {
4463 errmsg = e_invarg;
4464 goto skip;
4465 }
4466
4467 /*
4468 * ":set opt!": invert
4469 * ":set opt&": reset to default value
4470 * ":set opt<": reset to global value
4471 */
4472 if (nextchar == '!')
4473 value = *(int *)(varp) ^ 1;
4474 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004475 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004476 ((flags & P_VI_DEF) || cp_val)
4477 ? VI_DEFAULT : VIM_DEFAULT];
4478 else if (nextchar == '<')
4479 {
4480 /* For 'autoread' -1 means to use global value. */
4481 if ((int *)varp == &curbuf->b_p_ar
4482 && opt_flags == OPT_LOCAL)
4483 value = -1;
4484 else
4485 value = *(int *)get_varp_scope(&(options[opt_idx]),
4486 OPT_GLOBAL);
4487 }
4488 else
4489 {
4490 /*
4491 * ":set invopt": invert
4492 * ":set opt" or ":set noopt": set or reset
4493 */
4494 if (nextchar != NUL && !vim_iswhite(afterchar))
4495 {
4496 errmsg = e_trailing;
4497 goto skip;
4498 }
4499 if (prefix == 2) /* inv */
4500 value = *(int *)(varp) ^ 1;
4501 else
4502 value = prefix;
4503 }
4504
4505 errmsg = set_bool_option(opt_idx, varp, (int)value,
4506 opt_flags);
4507 }
4508 else /* numeric or string */
4509 {
4510 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4511 || prefix != 1)
4512 {
4513 errmsg = e_invarg;
4514 goto skip;
4515 }
4516
4517 if (flags & P_NUM) /* numeric */
4518 {
4519 /*
4520 * Different ways to set a number option:
4521 * & set to default value
4522 * < set to global value
4523 * <xx> accept special key codes for 'wildchar'
4524 * c accept any non-digit for 'wildchar'
4525 * [-]0-9 set number
4526 * other error
4527 */
4528 ++arg;
4529 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004530 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004531 ((flags & P_VI_DEF) || cp_val)
4532 ? VI_DEFAULT : VIM_DEFAULT];
4533 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004534 {
4535 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4536 * use the global value. */
4537 if ((long *)varp == &curbuf->b_p_ul
4538 && opt_flags == OPT_LOCAL)
4539 value = NO_LOCAL_UNDOLEVEL;
4540 else
4541 value = *(long *)get_varp_scope(
4542 &(options[opt_idx]), OPT_GLOBAL);
4543 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004544 else if (((long *)varp == &p_wc
4545 || (long *)varp == &p_wcm)
4546 && (*arg == '<'
4547 || *arg == '^'
4548 || ((!arg[1] || vim_iswhite(arg[1]))
4549 && !VIM_ISDIGIT(*arg))))
4550 {
4551 value = string_to_key(arg);
4552 if (value == 0 && (long *)varp != &p_wcm)
4553 {
4554 errmsg = e_invarg;
4555 goto skip;
4556 }
4557 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004558 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4559 {
Bram Moolenaar18400e62015-01-27 15:58:40 +01004560 /* Allow negative (for 'undolevels'), octal and
4561 * hex numbers. */
Bram Moolenaar5d1bc782015-07-17 13:03:48 +02004562 vim_str2nr(arg, NULL, &i, TRUE, TRUE, &value, NULL, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004563 if (arg[i] != NUL && !vim_iswhite(arg[i]))
4564 {
4565 errmsg = e_invarg;
4566 goto skip;
4567 }
4568 }
4569 else
4570 {
4571 errmsg = (char_u *)N_("E521: Number required after =");
4572 goto skip;
4573 }
4574
4575 if (adding)
4576 value = *(long *)varp + value;
4577 if (prepending)
4578 value = *(long *)varp * value;
4579 if (removing)
4580 value = *(long *)varp - value;
4581 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004582 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004583 }
4584 else if (opt_idx >= 0) /* string */
4585 {
4586 char_u *save_arg = NULL;
4587 char_u *s = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004588 char_u *oldval = NULL; /* previous value if *varp */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004589 char_u *newval;
Bram Moolenaar53744302015-07-17 17:38:22 +02004590 char_u *origval = NULL;
4591#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4592 char_u *saved_origval = NULL;
4593#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004594 unsigned newlen;
4595 int comma;
4596 int bs;
4597 int new_value_alloced; /* new string option
4598 was allocated */
4599
4600 /* When using ":set opt=val" for a global option
4601 * with a local value the local value will be
4602 * reset, use the global value here. */
4603 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004604 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004605 varp = options[opt_idx].var;
4606
4607 /* The old value is kept until we are sure that the
4608 * new value is valid. */
4609 oldval = *(char_u **)varp;
4610 if (nextchar == '&') /* set to default val */
4611 {
4612 newval = options[opt_idx].def_val[
4613 ((flags & P_VI_DEF) || cp_val)
4614 ? VI_DEFAULT : VIM_DEFAULT];
4615 if ((char_u **)varp == &p_bg)
4616 {
4617 /* guess the value of 'background' */
4618#ifdef FEAT_GUI
4619 if (gui.in_use)
4620 newval = gui_bg_default();
4621 else
4622#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004623 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004624 }
4625
4626 /* expand environment variables and ~ (since the
4627 * default value was already expanded, only
4628 * required when an environment variable was set
4629 * later */
4630 if (newval == NULL)
4631 newval = empty_option;
4632 else
4633 {
4634 s = option_expand(opt_idx, newval);
4635 if (s == NULL)
4636 s = newval;
4637 newval = vim_strsave(s);
4638 }
4639 new_value_alloced = TRUE;
4640 }
4641 else if (nextchar == '<') /* set to global val */
4642 {
4643 newval = vim_strsave(*(char_u **)get_varp_scope(
4644 &(options[opt_idx]), OPT_GLOBAL));
4645 new_value_alloced = TRUE;
4646 }
4647 else
4648 {
4649 ++arg; /* jump to after the '=' or ':' */
4650
4651 /*
4652 * Set 'keywordprg' to ":help" if an empty
4653 * value was passed to :set by the user.
4654 * Misuse errbuf[] for the resulting string.
4655 */
4656 if (varp == (char_u *)&p_kp
4657 && (*arg == NUL || *arg == ' '))
4658 {
4659 STRCPY(errbuf, ":help");
4660 save_arg = arg;
4661 arg = errbuf;
4662 }
4663 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004664 * Convert 'backspace' number to string, for
4665 * adding, prepending and removing string.
4666 */
4667 else if (varp == (char_u *)&p_bs
4668 && VIM_ISDIGIT(**(char_u **)varp))
4669 {
4670 i = getdigits((char_u **)varp);
4671 switch (i)
4672 {
4673 case 0:
4674 *(char_u **)varp = empty_option;
4675 break;
4676 case 1:
4677 *(char_u **)varp = vim_strsave(
4678 (char_u *)"indent,eol");
4679 break;
4680 case 2:
4681 *(char_u **)varp = vim_strsave(
4682 (char_u *)"indent,eol,start");
4683 break;
4684 }
4685 vim_free(oldval);
4686 oldval = *(char_u **)varp;
4687 }
4688 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004689 * Convert 'whichwrap' number to string, for
4690 * backwards compatibility with Vim 3.0.
4691 * Misuse errbuf[] for the resulting string.
4692 */
4693 else if (varp == (char_u *)&p_ww
4694 && VIM_ISDIGIT(*arg))
4695 {
4696 *errbuf = NUL;
4697 i = getdigits(&arg);
4698 if (i & 1)
4699 STRCAT(errbuf, "b,");
4700 if (i & 2)
4701 STRCAT(errbuf, "s,");
4702 if (i & 4)
4703 STRCAT(errbuf, "h,l,");
4704 if (i & 8)
4705 STRCAT(errbuf, "<,>,");
4706 if (i & 16)
4707 STRCAT(errbuf, "[,],");
4708 if (*errbuf != NUL) /* remove trailing , */
4709 errbuf[STRLEN(errbuf) - 1] = NUL;
4710 save_arg = arg;
4711 arg = errbuf;
4712 }
4713 /*
4714 * Remove '>' before 'dir' and 'bdir', for
4715 * backwards compatibility with version 3.0
4716 */
4717 else if ( *arg == '>'
4718 && (varp == (char_u *)&p_dir
4719 || varp == (char_u *)&p_bdir))
4720 {
4721 ++arg;
4722 }
4723
4724 /* When setting the local value of a global
4725 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004726 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004727 && (opt_flags & OPT_LOCAL))
4728 origval = *(char_u **)get_varp(
4729 &options[opt_idx]);
4730 else
4731 origval = oldval;
4732
4733 /*
4734 * Copy the new string into allocated memory.
4735 * Can't use set_string_option_direct(), because
4736 * we need to remove the backslashes.
4737 */
4738 /* get a bit too much */
4739 newlen = (unsigned)STRLEN(arg) + 1;
4740 if (adding || prepending || removing)
4741 newlen += (unsigned)STRLEN(origval) + 1;
4742 newval = alloc(newlen);
4743 if (newval == NULL) /* out of mem, don't change */
4744 break;
4745 s = newval;
4746
4747 /*
4748 * Copy the string, skip over escaped chars.
4749 * For MS-DOS and WIN32 backslashes before normal
4750 * file name characters are not removed, and keep
4751 * backslash at start, for "\\machine\path", but
4752 * do remove it for "\\\\machine\\path".
4753 * The reverse is found in ExpandOldSetting().
4754 */
4755 while (*arg && !vim_iswhite(*arg))
4756 {
4757 if (*arg == '\\' && arg[1] != NUL
4758#ifdef BACKSLASH_IN_FILENAME
4759 && !((flags & P_EXPAND)
4760 && vim_isfilec(arg[1])
4761 && (arg[1] != '\\'
4762 || (s == newval
4763 && arg[2] != '\\')))
4764#endif
4765 )
4766 ++arg; /* remove backslash */
4767#ifdef FEAT_MBYTE
4768 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00004769 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004770 {
4771 /* copy multibyte char */
4772 mch_memmove(s, arg, (size_t)i);
4773 arg += i;
4774 s += i;
4775 }
4776 else
4777#endif
4778 *s++ = *arg++;
4779 }
4780 *s = NUL;
4781
4782 /*
4783 * Expand environment variables and ~.
4784 * Don't do it when adding without inserting a
4785 * comma.
4786 */
4787 if (!(adding || prepending || removing)
4788 || (flags & P_COMMA))
4789 {
4790 s = option_expand(opt_idx, newval);
4791 if (s != NULL)
4792 {
4793 vim_free(newval);
4794 newlen = (unsigned)STRLEN(s) + 1;
4795 if (adding || prepending || removing)
4796 newlen += (unsigned)STRLEN(origval) + 1;
4797 newval = alloc(newlen);
4798 if (newval == NULL)
4799 break;
4800 STRCPY(newval, s);
4801 }
4802 }
4803
4804 /* locate newval[] in origval[] when removing it
4805 * and when adding to avoid duplicates */
4806 i = 0; /* init for GCC */
4807 if (removing || (flags & P_NODUP))
4808 {
4809 i = (int)STRLEN(newval);
4810 bs = 0;
4811 for (s = origval; *s; ++s)
4812 {
4813 if ((!(flags & P_COMMA)
4814 || s == origval
4815 || (s[-1] == ',' && !(bs & 1)))
4816 && STRNCMP(s, newval, i) == 0
4817 && (!(flags & P_COMMA)
4818 || s[i] == ','
4819 || s[i] == NUL))
4820 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004821 /* Count backslashes. Only a comma with an
4822 * even number of backslashes before it is
Bram Moolenaar071d4272004-06-13 20:20:40 +00004823 * recognized as a separator */
4824 if (s > origval && s[-1] == '\\')
4825 ++bs;
4826 else
4827 bs = 0;
4828 }
4829
4830 /* do not add if already there */
4831 if ((adding || prepending) && *s)
4832 {
4833 prepending = FALSE;
4834 adding = FALSE;
4835 STRCPY(newval, origval);
4836 }
4837 }
4838
4839 /* concatenate the two strings; add a ',' if
4840 * needed */
4841 if (adding || prepending)
4842 {
4843 comma = ((flags & P_COMMA) && *origval != NUL
4844 && *newval != NUL);
4845 if (adding)
4846 {
4847 i = (int)STRLEN(origval);
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004848 /* strip a trailing comma, would get 2 */
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02004849 if (comma && (flags & P_ONECOMMA) && i > 1
4850 && origval[i - 1] == ','
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004851 && origval[i - 2] != '\\')
4852 i--;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004853 mch_memmove(newval + i + comma, newval,
4854 STRLEN(newval) + 1);
4855 mch_memmove(newval, origval, (size_t)i);
4856 }
4857 else
4858 {
4859 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004860 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004861 }
4862 if (comma)
4863 newval[i] = ',';
4864 }
4865
4866 /* Remove newval[] from origval[]. (Note: "i" has
4867 * been set above and is used here). */
4868 if (removing)
4869 {
4870 STRCPY(newval, origval);
4871 if (*s)
4872 {
4873 /* may need to remove a comma */
4874 if (flags & P_COMMA)
4875 {
4876 if (s == origval)
4877 {
4878 /* include comma after string */
4879 if (s[i] == ',')
4880 ++i;
4881 }
4882 else
4883 {
4884 /* include comma before string */
4885 --s;
4886 ++i;
4887 }
4888 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004889 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004890 }
4891 }
4892
4893 if (flags & P_FLAGLIST)
4894 {
4895 /* Remove flags that appear twice. */
4896 for (s = newval; *s; ++s)
4897 if ((!(flags & P_COMMA) || *s != ',')
4898 && vim_strchr(s + 1, *s) != NULL)
4899 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004900 STRMOVE(s, s + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004901 --s;
4902 }
4903 }
4904
4905 if (save_arg != NULL) /* number for 'whichwrap' */
4906 arg = save_arg;
4907 new_value_alloced = TRUE;
4908 }
4909
4910 /* Set the new value. */
4911 *(char_u **)(varp) = newval;
4912
Bram Moolenaar53744302015-07-17 17:38:22 +02004913#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02004914 if (!starting
4915# ifdef FEAT_CRYPT
4916 && options[opt_idx].indir != PV_KEY
4917# endif
Bram Moolenaar53744302015-07-17 17:38:22 +02004918 && origval != NULL)
4919 /* origval may be freed by
4920 * did_set_string_option(), make a copy. */
4921 saved_origval = vim_strsave(origval);
4922#endif
4923
Bram Moolenaar071d4272004-06-13 20:20:40 +00004924 /* Handle side effects, and set the global value for
4925 * ":set" on local options. */
4926 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
4927 new_value_alloced, oldval, errbuf, opt_flags);
4928
4929 /* If error detected, print the error message. */
4930 if (errmsg != NULL)
4931 goto skip;
Bram Moolenaar53744302015-07-17 17:38:22 +02004932#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4933 if (saved_origval != NULL)
4934 {
4935 char_u buf_type[7];
4936
4937 sprintf((char *)buf_type, "%s",
4938 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02004939 set_vim_var_string(VV_OPTION_NEW,
4940 *(char_u **)varp, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02004941 set_vim_var_string(VV_OPTION_OLD, saved_origval, -1);
4942 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
4943 apply_autocmds(EVENT_OPTIONSET,
4944 (char_u *)options[opt_idx].fullname,
4945 NULL, FALSE, NULL);
4946 reset_v_option_vars();
4947 vim_free(saved_origval);
4948 }
4949#endif
4950
Bram Moolenaar071d4272004-06-13 20:20:40 +00004951 }
4952 else /* key code option */
4953 {
4954 char_u *p;
4955
4956 if (nextchar == '&')
4957 {
4958 if (add_termcap_entry(key_name, TRUE) == FAIL)
4959 errmsg = (char_u *)N_("E522: Not found in termcap");
4960 }
4961 else
4962 {
4963 ++arg; /* jump to after the '=' or ':' */
4964 for (p = arg; *p && !vim_iswhite(*p); ++p)
4965 if (*p == '\\' && p[1] != NUL)
4966 ++p;
4967 nextchar = *p;
4968 *p = NUL;
4969 add_termcode(key_name, arg, FALSE);
4970 *p = nextchar;
4971 }
4972 if (full_screen)
4973 ttest(FALSE);
4974 redraw_all_later(CLEAR);
4975 }
4976 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004977
Bram Moolenaar071d4272004-06-13 20:20:40 +00004978 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004979 did_set_option(opt_idx, opt_flags,
4980 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004981 }
4982
4983skip:
4984 /*
4985 * Advance to next argument.
4986 * - skip until a blank found, taking care of backslashes
4987 * - skip blanks
4988 * - skip one "=val" argument (for hidden options ":set gfn =xx")
4989 */
4990 for (i = 0; i < 2 ; ++i)
4991 {
4992 while (*arg != NUL && !vim_iswhite(*arg))
4993 if (*arg++ == '\\' && *arg != NUL)
4994 ++arg;
4995 arg = skipwhite(arg);
4996 if (*arg != '=')
4997 break;
4998 }
4999 }
5000
5001 if (errmsg != NULL)
5002 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005003 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005004 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005005 if (i + (arg - startarg) < IOSIZE)
5006 {
5007 /* append the argument with the error */
5008 STRCAT(IObuff, ": ");
5009 mch_memmove(IObuff + i, startarg, (arg - startarg));
5010 IObuff[i + (arg - startarg)] = NUL;
5011 }
5012 /* make sure all characters are printable */
5013 trans_characters(IObuff, IOSIZE);
5014
5015 ++no_wait_return; /* wait_return done later */
5016 emsg(IObuff); /* show error highlighted */
5017 --no_wait_return;
5018
5019 return FAIL;
5020 }
5021
5022 arg = skipwhite(arg);
5023 }
5024
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005025theend:
5026 if (silent_mode && did_show)
5027 {
5028 /* After displaying option values in silent mode. */
5029 silent_mode = FALSE;
5030 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5031 msg_putchar('\n');
5032 cursor_on(); /* msg_start() switches it off */
5033 out_flush();
5034 silent_mode = TRUE;
5035 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5036 }
5037
Bram Moolenaar071d4272004-06-13 20:20:40 +00005038 return OK;
5039}
5040
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005041/*
5042 * Call this when an option has been given a new value through a user command.
5043 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5044 */
5045 static void
5046did_set_option(opt_idx, opt_flags, new_value)
5047 int opt_idx;
5048 int opt_flags; /* possibly with OPT_MODELINE */
5049 int new_value; /* value was replaced completely */
5050{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005051 long_u *p;
5052
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005053 options[opt_idx].flags |= P_WAS_SET;
5054
5055 /* When an option is set in the sandbox, from a modeline or in secure mode
5056 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005057 * flag. */
5058 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005059 if (secure
5060#ifdef HAVE_SANDBOX
5061 || sandbox != 0
5062#endif
5063 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005064 *p = *p | P_INSECURE;
5065 else if (new_value)
5066 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005067}
5068
Bram Moolenaar071d4272004-06-13 20:20:40 +00005069 static char_u *
5070illegal_char(errbuf, c)
5071 char_u *errbuf;
5072 int c;
5073{
5074 if (errbuf == NULL)
5075 return (char_u *)"";
5076 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005077 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005078 return errbuf;
5079}
5080
5081/*
5082 * Convert a key name or string into a key value.
5083 * Used for 'wildchar' and 'cedit' options.
5084 */
5085 static int
5086string_to_key(arg)
5087 char_u *arg;
5088{
5089 if (*arg == '<')
5090 return find_key_option(arg + 1);
5091 if (*arg == '^')
5092 return Ctrl_chr(arg[1]);
5093 return *arg;
5094}
5095
5096#ifdef FEAT_CMDWIN
5097/*
5098 * Check value of 'cedit' and set cedit_key.
5099 * Returns NULL if value is OK, error message otherwise.
5100 */
5101 static char_u *
5102check_cedit()
5103{
5104 int n;
5105
5106 if (*p_cedit == NUL)
5107 cedit_key = -1;
5108 else
5109 {
5110 n = string_to_key(p_cedit);
5111 if (vim_isprintc(n))
5112 return e_invarg;
5113 cedit_key = n;
5114 }
5115 return NULL;
5116}
5117#endif
5118
5119#ifdef FEAT_TITLE
5120/*
5121 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5122 * maketitle() to create and display it.
5123 * When switching the title or icon off, call mch_restore_title() to get
5124 * the old value back.
5125 */
5126 static void
5127did_set_title(icon)
5128 int icon; /* Did set icon instead of title */
5129{
5130 if (starting != NO_SCREEN
5131#ifdef FEAT_GUI
5132 && !gui.starting
5133#endif
5134 )
5135 {
5136 maketitle();
5137 if (icon)
5138 {
5139 if (!p_icon)
5140 mch_restore_title(2);
5141 }
5142 else
5143 {
5144 if (!p_title)
5145 mch_restore_title(1);
5146 }
5147 }
5148}
5149#endif
5150
5151/*
5152 * set_options_bin - called when 'bin' changes value.
5153 */
5154 void
5155set_options_bin(oldval, newval, opt_flags)
5156 int oldval;
5157 int newval;
5158 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5159{
5160 /*
5161 * The option values that are changed when 'bin' changes are
5162 * copied when 'bin is set and restored when 'bin' is reset.
5163 */
5164 if (newval)
5165 {
5166 if (!oldval) /* switched on */
5167 {
5168 if (!(opt_flags & OPT_GLOBAL))
5169 {
5170 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5171 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5172 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5173 curbuf->b_p_et_nobin = curbuf->b_p_et;
5174 }
5175 if (!(opt_flags & OPT_LOCAL))
5176 {
5177 p_tw_nobin = p_tw;
5178 p_wm_nobin = p_wm;
5179 p_ml_nobin = p_ml;
5180 p_et_nobin = p_et;
5181 }
5182 }
5183
5184 if (!(opt_flags & OPT_GLOBAL))
5185 {
5186 curbuf->b_p_tw = 0; /* no automatic line wrap */
5187 curbuf->b_p_wm = 0; /* no automatic line wrap */
5188 curbuf->b_p_ml = 0; /* no modelines */
5189 curbuf->b_p_et = 0; /* no expandtab */
5190 }
5191 if (!(opt_flags & OPT_LOCAL))
5192 {
5193 p_tw = 0;
5194 p_wm = 0;
5195 p_ml = FALSE;
5196 p_et = FALSE;
5197 p_bin = TRUE; /* needed when called for the "-b" argument */
5198 }
5199 }
5200 else if (oldval) /* switched off */
5201 {
5202 if (!(opt_flags & OPT_GLOBAL))
5203 {
5204 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5205 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5206 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5207 curbuf->b_p_et = curbuf->b_p_et_nobin;
5208 }
5209 if (!(opt_flags & OPT_LOCAL))
5210 {
5211 p_tw = p_tw_nobin;
5212 p_wm = p_wm_nobin;
5213 p_ml = p_ml_nobin;
5214 p_et = p_et_nobin;
5215 }
5216 }
5217}
5218
5219#ifdef FEAT_VIMINFO
5220/*
5221 * Find the parameter represented by the given character (eg ', :, ", or /),
5222 * and return its associated value in the 'viminfo' string.
5223 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005224 * If the parameter is not specified in the string or there is no following
5225 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005226 */
5227 int
5228get_viminfo_parameter(type)
5229 int type;
5230{
5231 char_u *p;
5232
5233 p = find_viminfo_parameter(type);
5234 if (p != NULL && VIM_ISDIGIT(*p))
5235 return atoi((char *)p);
5236 return -1;
5237}
5238
5239/*
5240 * Find the parameter represented by the given character (eg ''', ':', '"', or
5241 * '/') in the 'viminfo' option and return a pointer to the string after it.
5242 * Return NULL if the parameter is not specified in the string.
5243 */
5244 char_u *
5245find_viminfo_parameter(type)
5246 int type;
5247{
5248 char_u *p;
5249
5250 for (p = p_viminfo; *p; ++p)
5251 {
5252 if (*p == type)
5253 return p + 1;
5254 if (*p == 'n') /* 'n' is always the last one */
5255 break;
5256 p = vim_strchr(p, ','); /* skip until next ',' */
5257 if (p == NULL) /* hit the end without finding parameter */
5258 break;
5259 }
5260 return NULL;
5261}
5262#endif
5263
5264/*
5265 * Expand environment variables for some string options.
5266 * These string options cannot be indirect!
5267 * If "val" is NULL expand the current value of the option.
5268 * Return pointer to NameBuff, or NULL when not expanded.
5269 */
5270 static char_u *
5271option_expand(opt_idx, val)
5272 int opt_idx;
5273 char_u *val;
5274{
5275 /* if option doesn't need expansion nothing to do */
5276 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5277 return NULL;
5278
5279 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5280 * expand_env() would truncate the string. */
5281 if (val != NULL && STRLEN(val) > MAXPATHL)
5282 return NULL;
5283
5284 if (val == NULL)
5285 val = *(char_u **)options[opt_idx].var;
5286
5287 /*
5288 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5289 * Escape spaces when expanding 'tags', they are used to separate file
5290 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005291 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005292 */
5293 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005294 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005295#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005296 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5297#endif
5298 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005299 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5300 return NULL;
5301
5302 return NameBuff;
5303}
5304
5305/*
5306 * After setting various option values: recompute variables that depend on
5307 * option values.
5308 */
5309 static void
5310didset_options()
5311{
5312 /* initialize the table for 'iskeyword' et.al. */
5313 (void)init_chartab();
5314
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005315#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005316 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005317#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005318 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
Bram Moolenaar165bc692015-07-21 17:53:25 +02005319 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005320#ifdef FEAT_SESSION
5321 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5322 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5323#endif
5324#ifdef FEAT_FOLDING
5325 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5326#endif
5327 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
5328#ifdef FEAT_VIRTUALEDIT
5329 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5330#endif
5331#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5332 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5333#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005334#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005335 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005336 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005337 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005338 (void)did_set_spell_option(TRUE);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005339#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005340#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5341 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5342#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005343#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005344 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5345#endif
5346#ifdef FEAT_CMDWIN
5347 /* set cedit_key */
5348 (void)check_cedit();
5349#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005350#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005351 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005352#endif
Bram Moolenaare68c25c2015-08-25 15:39:55 +02005353#ifdef FEAT_LINEBREAK
5354 /* initialize the table for 'breakat'. */
5355 fill_breakat_flags();
5356#endif
5357
5358}
5359
5360/*
5361 * More side effects of setting options.
5362 */
5363 static void
5364didset_options2()
5365{
5366 /* Initialize the highlight_attr[] table. */
5367 (void)highlight_changed();
5368
5369 /* Parse default for 'wildmode' */
5370 check_opt_wim();
5371
5372 (void)set_chars_option(&p_lcs);
5373#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5374 /* Parse default for 'fillchars'. */
5375 (void)set_chars_option(&p_fcs);
5376#endif
5377
5378#ifdef FEAT_CLIPBOARD
5379 /* Parse default for 'clipboard' */
5380 (void)check_clipboard_option();
5381#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005382}
5383
5384/*
5385 * Check for string options that are NULL (normally only termcap options).
5386 */
5387 void
5388check_options()
5389{
5390 int opt_idx;
5391
5392 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5393 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5394 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5395}
5396
5397/*
5398 * Check string options in a buffer for NULL value.
5399 */
5400 void
5401check_buf_options(buf)
5402 buf_T *buf;
5403{
5404#if defined(FEAT_QUICKFIX)
5405 check_string_option(&buf->b_p_bh);
5406 check_string_option(&buf->b_p_bt);
5407#endif
5408#ifdef FEAT_MBYTE
5409 check_string_option(&buf->b_p_fenc);
5410#endif
5411 check_string_option(&buf->b_p_ff);
5412#ifdef FEAT_FIND_ID
5413 check_string_option(&buf->b_p_def);
5414 check_string_option(&buf->b_p_inc);
5415# ifdef FEAT_EVAL
5416 check_string_option(&buf->b_p_inex);
5417# endif
5418#endif
5419#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5420 check_string_option(&buf->b_p_inde);
5421 check_string_option(&buf->b_p_indk);
5422#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005423#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5424 check_string_option(&buf->b_p_bexpr);
5425#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005426#if defined(FEAT_CRYPT)
5427 check_string_option(&buf->b_p_cm);
5428#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005429#if defined(FEAT_EVAL)
5430 check_string_option(&buf->b_p_fex);
5431#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005432#ifdef FEAT_CRYPT
5433 check_string_option(&buf->b_p_key);
5434#endif
5435 check_string_option(&buf->b_p_kp);
5436 check_string_option(&buf->b_p_mps);
5437 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005438 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005439 check_string_option(&buf->b_p_isk);
5440#ifdef FEAT_COMMENTS
5441 check_string_option(&buf->b_p_com);
5442#endif
5443#ifdef FEAT_FOLDING
5444 check_string_option(&buf->b_p_cms);
5445#endif
5446 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005447#ifdef FEAT_TEXTOBJ
5448 check_string_option(&buf->b_p_qe);
5449#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005450#ifdef FEAT_SYN_HL
5451 check_string_option(&buf->b_p_syn);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005452#endif
5453#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005454 check_string_option(&buf->b_s.b_p_spc);
5455 check_string_option(&buf->b_s.b_p_spf);
5456 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005457#endif
5458#ifdef FEAT_SEARCHPATH
5459 check_string_option(&buf->b_p_sua);
5460#endif
5461#ifdef FEAT_CINDENT
5462 check_string_option(&buf->b_p_cink);
5463 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005464 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005465#endif
5466#ifdef FEAT_AUTOCMD
5467 check_string_option(&buf->b_p_ft);
5468#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005469#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5470 check_string_option(&buf->b_p_cinw);
5471#endif
5472#ifdef FEAT_INS_EXPAND
5473 check_string_option(&buf->b_p_cpt);
5474#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005475#ifdef FEAT_COMPL_FUNC
5476 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005477 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005478#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005479#ifdef FEAT_KEYMAP
5480 check_string_option(&buf->b_p_keymap);
5481#endif
5482#ifdef FEAT_QUICKFIX
5483 check_string_option(&buf->b_p_gp);
5484 check_string_option(&buf->b_p_mp);
5485 check_string_option(&buf->b_p_efm);
5486#endif
5487 check_string_option(&buf->b_p_ep);
5488 check_string_option(&buf->b_p_path);
5489 check_string_option(&buf->b_p_tags);
5490#ifdef FEAT_INS_EXPAND
5491 check_string_option(&buf->b_p_dict);
5492 check_string_option(&buf->b_p_tsr);
5493#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005494#ifdef FEAT_LISP
5495 check_string_option(&buf->b_p_lw);
5496#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005497 check_string_option(&buf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005498}
5499
5500/*
5501 * Free the string allocated for an option.
5502 * Checks for the string being empty_option. This may happen if we're out of
5503 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5504 * check_options().
5505 * Does NOT check for P_ALLOCED flag!
5506 */
5507 void
5508free_string_option(p)
5509 char_u *p;
5510{
5511 if (p != empty_option)
5512 vim_free(p);
5513}
5514
5515 void
5516clear_string_option(pp)
5517 char_u **pp;
5518{
5519 if (*pp != empty_option)
5520 vim_free(*pp);
5521 *pp = empty_option;
5522}
5523
5524 static void
5525check_string_option(pp)
5526 char_u **pp;
5527{
5528 if (*pp == NULL)
5529 *pp = empty_option;
5530}
5531
5532/*
5533 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5534 */
5535 void
5536set_term_option_alloced(p)
5537 char_u **p;
5538{
5539 int opt_idx;
5540
5541 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5542 if (options[opt_idx].var == (char_u *)p)
5543 {
5544 options[opt_idx].flags |= P_ALLOCED;
5545 return;
5546 }
5547 return; /* cannot happen: didn't find it! */
5548}
5549
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005550#if defined(FEAT_EVAL) || defined(PROTO)
5551/*
5552 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5553 * Return FALSE when it wasn't.
5554 * Return -1 for an unknown option.
5555 */
5556 int
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005557was_set_insecurely(opt, opt_flags)
5558 char_u *opt;
5559 int opt_flags;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005560{
5561 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005562 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005563
5564 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005565 {
5566 flagp = insecure_flag(idx, opt_flags);
5567 return (*flagp & P_INSECURE) != 0;
5568 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005569 EMSG2(_(e_intern2), "was_set_insecurely()");
5570 return -1;
5571}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005572
5573/*
5574 * Get a pointer to the flags used for the P_INSECURE flag of option
5575 * "opt_idx". For some local options a local flags field is used.
5576 */
5577 static long_u *
5578insecure_flag(opt_idx, opt_flags)
5579 int opt_idx;
5580 int opt_flags;
5581{
5582 if (opt_flags & OPT_LOCAL)
5583 switch ((int)options[opt_idx].indir)
5584 {
5585#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005586 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005587#endif
5588#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005589# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005590 case PV_FDE: return &curwin->w_p_fde_flags;
5591 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005592# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005593# ifdef FEAT_BEVAL
5594 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5595# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005596# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005597 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005598# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005599 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005600# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005601 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005602# endif
5603#endif
5604 }
5605
5606 /* Nothing special, return global flags field. */
5607 return &options[opt_idx].flags;
5608}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005609#endif
5610
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005611#ifdef FEAT_TITLE
5612static void redraw_titles __ARGS((void));
5613
5614/*
5615 * Redraw the window title and/or tab page text later.
5616 */
5617static void redraw_titles()
5618{
5619 need_maketitle = TRUE;
5620# ifdef FEAT_WINDOWS
5621 redraw_tabline = TRUE;
5622# endif
5623}
5624#endif
5625
Bram Moolenaar071d4272004-06-13 20:20:40 +00005626/*
5627 * Set a string option to a new value (without checking the effect).
5628 * The string is copied into allocated memory.
5629 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005630 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005631 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005632 */
5633 void
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005634set_string_option_direct(name, opt_idx, val, opt_flags, set_sid)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005635 char_u *name;
5636 int opt_idx;
5637 char_u *val;
5638 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar78a15312009-05-15 19:33:18 +00005639 int set_sid UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005640{
5641 char_u *s;
5642 char_u **varp;
5643 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005644 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005645
Bram Moolenaar89d40322006-08-29 15:30:07 +00005646 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005647 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005648 idx = findoption(name);
5649 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005650 {
5651 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar0b105412014-11-30 13:34:23 +01005652 EMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005653 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005654 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005655 }
5656
Bram Moolenaar89d40322006-08-29 15:30:07 +00005657 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005658 return;
5659
5660 s = vim_strsave(val);
5661 if (s != NULL)
5662 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005663 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005664 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005665 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005666 free_string_option(*varp);
5667 *varp = s;
5668
5669 /* For buffer/window local option may also set the global value. */
5670 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005671 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005672
Bram Moolenaar89d40322006-08-29 15:30:07 +00005673 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005674
5675 /* When setting both values of a global option with a local value,
5676 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005677 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005678 {
5679 free_string_option(*varp);
5680 *varp = empty_option;
5681 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005682# ifdef FEAT_EVAL
5683 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005684 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005685 set_sid == 0 ? current_SID : set_sid);
5686# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005687 }
5688}
5689
5690/*
5691 * Set global value for string option when it's a local option.
5692 */
5693 static void
5694set_string_option_global(opt_idx, varp)
5695 int opt_idx; /* option index */
5696 char_u **varp; /* pointer to option variable */
5697{
5698 char_u **p, *s;
5699
5700 /* the global value is always allocated */
5701 if (options[opt_idx].var == VAR_WIN)
5702 p = (char_u **)GLOBAL_WO(varp);
5703 else
5704 p = (char_u **)options[opt_idx].var;
5705 if (options[opt_idx].indir != PV_NONE
5706 && p != varp
5707 && (s = vim_strsave(*varp)) != NULL)
5708 {
5709 free_string_option(*p);
5710 *p = s;
5711 }
5712}
5713
5714/*
5715 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005716 *
5717 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005718 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005719 static char_u *
Bram Moolenaar071d4272004-06-13 20:20:40 +00005720set_string_option(opt_idx, value, opt_flags)
5721 int opt_idx;
5722 char_u *value;
5723 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5724{
5725 char_u *s;
5726 char_u **varp;
5727 char_u *oldval;
Bram Moolenaar53744302015-07-17 17:38:22 +02005728#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5729 char_u *saved_oldval = NULL;
5730#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005731 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005732
5733 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005734 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005735
5736 s = vim_strsave(value);
5737 if (s != NULL)
5738 {
5739 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5740 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005741 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005742 ? OPT_GLOBAL : OPT_LOCAL)
5743 : opt_flags);
5744 oldval = *varp;
5745 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02005746
5747#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005748 if (!starting
5749# ifdef FEAT_CRYPT
5750 && options[opt_idx].indir != PV_KEY
5751# endif
5752 )
Bram Moolenaar53744302015-07-17 17:38:22 +02005753 saved_oldval = vim_strsave(oldval);
5754#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005755 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5756 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005757 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02005758
5759 /* call autocomamnd after handling side effects */
5760#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5761 if (saved_oldval != NULL)
5762 {
5763 char_u buf_type[7];
5764 sprintf((char *)buf_type, "%s",
5765 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02005766 set_vim_var_string(VV_OPTION_NEW, *varp, -1);
5767 set_vim_var_string(VV_OPTION_OLD, saved_oldval, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02005768 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
5769 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
5770 reset_v_option_vars();
5771 vim_free(saved_oldval);
5772 }
5773#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005774 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005775 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005776}
5777
5778/*
5779 * Handle string options that need some action to perform when changed.
5780 * Returns NULL for success, or an error message for an error.
5781 */
5782 static char_u *
5783did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
5784 opt_flags)
5785 int opt_idx; /* index in options[] table */
5786 char_u **varp; /* pointer to the option variable */
5787 int new_value_alloced; /* new value was allocated */
5788 char_u *oldval; /* previous value of the option */
5789 char_u *errbuf; /* buffer for errors, or NULL */
5790 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5791{
5792 char_u *errmsg = NULL;
5793 char_u *s, *p;
5794 int did_chartab = FALSE;
5795 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005796 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00005797#ifdef FEAT_GUI
5798 /* set when changing an option that only requires a redraw in the GUI */
5799 int redraw_gui_only = FALSE;
5800#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005801
5802 /* Get the global option to compare with, otherwise we would have to check
5803 * two values for all local options. */
5804 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
5805
5806 /* Disallow changing some options from secure mode */
5807 if ((secure
5808#ifdef HAVE_SANDBOX
5809 || sandbox != 0
5810#endif
5811 ) && (options[opt_idx].flags & P_SECURE))
5812 {
5813 errmsg = e_secure;
5814 }
5815
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005816 /* Check for a "normal" file name in some options. Disallow a path
5817 * separator (slash and/or backslash), wildcards and characters that are
5818 * often illegal in a file name. */
5819 else if ((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005820 && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL)
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005821 {
5822 errmsg = e_invarg;
5823 }
5824
Bram Moolenaar071d4272004-06-13 20:20:40 +00005825 /* 'term' */
5826 else if (varp == &T_NAME)
5827 {
5828 if (T_NAME[0] == NUL)
5829 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
5830#ifdef FEAT_GUI
5831 if (gui.in_use)
5832 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
5833 else if (term_is_gui(T_NAME))
5834 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
5835#endif
5836 else if (set_termname(T_NAME) == FAIL)
5837 errmsg = (char_u *)N_("E522: Not found in termcap");
5838 else
5839 /* Screen colors may have changed. */
5840 redraw_later_clear();
5841 }
5842
5843 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005844 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005845 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005846 char_u *bkc = p_bkc;
5847 unsigned int *flags = &bkc_flags;
5848
5849 if (opt_flags & OPT_LOCAL)
5850 {
5851 bkc = curbuf->b_p_bkc;
5852 flags = &curbuf->b_bkc_flags;
5853 }
5854
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005855 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
5856 /* make the local value empty: use the global value */
5857 *flags = 0;
5858 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00005859 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005860 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
5861 errmsg = e_invarg;
5862 if ((((int)*flags & BKC_AUTO) != 0)
5863 + (((int)*flags & BKC_YES) != 0)
5864 + (((int)*flags & BKC_NO) != 0) != 1)
5865 {
5866 /* Must have exactly one of "auto", "yes" and "no". */
5867 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
5868 errmsg = e_invarg;
5869 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005870 }
5871 }
5872
5873 /* 'backupext' and 'patchmode' */
5874 else if (varp == &p_bex || varp == &p_pm)
5875 {
5876 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
5877 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
5878 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
5879 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02005880#ifdef FEAT_LINEBREAK
5881 /* 'breakindentopt' */
5882 else if (varp == &curwin->w_p_briopt)
5883 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005884 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02005885 errmsg = e_invarg;
5886 }
5887#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005888
5889 /*
5890 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[]
5891 * If the new option is invalid, use old value. 'lisp' option: refill
5892 * chartab[] for '-' char
5893 */
5894 else if ( varp == &p_isi
5895 || varp == &(curbuf->b_p_isk)
5896 || varp == &p_isp
5897 || varp == &p_isf)
5898 {
5899 if (init_chartab() == FAIL)
5900 {
5901 did_chartab = TRUE; /* need to restore it below */
5902 errmsg = e_invarg; /* error in value */
5903 }
5904 }
5905
5906 /* 'helpfile' */
5907 else if (varp == &p_hf)
5908 {
5909 /* May compute new values for $VIM and $VIMRUNTIME */
5910 if (didset_vim)
5911 {
5912 vim_setenv((char_u *)"VIM", (char_u *)"");
5913 didset_vim = FALSE;
5914 }
5915 if (didset_vimruntime)
5916 {
5917 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
5918 didset_vimruntime = FALSE;
5919 }
5920 }
5921
Bram Moolenaar1a384422010-07-14 19:53:30 +02005922#ifdef FEAT_SYN_HL
5923 /* 'colorcolumn' */
5924 else if (varp == &curwin->w_p_cc)
5925 errmsg = check_colorcolumn(curwin);
5926#endif
5927
Bram Moolenaar071d4272004-06-13 20:20:40 +00005928#ifdef FEAT_MULTI_LANG
5929 /* 'helplang' */
5930 else if (varp == &p_hlg)
5931 {
5932 /* Check for "", "ab", "ab,cd", etc. */
5933 for (s = p_hlg; *s != NUL; s += 3)
5934 {
5935 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
5936 {
5937 errmsg = e_invarg;
5938 break;
5939 }
5940 if (s[2] == NUL)
5941 break;
5942 }
5943 }
5944#endif
5945
5946 /* 'highlight' */
5947 else if (varp == &p_hl)
5948 {
5949 if (highlight_changed() == FAIL)
5950 errmsg = e_invarg; /* invalid flags */
5951 }
5952
5953 /* 'nrformats' */
5954 else if (gvarp == &p_nf)
5955 {
5956 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
5957 errmsg = e_invarg;
5958 }
5959
5960#ifdef FEAT_SESSION
5961 /* 'sessionoptions' */
5962 else if (varp == &p_ssop)
5963 {
5964 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
5965 errmsg = e_invarg;
5966 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
5967 {
5968 /* Don't allow both "sesdir" and "curdir". */
5969 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
5970 errmsg = e_invarg;
5971 }
5972 }
5973 /* 'viewoptions' */
5974 else if (varp == &p_vop)
5975 {
5976 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
5977 errmsg = e_invarg;
5978 }
5979#endif
5980
5981 /* 'scrollopt' */
5982#ifdef FEAT_SCROLLBIND
5983 else if (varp == &p_sbo)
5984 {
5985 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
5986 errmsg = e_invarg;
5987 }
5988#endif
5989
5990 /* 'ambiwidth' */
5991#ifdef FEAT_MBYTE
5992 else if (varp == &p_ambw)
5993 {
5994 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
5995 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02005996 else if (set_chars_option(&p_lcs) != NULL)
5997 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
5998# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5999 else if (set_chars_option(&p_fcs) != NULL)
6000 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
6001# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006002 }
6003#endif
6004
6005 /* 'background' */
6006 else if (varp == &p_bg)
6007 {
6008 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
6009 {
6010#ifdef FEAT_EVAL
6011 int dark = (*p_bg == 'd');
6012#endif
6013
6014 init_highlight(FALSE, FALSE);
6015
6016#ifdef FEAT_EVAL
6017 if (dark != (*p_bg == 'd')
6018 && get_var_value((char_u *)"g:colors_name") != NULL)
6019 {
6020 /* The color scheme must have set 'background' back to another
6021 * value, that's not what we want here. Disable the color
6022 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00006023 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006024 free_string_option(p_bg);
6025 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
6026 check_string_option(&p_bg);
6027 init_highlight(FALSE, FALSE);
6028 }
6029#endif
6030 }
6031 else
6032 errmsg = e_invarg;
6033 }
6034
6035 /* 'wildmode' */
6036 else if (varp == &p_wim)
6037 {
6038 if (check_opt_wim() == FAIL)
6039 errmsg = e_invarg;
6040 }
6041
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006042#ifdef FEAT_CMDL_COMPL
6043 /* 'wildoptions' */
6044 else if (varp == &p_wop)
6045 {
6046 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6047 errmsg = e_invarg;
6048 }
6049#endif
6050
Bram Moolenaar071d4272004-06-13 20:20:40 +00006051#ifdef FEAT_WAK
6052 /* 'winaltkeys' */
6053 else if (varp == &p_wak)
6054 {
6055 if (*p_wak == NUL
6056 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6057 errmsg = e_invarg;
6058# ifdef FEAT_MENU
6059# ifdef FEAT_GUI_MOTIF
6060 else if (gui.in_use)
6061 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6062# else
6063# ifdef FEAT_GUI_GTK
6064 else if (gui.in_use)
6065 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6066# endif
6067# endif
6068# endif
6069 }
6070#endif
6071
6072#ifdef FEAT_AUTOCMD
6073 /* 'eventignore' */
6074 else if (varp == &p_ei)
6075 {
6076 if (check_ei() == FAIL)
6077 errmsg = e_invarg;
6078 }
6079#endif
6080
6081#ifdef FEAT_MBYTE
6082 /* 'encoding' and 'fileencoding' */
6083 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc)
6084 {
6085 if (gvarp == &p_fenc)
6086 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006087 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006088 errmsg = e_modifiable;
6089 else if (vim_strchr(*varp, ',') != NULL)
6090 /* No comma allowed in 'fileencoding'; catches confusing it
6091 * with 'fileencodings'. */
6092 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006093 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006094 {
6095# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006096 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006097 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006098# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006099 /* Add 'fileencoding' to the swap file. */
6100 ml_setflags(curbuf);
6101 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006102 }
6103 if (errmsg == NULL)
6104 {
6105 /* canonize the value, so that STRCMP() can be used on it */
6106 p = enc_canonize(*varp);
6107 if (p != NULL)
6108 {
6109 vim_free(*varp);
6110 *varp = p;
6111 }
6112 if (varp == &p_enc)
6113 {
6114 errmsg = mb_init();
6115# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006116 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006117# endif
6118 }
6119 }
6120
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006121# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006122 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6123 {
6124 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6125 if (STRCMP(p_tenc, "utf-8") != 0)
6126 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6127 }
6128# endif
6129
6130 if (errmsg == NULL)
6131 {
6132# ifdef FEAT_KEYMAP
6133 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6134 * (with another encoding). */
6135 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6136 (void)keymap_init();
6137# endif
6138
6139 /* When 'termencoding' is not empty and 'encoding' changes or when
6140 * 'termencoding' changes, need to setup for keyboard input and
6141 * display output conversion. */
6142 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6143 {
6144 convert_setup(&input_conv, p_tenc, p_enc);
6145 convert_setup(&output_conv, p_enc, p_tenc);
6146 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006147
6148# if defined(WIN3264) && defined(FEAT_MBYTE)
6149 /* $HOME may have characters in active code page. */
6150 if (varp == &p_enc)
6151 init_homedir();
6152# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006153 }
6154 }
6155#endif
6156
6157#if defined(FEAT_POSTSCRIPT)
6158 else if (varp == &p_penc)
6159 {
6160 /* Canonize printencoding if VIM standard one */
6161 p = enc_canonize(p_penc);
6162 if (p != NULL)
6163 {
6164 vim_free(p_penc);
6165 p_penc = p;
6166 }
6167 else
6168 {
6169 /* Ensure lower case and '-' for '_' */
6170 for (s = p_penc; *s != NUL; s++)
6171 {
6172 if (*s == '_')
6173 *s = '-';
6174 else
6175 *s = TOLOWER_ASC(*s);
6176 }
6177 }
6178 }
6179#endif
6180
Bram Moolenaar9372a112005-12-06 19:59:18 +00006181#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006182 else if (varp == &p_imak)
6183 {
6184 if (gui.in_use && !im_xim_isvalid_imactivate())
6185 errmsg = e_invarg;
6186 }
6187#endif
6188
6189#ifdef FEAT_KEYMAP
6190 else if (varp == &curbuf->b_p_keymap)
6191 {
6192 /* load or unload key mapping tables */
6193 errmsg = keymap_init();
6194
Bram Moolenaarfab06232009-03-04 03:13:35 +00006195 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006196 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006197 if (*curbuf->b_p_keymap != NUL)
6198 {
6199 /* Installed a new keymap, switch on using it. */
6200 curbuf->b_p_iminsert = B_IMODE_LMAP;
6201 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6202 curbuf->b_p_imsearch = B_IMODE_LMAP;
6203 }
6204 else
6205 {
6206 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6207 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6208 curbuf->b_p_iminsert = B_IMODE_NONE;
6209 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6210 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6211 }
6212 if ((opt_flags & OPT_LOCAL) == 0)
6213 {
6214 set_iminsert_global();
6215 set_imsearch_global();
6216 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006217# ifdef FEAT_WINDOWS
6218 status_redraw_curbuf();
6219# endif
6220 }
6221 }
6222#endif
6223
6224 /* 'fileformat' */
6225 else if (gvarp == &p_ff)
6226 {
6227 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6228 errmsg = e_modifiable;
6229 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6230 errmsg = e_invarg;
6231 else
6232 {
6233 /* may also change 'textmode' */
6234 if (get_fileformat(curbuf) == EOL_DOS)
6235 curbuf->b_p_tx = TRUE;
6236 else
6237 curbuf->b_p_tx = FALSE;
6238#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006239 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006240#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006241 /* update flag in swap file */
6242 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006243 /* Redraw needed when switching to/from "mac": a CR in the text
6244 * will be displayed differently. */
6245 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6246 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006247 }
6248 }
6249
6250 /* 'fileformats' */
6251 else if (varp == &p_ffs)
6252 {
6253 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6254 errmsg = e_invarg;
6255 else
6256 {
6257 /* also change 'textauto' */
6258 if (*p_ffs == NUL)
6259 p_ta = FALSE;
6260 else
6261 p_ta = TRUE;
6262 }
6263 }
6264
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006265#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006266 /* 'cryptkey' */
6267 else if (gvarp == &p_key)
6268 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006269# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006270 /* Make sure the ":set" command doesn't show the new value in the
6271 * history. */
6272 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006273# endif
6274 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6275 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006276 ml_set_crypt_key(curbuf, oldval,
6277 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006278 }
6279
6280 else if (gvarp == &p_cm)
6281 {
6282 if (opt_flags & OPT_LOCAL)
6283 p = curbuf->b_p_cm;
6284 else
6285 p = p_cm;
6286 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6287 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006288 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006289 errmsg = e_invarg;
6290 else
6291 {
6292 /* When setting the global value to empty, make it "zip". */
6293 if (*p_cm == NUL)
6294 {
6295 if (new_value_alloced)
6296 free_string_option(p_cm);
6297 p_cm = vim_strsave((char_u *)"zip");
6298 new_value_alloced = TRUE;
6299 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006300 /* When using ":set cm=name" the local value is going to be empty.
6301 * Do that here, otherwise the crypt functions will still use the
6302 * local value. */
6303 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6304 {
6305 free_string_option(curbuf->b_p_cm);
6306 curbuf->b_p_cm = empty_option;
6307 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006308
6309 /* Need to update the swapfile when the effective method changed.
6310 * Set "s" to the effective old value, "p" to the effective new
6311 * method and compare. */
6312 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6313 s = p_cm; /* was previously using the global value */
6314 else
6315 s = oldval;
6316 if (*curbuf->b_p_cm == NUL)
6317 p = p_cm; /* is now using the global value */
6318 else
6319 p = curbuf->b_p_cm;
6320 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006321 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006322
6323 /* If the global value changes need to update the swapfile for all
6324 * buffers using that value. */
6325 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6326 {
6327 buf_T *buf;
6328
6329 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
6330 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006331 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006332 }
6333 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006334 }
6335#endif
6336
6337 /* 'matchpairs' */
6338 else if (gvarp == &p_mps)
6339 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006340#ifdef FEAT_MBYTE
6341 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006342 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006343 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006344 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006345 int x2 = -1;
6346 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006347
6348 if (*p != NUL)
6349 p += mb_ptr2len(p);
6350 if (*p != NUL)
6351 x2 = *p++;
6352 if (*p != NUL)
6353 {
6354 x3 = mb_ptr2char(p);
6355 p += mb_ptr2len(p);
6356 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006357 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006358 {
6359 errmsg = e_invarg;
6360 break;
6361 }
6362 if (*p == NUL)
6363 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006364 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006365 }
6366 else
6367#endif
6368 {
6369 /* Check for "x:y,x:y" */
6370 for (p = *varp; *p != NUL; p += 4)
6371 {
6372 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6373 {
6374 errmsg = e_invarg;
6375 break;
6376 }
6377 if (p[3] == NUL)
6378 break;
6379 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006380 }
6381 }
6382
6383#ifdef FEAT_COMMENTS
6384 /* 'comments' */
6385 else if (gvarp == &p_com)
6386 {
6387 for (s = *varp; *s; )
6388 {
6389 while (*s && *s != ':')
6390 {
6391 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6392 && !VIM_ISDIGIT(*s) && *s != '-')
6393 {
6394 errmsg = illegal_char(errbuf, *s);
6395 break;
6396 }
6397 ++s;
6398 }
6399 if (*s++ == NUL)
6400 errmsg = (char_u *)N_("E524: Missing colon");
6401 else if (*s == ',' || *s == NUL)
6402 errmsg = (char_u *)N_("E525: Zero length string");
6403 if (errmsg != NULL)
6404 break;
6405 while (*s && *s != ',')
6406 {
6407 if (*s == '\\' && s[1] != NUL)
6408 ++s;
6409 ++s;
6410 }
6411 s = skip_to_option_part(s);
6412 }
6413 }
6414#endif
6415
6416 /* 'listchars' */
6417 else if (varp == &p_lcs)
6418 {
6419 errmsg = set_chars_option(varp);
6420 }
6421
6422#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6423 /* 'fillchars' */
6424 else if (varp == &p_fcs)
6425 {
6426 errmsg = set_chars_option(varp);
6427 }
6428#endif
6429
6430#ifdef FEAT_CMDWIN
6431 /* 'cedit' */
6432 else if (varp == &p_cedit)
6433 {
6434 errmsg = check_cedit();
6435 }
6436#endif
6437
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006438 /* 'verbosefile' */
6439 else if (varp == &p_vfile)
6440 {
6441 verbose_stop();
6442 if (*p_vfile != NUL && verbose_open() == FAIL)
6443 errmsg = e_invarg;
6444 }
6445
Bram Moolenaar071d4272004-06-13 20:20:40 +00006446#ifdef FEAT_VIMINFO
6447 /* 'viminfo' */
6448 else if (varp == &p_viminfo)
6449 {
6450 for (s = p_viminfo; *s;)
6451 {
6452 /* Check it's a valid character */
6453 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6454 {
6455 errmsg = illegal_char(errbuf, *s);
6456 break;
6457 }
6458 if (*s == 'n') /* name is always last one */
6459 {
6460 break;
6461 }
6462 else if (*s == 'r') /* skip until next ',' */
6463 {
6464 while (*++s && *s != ',')
6465 ;
6466 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006467 else if (*s == '%')
6468 {
6469 /* optional number */
6470 while (vim_isdigit(*++s))
6471 ;
6472 }
6473 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006474 ++s; /* no extra chars */
6475 else /* must have a number */
6476 {
6477 while (vim_isdigit(*++s))
6478 ;
6479
6480 if (!VIM_ISDIGIT(*(s - 1)))
6481 {
6482 if (errbuf != NULL)
6483 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006484 sprintf((char *)errbuf,
6485 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006486 transchar_byte(*(s - 1)));
6487 errmsg = errbuf;
6488 }
6489 else
6490 errmsg = (char_u *)"";
6491 break;
6492 }
6493 }
6494 if (*s == ',')
6495 ++s;
6496 else if (*s)
6497 {
6498 if (errbuf != NULL)
6499 errmsg = (char_u *)N_("E527: Missing comma");
6500 else
6501 errmsg = (char_u *)"";
6502 break;
6503 }
6504 }
6505 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6506 errmsg = (char_u *)N_("E528: Must specify a ' value");
6507 }
6508#endif /* FEAT_VIMINFO */
6509
6510 /* terminal options */
6511 else if (istermoption(&options[opt_idx]) && full_screen)
6512 {
6513 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6514 if (varp == &T_CCO)
6515 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006516 int colors = atoi((char *)T_CCO);
6517
6518 /* Only reinitialize colors if t_Co value has really changed to
6519 * avoid expensive reload of colorscheme if t_Co is set to the
6520 * same value multiple times. */
6521 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006522 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006523 t_colors = colors;
6524 if (t_colors <= 1)
6525 {
6526 if (new_value_alloced)
6527 vim_free(T_CCO);
6528 T_CCO = empty_option;
6529 }
6530 /* We now have a different color setup, initialize it again. */
6531 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006532 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006533 }
6534 ttest(FALSE);
6535 if (varp == &T_ME)
6536 {
6537 out_str(T_ME);
6538 redraw_later(CLEAR);
6539#if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32))
6540 /* Since t_me has been set, this probably means that the user
6541 * wants to use this as default colors. Need to reset default
6542 * background/foreground colors. */
6543 mch_set_normal_colors();
6544#endif
6545 }
6546 }
6547
6548#ifdef FEAT_LINEBREAK
6549 /* 'showbreak' */
6550 else if (varp == &p_sbr)
6551 {
6552 for (s = p_sbr; *s; )
6553 {
6554 if (ptr2cells(s) != 1)
6555 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006556 mb_ptr_adv(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006557 }
6558 }
6559#endif
6560
6561#ifdef FEAT_GUI
6562 /* 'guifont' */
6563 else if (varp == &p_guifont)
6564 {
6565 if (gui.in_use)
6566 {
6567 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006568# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006569 /*
6570 * Put up a font dialog and let the user select a new value.
6571 * If this is cancelled go back to the old value but don't
6572 * give an error message.
6573 */
6574 if (STRCMP(p, "*") == 0)
6575 {
6576 p = gui_mch_font_dialog(oldval);
6577
6578 if (new_value_alloced)
6579 free_string_option(p_guifont);
6580
6581 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6582 new_value_alloced = TRUE;
6583 }
6584# endif
6585 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6586 {
6587# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6588 if (STRCMP(p_guifont, "*") == 0)
6589 {
6590 /* Dialog was cancelled: Keep the old value without giving
6591 * an error message. */
6592 if (new_value_alloced)
6593 free_string_option(p_guifont);
6594 p_guifont = vim_strsave(oldval);
6595 new_value_alloced = TRUE;
6596 }
6597 else
6598# endif
6599 errmsg = (char_u *)N_("E596: Invalid font(s)");
6600 }
6601 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006602 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006603 }
6604# ifdef FEAT_XFONTSET
6605 else if (varp == &p_guifontset)
6606 {
6607 if (STRCMP(p_guifontset, "*") == 0)
6608 errmsg = (char_u *)N_("E597: can't select fontset");
6609 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6610 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006611 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006612 }
6613# endif
6614# ifdef FEAT_MBYTE
6615 else if (varp == &p_guifontwide)
6616 {
6617 if (STRCMP(p_guifontwide, "*") == 0)
6618 errmsg = (char_u *)N_("E533: can't select wide font");
6619 else if (gui_get_wide_font() == FAIL)
6620 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006621 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006622 }
6623# endif
6624#endif
6625
6626#ifdef CURSOR_SHAPE
6627 /* 'guicursor' */
6628 else if (varp == &p_guicursor)
6629 errmsg = parse_shape_opt(SHAPE_CURSOR);
6630#endif
6631
6632#ifdef FEAT_MOUSESHAPE
6633 /* 'mouseshape' */
6634 else if (varp == &p_mouseshape)
6635 {
6636 errmsg = parse_shape_opt(SHAPE_MOUSE);
6637 update_mouseshape(-1);
6638 }
6639#endif
6640
6641#ifdef FEAT_PRINTER
6642 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006643 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006644# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006645 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006646 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006647# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006648#endif
6649
6650#ifdef FEAT_LANGMAP
6651 /* 'langmap' */
6652 else if (varp == &p_langmap)
6653 langmap_set();
6654#endif
6655
6656#ifdef FEAT_LINEBREAK
6657 /* 'breakat' */
6658 else if (varp == &p_breakat)
6659 fill_breakat_flags();
6660#endif
6661
6662#ifdef FEAT_TITLE
6663 /* 'titlestring' and 'iconstring' */
6664 else if (varp == &p_titlestring || varp == &p_iconstring)
6665 {
6666# ifdef FEAT_STL_OPT
6667 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6668
6669 /* NULL => statusline syntax */
6670 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6671 stl_syntax |= flagval;
6672 else
6673 stl_syntax &= ~flagval;
6674# endif
6675 did_set_title(varp == &p_iconstring);
6676
6677 }
6678#endif
6679
6680#ifdef FEAT_GUI
6681 /* 'guioptions' */
6682 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006683 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006684 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006685 redraw_gui_only = TRUE;
6686 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006687#endif
6688
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006689#if defined(FEAT_GUI_TABLINE)
6690 /* 'guitablabel' */
6691 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006692 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006693 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006694 redraw_gui_only = TRUE;
6695 }
6696 /* 'guitabtooltip' */
6697 else if (varp == &p_gtt)
6698 {
6699 redraw_gui_only = TRUE;
6700 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006701#endif
6702
Bram Moolenaar071d4272004-06-13 20:20:40 +00006703#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6704 /* 'ttymouse' */
6705 else if (varp == &p_ttym)
6706 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006707 /* Switch the mouse off before changing the escape sequences used for
6708 * that. */
6709 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006710 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6711 errmsg = e_invarg;
6712 else
6713 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006714 if (termcap_active)
6715 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006716 }
6717#endif
6718
Bram Moolenaar071d4272004-06-13 20:20:40 +00006719 /* 'selection' */
6720 else if (varp == &p_sel)
6721 {
6722 if (*p_sel == NUL
6723 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6724 errmsg = e_invarg;
6725 }
6726
6727 /* 'selectmode' */
6728 else if (varp == &p_slm)
6729 {
6730 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6731 errmsg = e_invarg;
6732 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006733
6734#ifdef FEAT_BROWSE
6735 /* 'browsedir' */
6736 else if (varp == &p_bsdir)
6737 {
6738 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
6739 && !mch_isdir(p_bsdir))
6740 errmsg = e_invarg;
6741 }
6742#endif
6743
Bram Moolenaar071d4272004-06-13 20:20:40 +00006744 /* 'keymodel' */
6745 else if (varp == &p_km)
6746 {
6747 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
6748 errmsg = e_invarg;
6749 else
6750 {
6751 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
6752 km_startsel = (vim_strchr(p_km, 'a') != NULL);
6753 }
6754 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006755
6756 /* 'mousemodel' */
6757 else if (varp == &p_mousem)
6758 {
6759 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
6760 errmsg = e_invarg;
6761#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
6762 else if (*p_mousem != *oldval)
6763 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
6764 * to create or delete the popup menus. */
6765 gui_motif_update_mousemodel(root_menu);
6766#endif
6767 }
6768
6769 /* 'switchbuf' */
6770 else if (varp == &p_swb)
6771 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00006772 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006773 errmsg = e_invarg;
6774 }
6775
6776 /* 'debug' */
6777 else if (varp == &p_debug)
6778 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00006779 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006780 errmsg = e_invarg;
6781 }
6782
6783 /* 'display' */
6784 else if (varp == &p_dy)
6785 {
6786 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
6787 errmsg = e_invarg;
6788 else
6789 (void)init_chartab();
6790
6791 }
6792
6793#ifdef FEAT_VERTSPLIT
6794 /* 'eadirection' */
6795 else if (varp == &p_ead)
6796 {
6797 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
6798 errmsg = e_invarg;
6799 }
6800#endif
6801
6802#ifdef FEAT_CLIPBOARD
6803 /* 'clipboard' */
6804 else if (varp == &p_cb)
6805 errmsg = check_clipboard_option();
6806#endif
6807
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00006808#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006809 /* When 'spelllang' or 'spellfile' is set and there is a window for this
6810 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006811 else if (varp == &(curwin->w_s->b_p_spl)
6812 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00006813 {
Bram Moolenaare68c25c2015-08-25 15:39:55 +02006814 errmsg = did_set_spell_option(varp == &(curwin->w_s->b_p_spf));
Bram Moolenaar217ad922005-03-20 22:37:15 +00006815 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006816 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006817 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006818 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006819 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006820 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006821 /* 'spellsuggest' */
6822 else if (varp == &p_sps)
6823 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00006824 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006825 errmsg = e_invarg;
6826 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00006827 /* 'mkspellmem' */
6828 else if (varp == &p_msm)
6829 {
6830 if (spell_check_msm() != OK)
6831 errmsg = e_invarg;
6832 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006833#endif
6834
Bram Moolenaar071d4272004-06-13 20:20:40 +00006835#ifdef FEAT_QUICKFIX
6836 /* When 'bufhidden' is set, check for valid value. */
6837 else if (gvarp == &p_bh)
6838 {
6839 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
6840 errmsg = e_invarg;
6841 }
6842
6843 /* When 'buftype' is set, check for valid value. */
6844 else if (gvarp == &p_bt)
6845 {
6846 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
6847 errmsg = e_invarg;
6848 else
6849 {
6850# ifdef FEAT_WINDOWS
6851 if (curwin->w_status_height)
6852 {
6853 curwin->w_redr_status = TRUE;
6854 redraw_later(VALID);
6855 }
6856# endif
6857 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar5075aad2010-01-27 15:58:13 +01006858# ifdef FEAT_TITLE
6859 redraw_titles();
6860# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006861 }
6862 }
6863#endif
6864
6865#ifdef FEAT_STL_OPT
6866 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006867 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006868 {
6869 int wid;
6870
6871 if (varp == &p_ruf) /* reset ru_wid first */
6872 ru_wid = 0;
6873 s = *varp;
6874 if (varp == &p_ruf && *s == '%')
6875 {
6876 /* set ru_wid if 'ruf' starts with "%99(" */
6877 if (*++s == '-') /* ignore a '-' */
6878 s++;
6879 wid = getdigits(&s);
6880 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
6881 ru_wid = wid;
6882 else
6883 errmsg = check_stl_option(p_ruf);
6884 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00006885 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00006886 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006887 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006888 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006889 comp_col();
6890 }
6891#endif
6892
6893#ifdef FEAT_INS_EXPAND
6894 /* check if it is a valid value for 'complete' -- Acevedo */
6895 else if (gvarp == &p_cpt)
6896 {
6897 for (s = *varp; *s;)
6898 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02006899 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006900 s++;
6901 if (!*s)
6902 break;
6903 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
6904 {
6905 errmsg = illegal_char(errbuf, *s);
6906 break;
6907 }
6908 if (*++s != NUL && *s != ',' && *s != ' ')
6909 {
6910 if (s[-1] == 'k' || s[-1] == 's')
6911 {
6912 /* skip optional filename after 'k' and 's' */
6913 while (*s && *s != ',' && *s != ' ')
6914 {
6915 if (*s == '\\')
6916 ++s;
6917 ++s;
6918 }
6919 }
6920 else
6921 {
6922 if (errbuf != NULL)
6923 {
6924 sprintf((char *)errbuf,
6925 _("E535: Illegal character after <%c>"),
6926 *--s);
6927 errmsg = errbuf;
6928 }
6929 else
6930 errmsg = (char_u *)"";
6931 break;
6932 }
6933 }
6934 }
6935 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00006936
6937 /* 'completeopt' */
6938 else if (varp == &p_cot)
6939 {
6940 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
6941 errmsg = e_invarg;
6942 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006943#endif /* FEAT_INS_EXPAND */
6944
6945
6946#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
6947 else if (varp == &p_toolbar)
6948 {
6949 if (opt_strings_flags(p_toolbar, p_toolbar_values,
6950 &toolbar_flags, TRUE) != OK)
6951 errmsg = e_invarg;
6952 else
6953 {
6954 out_flush();
6955 gui_mch_show_toolbar((toolbar_flags &
6956 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6957 }
6958 }
6959#endif
6960
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006961#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006962 /* 'toolbariconsize': GTK+ 2 only */
6963 else if (varp == &p_tbis)
6964 {
6965 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
6966 errmsg = e_invarg;
6967 else
6968 {
6969 out_flush();
6970 gui_mch_show_toolbar((toolbar_flags &
6971 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6972 }
6973 }
6974#endif
6975
6976 /* 'pastetoggle': translate key codes like in a mapping */
6977 else if (varp == &p_pt)
6978 {
6979 if (*p_pt)
6980 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00006981 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006982 if (p != NULL)
6983 {
6984 if (new_value_alloced)
6985 free_string_option(p_pt);
6986 p_pt = p;
6987 new_value_alloced = TRUE;
6988 }
6989 }
6990 }
6991
6992 /* 'backspace' */
6993 else if (varp == &p_bs)
6994 {
6995 if (VIM_ISDIGIT(*p_bs))
6996 {
6997 if (*p_bs >'2' || p_bs[1] != NUL)
6998 errmsg = e_invarg;
6999 }
7000 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
7001 errmsg = e_invarg;
7002 }
Bram Moolenaar165bc692015-07-21 17:53:25 +02007003 else if (varp == &p_bo)
7004 {
7005 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK)
7006 errmsg = e_invarg;
7007 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007008
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007009#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007010 /* 'casemap' */
7011 else if (varp == &p_cmp)
7012 {
7013 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
7014 errmsg = e_invarg;
7015 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007016#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007017
7018#ifdef FEAT_DIFF
7019 /* 'diffopt' */
7020 else if (varp == &p_dip)
7021 {
7022 if (diffopt_changed() == FAIL)
7023 errmsg = e_invarg;
7024 }
7025#endif
7026
7027#ifdef FEAT_FOLDING
7028 /* 'foldmethod' */
7029 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7030 {
7031 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7032 || *curwin->w_p_fdm == NUL)
7033 errmsg = e_invarg;
7034 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007035 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007036 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007037 if (foldmethodIsDiff(curwin))
7038 newFoldLevel();
7039 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007040 }
7041# ifdef FEAT_EVAL
7042 /* 'foldexpr' */
7043 else if (varp == &curwin->w_p_fde)
7044 {
7045 if (foldmethodIsExpr(curwin))
7046 foldUpdateAll(curwin);
7047 }
7048# endif
7049 /* 'foldmarker' */
7050 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7051 {
7052 p = vim_strchr(*varp, ',');
7053 if (p == NULL)
7054 errmsg = (char_u *)N_("E536: comma required");
7055 else if (p == *varp || p[1] == NUL)
7056 errmsg = e_invarg;
7057 else if (foldmethodIsMarker(curwin))
7058 foldUpdateAll(curwin);
7059 }
7060 /* 'commentstring' */
7061 else if (gvarp == &p_cms)
7062 {
7063 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7064 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7065 }
7066 /* 'foldopen' */
7067 else if (varp == &p_fdo)
7068 {
7069 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7070 errmsg = e_invarg;
7071 }
7072 /* 'foldclose' */
7073 else if (varp == &p_fcl)
7074 {
7075 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7076 errmsg = e_invarg;
7077 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007078 /* 'foldignore' */
7079 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7080 {
7081 if (foldmethodIsIndent(curwin))
7082 foldUpdateAll(curwin);
7083 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007084#endif
7085
7086#ifdef FEAT_VIRTUALEDIT
7087 /* 'virtualedit' */
7088 else if (varp == &p_ve)
7089 {
7090 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7091 errmsg = e_invarg;
7092 else if (STRCMP(p_ve, oldval) != 0)
7093 {
7094 /* Recompute cursor position in case the new 've' setting
7095 * changes something. */
7096 validate_virtcol();
7097 coladvance(curwin->w_virtcol);
7098 }
7099 }
7100#endif
7101
7102#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7103 else if (varp == &p_csqf)
7104 {
7105 if (p_csqf != NULL)
7106 {
7107 p = p_csqf;
7108 while (*p != NUL)
7109 {
7110 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7111 || p[1] == NUL
7112 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7113 || (p[2] != NUL && p[2] != ','))
7114 {
7115 errmsg = e_invarg;
7116 break;
7117 }
7118 else if (p[2] == NUL)
7119 break;
7120 else
7121 p += 3;
7122 }
7123 }
7124 }
7125#endif
7126
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007127#ifdef FEAT_CINDENT
7128 /* 'cinoptions' */
7129 else if (gvarp == &p_cino)
7130 {
7131 /* TODO: recognize errors */
7132 parse_cino(curbuf);
7133 }
7134#endif
7135
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007136#if defined(FEAT_RENDER_OPTIONS)
7137 else if (varp == &p_rop && gui.in_use)
7138 {
7139 if (!gui_mch_set_rendering_options(p_rop))
7140 errmsg = e_invarg;
7141 }
7142#endif
7143
Bram Moolenaar071d4272004-06-13 20:20:40 +00007144 /* Options that are a list of flags. */
7145 else
7146 {
7147 p = NULL;
7148 if (varp == &p_ww)
7149 p = (char_u *)WW_ALL;
7150 if (varp == &p_shm)
7151 p = (char_u *)SHM_ALL;
7152 else if (varp == &(p_cpo))
7153 p = (char_u *)CPO_ALL;
7154 else if (varp == &(curbuf->b_p_fo))
7155 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007156#ifdef FEAT_CONCEAL
7157 else if (varp == &curwin->w_p_cocu)
7158 p = (char_u *)COCU_ALL;
7159#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007160 else if (varp == &p_mouse)
7161 {
7162#ifdef FEAT_MOUSE
7163 p = (char_u *)MOUSE_ALL;
7164#else
7165 if (*p_mouse != NUL)
7166 errmsg = (char_u *)N_("E538: No mouse support");
7167#endif
7168 }
7169#if defined(FEAT_GUI)
7170 else if (varp == &p_go)
7171 p = (char_u *)GO_ALL;
7172#endif
7173 if (p != NULL)
7174 {
7175 for (s = *varp; *s; ++s)
7176 if (vim_strchr(p, *s) == NULL)
7177 {
7178 errmsg = illegal_char(errbuf, *s);
7179 break;
7180 }
7181 }
7182 }
7183
7184 /*
7185 * If error detected, restore the previous value.
7186 */
7187 if (errmsg != NULL)
7188 {
7189 if (new_value_alloced)
7190 free_string_option(*varp);
7191 *varp = oldval;
7192 /*
7193 * When resetting some values, need to act on it.
7194 */
7195 if (did_chartab)
7196 (void)init_chartab();
7197 if (varp == &p_hl)
7198 (void)highlight_changed();
7199 }
7200 else
7201 {
7202#ifdef FEAT_EVAL
7203 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007204 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007205#endif
7206 /*
7207 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007208 * Use "free_oldval", because recursiveness may change the flags under
7209 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007210 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007211 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007212 free_string_option(oldval);
7213 if (new_value_alloced)
7214 options[opt_idx].flags |= P_ALLOCED;
7215 else
7216 options[opt_idx].flags &= ~P_ALLOCED;
7217
7218 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007219 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007220 {
7221 /* global option with local value set to use global value; free
7222 * the local value and make it empty */
7223 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7224 free_string_option(*(char_u **)p);
7225 *(char_u **)p = empty_option;
7226 }
7227
7228 /* May set global value for local option. */
7229 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7230 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007231
7232#ifdef FEAT_AUTOCMD
7233 /*
7234 * Trigger the autocommand only after setting the flags.
7235 */
7236# ifdef FEAT_SYN_HL
7237 /* When 'syntax' is set, load the syntax of that name */
7238 if (varp == &(curbuf->b_p_syn))
7239 {
7240 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7241 curbuf->b_fname, TRUE, curbuf);
7242 }
7243# endif
7244 else if (varp == &(curbuf->b_p_ft))
7245 {
7246 /* 'filetype' is set, trigger the FileType autocommand */
7247 did_filetype = TRUE;
7248 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
7249 curbuf->b_fname, TRUE, curbuf);
7250 }
7251#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007252#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007253 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007254 {
7255 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007256 char_u *q = curwin->w_s->b_p_spl;
7257
7258 /* Skip the first name if it is "cjk". */
7259 if (STRNCMP(q, "cjk,", 4) == 0)
7260 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007261
7262 /*
7263 * Source the spell/LANG.vim in 'runtimepath'.
7264 * They could set 'spellcapcheck' depending on the language.
7265 * Use the first name in 'spelllang' up to '_region' or
7266 * '.encoding'.
7267 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007268 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007269 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7270 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007271 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007272 source_runtime(fname, TRUE);
7273 }
7274#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007275 }
7276
7277#ifdef FEAT_MOUSE
7278 if (varp == &p_mouse)
7279 {
7280# ifdef FEAT_MOUSE_TTY
7281 if (*p_mouse == NUL)
7282 mch_setmouse(FALSE); /* switch mouse off */
7283 else
7284# endif
7285 setmouse(); /* in case 'mouse' changed */
7286 }
7287#endif
7288
Bram Moolenaar913077c2012-03-28 19:59:04 +02007289 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007290 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007291 curwin->w_set_curswant = TRUE;
7292
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007293#ifdef FEAT_GUI
7294 /* check redraw when it's not a GUI option or the GUI is active. */
7295 if (!redraw_gui_only || gui.in_use)
7296#endif
7297 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007298
7299 return errmsg;
7300}
7301
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007302#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007303/*
7304 * Simple int comparison function for use with qsort()
7305 */
7306 static int
7307int_cmp(a, b)
7308 const void *a;
7309 const void *b;
7310{
7311 return *(const int *)a - *(const int *)b;
7312}
7313
7314/*
7315 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7316 * Returns error message, NULL if it's OK.
7317 */
7318 char_u *
7319check_colorcolumn(wp)
7320 win_T *wp;
7321{
7322 char_u *s;
7323 int col;
7324 int count = 0;
7325 int color_cols[256];
7326 int i;
7327 int j = 0;
7328
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007329 if (wp->w_buffer == NULL)
7330 return NULL; /* buffer was closed */
7331
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007332 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007333 {
7334 if (*s == '-' || *s == '+')
7335 {
7336 /* -N and +N: add to 'textwidth' */
7337 col = (*s == '-') ? -1 : 1;
7338 ++s;
7339 if (!VIM_ISDIGIT(*s))
7340 return e_invarg;
7341 col = col * getdigits(&s);
7342 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007343 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007344 col += wp->w_buffer->b_p_tw;
7345 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007346 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007347 }
7348 else if (VIM_ISDIGIT(*s))
7349 col = getdigits(&s);
7350 else
7351 return e_invarg;
7352 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007353skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007354 if (*s == NUL)
7355 break;
7356 if (*s != ',')
7357 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007358 if (*++s == NUL)
7359 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007360 }
7361
7362 vim_free(wp->w_p_cc_cols);
7363 if (count == 0)
7364 wp->w_p_cc_cols = NULL;
7365 else
7366 {
7367 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7368 if (wp->w_p_cc_cols != NULL)
7369 {
7370 /* sort the columns for faster usage on screen redraw inside
7371 * win_line() */
7372 qsort(color_cols, count, sizeof(int), int_cmp);
7373
7374 for (i = 0; i < count; ++i)
7375 /* skip duplicates */
7376 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7377 wp->w_p_cc_cols[j++] = color_cols[i];
7378 wp->w_p_cc_cols[j] = -1; /* end marker */
7379 }
7380 }
7381
7382 return NULL; /* no error */
7383}
7384#endif
7385
Bram Moolenaar071d4272004-06-13 20:20:40 +00007386/*
7387 * Handle setting 'listchars' or 'fillchars'.
7388 * Returns error message, NULL if it's OK.
7389 */
7390 static char_u *
7391set_chars_option(varp)
7392 char_u **varp;
7393{
7394 int round, i, len, entries;
7395 char_u *p, *s;
7396 int c1, c2 = 0;
7397 struct charstab
7398 {
7399 int *cp;
7400 char *name;
7401 };
7402#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7403 static struct charstab filltab[] =
7404 {
7405 {&fill_stl, "stl"},
7406 {&fill_stlnc, "stlnc"},
7407 {&fill_vert, "vert"},
7408 {&fill_fold, "fold"},
7409 {&fill_diff, "diff"},
7410 };
7411#endif
7412 static struct charstab lcstab[] =
7413 {
7414 {&lcs_eol, "eol"},
7415 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007416 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007417 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007418 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007419 {&lcs_tab2, "tab"},
7420 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007421#ifdef FEAT_CONCEAL
7422 {&lcs_conceal, "conceal"},
7423#else
7424 {NULL, "conceal"},
7425#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007426 };
7427 struct charstab *tab;
7428
7429#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7430 if (varp == &p_lcs)
7431#endif
7432 {
7433 tab = lcstab;
7434 entries = sizeof(lcstab) / sizeof(struct charstab);
7435 }
7436#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7437 else
7438 {
7439 tab = filltab;
7440 entries = sizeof(filltab) / sizeof(struct charstab);
7441 }
7442#endif
7443
7444 /* first round: check for valid value, second round: assign values */
7445 for (round = 0; round <= 1; ++round)
7446 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007447 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007448 {
7449 /* After checking that the value is valid: set defaults: space for
7450 * 'fillchars', NUL for 'listchars' */
7451 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007452 if (tab[i].cp != NULL)
7453 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007454 if (varp == &p_lcs)
7455 lcs_tab1 = NUL;
7456#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7457 else
7458 fill_diff = '-';
7459#endif
7460 }
7461 p = *varp;
7462 while (*p)
7463 {
7464 for (i = 0; i < entries; ++i)
7465 {
7466 len = (int)STRLEN(tab[i].name);
7467 if (STRNCMP(p, tab[i].name, len) == 0
7468 && p[len] == ':'
7469 && p[len + 1] != NUL)
7470 {
7471 s = p + len + 1;
7472#ifdef FEAT_MBYTE
7473 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007474 if (mb_char2cells(c1) > 1)
7475 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007476#else
7477 c1 = *s++;
7478#endif
7479 if (tab[i].cp == &lcs_tab2)
7480 {
7481 if (*s == NUL)
7482 continue;
7483#ifdef FEAT_MBYTE
7484 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007485 if (mb_char2cells(c2) > 1)
7486 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007487#else
7488 c2 = *s++;
7489#endif
7490 }
7491 if (*s == ',' || *s == NUL)
7492 {
7493 if (round)
7494 {
7495 if (tab[i].cp == &lcs_tab2)
7496 {
7497 lcs_tab1 = c1;
7498 lcs_tab2 = c2;
7499 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007500 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007501 *(tab[i].cp) = c1;
7502
7503 }
7504 p = s;
7505 break;
7506 }
7507 }
7508 }
7509
7510 if (i == entries)
7511 return e_invarg;
7512 if (*p == ',')
7513 ++p;
7514 }
7515 }
7516
7517 return NULL; /* no error */
7518}
7519
7520#ifdef FEAT_STL_OPT
7521/*
7522 * Check validity of options with the 'statusline' format.
7523 * Return error message or NULL.
7524 */
7525 char_u *
7526check_stl_option(s)
7527 char_u *s;
7528{
7529 int itemcnt = 0;
7530 int groupdepth = 0;
7531 static char_u errbuf[80];
7532
7533 while (*s && itemcnt < STL_MAX_ITEM)
7534 {
7535 /* Check for valid keys after % sequences */
7536 while (*s && *s != '%')
7537 s++;
7538 if (!*s)
7539 break;
7540 s++;
7541 if (*s != '%' && *s != ')')
7542 ++itemcnt;
7543 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7544 {
7545 s++;
7546 continue;
7547 }
7548 if (*s == ')')
7549 {
7550 s++;
7551 if (--groupdepth < 0)
7552 break;
7553 continue;
7554 }
7555 if (*s == '-')
7556 s++;
7557 while (VIM_ISDIGIT(*s))
7558 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007559 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007560 continue;
7561 if (*s == '.')
7562 {
7563 s++;
7564 while (*s && VIM_ISDIGIT(*s))
7565 s++;
7566 }
7567 if (*s == '(')
7568 {
7569 groupdepth++;
7570 continue;
7571 }
7572 if (vim_strchr(STL_ALL, *s) == NULL)
7573 {
7574 return illegal_char(errbuf, *s);
7575 }
7576 if (*s == '{')
7577 {
7578 s++;
7579 while (*s != '}' && *s)
7580 s++;
7581 if (*s != '}')
7582 return (char_u *)N_("E540: Unclosed expression sequence");
7583 }
7584 }
7585 if (itemcnt >= STL_MAX_ITEM)
7586 return (char_u *)N_("E541: too many items");
7587 if (groupdepth != 0)
7588 return (char_u *)N_("E542: unbalanced groups");
7589 return NULL;
7590}
7591#endif
7592
7593#ifdef FEAT_CLIPBOARD
7594/*
7595 * Extract the items in the 'clipboard' option and set global values.
7596 */
7597 static char_u *
7598check_clipboard_option()
7599{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007600 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007601 int new_autoselect_star = FALSE;
7602 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007603 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007604 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007605 regprog_T *new_exclude_prog = NULL;
7606 char_u *errmsg = NULL;
7607 char_u *p;
7608
7609 for (p = p_cb; *p != NUL; )
7610 {
7611 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7612 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007613 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007614 p += 7;
7615 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007616 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007617 && (p[11] == ',' || p[11] == NUL))
7618 {
7619 new_unnamed |= CLIP_UNNAMED_PLUS;
7620 p += 11;
7621 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007622 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007623 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007624 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007625 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007626 p += 10;
7627 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007628 else if (STRNCMP(p, "autoselectplus", 14) == 0
7629 && (p[14] == ',' || p[14] == NUL))
7630 {
7631 new_autoselect_plus = TRUE;
7632 p += 14;
7633 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007634 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007635 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007636 {
7637 new_autoselectml = TRUE;
7638 p += 12;
7639 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007640 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7641 {
7642 new_html = TRUE;
7643 p += 4;
7644 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007645 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7646 {
7647 p += 8;
7648 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7649 if (new_exclude_prog == NULL)
7650 errmsg = e_invarg;
7651 break;
7652 }
7653 else
7654 {
7655 errmsg = e_invarg;
7656 break;
7657 }
7658 if (*p == ',')
7659 ++p;
7660 }
7661 if (errmsg == NULL)
7662 {
7663 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007664 clip_autoselect_star = new_autoselect_star;
7665 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007666 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007667 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02007668 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007669 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02007670#ifdef FEAT_GUI_GTK
7671 if (gui.in_use)
7672 {
7673 gui_gtk_set_selection_targets();
7674 gui_gtk_set_dnd_targets();
7675 }
7676#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007677 }
7678 else
Bram Moolenaar473de612013-06-08 18:19:48 +02007679 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007680
7681 return errmsg;
7682}
7683#endif
7684
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007685#ifdef FEAT_SPELL
Bram Moolenaare68c25c2015-08-25 15:39:55 +02007686 static char_u *
7687did_set_spell_option(is_spellfile)
7688 int is_spellfile;
7689{
7690 char_u *errmsg = NULL;
7691 win_T *wp;
7692 int l;
7693
7694 if (is_spellfile)
7695 {
7696 l = (int)STRLEN(curwin->w_s->b_p_spf);
7697 if (l > 0 && (l < 4
7698 || STRCMP(curwin->w_s->b_p_spf + l - 4, ".add") != 0))
7699 errmsg = e_invarg;
7700 }
7701
7702 if (errmsg == NULL)
7703 {
7704 FOR_ALL_WINDOWS(wp)
7705 if (wp->w_buffer == curbuf && wp->w_p_spell)
7706 {
7707 errmsg = did_set_spelllang(wp);
7708# ifdef FEAT_WINDOWS
7709 break;
7710# endif
7711 }
7712 }
7713 return errmsg;
7714}
7715
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007716/*
7717 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
7718 * Return error message when failed, NULL when OK.
7719 */
7720 static char_u *
Bram Moolenaar860cae12010-06-05 23:22:07 +02007721compile_cap_prog(synblock)
7722 synblock_T *synblock;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007723{
Bram Moolenaar860cae12010-06-05 23:22:07 +02007724 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007725 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007726
Bram Moolenaar860cae12010-06-05 23:22:07 +02007727 if (*synblock->b_p_spc == NUL)
7728 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007729 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007730 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007731 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007732 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007733 if (re != NULL)
7734 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007735 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02007736 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02007737 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007738 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007739 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007740 return e_invarg;
7741 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007742 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007743 }
7744
Bram Moolenaar473de612013-06-08 18:19:48 +02007745 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007746 return NULL;
7747}
7748#endif
7749
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007750#if defined(FEAT_EVAL) || defined(PROTO)
7751/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007752 * Set the scriptID for an option, taking care of setting the buffer- or
7753 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007754 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007755 static void
7756set_option_scriptID_idx(opt_idx, opt_flags, id)
7757 int opt_idx;
7758 int opt_flags;
7759 int id;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007760{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007761 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
7762 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007763
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007764 /* Remember where the option was set. For local options need to do that
7765 * in the buffer or window structure. */
7766 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007767 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007768 if (both || (opt_flags & OPT_LOCAL))
7769 {
7770 if (indir & PV_BUF)
7771 curbuf->b_p_scriptID[indir & PV_MASK] = id;
7772 else if (indir & PV_WIN)
7773 curwin->w_p_scriptID[indir & PV_MASK] = id;
7774 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007775}
7776#endif
7777
Bram Moolenaar071d4272004-06-13 20:20:40 +00007778/*
7779 * Set the value of a boolean option, and take care of side effects.
7780 * Returns NULL for success, or an error message for an error.
7781 */
7782 static char_u *
7783set_bool_option(opt_idx, varp, value, opt_flags)
7784 int opt_idx; /* index in options[] table */
7785 char_u *varp; /* pointer to the option variable */
7786 int value; /* new value */
7787 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
7788{
7789 int old_value = *(int *)varp;
7790
Bram Moolenaar071d4272004-06-13 20:20:40 +00007791 /* Disallow changing some options from secure mode */
7792 if ((secure
7793#ifdef HAVE_SANDBOX
7794 || sandbox != 0
7795#endif
7796 ) && (options[opt_idx].flags & P_SECURE))
7797 return e_secure;
7798
7799 *(int *)varp = value; /* set the new value */
7800#ifdef FEAT_EVAL
7801 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007802 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007803#endif
7804
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00007805#ifdef FEAT_GUI
7806 need_mouse_correct = TRUE;
7807#endif
7808
Bram Moolenaar071d4272004-06-13 20:20:40 +00007809 /* May set global value for local option. */
7810 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
7811 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
7812
7813 /*
7814 * Handle side effects of changing a bool option.
7815 */
7816
7817 /* 'compatible' */
7818 if ((int *)varp == &p_cp)
7819 {
7820 compatible_set();
7821 }
7822
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007823#ifdef FEAT_PERSISTENT_UNDO
7824 /* 'undofile' */
7825 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
7826 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007827 /* Only take action when the option was set. When reset we do not
7828 * delete the undo file, the option may be set again without making
7829 * any changes in between. */
7830 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007831 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007832 char_u hash[UNDO_HASH_SIZE];
7833 buf_T *save_curbuf = curbuf;
7834
7835 for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007836 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007837 /* When 'undofile' is set globally: for every buffer, otherwise
7838 * only for the current buffer: Try to read in the undofile,
7839 * if one exists, the buffer wasn't changed and the buffer was
7840 * loaded */
7841 if ((curbuf == save_curbuf
7842 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
7843 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
7844 {
7845 u_compute_hash(hash);
7846 u_read_undo(NULL, hash, curbuf->b_fname);
7847 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007848 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007849 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007850 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007851 }
7852#endif
7853
Bram Moolenaar071d4272004-06-13 20:20:40 +00007854 else if ((int *)varp == &curbuf->b_p_ro)
7855 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007856 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007857 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
7858 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007859
7860 /* when 'readonly' is set may give W10 again */
7861 if (curbuf->b_p_ro)
7862 curbuf->b_did_warn = FALSE;
7863
Bram Moolenaar071d4272004-06-13 20:20:40 +00007864#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007865 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007866#endif
7867 }
7868
Bram Moolenaar9c449722010-07-20 18:44:27 +02007869#ifdef FEAT_GUI
7870 else if ((int *)varp == &p_mh)
7871 {
7872 if (!p_mh)
7873 gui_mch_mousehide(FALSE);
7874 }
7875#endif
7876
Bram Moolenaara539df02010-08-01 14:35:05 +02007877#ifdef FEAT_TITLE
7878 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007879 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007880 {
7881 redraw_titles();
7882 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007883 /* when 'endofline' is changed, redraw the window title */
7884 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007885 {
7886 redraw_titles();
7887 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02007888 /* when 'fixeol' is changed, redraw the window title */
7889 else if ((int *)varp == &curbuf->b_p_fixeol)
7890 {
7891 redraw_titles();
7892 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007893# ifdef FEAT_MBYTE
7894 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00007895 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007896 {
7897 redraw_titles();
7898 }
7899# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007900#endif
7901
7902 /* when 'bin' is set also set some other options */
7903 else if ((int *)varp == &curbuf->b_p_bin)
7904 {
7905 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
7906#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007907 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007908#endif
7909 }
7910
7911#ifdef FEAT_AUTOCMD
7912 /* when 'buflisted' changes, trigger autocommands */
7913 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
7914 {
7915 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
7916 NULL, NULL, TRUE, curbuf);
7917 }
7918#endif
7919
7920 /* when 'swf' is set, create swapfile, when reset remove swapfile */
7921 else if ((int *)varp == &curbuf->b_p_swf)
7922 {
7923 if (curbuf->b_p_swf && p_uc)
7924 ml_open_file(curbuf); /* create the swap file */
7925 else
Bram Moolenaard55de222007-05-06 13:38:48 +00007926 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
7927 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007928 mf_close_file(curbuf, TRUE); /* remove the swap file */
7929 }
7930
7931 /* when 'terse' is set change 'shortmess' */
7932 else if ((int *)varp == &p_terse)
7933 {
7934 char_u *p;
7935
7936 p = vim_strchr(p_shm, SHM_SEARCH);
7937
7938 /* insert 's' in p_shm */
7939 if (p_terse && p == NULL)
7940 {
7941 STRCPY(IObuff, p_shm);
7942 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007943 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007944 }
7945 /* remove 's' from p_shm */
7946 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007947 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007948 }
7949
7950 /* when 'paste' is set or reset also change other options */
7951 else if ((int *)varp == &p_paste)
7952 {
7953 paste_option_changed();
7954 }
7955
7956 /* when 'insertmode' is set from an autocommand need to do work here */
7957 else if ((int *)varp == &p_im)
7958 {
7959 if (p_im)
7960 {
7961 if ((State & INSERT) == 0)
7962 need_start_insertmode = TRUE;
7963 stop_insert_mode = FALSE;
7964 }
7965 else
7966 {
7967 need_start_insertmode = FALSE;
7968 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00007969 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007970 clear_cmdline = TRUE; /* remove "(insert)" */
7971 restart_edit = 0;
7972 }
7973 }
7974
7975 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
7976 else if ((int *)varp == &p_ic && p_hls)
7977 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007978 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007979 }
7980
7981#ifdef FEAT_SEARCH_EXTRA
7982 /* when 'hlsearch' is set or reset: reset no_hlsearch */
7983 else if ((int *)varp == &p_hls)
7984 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01007985 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007986 }
7987#endif
7988
7989#ifdef FEAT_SCROLLBIND
7990 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
7991 * at the end of normal_cmd() */
7992 else if ((int *)varp == &curwin->w_p_scb)
7993 {
7994 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02007995 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007996 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02007997 curwin->w_scbind_pos = curwin->w_topline;
7998 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007999 }
8000#endif
8001
8002#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
8003 /* There can be only one window with 'previewwindow' set. */
8004 else if ((int *)varp == &curwin->w_p_pvw)
8005 {
8006 if (curwin->w_p_pvw)
8007 {
8008 win_T *win;
8009
8010 for (win = firstwin; win != NULL; win = win->w_next)
8011 if (win->w_p_pvw && win != curwin)
8012 {
8013 curwin->w_p_pvw = FALSE;
8014 return (char_u *)N_("E590: A preview window already exists");
8015 }
8016 }
8017 }
8018#endif
8019
8020 /* when 'textmode' is set or reset also change 'fileformat' */
8021 else if ((int *)varp == &curbuf->b_p_tx)
8022 {
8023 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
8024 }
8025
8026 /* when 'textauto' is set or reset also change 'fileformats' */
8027 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008028 set_string_option_direct((char_u *)"ffs", -1,
8029 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008030 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008031
8032 /*
8033 * When 'lisp' option changes include/exclude '-' in
8034 * keyword characters.
8035 */
8036#ifdef FEAT_LISP
8037 else if (varp == (char_u *)&(curbuf->b_p_lisp))
8038 {
8039 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
8040 }
8041#endif
8042
8043#ifdef FEAT_TITLE
8044 /* when 'title' changed, may need to change the title; same for 'icon' */
8045 else if ((int *)varp == &p_title)
8046 {
8047 did_set_title(FALSE);
8048 }
8049
8050 else if ((int *)varp == &p_icon)
8051 {
8052 did_set_title(TRUE);
8053 }
8054#endif
8055
8056 else if ((int *)varp == &curbuf->b_changed)
8057 {
8058 if (!value)
8059 save_file_ff(curbuf); /* Buffer is unchanged */
8060#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008061 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008062#endif
8063#ifdef FEAT_AUTOCMD
8064 modified_was_set = value;
8065#endif
8066 }
8067
8068#ifdef BACKSLASH_IN_FILENAME
8069 else if ((int *)varp == &p_ssl)
8070 {
8071 if (p_ssl)
8072 {
8073 psepc = '/';
8074 psepcN = '\\';
8075 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008076 }
8077 else
8078 {
8079 psepc = '\\';
8080 psepcN = '/';
8081 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008082 }
8083
8084 /* need to adjust the file name arguments and buffer names. */
8085 buflist_slash_adjust();
8086 alist_slash_adjust();
8087# ifdef FEAT_EVAL
8088 scriptnames_slash_adjust();
8089# endif
8090 }
8091#endif
8092
8093 /* If 'wrap' is set, set w_leftcol to zero. */
8094 else if ((int *)varp == &curwin->w_p_wrap)
8095 {
8096 if (curwin->w_p_wrap)
8097 curwin->w_leftcol = 0;
8098 }
8099
8100#ifdef FEAT_WINDOWS
8101 else if ((int *)varp == &p_ea)
8102 {
8103 if (p_ea && !old_value)
8104 win_equal(curwin, FALSE, 0);
8105 }
8106#endif
8107
8108 else if ((int *)varp == &p_wiv)
8109 {
8110 /*
8111 * When 'weirdinvert' changed, set/reset 't_xs'.
8112 * Then set 'weirdinvert' according to value of 't_xs'.
8113 */
8114 if (p_wiv && !old_value)
8115 T_XS = (char_u *)"y";
8116 else if (!p_wiv && old_value)
8117 T_XS = empty_option;
8118 p_wiv = (*T_XS != NUL);
8119 }
8120
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00008121#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00008122 else if ((int *)varp == &p_beval)
8123 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008124 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008125 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008126 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008127 gui_mch_disable_beval_area(balloonEval);
8128 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008129#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008130
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008131#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008132 else if ((int *)varp == &p_acd)
8133 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008134 /* Change directories when the 'acd' option is set now. */
8135 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008136 }
8137#endif
8138
8139#ifdef FEAT_DIFF
8140 /* 'diff' */
8141 else if ((int *)varp == &curwin->w_p_diff)
8142 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008143 /* May add or remove the buffer from the list of diff buffers. */
8144 diff_buf_adjust(curwin);
8145# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008146 if (foldmethodIsDiff(curwin))
8147 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008148# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008149 }
8150#endif
8151
8152#ifdef USE_IM_CONTROL
8153 /* 'imdisable' */
8154 else if ((int *)varp == &p_imdisable)
8155 {
8156 /* Only de-activate it here, it will be enabled when changing mode. */
8157 if (p_imdisable)
8158 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008159 else if (State & INSERT)
8160 /* When the option is set from an autocommand, it may need to take
8161 * effect right away. */
8162 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008163 }
8164#endif
8165
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008166#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008167 /* 'spell' */
8168 else if ((int *)varp == &curwin->w_p_spell)
8169 {
8170 if (curwin->w_p_spell)
8171 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008172 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008173 if (errmsg != NULL)
8174 EMSG(_(errmsg));
8175 }
8176 }
8177#endif
8178
Bram Moolenaar071d4272004-06-13 20:20:40 +00008179#ifdef FEAT_FKMAP
8180 else if ((int *)varp == &p_altkeymap)
8181 {
8182 if (old_value != p_altkeymap)
8183 {
8184 if (!p_altkeymap)
8185 {
8186 p_hkmap = p_fkmap;
8187 p_fkmap = 0;
8188 }
8189 else
8190 {
8191 p_fkmap = p_hkmap;
8192 p_hkmap = 0;
8193 }
8194 (void)init_chartab();
8195 }
8196 }
8197
8198 /*
8199 * In case some second language keymapping options have changed, check
8200 * and correct the setting in a consistent way.
8201 */
8202
8203 /*
8204 * If hkmap or fkmap are set, reset Arabic keymapping.
8205 */
8206 if ((p_hkmap || p_fkmap) && p_altkeymap)
8207 {
8208 p_altkeymap = p_fkmap;
8209# ifdef FEAT_ARABIC
8210 curwin->w_p_arab = FALSE;
8211# endif
8212 (void)init_chartab();
8213 }
8214
8215 /*
8216 * If hkmap set, reset Farsi keymapping.
8217 */
8218 if (p_hkmap && p_altkeymap)
8219 {
8220 p_altkeymap = 0;
8221 p_fkmap = 0;
8222# ifdef FEAT_ARABIC
8223 curwin->w_p_arab = FALSE;
8224# endif
8225 (void)init_chartab();
8226 }
8227
8228 /*
8229 * If fkmap set, reset Hebrew keymapping.
8230 */
8231 if (p_fkmap && !p_altkeymap)
8232 {
8233 p_altkeymap = 1;
8234 p_hkmap = 0;
8235# ifdef FEAT_ARABIC
8236 curwin->w_p_arab = FALSE;
8237# endif
8238 (void)init_chartab();
8239 }
8240#endif
8241
8242#ifdef FEAT_ARABIC
8243 if ((int *)varp == &curwin->w_p_arab)
8244 {
8245 if (curwin->w_p_arab)
8246 {
8247 /*
8248 * 'arabic' is set, handle various sub-settings.
8249 */
8250 if (!p_tbidi)
8251 {
8252 /* set rightleft mode */
8253 if (!curwin->w_p_rl)
8254 {
8255 curwin->w_p_rl = TRUE;
8256 changed_window_setting();
8257 }
8258
8259 /* Enable Arabic shaping (major part of what Arabic requires) */
8260 if (!p_arshape)
8261 {
8262 p_arshape = TRUE;
8263 redraw_later_clear();
8264 }
8265 }
8266
8267 /* Arabic requires a utf-8 encoding, inform the user if its not
8268 * set. */
8269 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008270 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008271 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8272
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008273 msg_source(hl_attr(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008274 MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
8275#ifdef FEAT_EVAL
8276 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8277#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008278 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008279
8280# ifdef FEAT_MBYTE
8281 /* set 'delcombine' */
8282 p_deco = TRUE;
8283# endif
8284
8285# ifdef FEAT_KEYMAP
8286 /* Force-set the necessary keymap for arabic */
8287 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8288 OPT_LOCAL);
8289# endif
8290# ifdef FEAT_FKMAP
8291 p_altkeymap = 0;
8292 p_hkmap = 0;
8293 p_fkmap = 0;
8294 (void)init_chartab();
8295# endif
8296 }
8297 else
8298 {
8299 /*
8300 * 'arabic' is reset, handle various sub-settings.
8301 */
8302 if (!p_tbidi)
8303 {
8304 /* reset rightleft mode */
8305 if (curwin->w_p_rl)
8306 {
8307 curwin->w_p_rl = FALSE;
8308 changed_window_setting();
8309 }
8310
8311 /* 'arabicshape' isn't reset, it is a global option and
8312 * another window may still need it "on". */
8313 }
8314
8315 /* 'delcombine' isn't reset, it is a global option and another
8316 * window may still want it "on". */
8317
8318# ifdef FEAT_KEYMAP
8319 /* Revert to the default keymap */
8320 curbuf->b_p_iminsert = B_IMODE_NONE;
8321 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8322# endif
8323 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008324 }
8325
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008326#endif
8327
Bram Moolenaar071d4272004-06-13 20:20:40 +00008328 /*
8329 * End of handling side effects for bool options.
8330 */
8331
Bram Moolenaar53744302015-07-17 17:38:22 +02008332 /* after handling side effects, call autocommand */
8333
Bram Moolenaar071d4272004-06-13 20:20:40 +00008334 options[opt_idx].flags |= P_WAS_SET;
8335
Bram Moolenaar53744302015-07-17 17:38:22 +02008336#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8337 if (!starting)
8338 {
8339 char_u buf_old[2], buf_new[2], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008340 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8341 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8342 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008343 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8344 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8345 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8346 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8347 reset_v_option_vars();
8348 }
8349#endif
8350
Bram Moolenaar071d4272004-06-13 20:20:40 +00008351 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008352 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008353 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008354 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008355 check_redraw(options[opt_idx].flags);
8356
8357 return NULL;
8358}
8359
8360/*
8361 * Set the value of a number option, and take care of side effects.
8362 * Returns NULL for success, or an error message for an error.
8363 */
8364 static char_u *
Bram Moolenaar555b2802005-05-19 21:08:39 +00008365set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008366 int opt_idx; /* index in options[] table */
8367 char_u *varp; /* pointer to the option variable */
8368 long value; /* new value */
8369 char_u *errbuf; /* buffer for error messages */
Bram Moolenaar555b2802005-05-19 21:08:39 +00008370 size_t errbuflen; /* length of "errbuf" */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008371 int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and
8372 OPT_MODELINE */
8373{
8374 char_u *errmsg = NULL;
8375 long old_value = *(long *)varp;
8376 long old_Rows = Rows; /* remember old Rows */
8377 long old_Columns = Columns; /* remember old Columns */
8378 long *pp = (long *)varp;
8379
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008380 /* Disallow changing some options from secure mode. */
8381 if ((secure
8382#ifdef HAVE_SANDBOX
8383 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008384#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008385 ) && (options[opt_idx].flags & P_SECURE))
8386 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008387
8388 *pp = value;
8389#ifdef FEAT_EVAL
8390 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008391 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008392#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008393#ifdef FEAT_GUI
8394 need_mouse_correct = TRUE;
8395#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008396
Bram Moolenaar14f24742012-08-08 18:01:05 +02008397 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008398 {
8399 errmsg = e_positive;
8400 curbuf->b_p_sw = curbuf->b_p_ts;
8401 }
8402
8403 /*
8404 * Number options that need some action when changed
8405 */
8406#ifdef FEAT_WINDOWS
8407 if (pp == &p_wh || pp == &p_hh)
8408 {
8409 if (p_wh < 1)
8410 {
8411 errmsg = e_positive;
8412 p_wh = 1;
8413 }
8414 if (p_wmh > p_wh)
8415 {
8416 errmsg = e_winheight;
8417 p_wh = p_wmh;
8418 }
8419 if (p_hh < 0)
8420 {
8421 errmsg = e_positive;
8422 p_hh = 0;
8423 }
8424
8425 /* Change window height NOW */
8426 if (lastwin != firstwin)
8427 {
8428 if (pp == &p_wh && curwin->w_height < p_wh)
8429 win_setheight((int)p_wh);
8430 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8431 win_setheight((int)p_hh);
8432 }
8433 }
8434
8435 /* 'winminheight' */
8436 else if (pp == &p_wmh)
8437 {
8438 if (p_wmh < 0)
8439 {
8440 errmsg = e_positive;
8441 p_wmh = 0;
8442 }
8443 if (p_wmh > p_wh)
8444 {
8445 errmsg = e_winheight;
8446 p_wmh = p_wh;
8447 }
8448 win_setminheight();
8449 }
8450
8451# ifdef FEAT_VERTSPLIT
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008452 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008453 {
8454 if (p_wiw < 1)
8455 {
8456 errmsg = e_positive;
8457 p_wiw = 1;
8458 }
8459 if (p_wmw > p_wiw)
8460 {
8461 errmsg = e_winwidth;
8462 p_wiw = p_wmw;
8463 }
8464
8465 /* Change window width NOW */
8466 if (lastwin != firstwin && curwin->w_width < p_wiw)
8467 win_setwidth((int)p_wiw);
8468 }
8469
8470 /* 'winminwidth' */
8471 else if (pp == &p_wmw)
8472 {
8473 if (p_wmw < 0)
8474 {
8475 errmsg = e_positive;
8476 p_wmw = 0;
8477 }
8478 if (p_wmw > p_wiw)
8479 {
8480 errmsg = e_winwidth;
8481 p_wmw = p_wiw;
8482 }
8483 win_setminheight();
8484 }
8485# endif
8486
8487#endif
8488
8489#ifdef FEAT_WINDOWS
8490 /* (re)set last window status line */
8491 else if (pp == &p_ls)
8492 {
8493 last_status(FALSE);
8494 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008495
8496 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008497 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008498 {
8499 shell_new_rows(); /* recompute window positions and heights */
8500 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008501#endif
8502
8503#ifdef FEAT_GUI
8504 else if (pp == &p_linespace)
8505 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008506 /* Recompute gui.char_height and resize the Vim window to keep the
8507 * same number of lines. */
8508 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008509 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008510 }
8511#endif
8512
8513#ifdef FEAT_FOLDING
8514 /* 'foldlevel' */
8515 else if (pp == &curwin->w_p_fdl)
8516 {
8517 if (curwin->w_p_fdl < 0)
8518 curwin->w_p_fdl = 0;
8519 newFoldLevel();
8520 }
8521
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008522 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008523 else if (pp == &curwin->w_p_fml)
8524 {
8525 foldUpdateAll(curwin);
8526 }
8527
8528 /* 'foldnestmax' */
8529 else if (pp == &curwin->w_p_fdn)
8530 {
8531 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8532 foldUpdateAll(curwin);
8533 }
8534
8535 /* 'foldcolumn' */
8536 else if (pp == &curwin->w_p_fdc)
8537 {
8538 if (curwin->w_p_fdc < 0)
8539 {
8540 errmsg = e_positive;
8541 curwin->w_p_fdc = 0;
8542 }
8543 else if (curwin->w_p_fdc > 12)
8544 {
8545 errmsg = e_invarg;
8546 curwin->w_p_fdc = 12;
8547 }
8548 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008549#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008550
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008551#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008552 /* 'shiftwidth' or 'tabstop' */
8553 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8554 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008555# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008556 if (foldmethodIsIndent(curwin))
8557 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008558# endif
8559# ifdef FEAT_CINDENT
8560 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8561 * parse 'cinoptions'. */
8562 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8563 parse_cino(curbuf);
8564# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008565 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008566#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008567
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008568#ifdef FEAT_MBYTE
8569 /* 'maxcombine' */
8570 else if (pp == &p_mco)
8571 {
8572 if (p_mco > MAX_MCO)
8573 p_mco = MAX_MCO;
8574 else if (p_mco < 0)
8575 p_mco = 0;
8576 screenclear(); /* will re-allocate the screen */
8577 }
8578#endif
8579
Bram Moolenaar071d4272004-06-13 20:20:40 +00008580 else if (pp == &curbuf->b_p_iminsert)
8581 {
8582 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8583 {
8584 errmsg = e_invarg;
8585 curbuf->b_p_iminsert = B_IMODE_NONE;
8586 }
8587 p_iminsert = curbuf->b_p_iminsert;
8588 if (termcap_active) /* don't do this in the alternate screen */
8589 showmode();
8590#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8591 /* Show/unshow value of 'keymap' in status lines. */
8592 status_redraw_curbuf();
8593#endif
8594 }
8595
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008596 else if (pp == &p_window)
8597 {
8598 if (p_window < 1)
8599 p_window = 1;
8600 else if (p_window >= Rows)
8601 p_window = Rows - 1;
8602 }
8603
Bram Moolenaar071d4272004-06-13 20:20:40 +00008604 else if (pp == &curbuf->b_p_imsearch)
8605 {
8606 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8607 {
8608 errmsg = e_invarg;
8609 curbuf->b_p_imsearch = B_IMODE_NONE;
8610 }
8611 p_imsearch = curbuf->b_p_imsearch;
8612 }
8613
8614#ifdef FEAT_TITLE
8615 /* if 'titlelen' has changed, redraw the title */
8616 else if (pp == &p_titlelen)
8617 {
8618 if (p_titlelen < 0)
8619 {
8620 errmsg = e_positive;
8621 p_titlelen = 85;
8622 }
8623 if (starting != NO_SCREEN && old_value != p_titlelen)
8624 need_maketitle = TRUE;
8625 }
8626#endif
8627
8628 /* if p_ch changed value, change the command line height */
8629 else if (pp == &p_ch)
8630 {
8631 if (p_ch < 1)
8632 {
8633 errmsg = e_positive;
8634 p_ch = 1;
8635 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008636 if (p_ch > Rows - min_rows() + 1)
8637 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008638
8639 /* Only compute the new window layout when startup has been
8640 * completed. Otherwise the frame sizes may be wrong. */
8641 if (p_ch != old_value && full_screen
8642#ifdef FEAT_GUI
8643 && !gui.starting
8644#endif
8645 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008646 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008647 }
8648
8649 /* when 'updatecount' changes from zero to non-zero, open swap files */
8650 else if (pp == &p_uc)
8651 {
8652 if (p_uc < 0)
8653 {
8654 errmsg = e_positive;
8655 p_uc = 100;
8656 }
8657 if (p_uc && !old_value)
8658 ml_open_files();
8659 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008660#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008661 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008662 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008663 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008664 {
8665 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008666 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008667 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008668 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008669 {
8670 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008671 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008672 }
8673 }
8674#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008675#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008676 else if (pp == &p_mzq)
8677 mzvim_reset_timer();
8678#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008679
8680 /* sync undo before 'undolevels' changes */
8681 else if (pp == &p_ul)
8682 {
8683 /* use the old value, otherwise u_sync() may not work properly */
8684 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00008685 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008686 p_ul = value;
8687 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01008688 else if (pp == &curbuf->b_p_ul)
8689 {
8690 /* use the old value, otherwise u_sync() may not work properly */
8691 curbuf->b_p_ul = old_value;
8692 u_sync(TRUE);
8693 curbuf->b_p_ul = value;
8694 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008695
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008696#ifdef FEAT_LINEBREAK
8697 /* 'numberwidth' must be positive */
8698 else if (pp == &curwin->w_p_nuw)
8699 {
8700 if (curwin->w_p_nuw < 1)
8701 {
8702 errmsg = e_positive;
8703 curwin->w_p_nuw = 1;
8704 }
8705 if (curwin->w_p_nuw > 10)
8706 {
8707 errmsg = e_invarg;
8708 curwin->w_p_nuw = 10;
8709 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02008710 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008711 }
8712#endif
8713
Bram Moolenaar1a384422010-07-14 19:53:30 +02008714 else if (pp == &curbuf->b_p_tw)
8715 {
8716 if (curbuf->b_p_tw < 0)
8717 {
8718 errmsg = e_positive;
8719 curbuf->b_p_tw = 0;
8720 }
8721#ifdef FEAT_SYN_HL
8722# ifdef FEAT_WINDOWS
8723 {
8724 win_T *wp;
8725 tabpage_T *tp;
8726
8727 FOR_ALL_TAB_WINDOWS(tp, wp)
8728 check_colorcolumn(wp);
8729 }
8730# else
8731 check_colorcolumn(curwin);
8732# endif
8733#endif
8734 }
8735
Bram Moolenaar071d4272004-06-13 20:20:40 +00008736 /*
8737 * Check the bounds for numeric options here
8738 */
8739 if (Rows < min_rows() && full_screen)
8740 {
8741 if (errbuf != NULL)
8742 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008743 vim_snprintf((char *)errbuf, errbuflen,
8744 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00008745 errmsg = errbuf;
8746 }
8747 Rows = min_rows();
8748 }
8749 if (Columns < MIN_COLUMNS && full_screen)
8750 {
8751 if (errbuf != NULL)
8752 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008753 vim_snprintf((char *)errbuf, errbuflen,
8754 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008755 errmsg = errbuf;
8756 }
8757 Columns = MIN_COLUMNS;
8758 }
Bram Moolenaare057d402013-06-30 17:51:51 +02008759 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008760
8761#ifdef DJGPP
8762 /* avoid a crash by checking for a too large value of 'columns' */
8763 if (old_Columns != Columns && full_screen && term_console)
8764 mch_check_columns();
8765#endif
8766
8767 /*
8768 * If the screen (shell) height has been changed, assume it is the
8769 * physical screenheight.
8770 */
8771 if (old_Rows != Rows || old_Columns != Columns)
8772 {
8773 /* Changing the screen size is not allowed while updating the screen. */
8774 if (updating_screen)
8775 *pp = old_value;
8776 else if (full_screen
8777#ifdef FEAT_GUI
8778 && !gui.starting
8779#endif
8780 )
8781 set_shellsize((int)Columns, (int)Rows, TRUE);
8782 else
8783 {
8784 /* Postpone the resizing; check the size and cmdline position for
8785 * messages. */
8786 check_shellsize();
8787 if (cmdline_row > Rows - p_ch && Rows > p_ch)
8788 cmdline_row = Rows - p_ch;
8789 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00008790 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008791 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008792 }
8793
Bram Moolenaar071d4272004-06-13 20:20:40 +00008794 if (curbuf->b_p_ts <= 0)
8795 {
8796 errmsg = e_positive;
8797 curbuf->b_p_ts = 8;
8798 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008799 if (p_tm < 0)
8800 {
8801 errmsg = e_positive;
8802 p_tm = 0;
8803 }
8804 if ((curwin->w_p_scr <= 0
8805 || (curwin->w_p_scr > curwin->w_height
8806 && curwin->w_height > 0))
8807 && full_screen)
8808 {
8809 if (pp == &(curwin->w_p_scr))
8810 {
8811 if (curwin->w_p_scr != 0)
8812 errmsg = e_scroll;
8813 win_comp_scroll(curwin);
8814 }
8815 /* If 'scroll' became invalid because of a side effect silently adjust
8816 * it. */
8817 else if (curwin->w_p_scr <= 0)
8818 curwin->w_p_scr = 1;
8819 else /* curwin->w_p_scr > curwin->w_height */
8820 curwin->w_p_scr = curwin->w_height;
8821 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00008822 if (p_hi < 0)
8823 {
8824 errmsg = e_positive;
8825 p_hi = 0;
8826 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02008827 else if (p_hi > 10000)
8828 {
8829 errmsg = e_invarg;
8830 p_hi = 10000;
8831 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02008832 if (p_re < 0 || p_re > 2)
8833 {
8834 errmsg = e_invarg;
8835 p_re = 0;
8836 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008837 if (p_report < 0)
8838 {
8839 errmsg = e_positive;
8840 p_report = 1;
8841 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00008842 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008843 {
8844 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
8845 p_sj = Rows / 2;
8846 else
8847 {
8848 errmsg = e_scroll;
8849 p_sj = 1;
8850 }
8851 }
8852 if (p_so < 0 && full_screen)
8853 {
8854 errmsg = e_scroll;
8855 p_so = 0;
8856 }
8857 if (p_siso < 0 && full_screen)
8858 {
8859 errmsg = e_positive;
8860 p_siso = 0;
8861 }
8862#ifdef FEAT_CMDWIN
8863 if (p_cwh < 1)
8864 {
8865 errmsg = e_positive;
8866 p_cwh = 1;
8867 }
8868#endif
8869 if (p_ut < 0)
8870 {
8871 errmsg = e_positive;
8872 p_ut = 2000;
8873 }
8874 if (p_ss < 0)
8875 {
8876 errmsg = e_positive;
8877 p_ss = 0;
8878 }
8879
8880 /* May set global value for local option. */
8881 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8882 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
8883
8884 options[opt_idx].flags |= P_WAS_SET;
8885
Bram Moolenaar53744302015-07-17 17:38:22 +02008886#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8887 if (!starting && errmsg == NULL)
8888 {
8889 char_u buf_old[11], buf_new[11], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008890 vim_snprintf((char *)buf_old, 10, "%ld", old_value);
8891 vim_snprintf((char *)buf_new, 10, "%ld", value);
8892 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008893 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8894 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8895 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8896 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8897 reset_v_option_vars();
8898 }
8899#endif
8900
Bram Moolenaar071d4272004-06-13 20:20:40 +00008901 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008902 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008903 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008904 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008905 check_redraw(options[opt_idx].flags);
8906
8907 return errmsg;
8908}
8909
8910/*
8911 * Called after an option changed: check if something needs to be redrawn.
8912 */
8913 static void
8914check_redraw(flags)
8915 long_u flags;
8916{
8917 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008918 int doclear = (flags & P_RCLR) == P_RCLR;
8919 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008920
8921#ifdef FEAT_WINDOWS
8922 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
8923 status_redraw_all();
8924#endif
8925
8926 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
8927 changed_window_setting();
8928 if (flags & P_RBUF)
8929 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008930 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008931 redraw_all_later(CLEAR);
8932 else if (all)
8933 redraw_all_later(NOT_VALID);
8934}
8935
8936/*
8937 * Find index for option 'arg'.
8938 * Return -1 if not found.
8939 */
8940 static int
8941findoption(arg)
8942 char_u *arg;
8943{
8944 int opt_idx;
8945 char *s, *p;
8946 static short quick_tab[27] = {0, 0}; /* quick access table */
8947 int is_term_opt;
8948
8949 /*
8950 * For first call: Initialize the quick-access table.
8951 * It contains the index for the first option that starts with a certain
8952 * letter. There are 26 letters, plus the first "t_" option.
8953 */
8954 if (quick_tab[1] == 0)
8955 {
8956 p = options[0].fullname;
8957 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8958 {
8959 if (s[0] != p[0])
8960 {
8961 if (s[0] == 't' && s[1] == '_')
8962 quick_tab[26] = opt_idx;
8963 else
8964 quick_tab[CharOrdLow(s[0])] = opt_idx;
8965 }
8966 p = s;
8967 }
8968 }
8969
8970 /*
8971 * Check for name starting with an illegal character.
8972 */
8973#ifdef EBCDIC
8974 if (!islower(arg[0]))
8975#else
8976 if (arg[0] < 'a' || arg[0] > 'z')
8977#endif
8978 return -1;
8979
8980 is_term_opt = (arg[0] == 't' && arg[1] == '_');
8981 if (is_term_opt)
8982 opt_idx = quick_tab[26];
8983 else
8984 opt_idx = quick_tab[CharOrdLow(arg[0])];
8985 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8986 {
8987 if (STRCMP(arg, s) == 0) /* match full name */
8988 break;
8989 }
8990 if (s == NULL && !is_term_opt)
8991 {
8992 opt_idx = quick_tab[CharOrdLow(arg[0])];
8993 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
8994 {
8995 s = options[opt_idx].shortname;
8996 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
8997 break;
8998 s = NULL;
8999 }
9000 }
9001 if (s == NULL)
9002 opt_idx = -1;
9003 return opt_idx;
9004}
9005
Bram Moolenaar325b7a22004-07-05 15:58:32 +00009006#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009007/*
9008 * Get the value for an option.
9009 *
9010 * Returns:
9011 * Number or Toggle option: 1, *numval gets value.
9012 * String option: 0, *stringval gets allocated string.
9013 * Hidden Number or Toggle option: -1.
9014 * hidden String option: -2.
9015 * unknown option: -3.
9016 */
9017 int
9018get_option_value(name, numval, stringval, opt_flags)
9019 char_u *name;
9020 long *numval;
Bram Moolenaar370df582010-06-22 05:16:38 +02009021 char_u **stringval; /* NULL when only checking existence */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009022 int opt_flags;
9023{
9024 int opt_idx;
9025 char_u *varp;
9026
9027 opt_idx = findoption(name);
9028 if (opt_idx < 0) /* unknown option */
9029 return -3;
9030
9031 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
9032
9033 if (options[opt_idx].flags & P_STRING)
9034 {
9035 if (varp == NULL) /* hidden option */
9036 return -2;
9037 if (stringval != NULL)
9038 {
9039#ifdef FEAT_CRYPT
9040 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00009041 if ((char_u **)varp == &curbuf->b_p_key
9042 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009043 *stringval = vim_strsave((char_u *)"*****");
9044 else
9045#endif
9046 *stringval = vim_strsave(*(char_u **)(varp));
9047 }
9048 return 0;
9049 }
9050
9051 if (varp == NULL) /* hidden option */
9052 return -1;
9053 if (options[opt_idx].flags & P_NUM)
9054 *numval = *(long *)varp;
9055 else
9056 {
9057 /* Special case: 'modified' is b_changed, but we also want to consider
9058 * it set when 'ff' or 'fenc' changed. */
9059 if ((int *)varp == &curbuf->b_changed)
9060 *numval = curbufIsChanged();
9061 else
9062 *numval = *(int *)varp;
9063 }
9064 return 1;
9065}
9066#endif
9067
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009068#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009069/*
9070 * Returns the option attributes and its value. Unlike the above function it
9071 * will return either global value or local value of the option depending on
9072 * what was requested, but it will never return global value if it was
9073 * requested to return local one and vice versa. Neither it will return
9074 * buffer-local value if it was requested to return window-local one.
9075 *
9076 * Pretends that option is absent if it is not present in the requested scope
9077 * (i.e. has no global, window-local or buffer-local value depending on
9078 * opt_type). Uses
9079 *
9080 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009081 * 0 hidden or unknown option, also option that does not have requested
9082 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009083 * see SOPT_* in vim.h for other flags
9084 *
9085 * Possible opt_type values: see SREQ_* in vim.h
9086 */
9087 int
9088get_option_value_strict(name, numval, stringval, opt_type, from)
9089 char_u *name;
9090 long *numval;
9091 char_u **stringval; /* NULL when only obtaining attributes */
9092 int opt_type;
9093 void *from;
9094{
9095 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009096 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009097 struct vimoption *p;
9098 int r = 0;
9099
9100 opt_idx = findoption(name);
9101 if (opt_idx < 0)
9102 return 0;
9103
9104 p = &(options[opt_idx]);
9105
9106 /* Hidden option */
9107 if (p->var == NULL)
9108 return 0;
9109
9110 if (p->flags & P_BOOL)
9111 r |= SOPT_BOOL;
9112 else if (p->flags & P_NUM)
9113 r |= SOPT_NUM;
9114 else if (p->flags & P_STRING)
9115 r |= SOPT_STRING;
9116
9117 if (p->indir == PV_NONE)
9118 {
9119 if (opt_type == SREQ_GLOBAL)
9120 r |= SOPT_GLOBAL;
9121 else
9122 return 0; /* Did not request global-only option */
9123 }
9124 else
9125 {
9126 if (p->indir & PV_BOTH)
9127 r |= SOPT_GLOBAL;
9128 else if (opt_type == SREQ_GLOBAL)
9129 return 0; /* Requested global option */
9130
9131 if (p->indir & PV_WIN)
9132 {
9133 if (opt_type == SREQ_BUF)
9134 return 0; /* Did not request window-local option */
9135 else
9136 r |= SOPT_WIN;
9137 }
9138 else if (p->indir & PV_BUF)
9139 {
9140 if (opt_type == SREQ_WIN)
9141 return 0; /* Did not request buffer-local option */
9142 else
9143 r |= SOPT_BUF;
9144 }
9145 }
9146
9147 if (stringval == NULL)
9148 return r;
9149
9150 if (opt_type == SREQ_GLOBAL)
9151 varp = p->var;
9152 else
9153 {
9154 if (opt_type == SREQ_BUF)
9155 {
9156 /* Special case: 'modified' is b_changed, but we also want to
9157 * consider it set when 'ff' or 'fenc' changed. */
9158 if (p->indir == PV_MOD)
9159 {
9160 *numval = bufIsChanged((buf_T *) from);
9161 varp = NULL;
9162 }
9163#ifdef FEAT_CRYPT
9164 else if (p->indir == PV_KEY)
9165 {
9166 /* never return the value of the crypt key */
9167 *stringval = NULL;
9168 varp = NULL;
9169 }
9170#endif
9171 else
9172 {
9173 aco_save_T aco;
9174 aucmd_prepbuf(&aco, (buf_T *) from);
9175 varp = get_varp(p);
9176 aucmd_restbuf(&aco);
9177 }
9178 }
9179 else if (opt_type == SREQ_WIN)
9180 {
9181 win_T *save_curwin;
9182 save_curwin = curwin;
9183 curwin = (win_T *) from;
9184 curbuf = curwin->w_buffer;
9185 varp = get_varp(p);
9186 curwin = save_curwin;
9187 curbuf = curwin->w_buffer;
9188 }
9189 if (varp == p->var)
9190 return (r | SOPT_UNSET);
9191 }
9192
9193 if (varp != NULL)
9194 {
9195 if (p->flags & P_STRING)
9196 *stringval = vim_strsave(*(char_u **)(varp));
9197 else if (p->flags & P_NUM)
9198 *numval = *(long *) varp;
9199 else
9200 *numval = *(int *)varp;
9201 }
9202
9203 return r;
9204}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009205
9206/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009207 * Iterate over options. First argument is a pointer to a pointer to a
9208 * structure inside options[] array, second is option type like in the above
9209 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009210 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009211 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009212 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009213 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009214 * first argument to NULL.
9215 *
9216 * Returns full option name for current option on each call.
9217 */
9218 char_u *
9219option_iter_next(option, opt_type)
9220 void **option;
9221 int opt_type;
9222{
9223 struct vimoption *ret = NULL;
9224 do
9225 {
9226 if (*option == NULL)
9227 *option = (void *) options;
9228 else if (((struct vimoption *) (*option))->fullname == NULL)
9229 {
9230 *option = NULL;
9231 return NULL;
9232 }
9233 else
9234 *option = (void *) (((struct vimoption *) (*option)) + 1);
9235
9236 ret = ((struct vimoption *) (*option));
9237
9238 /* Hidden option */
9239 if (ret->var == NULL)
9240 {
9241 ret = NULL;
9242 continue;
9243 }
9244
9245 switch (opt_type)
9246 {
9247 case SREQ_GLOBAL:
9248 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9249 ret = NULL;
9250 break;
9251 case SREQ_BUF:
9252 if (!(ret->indir & PV_BUF))
9253 ret = NULL;
9254 break;
9255 case SREQ_WIN:
9256 if (!(ret->indir & PV_WIN))
9257 ret = NULL;
9258 break;
9259 default:
9260 EMSG2(_(e_intern2), "option_iter_next()");
9261 return NULL;
9262 }
9263 }
9264 while (ret == NULL);
9265
9266 return (char_u *)ret->fullname;
9267}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009268#endif
9269
Bram Moolenaar071d4272004-06-13 20:20:40 +00009270/*
9271 * Set the value of option "name".
9272 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009273 *
9274 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009275 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009276 char_u *
Bram Moolenaar071d4272004-06-13 20:20:40 +00009277set_option_value(name, number, string, opt_flags)
9278 char_u *name;
9279 long number;
9280 char_u *string;
9281 int opt_flags; /* OPT_LOCAL or 0 (both) */
9282{
9283 int opt_idx;
9284 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009285 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009286
9287 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009288 if (opt_idx < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009289 EMSG2(_("E355: Unknown option: %s"), name);
9290 else
9291 {
9292 flags = options[opt_idx].flags;
9293#ifdef HAVE_SANDBOX
9294 /* Disallow changing some options in the sandbox */
9295 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009296 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009297 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009298 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009299 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009300#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009301 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009302 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009303 else
9304 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009305 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009306 if (varp != NULL) /* hidden option is not changed */
9307 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009308 if (number == 0 && string != NULL)
9309 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009310 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009311
9312 /* Either we are given a string or we are setting option
9313 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009314 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009315 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009316 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009317 {
9318 /* There's another character after zeros or the string
9319 * is empty. In both cases, we are trying to set a
9320 * num option using a string. */
9321 EMSG3(_("E521: Number required: &%s = '%s'"),
9322 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009323 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009324
9325 }
9326 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009327 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009328 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009329 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009330 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009331 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009332 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009333 }
9334 }
9335 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009336 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009337}
9338
9339/*
9340 * Get the terminal code for a terminal option.
9341 * Returns NULL when not found.
9342 */
9343 char_u *
9344get_term_code(tname)
9345 char_u *tname;
9346{
9347 int opt_idx;
9348 char_u *varp;
9349
9350 if (tname[0] != 't' || tname[1] != '_' ||
9351 tname[2] == NUL || tname[3] == NUL)
9352 return NULL;
9353 if ((opt_idx = findoption(tname)) >= 0)
9354 {
9355 varp = get_varp(&(options[opt_idx]));
9356 if (varp != NULL)
9357 varp = *(char_u **)(varp);
9358 return varp;
9359 }
9360 return find_termcode(tname + 2);
9361}
9362
9363 char_u *
9364get_highlight_default()
9365{
9366 int i;
9367
9368 i = findoption((char_u *)"hl");
9369 if (i >= 0)
9370 return options[i].def_val[VI_DEFAULT];
9371 return (char_u *)NULL;
9372}
9373
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009374#if defined(FEAT_MBYTE) || defined(PROTO)
9375 char_u *
9376get_encoding_default()
9377{
9378 int i;
9379
9380 i = findoption((char_u *)"enc");
9381 if (i >= 0)
9382 return options[i].def_val[VI_DEFAULT];
9383 return (char_u *)NULL;
9384}
9385#endif
9386
Bram Moolenaar071d4272004-06-13 20:20:40 +00009387/*
9388 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9389 */
9390 static int
9391find_key_option(arg)
9392 char_u *arg;
9393{
9394 int key;
9395 int modifiers;
9396
9397 /*
9398 * Don't use get_special_key_code() for t_xx, we don't want it to call
9399 * add_termcap_entry().
9400 */
9401 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9402 key = TERMCAP2KEY(arg[2], arg[3]);
9403 else
9404 {
9405 --arg; /* put arg at the '<' */
9406 modifiers = 0;
Bram Moolenaar2a8ced02008-12-24 11:54:31 +00009407 key = find_special_key(&arg, &modifiers, TRUE, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009408 if (modifiers) /* can't handle modifiers here */
9409 key = 0;
9410 }
9411 return key;
9412}
9413
9414/*
9415 * if 'all' == 0: show changed options
9416 * if 'all' == 1: show all normal options
9417 * if 'all' == 2: show all terminal options
9418 */
9419 static void
9420showoptions(all, opt_flags)
9421 int all;
9422 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
9423{
9424 struct vimoption *p;
9425 int col;
9426 int isterm;
9427 char_u *varp;
9428 struct vimoption **items;
9429 int item_count;
9430 int run;
9431 int row, rows;
9432 int cols;
9433 int i;
9434 int len;
9435
9436#define INC 20
9437#define GAP 3
9438
9439 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9440 PARAM_COUNT));
9441 if (items == NULL)
9442 return;
9443
9444 /* Highlight title */
9445 if (all == 2)
9446 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9447 else if (opt_flags & OPT_GLOBAL)
9448 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9449 else if (opt_flags & OPT_LOCAL)
9450 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9451 else
9452 MSG_PUTS_TITLE(_("\n--- Options ---"));
9453
9454 /*
9455 * do the loop two times:
9456 * 1. display the short items
9457 * 2. display the long items (only strings and numbers)
9458 */
9459 for (run = 1; run <= 2 && !got_int; ++run)
9460 {
9461 /*
9462 * collect the items in items[]
9463 */
9464 item_count = 0;
9465 for (p = &options[0]; p->fullname != NULL; p++)
9466 {
9467 varp = NULL;
9468 isterm = istermoption(p);
9469 if (opt_flags != 0)
9470 {
9471 if (p->indir != PV_NONE && !isterm)
9472 varp = get_varp_scope(p, opt_flags);
9473 }
9474 else
9475 varp = get_varp(p);
9476 if (varp != NULL
9477 && ((all == 2 && isterm)
9478 || (all == 1 && !isterm)
9479 || (all == 0 && !optval_default(p, varp))))
9480 {
9481 if (p->flags & P_BOOL)
9482 len = 1; /* a toggle option fits always */
9483 else
9484 {
9485 option_value2string(p, opt_flags);
9486 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9487 }
9488 if ((len <= INC - GAP && run == 1) ||
9489 (len > INC - GAP && run == 2))
9490 items[item_count++] = p;
9491 }
9492 }
9493
9494 /*
9495 * display the items
9496 */
9497 if (run == 1)
9498 {
9499 cols = (Columns + GAP - 3) / INC;
9500 if (cols == 0)
9501 cols = 1;
9502 rows = (item_count + cols - 1) / cols;
9503 }
9504 else /* run == 2 */
9505 rows = item_count;
9506 for (row = 0; row < rows && !got_int; ++row)
9507 {
9508 msg_putchar('\n'); /* go to next line */
9509 if (got_int) /* 'q' typed in more */
9510 break;
9511 col = 0;
9512 for (i = row; i < item_count; i += rows)
9513 {
9514 msg_col = col; /* make columns */
9515 showoneopt(items[i], opt_flags);
9516 col += INC;
9517 }
9518 out_flush();
9519 ui_breakcheck();
9520 }
9521 }
9522 vim_free(items);
9523}
9524
9525/*
9526 * Return TRUE if option "p" has its default value.
9527 */
9528 static int
9529optval_default(p, varp)
9530 struct vimoption *p;
9531 char_u *varp;
9532{
9533 int dvi;
9534
9535 if (varp == NULL)
9536 return TRUE; /* hidden option is always at default */
9537 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9538 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009539 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009540 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009541 /* the cast to long is required for Manx C, long_i is
9542 * needed for MSVC */
9543 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009544 /* P_STRING */
9545 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9546}
9547
9548/*
9549 * showoneopt: show the value of one option
9550 * must not be called with a hidden option!
9551 */
9552 static void
9553showoneopt(p, opt_flags)
9554 struct vimoption *p;
9555 int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */
9556{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009557 char_u *varp;
9558 int save_silent = silent_mode;
9559
9560 silent_mode = FALSE;
9561 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009562
9563 varp = get_varp_scope(p, opt_flags);
9564
9565 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9566 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9567 ? !curbufIsChanged() : !*(int *)varp))
9568 MSG_PUTS("no");
9569 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9570 MSG_PUTS("--");
9571 else
9572 MSG_PUTS(" ");
9573 MSG_PUTS(p->fullname);
9574 if (!(p->flags & P_BOOL))
9575 {
9576 msg_putchar('=');
9577 /* put value string in NameBuff */
9578 option_value2string(p, opt_flags);
9579 msg_outtrans(NameBuff);
9580 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009581
9582 silent_mode = save_silent;
9583 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009584}
9585
9586/*
9587 * Write modified options as ":set" commands to a file.
9588 *
9589 * There are three values for "opt_flags":
9590 * OPT_GLOBAL: Write global option values and fresh values of
9591 * buffer-local options (used for start of a session
9592 * file).
9593 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
9594 * curwin (used for a vimrc file).
9595 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
9596 * and local values for window-local options of
9597 * curwin. Local values are also written when at the
9598 * default value, because a modeline or autocommand
9599 * may have set them when doing ":edit file" and the
9600 * user has set them back at the default or fresh
9601 * value.
9602 * When "local_only" is TRUE, don't write fresh
9603 * values, only local values (for ":mkview").
9604 * (fresh value = value used for a new buffer or window for a local option).
9605 *
9606 * Return FAIL on error, OK otherwise.
9607 */
9608 int
9609makeset(fd, opt_flags, local_only)
9610 FILE *fd;
9611 int opt_flags;
9612 int local_only;
9613{
9614 struct vimoption *p;
9615 char_u *varp; /* currently used value */
9616 char_u *varp_fresh; /* local value */
9617 char_u *varp_local = NULL; /* fresh value */
9618 char *cmd;
9619 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009620 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009621
9622 /*
9623 * The options that don't have a default (terminal name, columns, lines)
9624 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009625 * Do the loop over "options[]" twice: once for options with the
9626 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009627 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009628 for (pri = 1; pri >= 0; --pri)
9629 {
9630 for (p = &options[0]; !istermoption(p); p++)
9631 if (!(p->flags & P_NO_MKRC)
9632 && !istermoption(p)
9633 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009634 {
9635 /* skip global option when only doing locals */
9636 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
9637 continue;
9638
9639 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
9640 * file, they are always buffer-specific. */
9641 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
9642 continue;
9643
9644 /* Global values are only written when not at the default value. */
9645 varp = get_varp_scope(p, opt_flags);
9646 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
9647 continue;
9648
9649 round = 2;
9650 if (p->indir != PV_NONE)
9651 {
9652 if (p->var == VAR_WIN)
9653 {
9654 /* skip window-local option when only doing globals */
9655 if (!(opt_flags & OPT_LOCAL))
9656 continue;
9657 /* When fresh value of window-local option is not at the
9658 * default, need to write it too. */
9659 if (!(opt_flags & OPT_GLOBAL) && !local_only)
9660 {
9661 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
9662 if (!optval_default(p, varp_fresh))
9663 {
9664 round = 1;
9665 varp_local = varp;
9666 varp = varp_fresh;
9667 }
9668 }
9669 }
9670 }
9671
9672 /* Round 1: fresh value for window-local options.
9673 * Round 2: other values */
9674 for ( ; round <= 2; varp = varp_local, ++round)
9675 {
9676 if (round == 1 || (opt_flags & OPT_GLOBAL))
9677 cmd = "set";
9678 else
9679 cmd = "setlocal";
9680
9681 if (p->flags & P_BOOL)
9682 {
9683 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
9684 return FAIL;
9685 }
9686 else if (p->flags & P_NUM)
9687 {
9688 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
9689 return FAIL;
9690 }
9691 else /* P_STRING */
9692 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009693#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9694 int do_endif = FALSE;
9695
Bram Moolenaar071d4272004-06-13 20:20:40 +00009696 /* Don't set 'syntax' and 'filetype' again if the value is
9697 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009698 if (
9699# if defined(FEAT_SYN_HL)
9700 p->indir == PV_SYN
9701# if defined(FEAT_AUTOCMD)
9702 ||
9703# endif
9704# endif
9705# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009706 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009707# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009708 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00009709 {
9710 if (fprintf(fd, "if &%s != '%s'", p->fullname,
9711 *(char_u **)(varp)) < 0
9712 || put_eol(fd) < 0)
9713 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009714 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009715 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009716#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009717 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
9718 (p->flags & P_EXPAND) != 0) == FAIL)
9719 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009720#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9721 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009722 {
9723 if (put_line(fd, "endif") == FAIL)
9724 return FAIL;
9725 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009726#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009727 }
9728 }
9729 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009730 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009731 return OK;
9732}
9733
9734#if defined(FEAT_FOLDING) || defined(PROTO)
9735/*
9736 * Generate set commands for the local fold options only. Used when
9737 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
9738 */
9739 int
9740makefoldset(fd)
9741 FILE *fd;
9742{
9743 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
9744# ifdef FEAT_EVAL
9745 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
9746 == FAIL
9747# endif
9748 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
9749 == FAIL
9750 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
9751 == FAIL
9752 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
9753 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
9754 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
9755 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
9756 )
9757 return FAIL;
9758
9759 return OK;
9760}
9761#endif
9762
9763 static int
9764put_setstring(fd, cmd, name, valuep, expand)
9765 FILE *fd;
9766 char *cmd;
9767 char *name;
9768 char_u **valuep;
9769 int expand;
9770{
9771 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009772 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009773
9774 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9775 return FAIL;
9776 if (*valuep != NULL)
9777 {
9778 /* Output 'pastetoggle' as key names. For other
9779 * options some characters have to be escaped with
9780 * CTRL-V or backslash */
9781 if (valuep == &p_pt)
9782 {
9783 s = *valuep;
9784 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +00009785 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009786 return FAIL;
9787 }
9788 else if (expand)
9789 {
Bram Moolenaarf8441472011-04-28 17:24:58 +02009790 buf = alloc(MAXPATHL);
9791 if (buf == NULL)
9792 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009793 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
9794 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +02009795 {
9796 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009797 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009798 }
9799 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009800 }
9801 else if (put_escstr(fd, *valuep, 2) == FAIL)
9802 return FAIL;
9803 }
9804 if (put_eol(fd) < 0)
9805 return FAIL;
9806 return OK;
9807}
9808
9809 static int
9810put_setnum(fd, cmd, name, valuep)
9811 FILE *fd;
9812 char *cmd;
9813 char *name;
9814 long *valuep;
9815{
9816 long wc;
9817
9818 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9819 return FAIL;
9820 if (wc_use_keyname((char_u *)valuep, &wc))
9821 {
9822 /* print 'wildchar' and 'wildcharm' as a key name */
9823 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
9824 return FAIL;
9825 }
9826 else if (fprintf(fd, "%ld", *valuep) < 0)
9827 return FAIL;
9828 if (put_eol(fd) < 0)
9829 return FAIL;
9830 return OK;
9831}
9832
9833 static int
9834put_setbool(fd, cmd, name, value)
9835 FILE *fd;
9836 char *cmd;
9837 char *name;
9838 int value;
9839{
Bram Moolenaar893de922007-10-02 18:40:57 +00009840 if (value < 0) /* global/local option using global value */
9841 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009842 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
9843 || put_eol(fd) < 0)
9844 return FAIL;
9845 return OK;
9846}
9847
9848/*
9849 * Clear all the terminal options.
9850 * If the option has been allocated, free the memory.
9851 * Terminal options are never hidden or indirect.
9852 */
9853 void
9854clear_termoptions()
9855{
Bram Moolenaar071d4272004-06-13 20:20:40 +00009856 /*
9857 * Reset a few things before clearing the old options. This may cause
9858 * outputting a few things that the terminal doesn't understand, but the
9859 * screen will be cleared later, so this is OK.
9860 */
9861#ifdef FEAT_MOUSE_TTY
9862 mch_setmouse(FALSE); /* switch mouse off */
9863#endif
9864#ifdef FEAT_TITLE
9865 mch_restore_title(3); /* restore window titles */
9866#endif
9867#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
9868 /* When starting the GUI close the display opened for the clipboard.
9869 * After restoring the title, because that will need the display. */
9870 if (gui.starting)
9871 clear_xterm_clip();
9872#endif
9873#ifdef WIN3264
9874 /*
9875 * Check if this is allowed now.
9876 */
9877 if (can_end_termcap_mode(FALSE) == TRUE)
9878#endif
9879 stoptermcap(); /* stop termcap mode */
9880
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00009881 free_termoptions();
9882}
9883
9884 void
9885free_termoptions()
9886{
9887 struct vimoption *p;
9888
Bram Moolenaar071d4272004-06-13 20:20:40 +00009889 for (p = &options[0]; p->fullname != NULL; p++)
9890 if (istermoption(p))
9891 {
9892 if (p->flags & P_ALLOCED)
9893 free_string_option(*(char_u **)(p->var));
9894 if (p->flags & P_DEF_ALLOCED)
9895 free_string_option(p->def_val[VI_DEFAULT]);
9896 *(char_u **)(p->var) = empty_option;
9897 p->def_val[VI_DEFAULT] = empty_option;
9898 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
9899 }
9900 clear_termcodes();
9901}
9902
9903/*
Bram Moolenaar363cb672009-07-22 12:28:17 +00009904 * Free the string for one term option, if it was allocated.
9905 * Set the string to empty_option and clear allocated flag.
9906 * "var" points to the option value.
9907 */
9908 void
9909free_one_termoption(var)
9910 char_u *var;
9911{
9912 struct vimoption *p;
9913
9914 for (p = &options[0]; p->fullname != NULL; p++)
9915 if (p->var == var)
9916 {
9917 if (p->flags & P_ALLOCED)
9918 free_string_option(*(char_u **)(p->var));
9919 *(char_u **)(p->var) = empty_option;
9920 p->flags &= ~P_ALLOCED;
9921 break;
9922 }
9923}
9924
9925/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00009926 * Set the terminal option defaults to the current value.
9927 * Used after setting the terminal name.
9928 */
9929 void
9930set_term_defaults()
9931{
9932 struct vimoption *p;
9933
9934 for (p = &options[0]; p->fullname != NULL; p++)
9935 {
9936 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
9937 {
9938 if (p->flags & P_DEF_ALLOCED)
9939 {
9940 free_string_option(p->def_val[VI_DEFAULT]);
9941 p->flags &= ~P_DEF_ALLOCED;
9942 }
9943 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
9944 if (p->flags & P_ALLOCED)
9945 {
9946 p->flags |= P_DEF_ALLOCED;
9947 p->flags &= ~P_ALLOCED; /* don't free the value now */
9948 }
9949 }
9950 }
9951}
9952
9953/*
9954 * return TRUE if 'p' starts with 't_'
9955 */
9956 static int
9957istermoption(p)
9958 struct vimoption *p;
9959{
9960 return (p->fullname[0] == 't' && p->fullname[1] == '_');
9961}
9962
9963/*
9964 * Compute columns for ruler and shown command. 'sc_col' is also used to
9965 * decide what the maximum length of a message on the status line can be.
9966 * If there is a status line for the last window, 'sc_col' is independent
9967 * of 'ru_col'.
9968 */
9969
9970#define COL_RULER 17 /* columns needed by standard ruler */
9971
9972 void
9973comp_col()
9974{
9975#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
9976 int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin));
9977
9978 sc_col = 0;
9979 ru_col = 0;
9980 if (p_ru)
9981 {
9982#ifdef FEAT_STL_OPT
9983 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
9984#else
9985 ru_col = COL_RULER + 1;
9986#endif
9987 /* no last status line, adjust sc_col */
9988 if (!last_has_status)
9989 sc_col = ru_col;
9990 }
9991 if (p_sc)
9992 {
9993 sc_col += SHOWCMD_COLS;
9994 if (!p_ru || last_has_status) /* no need for separating space */
9995 ++sc_col;
9996 }
9997 sc_col = Columns - sc_col;
9998 ru_col = Columns - ru_col;
9999 if (sc_col <= 0) /* screen too narrow, will become a mess */
10000 sc_col = 1;
10001 if (ru_col <= 0)
10002 ru_col = 1;
10003#else
10004 sc_col = Columns;
10005 ru_col = Columns;
10006#endif
10007}
10008
10009/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010010 * Unset local option value, similar to ":set opt<".
10011 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010012 void
10013unset_global_local_option(name, from)
10014 char_u *name;
10015 void *from;
10016{
10017 struct vimoption *p;
10018 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010019 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010020
10021 opt_idx = findoption(name);
Bram Moolenaarbd8539a2015-08-11 18:53:03 +020010022 if (opt_idx < 0)
10023 return;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010024 p = &(options[opt_idx]);
10025
10026 switch ((int)p->indir)
10027 {
10028 /* global option with local value: use local value if it's been set */
10029 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010030 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010031 break;
10032 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010033 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010034 break;
10035 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010036 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010037 break;
10038 case PV_AR:
10039 buf->b_p_ar = -1;
10040 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010041 case PV_BKC:
10042 clear_string_option(&buf->b_p_bkc);
10043 buf->b_bkc_flags = 0;
10044 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010045 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010046 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010047 break;
10048#ifdef FEAT_FIND_ID
10049 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010050 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010051 break;
10052 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010053 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010054 break;
10055#endif
10056#ifdef FEAT_INS_EXPAND
10057 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010058 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010059 break;
10060 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010061 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010062 break;
10063#endif
10064#ifdef FEAT_QUICKFIX
10065 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010066 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010067 break;
10068 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010069 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010070 break;
10071 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010072 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010073 break;
10074#endif
10075#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10076 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010077 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010078 break;
10079#endif
10080#if defined(FEAT_CRYPT)
10081 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010082 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010083 break;
10084#endif
10085#ifdef FEAT_STL_OPT
10086 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010087 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010088 break;
10089#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010090 case PV_UL:
10091 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10092 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010093#ifdef FEAT_LISP
10094 case PV_LW:
10095 clear_string_option(&buf->b_p_lw);
10096 break;
10097#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010098 }
10099}
10100
10101/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010102 * Get pointer to option variable, depending on local or global scope.
10103 */
10104 static char_u *
10105get_varp_scope(p, opt_flags)
10106 struct vimoption *p;
10107 int opt_flags;
10108{
10109 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10110 {
10111 if (p->var == VAR_WIN)
10112 return (char_u *)GLOBAL_WO(get_varp(p));
10113 return p->var;
10114 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010115 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010116 {
10117 switch ((int)p->indir)
10118 {
10119#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010120 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10121 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10122 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010123#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010124 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10125 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10126 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010127 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010128 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010129#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010130 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10131 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010132#endif
10133#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010134 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10135 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010136#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010137#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10138 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10139#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010140#if defined(FEAT_CRYPT)
10141 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10142#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010143#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010144 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010145#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010146 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010147#ifdef FEAT_LISP
10148 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10149#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010150 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010151 }
10152 return NULL; /* "cannot happen" */
10153 }
10154 return get_varp(p);
10155}
10156
10157/*
10158 * Get pointer to option variable.
10159 */
10160 static char_u *
10161get_varp(p)
10162 struct vimoption *p;
10163{
10164 /* hidden option, always return NULL */
10165 if (p->var == NULL)
10166 return NULL;
10167
10168 switch ((int)p->indir)
10169 {
10170 case PV_NONE: return p->var;
10171
10172 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010173 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010174 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010175 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010176 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010177 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010178 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010179 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010180 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010181 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010182 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010183 case PV_BKC: return *curbuf->b_p_bkc != NUL
10184 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010185#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010186 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010187 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010188 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010189 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10190#endif
10191#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010192 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010193 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010194 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010195 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10196#endif
10197#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010198 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010199 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010200 case PV_GP: return *curbuf->b_p_gp != NUL
10201 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10202 case PV_MP: return *curbuf->b_p_mp != NUL
10203 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010204#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010205#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10206 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10207 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10208#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010209#if defined(FEAT_CRYPT)
10210 case PV_CM: return *curbuf->b_p_cm != NUL
10211 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10212#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010213#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010214 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010215 ? (char_u *)&(curwin->w_p_stl) : p->var;
10216#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010217 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10218 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010219#ifdef FEAT_LISP
10220 case PV_LW: return *curbuf->b_p_lw != NUL
10221 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10222#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010223
10224#ifdef FEAT_ARABIC
10225 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10226#endif
10227 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010228#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010229 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10230#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010231#ifdef FEAT_SYN_HL
10232 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10233 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010234 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010235#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010236#ifdef FEAT_DIFF
10237 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10238#endif
10239#ifdef FEAT_FOLDING
10240 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10241 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10242 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10243 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10244 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10245 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10246 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10247# ifdef FEAT_EVAL
10248 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10249 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10250# endif
10251 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10252#endif
10253 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010254 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010255#ifdef FEAT_LINEBREAK
10256 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10257#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010258#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010259 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
10260#endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010261#ifdef FEAT_VERTSPLIT
10262 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10263#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010264#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10265 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10266#endif
10267#ifdef FEAT_RIGHTLEFT
10268 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10269 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10270#endif
10271 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10272 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10273#ifdef FEAT_LINEBREAK
10274 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010275 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10276 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010277#endif
10278#ifdef FEAT_SCROLLBIND
10279 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10280#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010281#ifdef FEAT_CURSORBIND
10282 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10283#endif
10284#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010285 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10286 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010287#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010288
10289 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10290 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10291#ifdef FEAT_MBYTE
10292 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10293#endif
10294#if defined(FEAT_QUICKFIX)
10295 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10296 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
10297#endif
10298 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10299 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10300#ifdef FEAT_CINDENT
10301 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10302 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10303 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10304#endif
10305#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10306 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10307#endif
10308#ifdef FEAT_COMMENTS
10309 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10310#endif
10311#ifdef FEAT_FOLDING
10312 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10313#endif
10314#ifdef FEAT_INS_EXPAND
10315 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10316#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010317#ifdef FEAT_COMPL_FUNC
10318 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010319 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010320#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010321 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010322 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010323 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10324#ifdef FEAT_MBYTE
10325 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10326#endif
10327 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10328#ifdef FEAT_AUTOCMD
10329 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10330#endif
10331 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010332 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010333 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10334 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10335 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10336 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10337#ifdef FEAT_FIND_ID
10338# ifdef FEAT_EVAL
10339 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10340# endif
10341#endif
10342#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10343 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10344 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10345#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010346#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010347 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10348#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010349#ifdef FEAT_CRYPT
10350 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10351#endif
10352#ifdef FEAT_LISP
10353 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10354#endif
10355 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10356 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10357 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10358 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10359 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010360 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010361#ifdef FEAT_TEXTOBJ
10362 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10363#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010364 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10365#ifdef FEAT_SMARTINDENT
10366 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10367#endif
10368#ifndef SHORT_FNAME
10369 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
10370#endif
10371 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10372#ifdef FEAT_SEARCHPATH
10373 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10374#endif
10375 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10376#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010377 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010378 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10379#endif
10380#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010381 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10382 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10383 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010384#endif
10385 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10386 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10387 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10388 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010389#ifdef FEAT_PERSISTENT_UNDO
10390 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10391#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010392 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10393#ifdef FEAT_KEYMAP
10394 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10395#endif
10396 default: EMSG(_("E356: get_varp ERROR"));
10397 }
10398 /* always return a valid pointer to avoid a crash! */
10399 return (char_u *)&(curbuf->b_p_wm);
10400}
10401
10402/*
10403 * Get the value of 'equalprg', either the buffer-local one or the global one.
10404 */
10405 char_u *
10406get_equalprg()
10407{
10408 if (*curbuf->b_p_ep == NUL)
10409 return p_ep;
10410 return curbuf->b_p_ep;
10411}
10412
10413#if defined(FEAT_WINDOWS) || defined(PROTO)
10414/*
10415 * Copy options from one window to another.
10416 * Used when splitting a window.
10417 */
10418 void
10419win_copy_options(wp_from, wp_to)
10420 win_T *wp_from;
10421 win_T *wp_to;
10422{
10423 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10424 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10425# ifdef FEAT_RIGHTLEFT
10426# ifdef FEAT_FKMAP
10427 /* Is this right? */
10428 wp_to->w_farsi = wp_from->w_farsi;
10429# endif
10430# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020010431#if defined(FEAT_LINEBREAK)
10432 briopt_check(wp_to);
10433#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010434}
10435#endif
10436
10437/*
10438 * Copy the options from one winopt_T to another.
10439 * Doesn't free the old option values in "to", use clear_winopt() for that.
10440 * The 'scroll' option is not copied, because it depends on the window height.
10441 * The 'previewwindow' option is reset, there can be only one preview window.
10442 */
10443 void
10444copy_winopt(from, to)
10445 winopt_T *from;
10446 winopt_T *to;
10447{
10448#ifdef FEAT_ARABIC
10449 to->wo_arab = from->wo_arab;
10450#endif
10451 to->wo_list = from->wo_list;
10452 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010453 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010454#ifdef FEAT_LINEBREAK
10455 to->wo_nuw = from->wo_nuw;
10456#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010457#ifdef FEAT_RIGHTLEFT
10458 to->wo_rl = from->wo_rl;
10459 to->wo_rlc = vim_strsave(from->wo_rlc);
10460#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010461#ifdef FEAT_STL_OPT
10462 to->wo_stl = vim_strsave(from->wo_stl);
10463#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010464 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010465#ifdef FEAT_DIFF
10466 to->wo_wrap_save = from->wo_wrap_save;
10467#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010468#ifdef FEAT_LINEBREAK
10469 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020010470 to->wo_bri = from->wo_bri;
10471 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010472#endif
10473#ifdef FEAT_SCROLLBIND
10474 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010475 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010476#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010477#ifdef FEAT_CURSORBIND
10478 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010479 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010480#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010481#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010482 to->wo_spell = from->wo_spell;
10483#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010484#ifdef FEAT_SYN_HL
10485 to->wo_cuc = from->wo_cuc;
10486 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010487 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010488#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010489#ifdef FEAT_DIFF
10490 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010491 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010492#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010493#ifdef FEAT_CONCEAL
10494 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010495 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010496#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010497#ifdef FEAT_FOLDING
10498 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010499 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010500 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010501 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010502 to->wo_fdi = vim_strsave(from->wo_fdi);
10503 to->wo_fml = from->wo_fml;
10504 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010505 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010506 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010507 to->wo_fdm_save = from->wo_diff_saved
10508 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010509 to->wo_fdn = from->wo_fdn;
10510# ifdef FEAT_EVAL
10511 to->wo_fde = vim_strsave(from->wo_fde);
10512 to->wo_fdt = vim_strsave(from->wo_fdt);
10513# endif
10514 to->wo_fmr = vim_strsave(from->wo_fmr);
10515#endif
10516 check_winopt(to); /* don't want NULL pointers */
10517}
10518
10519/*
10520 * Check string options in a window for a NULL value.
10521 */
10522 void
10523check_win_options(win)
10524 win_T *win;
10525{
10526 check_winopt(&win->w_onebuf_opt);
10527 check_winopt(&win->w_allbuf_opt);
10528}
10529
10530/*
10531 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10532 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020010533 static void
Bram Moolenaar071d4272004-06-13 20:20:40 +000010534check_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010535 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010536{
10537#ifdef FEAT_FOLDING
10538 check_string_option(&wop->wo_fdi);
10539 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010540 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010541# ifdef FEAT_EVAL
10542 check_string_option(&wop->wo_fde);
10543 check_string_option(&wop->wo_fdt);
10544# endif
10545 check_string_option(&wop->wo_fmr);
10546#endif
10547#ifdef FEAT_RIGHTLEFT
10548 check_string_option(&wop->wo_rlc);
10549#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010550#ifdef FEAT_STL_OPT
10551 check_string_option(&wop->wo_stl);
10552#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010553#ifdef FEAT_SYN_HL
10554 check_string_option(&wop->wo_cc);
10555#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010556#ifdef FEAT_CONCEAL
10557 check_string_option(&wop->wo_cocu);
10558#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010559#ifdef FEAT_LINEBREAK
10560 check_string_option(&wop->wo_briopt);
10561#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010562}
10563
10564/*
10565 * Free the allocated memory inside a winopt_T.
10566 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010567 void
10568clear_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010569 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010570{
10571#ifdef FEAT_FOLDING
10572 clear_string_option(&wop->wo_fdi);
10573 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010574 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010575# ifdef FEAT_EVAL
10576 clear_string_option(&wop->wo_fde);
10577 clear_string_option(&wop->wo_fdt);
10578# endif
10579 clear_string_option(&wop->wo_fmr);
10580#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010581#ifdef FEAT_LINEBREAK
10582 clear_string_option(&wop->wo_briopt);
10583#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010584#ifdef FEAT_RIGHTLEFT
10585 clear_string_option(&wop->wo_rlc);
10586#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010587#ifdef FEAT_STL_OPT
10588 clear_string_option(&wop->wo_stl);
10589#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010590#ifdef FEAT_SYN_HL
10591 clear_string_option(&wop->wo_cc);
10592#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010593#ifdef FEAT_CONCEAL
10594 clear_string_option(&wop->wo_cocu);
10595#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010596}
10597
10598/*
10599 * Copy global option values to local options for one buffer.
10600 * Used when creating a new buffer and sometimes when entering a buffer.
10601 * flags:
10602 * BCO_ENTER We will enter the buf buffer.
10603 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
10604 * appropriate.
10605 * BCO_NOHELP Don't copy the values to a help buffer.
10606 */
10607 void
10608buf_copy_options(buf, flags)
10609 buf_T *buf;
10610 int flags;
10611{
10612 int should_copy = TRUE;
10613 char_u *save_p_isk = NULL; /* init for GCC */
10614 int dont_do_help;
10615 int did_isk = FALSE;
10616
10617 /*
Bram Moolenaar1a384422010-07-14 19:53:30 +020010618 * Don't do anything if the buffer is invalid.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010619 */
10620 if (buf == NULL || !buf_valid(buf))
10621 return;
10622
10623 /*
10624 * Skip this when the option defaults have not been set yet. Happens when
10625 * main() allocates the first buffer.
10626 */
10627 if (p_cpo != NULL)
10628 {
10629 /*
10630 * Always copy when entering and 'cpo' contains 'S'.
10631 * Don't copy when already initialized.
10632 * Don't copy when 'cpo' contains 's' and not entering.
10633 * 'S' BCO_ENTER initialized 's' should_copy
10634 * yes yes X X TRUE
10635 * yes no yes X FALSE
10636 * no X yes X FALSE
10637 * X no no yes FALSE
10638 * X no no no TRUE
10639 * no yes no X TRUE
10640 */
10641 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
10642 && (buf->b_p_initialized
10643 || (!(flags & BCO_ENTER)
10644 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
10645 should_copy = FALSE;
10646
10647 if (should_copy || (flags & BCO_ALWAYS))
10648 {
10649 /* Don't copy the options specific to a help buffer when
10650 * BCO_NOHELP is given or the options were initialized already
10651 * (jumping back to a help file with CTRL-T or CTRL-O) */
10652 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
10653 || buf->b_p_initialized;
10654 if (dont_do_help) /* don't free b_p_isk */
10655 {
10656 save_p_isk = buf->b_p_isk;
10657 buf->b_p_isk = NULL;
10658 }
10659 /*
10660 * Always free the allocated strings.
10661 * If not already initialized, set 'readonly' and copy 'fileformat'.
10662 */
10663 if (!buf->b_p_initialized)
10664 {
10665 free_buf_options(buf, TRUE);
10666 buf->b_p_ro = FALSE; /* don't copy readonly */
10667 buf->b_p_tx = p_tx;
10668#ifdef FEAT_MBYTE
10669 buf->b_p_fenc = vim_strsave(p_fenc);
10670#endif
10671 buf->b_p_ff = vim_strsave(p_ff);
10672#if defined(FEAT_QUICKFIX)
10673 buf->b_p_bh = empty_option;
10674 buf->b_p_bt = empty_option;
10675#endif
10676 }
10677 else
10678 free_buf_options(buf, FALSE);
10679
10680 buf->b_p_ai = p_ai;
10681 buf->b_p_ai_nopaste = p_ai_nopaste;
10682 buf->b_p_sw = p_sw;
10683 buf->b_p_tw = p_tw;
10684 buf->b_p_tw_nopaste = p_tw_nopaste;
10685 buf->b_p_tw_nobin = p_tw_nobin;
10686 buf->b_p_wm = p_wm;
10687 buf->b_p_wm_nopaste = p_wm_nopaste;
10688 buf->b_p_wm_nobin = p_wm_nobin;
10689 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000010690#ifdef FEAT_MBYTE
10691 buf->b_p_bomb = p_bomb;
10692#endif
Bram Moolenaarb388be02015-07-22 22:19:38 +020010693 buf->b_p_fixeol = p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010694 buf->b_p_et = p_et;
10695 buf->b_p_et_nobin = p_et_nobin;
10696 buf->b_p_ml = p_ml;
10697 buf->b_p_ml_nobin = p_ml_nobin;
10698 buf->b_p_inf = p_inf;
10699 buf->b_p_swf = p_swf;
10700#ifdef FEAT_INS_EXPAND
10701 buf->b_p_cpt = vim_strsave(p_cpt);
10702#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010703#ifdef FEAT_COMPL_FUNC
10704 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010705 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010706#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010707 buf->b_p_sts = p_sts;
10708 buf->b_p_sts_nopaste = p_sts_nopaste;
10709#ifndef SHORT_FNAME
10710 buf->b_p_sn = p_sn;
10711#endif
10712#ifdef FEAT_COMMENTS
10713 buf->b_p_com = vim_strsave(p_com);
10714#endif
10715#ifdef FEAT_FOLDING
10716 buf->b_p_cms = vim_strsave(p_cms);
10717#endif
10718 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010719 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010720 buf->b_p_nf = vim_strsave(p_nf);
10721 buf->b_p_mps = vim_strsave(p_mps);
10722#ifdef FEAT_SMARTINDENT
10723 buf->b_p_si = p_si;
10724#endif
10725 buf->b_p_ci = p_ci;
10726#ifdef FEAT_CINDENT
10727 buf->b_p_cin = p_cin;
10728 buf->b_p_cink = vim_strsave(p_cink);
10729 buf->b_p_cino = vim_strsave(p_cino);
10730#endif
10731#ifdef FEAT_AUTOCMD
10732 /* Don't copy 'filetype', it must be detected */
10733 buf->b_p_ft = empty_option;
10734#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010735 buf->b_p_pi = p_pi;
10736#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10737 buf->b_p_cinw = vim_strsave(p_cinw);
10738#endif
10739#ifdef FEAT_LISP
10740 buf->b_p_lisp = p_lisp;
10741#endif
10742#ifdef FEAT_SYN_HL
10743 /* Don't copy 'syntax', it must be set */
10744 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010745 buf->b_p_smc = p_smc;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010746#endif
10747#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020010748 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010749 (void)compile_cap_prog(&buf->b_s);
10750 buf->b_s.b_p_spf = vim_strsave(p_spf);
10751 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010752#endif
10753#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10754 buf->b_p_inde = vim_strsave(p_inde);
10755 buf->b_p_indk = vim_strsave(p_indk);
10756#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010757#if defined(FEAT_EVAL)
10758 buf->b_p_fex = vim_strsave(p_fex);
10759#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010760#ifdef FEAT_CRYPT
10761 buf->b_p_key = vim_strsave(p_key);
10762#endif
10763#ifdef FEAT_SEARCHPATH
10764 buf->b_p_sua = vim_strsave(p_sua);
10765#endif
10766#ifdef FEAT_KEYMAP
10767 buf->b_p_keymap = vim_strsave(p_keymap);
10768 buf->b_kmap_state |= KEYMAP_INIT;
10769#endif
10770 /* This isn't really an option, but copying the langmap and IME
10771 * state from the current buffer is better than resetting it. */
10772 buf->b_p_iminsert = p_iminsert;
10773 buf->b_p_imsearch = p_imsearch;
10774
10775 /* options that are normally global but also have a local value
10776 * are not copied, start using the global value */
10777 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010778 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010779 buf->b_p_bkc = empty_option;
10780 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010781#ifdef FEAT_QUICKFIX
10782 buf->b_p_gp = empty_option;
10783 buf->b_p_mp = empty_option;
10784 buf->b_p_efm = empty_option;
10785#endif
10786 buf->b_p_ep = empty_option;
10787 buf->b_p_kp = empty_option;
10788 buf->b_p_path = empty_option;
10789 buf->b_p_tags = empty_option;
10790#ifdef FEAT_FIND_ID
10791 buf->b_p_def = empty_option;
10792 buf->b_p_inc = empty_option;
10793# ifdef FEAT_EVAL
10794 buf->b_p_inex = vim_strsave(p_inex);
10795# endif
10796#endif
10797#ifdef FEAT_INS_EXPAND
10798 buf->b_p_dict = empty_option;
10799 buf->b_p_tsr = empty_option;
10800#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010801#ifdef FEAT_TEXTOBJ
10802 buf->b_p_qe = vim_strsave(p_qe);
10803#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010804#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10805 buf->b_p_bexpr = empty_option;
10806#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010807#if defined(FEAT_CRYPT)
10808 buf->b_p_cm = empty_option;
10809#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010810#ifdef FEAT_PERSISTENT_UNDO
10811 buf->b_p_udf = p_udf;
10812#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010813#ifdef FEAT_LISP
10814 buf->b_p_lw = empty_option;
10815#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010816
10817 /*
10818 * Don't copy the options set by ex_help(), use the saved values,
10819 * when going from a help buffer to a non-help buffer.
10820 * Don't touch these at all when BCO_NOHELP is used and going from
10821 * or to a help buffer.
10822 */
10823 if (dont_do_help)
10824 buf->b_p_isk = save_p_isk;
10825 else
10826 {
10827 buf->b_p_isk = vim_strsave(p_isk);
10828 did_isk = TRUE;
10829 buf->b_p_ts = p_ts;
10830 buf->b_help = FALSE;
10831#ifdef FEAT_QUICKFIX
10832 if (buf->b_p_bt[0] == 'h')
10833 clear_string_option(&buf->b_p_bt);
10834#endif
10835 buf->b_p_ma = p_ma;
10836 }
10837 }
10838
10839 /*
10840 * When the options should be copied (ignoring BCO_ALWAYS), set the
10841 * flag that indicates that the options have been initialized.
10842 */
10843 if (should_copy)
10844 buf->b_p_initialized = TRUE;
10845 }
10846
10847 check_buf_options(buf); /* make sure we don't have NULLs */
10848 if (did_isk)
10849 (void)buf_init_chartab(buf, FALSE);
10850}
10851
10852/*
10853 * Reset the 'modifiable' option and its default value.
10854 */
10855 void
10856reset_modifiable()
10857{
10858 int opt_idx;
10859
10860 curbuf->b_p_ma = FALSE;
10861 p_ma = FALSE;
10862 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000010863 if (opt_idx >= 0)
10864 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010865}
10866
10867/*
10868 * Set the global value for 'iminsert' to the local value.
10869 */
10870 void
10871set_iminsert_global()
10872{
10873 p_iminsert = curbuf->b_p_iminsert;
10874}
10875
10876/*
10877 * Set the global value for 'imsearch' to the local value.
10878 */
10879 void
10880set_imsearch_global()
10881{
10882 p_imsearch = curbuf->b_p_imsearch;
10883}
10884
10885#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
10886static int expand_option_idx = -1;
10887static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
10888static int expand_option_flags = 0;
10889
10890 void
10891set_context_in_set_cmd(xp, arg, opt_flags)
10892 expand_T *xp;
10893 char_u *arg;
10894 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
10895{
10896 int nextchar;
10897 long_u flags = 0; /* init for GCC */
10898 int opt_idx = 0; /* init for GCC */
10899 char_u *p;
10900 char_u *s;
10901 int is_term_option = FALSE;
10902 int key;
10903
10904 expand_option_flags = opt_flags;
10905
10906 xp->xp_context = EXPAND_SETTINGS;
10907 if (*arg == NUL)
10908 {
10909 xp->xp_pattern = arg;
10910 return;
10911 }
10912 p = arg + STRLEN(arg) - 1;
10913 if (*p == ' ' && *(p - 1) != '\\')
10914 {
10915 xp->xp_pattern = p + 1;
10916 return;
10917 }
10918 while (p > arg)
10919 {
10920 s = p;
10921 /* count number of backslashes before ' ' or ',' */
10922 if (*p == ' ' || *p == ',')
10923 {
10924 while (s > arg && *(s - 1) == '\\')
10925 --s;
10926 }
10927 /* break at a space with an even number of backslashes */
10928 if (*p == ' ' && ((p - s) & 1) == 0)
10929 {
10930 ++p;
10931 break;
10932 }
10933 --p;
10934 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000010935 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010936 {
10937 xp->xp_context = EXPAND_BOOL_SETTINGS;
10938 p += 2;
10939 }
10940 if (STRNCMP(p, "inv", 3) == 0)
10941 {
10942 xp->xp_context = EXPAND_BOOL_SETTINGS;
10943 p += 3;
10944 }
10945 xp->xp_pattern = arg = p;
10946 if (*arg == '<')
10947 {
10948 while (*p != '>')
10949 if (*p++ == NUL) /* expand terminal option name */
10950 return;
10951 key = get_special_key_code(arg + 1);
10952 if (key == 0) /* unknown name */
10953 {
10954 xp->xp_context = EXPAND_NOTHING;
10955 return;
10956 }
10957 nextchar = *++p;
10958 is_term_option = TRUE;
10959 expand_option_name[2] = KEY2TERMCAP0(key);
10960 expand_option_name[3] = KEY2TERMCAP1(key);
10961 }
10962 else
10963 {
10964 if (p[0] == 't' && p[1] == '_')
10965 {
10966 p += 2;
10967 if (*p != NUL)
10968 ++p;
10969 if (*p == NUL)
10970 return; /* expand option name */
10971 nextchar = *++p;
10972 is_term_option = TRUE;
10973 expand_option_name[2] = p[-2];
10974 expand_option_name[3] = p[-1];
10975 }
10976 else
10977 {
10978 /* Allow * wildcard */
10979 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
10980 p++;
10981 if (*p == NUL)
10982 return;
10983 nextchar = *p;
10984 *p = NUL;
10985 opt_idx = findoption(arg);
10986 *p = nextchar;
10987 if (opt_idx == -1 || options[opt_idx].var == NULL)
10988 {
10989 xp->xp_context = EXPAND_NOTHING;
10990 return;
10991 }
10992 flags = options[opt_idx].flags;
10993 if (flags & P_BOOL)
10994 {
10995 xp->xp_context = EXPAND_NOTHING;
10996 return;
10997 }
10998 }
10999 }
11000 /* handle "-=" and "+=" */
11001 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
11002 {
11003 ++p;
11004 nextchar = '=';
11005 }
11006 if ((nextchar != '=' && nextchar != ':')
11007 || xp->xp_context == EXPAND_BOOL_SETTINGS)
11008 {
11009 xp->xp_context = EXPAND_UNSUCCESSFUL;
11010 return;
11011 }
11012 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
11013 {
11014 xp->xp_context = EXPAND_OLD_SETTING;
11015 if (is_term_option)
11016 expand_option_idx = -1;
11017 else
11018 expand_option_idx = opt_idx;
11019 xp->xp_pattern = p + 1;
11020 return;
11021 }
11022 xp->xp_context = EXPAND_NOTHING;
11023 if (is_term_option || (flags & P_NUM))
11024 return;
11025
11026 xp->xp_pattern = p + 1;
11027
11028 if (flags & P_EXPAND)
11029 {
11030 p = options[opt_idx].var;
11031 if (p == (char_u *)&p_bdir
11032 || p == (char_u *)&p_dir
11033 || p == (char_u *)&p_path
11034 || p == (char_u *)&p_rtp
11035#ifdef FEAT_SEARCHPATH
11036 || p == (char_u *)&p_cdpath
11037#endif
11038#ifdef FEAT_SESSION
11039 || p == (char_u *)&p_vdir
11040#endif
11041 )
11042 {
11043 xp->xp_context = EXPAND_DIRECTORIES;
11044 if (p == (char_u *)&p_path
11045#ifdef FEAT_SEARCHPATH
11046 || p == (char_u *)&p_cdpath
11047#endif
11048 )
11049 xp->xp_backslash = XP_BS_THREE;
11050 else
11051 xp->xp_backslash = XP_BS_ONE;
11052 }
11053 else
11054 {
11055 xp->xp_context = EXPAND_FILES;
11056 /* for 'tags' need three backslashes for a space */
11057 if (p == (char_u *)&p_tags)
11058 xp->xp_backslash = XP_BS_THREE;
11059 else
11060 xp->xp_backslash = XP_BS_ONE;
11061 }
11062 }
11063
11064 /* For an option that is a list of file names, find the start of the
11065 * last file name. */
11066 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11067 {
11068 /* count number of backslashes before ' ' or ',' */
11069 if (*p == ' ' || *p == ',')
11070 {
11071 s = p;
11072 while (s > xp->xp_pattern && *(s - 1) == '\\')
11073 --s;
11074 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11075 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11076 {
11077 xp->xp_pattern = p + 1;
11078 break;
11079 }
11080 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011081
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011082#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011083 /* for 'spellsuggest' start at "file:" */
11084 if (options[opt_idx].var == (char_u *)&p_sps
11085 && STRNCMP(p, "file:", 5) == 0)
11086 {
11087 xp->xp_pattern = p + 5;
11088 break;
11089 }
11090#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011091 }
11092
11093 return;
11094}
11095
11096 int
11097ExpandSettings(xp, regmatch, num_file, file)
11098 expand_T *xp;
11099 regmatch_T *regmatch;
11100 int *num_file;
11101 char_u ***file;
11102{
11103 int num_normal = 0; /* Nr of matching non-term-code settings */
11104 int num_term = 0; /* Nr of matching terminal code settings */
11105 int opt_idx;
11106 int match;
11107 int count = 0;
11108 char_u *str;
11109 int loop;
11110 int is_term_opt;
11111 char_u name_buf[MAX_KEY_NAME_LEN];
11112 static char *(names[]) = {"all", "termcap"};
11113 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11114
11115 /* do this loop twice:
11116 * loop == 0: count the number of matching options
11117 * loop == 1: copy the matching options into allocated memory
11118 */
11119 for (loop = 0; loop <= 1; ++loop)
11120 {
11121 regmatch->rm_ic = ic;
11122 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11123 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011124 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11125 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011126 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11127 {
11128 if (loop == 0)
11129 num_normal++;
11130 else
11131 (*file)[count++] = vim_strsave((char_u *)names[match]);
11132 }
11133 }
11134 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11135 opt_idx++)
11136 {
11137 if (options[opt_idx].var == NULL)
11138 continue;
11139 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11140 && !(options[opt_idx].flags & P_BOOL))
11141 continue;
11142 is_term_opt = istermoption(&options[opt_idx]);
11143 if (is_term_opt && num_normal > 0)
11144 continue;
11145 match = FALSE;
11146 if (vim_regexec(regmatch, str, (colnr_T)0)
11147 || (options[opt_idx].shortname != NULL
11148 && vim_regexec(regmatch,
11149 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11150 match = TRUE;
11151 else if (is_term_opt)
11152 {
11153 name_buf[0] = '<';
11154 name_buf[1] = 't';
11155 name_buf[2] = '_';
11156 name_buf[3] = str[2];
11157 name_buf[4] = str[3];
11158 name_buf[5] = '>';
11159 name_buf[6] = NUL;
11160 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11161 {
11162 match = TRUE;
11163 str = name_buf;
11164 }
11165 }
11166 if (match)
11167 {
11168 if (loop == 0)
11169 {
11170 if (is_term_opt)
11171 num_term++;
11172 else
11173 num_normal++;
11174 }
11175 else
11176 (*file)[count++] = vim_strsave(str);
11177 }
11178 }
11179 /*
11180 * Check terminal key codes, these are not in the option table
11181 */
11182 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11183 {
11184 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11185 {
11186 if (!isprint(str[0]) || !isprint(str[1]))
11187 continue;
11188
11189 name_buf[0] = 't';
11190 name_buf[1] = '_';
11191 name_buf[2] = str[0];
11192 name_buf[3] = str[1];
11193 name_buf[4] = NUL;
11194
11195 match = FALSE;
11196 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11197 match = TRUE;
11198 else
11199 {
11200 name_buf[0] = '<';
11201 name_buf[1] = 't';
11202 name_buf[2] = '_';
11203 name_buf[3] = str[0];
11204 name_buf[4] = str[1];
11205 name_buf[5] = '>';
11206 name_buf[6] = NUL;
11207
11208 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11209 match = TRUE;
11210 }
11211 if (match)
11212 {
11213 if (loop == 0)
11214 num_term++;
11215 else
11216 (*file)[count++] = vim_strsave(name_buf);
11217 }
11218 }
11219
11220 /*
11221 * Check special key names.
11222 */
11223 regmatch->rm_ic = TRUE; /* ignore case here */
11224 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11225 {
11226 name_buf[0] = '<';
11227 STRCPY(name_buf + 1, str);
11228 STRCAT(name_buf, ">");
11229
11230 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11231 {
11232 if (loop == 0)
11233 num_term++;
11234 else
11235 (*file)[count++] = vim_strsave(name_buf);
11236 }
11237 }
11238 }
11239 if (loop == 0)
11240 {
11241 if (num_normal > 0)
11242 *num_file = num_normal;
11243 else if (num_term > 0)
11244 *num_file = num_term;
11245 else
11246 return OK;
11247 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11248 if (*file == NULL)
11249 {
11250 *file = (char_u **)"";
11251 return FAIL;
11252 }
11253 }
11254 }
11255 return OK;
11256}
11257
11258 int
11259ExpandOldSetting(num_file, file)
11260 int *num_file;
11261 char_u ***file;
11262{
11263 char_u *var = NULL; /* init for GCC */
11264 char_u *buf;
11265
11266 *num_file = 0;
11267 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11268 if (*file == NULL)
11269 return FAIL;
11270
11271 /*
11272 * For a terminal key code expand_option_idx is < 0.
11273 */
11274 if (expand_option_idx < 0)
11275 {
11276 var = find_termcode(expand_option_name + 2);
11277 if (var == NULL)
11278 expand_option_idx = findoption(expand_option_name);
11279 }
11280
11281 if (expand_option_idx >= 0)
11282 {
11283 /* put string of option value in NameBuff */
11284 option_value2string(&options[expand_option_idx], expand_option_flags);
11285 var = NameBuff;
11286 }
11287 else if (var == NULL)
11288 var = (char_u *)"";
11289
11290 /* A backslash is required before some characters. This is the reverse of
11291 * what happens in do_set(). */
11292 buf = vim_strsave_escaped(var, escape_chars);
11293
11294 if (buf == NULL)
11295 {
11296 vim_free(*file);
11297 *file = NULL;
11298 return FAIL;
11299 }
11300
11301#ifdef BACKSLASH_IN_FILENAME
11302 /* For MS-Windows et al. we don't double backslashes at the start and
11303 * before a file name character. */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011304 for (var = buf; *var != NUL; mb_ptr_adv(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011305 if (var[0] == '\\' && var[1] == '\\'
11306 && expand_option_idx >= 0
11307 && (options[expand_option_idx].flags & P_EXPAND)
11308 && vim_isfilec(var[2])
11309 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011310 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011311#endif
11312
11313 *file[0] = buf;
11314 *num_file = 1;
11315 return OK;
11316}
11317#endif
11318
11319/*
11320 * Get the value for the numeric or string option *opp in a nice format into
11321 * NameBuff[]. Must not be called with a hidden option!
11322 */
11323 static void
11324option_value2string(opp, opt_flags)
11325 struct vimoption *opp;
11326 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
11327{
11328 char_u *varp;
11329
11330 varp = get_varp_scope(opp, opt_flags);
11331
11332 if (opp->flags & P_NUM)
11333 {
11334 long wc = 0;
11335
11336 if (wc_use_keyname(varp, &wc))
11337 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11338 else if (wc != 0)
11339 STRCPY(NameBuff, transchar((int)wc));
11340 else
11341 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11342 }
11343 else /* P_STRING */
11344 {
11345 varp = *(char_u **)(varp);
11346 if (varp == NULL) /* just in case */
11347 NameBuff[0] = NUL;
11348#ifdef FEAT_CRYPT
11349 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011350 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011351 STRCPY(NameBuff, "*****");
11352#endif
11353 else if (opp->flags & P_EXPAND)
11354 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11355 /* Translate 'pastetoggle' into special key names */
11356 else if ((char_u **)opp->var == &p_pt)
11357 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11358 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011359 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011360 }
11361}
11362
11363/*
11364 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11365 * printed as a keyname.
11366 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11367 */
11368 static int
11369wc_use_keyname(varp, wcp)
11370 char_u *varp;
11371 long *wcp;
11372{
11373 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11374 {
11375 *wcp = *(long *)varp;
11376 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11377 return TRUE;
11378 }
11379 return FALSE;
11380}
11381
Bram Moolenaar01615492015-02-03 13:00:38 +010011382#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011383/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011384 * Any character has an equivalent 'langmap' character. This is used for
11385 * keyboards that have a special language mode that sends characters above
11386 * 128 (although other characters can be translated too). The "to" field is a
11387 * Vim command character. This avoids having to switch the keyboard back to
11388 * ASCII mode when leaving Insert mode.
11389 *
11390 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11391 * commands.
11392 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11393 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11394 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011395 */
Bram Moolenaar01615492015-02-03 13:00:38 +010011396# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011397/*
11398 * With multi-byte support use growarray for 'langmap' chars >= 256
11399 */
11400typedef struct
11401{
11402 int from;
11403 int to;
11404} langmap_entry_T;
11405
11406static garray_T langmap_mapga;
11407static void langmap_set_entry __ARGS((int from, int to));
Bram Moolenaar071d4272004-06-13 20:20:40 +000011408
11409/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011410 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11411 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011412 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011413 static void
11414langmap_set_entry(from, to)
11415 int from;
11416 int to;
11417{
11418 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011419 int a = 0;
11420 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011421
11422 /* Do a binary search for an existing entry. */
11423 while (a != b)
11424 {
11425 int i = (a + b) / 2;
11426 int d = entries[i].from - from;
11427
11428 if (d == 0)
11429 {
11430 entries[i].to = to;
11431 return;
11432 }
11433 if (d < 0)
11434 a = i + 1;
11435 else
11436 b = i;
11437 }
11438
11439 if (ga_grow(&langmap_mapga, 1) != OK)
11440 return; /* out of memory */
11441
11442 /* insert new entry at position "a" */
11443 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11444 mch_memmove(entries + 1, entries,
11445 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11446 ++langmap_mapga.ga_len;
11447 entries[0].from = from;
11448 entries[0].to = to;
11449}
11450
11451/*
11452 * Apply 'langmap' to multi-byte character "c" and return the result.
11453 */
11454 int
11455langmap_adjust_mb(c)
11456 int c;
11457{
11458 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11459 int a = 0;
11460 int b = langmap_mapga.ga_len;
11461
11462 while (a != b)
11463 {
11464 int i = (a + b) / 2;
11465 int d = entries[i].from - c;
11466
11467 if (d == 0)
11468 return entries[i].to; /* found matching entry */
11469 if (d < 0)
11470 a = i + 1;
11471 else
11472 b = i;
11473 }
11474 return c; /* no entry found, return "c" unmodified */
11475}
11476# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011477
11478 static void
11479langmap_init()
11480{
11481 int i;
11482
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011483 for (i = 0; i < 256; i++)
11484 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11485# ifdef FEAT_MBYTE
11486 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11487# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011488}
11489
11490/*
11491 * Called when langmap option is set; the language map can be
11492 * changed at any time!
11493 */
11494 static void
11495langmap_set()
11496{
11497 char_u *p;
11498 char_u *p2;
11499 int from, to;
11500
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011501#ifdef FEAT_MBYTE
11502 ga_clear(&langmap_mapga); /* clear the previous map first */
11503#endif
11504 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011505
11506 for (p = p_langmap; p[0] != NUL; )
11507 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011508 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
11509 mb_ptr_adv(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011510 {
11511 if (p2[0] == '\\' && p2[1] != NUL)
11512 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011513 }
11514 if (p2[0] == ';')
11515 ++p2; /* abcd;ABCD form, p2 points to A */
11516 else
11517 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11518 while (p[0])
11519 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011520 if (p[0] == ',')
11521 {
11522 ++p;
11523 break;
11524 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011525 if (p[0] == '\\' && p[1] != NUL)
11526 ++p;
11527#ifdef FEAT_MBYTE
11528 from = (*mb_ptr2char)(p);
11529#else
11530 from = p[0];
11531#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011532 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011533 if (p2 == NULL)
11534 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011535 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011536 if (p[0] != ',')
11537 {
11538 if (p[0] == '\\')
11539 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011540#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011541 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011542#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011543 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011544#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011545 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011546 }
11547 else
11548 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011549 if (p2[0] != ',')
11550 {
11551 if (p2[0] == '\\')
11552 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011553#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011554 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011555#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011556 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011557#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011558 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011559 }
11560 if (to == NUL)
11561 {
11562 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
11563 transchar(from));
11564 return;
11565 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011566
11567#ifdef FEAT_MBYTE
11568 if (from >= 256)
11569 langmap_set_entry(from, to);
11570 else
11571#endif
11572 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011573
11574 /* Advance to next pair */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011575 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011576 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011577 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011578 mb_ptr_adv(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011579 if (*p == ';')
11580 {
11581 p = p2;
11582 if (p[0] != NUL)
11583 {
11584 if (p[0] != ',')
11585 {
11586 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
11587 return;
11588 }
11589 ++p;
11590 }
11591 break;
11592 }
11593 }
11594 }
11595 }
11596}
11597#endif
11598
11599/*
11600 * Return TRUE if format option 'x' is in effect.
11601 * Take care of no formatting when 'paste' is set.
11602 */
11603 int
11604has_format_option(x)
11605 int x;
11606{
11607 if (p_paste)
11608 return FALSE;
11609 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
11610}
11611
11612/*
11613 * Return TRUE if "x" is present in 'shortmess' option, or
11614 * 'shortmess' contains 'a' and "x" is present in SHM_A.
11615 */
11616 int
11617shortmess(x)
11618 int x;
11619{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010011620 return p_shm != NULL &&
11621 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000011622 || (vim_strchr(p_shm, 'a') != NULL
11623 && vim_strchr((char_u *)SHM_A, x) != NULL));
11624}
11625
11626/*
11627 * paste_option_changed() - Called after p_paste was set or reset.
11628 */
11629 static void
11630paste_option_changed()
11631{
11632 static int old_p_paste = FALSE;
11633 static int save_sm = 0;
11634#ifdef FEAT_CMDL_INFO
11635 static int save_ru = 0;
11636#endif
11637#ifdef FEAT_RIGHTLEFT
11638 static int save_ri = 0;
11639 static int save_hkmap = 0;
11640#endif
11641 buf_T *buf;
11642
11643 if (p_paste)
11644 {
11645 /*
11646 * Paste switched from off to on.
11647 * Save the current values, so they can be restored later.
11648 */
11649 if (!old_p_paste)
11650 {
11651 /* save options for each buffer */
11652 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11653 {
11654 buf->b_p_tw_nopaste = buf->b_p_tw;
11655 buf->b_p_wm_nopaste = buf->b_p_wm;
11656 buf->b_p_sts_nopaste = buf->b_p_sts;
11657 buf->b_p_ai_nopaste = buf->b_p_ai;
11658 }
11659
11660 /* save global options */
11661 save_sm = p_sm;
11662#ifdef FEAT_CMDL_INFO
11663 save_ru = p_ru;
11664#endif
11665#ifdef FEAT_RIGHTLEFT
11666 save_ri = p_ri;
11667 save_hkmap = p_hkmap;
11668#endif
11669 /* save global values for local buffer options */
11670 p_tw_nopaste = p_tw;
11671 p_wm_nopaste = p_wm;
11672 p_sts_nopaste = p_sts;
11673 p_ai_nopaste = p_ai;
11674 }
11675
11676 /*
11677 * Always set the option values, also when 'paste' is set when it is
11678 * already on.
11679 */
11680 /* set options for each buffer */
11681 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11682 {
11683 buf->b_p_tw = 0; /* textwidth is 0 */
11684 buf->b_p_wm = 0; /* wrapmargin is 0 */
11685 buf->b_p_sts = 0; /* softtabstop is 0 */
11686 buf->b_p_ai = 0; /* no auto-indent */
11687 }
11688
11689 /* set global options */
11690 p_sm = 0; /* no showmatch */
11691#ifdef FEAT_CMDL_INFO
11692# ifdef FEAT_WINDOWS
11693 if (p_ru)
11694 status_redraw_all(); /* redraw to remove the ruler */
11695# endif
11696 p_ru = 0; /* no ruler */
11697#endif
11698#ifdef FEAT_RIGHTLEFT
11699 p_ri = 0; /* no reverse insert */
11700 p_hkmap = 0; /* no Hebrew keyboard */
11701#endif
11702 /* set global values for local buffer options */
11703 p_tw = 0;
11704 p_wm = 0;
11705 p_sts = 0;
11706 p_ai = 0;
11707 }
11708
11709 /*
11710 * Paste switched from on to off: Restore saved values.
11711 */
11712 else if (old_p_paste)
11713 {
11714 /* restore options for each buffer */
11715 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11716 {
11717 buf->b_p_tw = buf->b_p_tw_nopaste;
11718 buf->b_p_wm = buf->b_p_wm_nopaste;
11719 buf->b_p_sts = buf->b_p_sts_nopaste;
11720 buf->b_p_ai = buf->b_p_ai_nopaste;
11721 }
11722
11723 /* restore global options */
11724 p_sm = save_sm;
11725#ifdef FEAT_CMDL_INFO
11726# ifdef FEAT_WINDOWS
11727 if (p_ru != save_ru)
11728 status_redraw_all(); /* redraw to draw the ruler */
11729# endif
11730 p_ru = save_ru;
11731#endif
11732#ifdef FEAT_RIGHTLEFT
11733 p_ri = save_ri;
11734 p_hkmap = save_hkmap;
11735#endif
11736 /* set global values for local buffer options */
11737 p_tw = p_tw_nopaste;
11738 p_wm = p_wm_nopaste;
11739 p_sts = p_sts_nopaste;
11740 p_ai = p_ai_nopaste;
11741 }
11742
11743 old_p_paste = p_paste;
11744}
11745
11746/*
11747 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
11748 *
11749 * Reset 'compatible' and set the values for options that didn't get set yet
11750 * to the Vim defaults.
11751 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011752 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011753 */
11754 void
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011755vimrc_found(fname, envname)
11756 char_u *fname;
11757 char_u *envname;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011758{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011759 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000011760 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011761 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011762
11763 if (!option_was_set((char_u *)"cp"))
11764 {
11765 p_cp = FALSE;
11766 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11767 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
11768 set_option_default(opt_idx, OPT_FREE, FALSE);
11769 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020011770 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000011771 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011772
11773 if (fname != NULL)
11774 {
11775 p = vim_getenv(envname, &dofree);
11776 if (p == NULL)
11777 {
11778 /* Set $MYVIMRC to the first vimrc file found. */
11779 p = FullName_save(fname, FALSE);
11780 if (p != NULL)
11781 {
11782 vim_setenv(envname, p);
11783 vim_free(p);
11784 }
11785 }
11786 else if (dofree)
11787 vim_free(p);
11788 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011789}
11790
11791/*
11792 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
11793 */
11794 void
11795change_compatible(on)
11796 int on;
11797{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011798 int opt_idx;
11799
Bram Moolenaar071d4272004-06-13 20:20:40 +000011800 if (p_cp != on)
11801 {
11802 p_cp = on;
11803 compatible_set();
11804 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011805 opt_idx = findoption((char_u *)"cp");
11806 if (opt_idx >= 0)
11807 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011808}
11809
11810/*
11811 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020011812 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011813 */
11814 int
11815option_was_set(name)
11816 char_u *name;
11817{
11818 int idx;
11819
11820 idx = findoption(name);
11821 if (idx < 0) /* unknown option */
11822 return FALSE;
11823 if (options[idx].flags & P_WAS_SET)
11824 return TRUE;
11825 return FALSE;
11826}
11827
11828/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010011829 * Reset the flag indicating option "name" was set.
11830 */
11831 void
11832reset_option_was_set(name)
11833 char_u *name;
11834{
11835 int idx = findoption(name);
11836
11837 if (idx >= 0)
11838 options[idx].flags &= ~P_WAS_SET;
11839}
11840
11841/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011842 * compatible_set() - Called when 'compatible' has been set or unset.
11843 *
11844 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
11845 * flag) to a Vi compatible value.
11846 * When 'compatible' is unset: Set all options that have a different default
11847 * for Vim (without the P_VI_DEF flag) to that default.
11848 */
11849 static void
11850compatible_set()
11851{
11852 int opt_idx;
11853
11854 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11855 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
11856 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
11857 set_option_default(opt_idx, OPT_FREE, p_cp);
11858 didset_options();
Bram Moolenaare68c25c2015-08-25 15:39:55 +020011859 didset_options2();
Bram Moolenaar071d4272004-06-13 20:20:40 +000011860}
11861
11862#ifdef FEAT_LINEBREAK
11863
11864# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
11865 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011866 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011867# endif
11868
11869/*
11870 * fill_breakat_flags() -- called when 'breakat' changes value.
11871 */
11872 static void
11873fill_breakat_flags()
11874{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011875 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011876 int i;
11877
11878 for (i = 0; i < 256; i++)
11879 breakat_flags[i] = FALSE;
11880
11881 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011882 for (p = p_breakat; *p; p++)
11883 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011884}
11885
11886# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011887 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011888# endif
11889
11890#endif
11891
11892/*
11893 * Check an option that can be a range of string values.
11894 *
11895 * Return OK for correct value, FAIL otherwise.
11896 * Empty is always OK.
11897 */
11898 static int
11899check_opt_strings(val, values, list)
11900 char_u *val;
11901 char **values;
11902 int list; /* when TRUE: accept a list of values */
11903{
11904 return opt_strings_flags(val, values, NULL, list);
11905}
11906
11907/*
11908 * Handle an option that can be a range of string values.
11909 * Set a flag in "*flagp" for each string present.
11910 *
11911 * Return OK for correct value, FAIL otherwise.
11912 * Empty is always OK.
11913 */
11914 static int
11915opt_strings_flags(val, values, flagp, list)
11916 char_u *val; /* new value */
11917 char **values; /* array of valid string values */
11918 unsigned *flagp;
11919 int list; /* when TRUE: accept a list of values */
11920{
11921 int i;
11922 int len;
11923 unsigned new_flags = 0;
11924
11925 while (*val)
11926 {
11927 for (i = 0; ; ++i)
11928 {
11929 if (values[i] == NULL) /* val not found in values[] */
11930 return FAIL;
11931
11932 len = (int)STRLEN(values[i]);
11933 if (STRNCMP(values[i], val, len) == 0
11934 && ((list && val[len] == ',') || val[len] == NUL))
11935 {
11936 val += len + (val[len] == ',');
11937 new_flags |= (1 << i);
11938 break; /* check next item in val list */
11939 }
11940 }
11941 }
11942 if (flagp != NULL)
11943 *flagp = new_flags;
11944
11945 return OK;
11946}
11947
11948/*
11949 * Read the 'wildmode' option, fill wim_flags[].
11950 */
11951 static int
11952check_opt_wim()
11953{
11954 char_u new_wim_flags[4];
11955 char_u *p;
11956 int i;
11957 int idx = 0;
11958
11959 for (i = 0; i < 4; ++i)
11960 new_wim_flags[i] = 0;
11961
11962 for (p = p_wim; *p; ++p)
11963 {
11964 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
11965 ;
11966 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
11967 return FAIL;
11968 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
11969 new_wim_flags[idx] |= WIM_LONGEST;
11970 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
11971 new_wim_flags[idx] |= WIM_FULL;
11972 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
11973 new_wim_flags[idx] |= WIM_LIST;
11974 else
11975 return FAIL;
11976 p += i;
11977 if (*p == NUL)
11978 break;
11979 if (*p == ',')
11980 {
11981 if (idx == 3)
11982 return FAIL;
11983 ++idx;
11984 }
11985 }
11986
11987 /* fill remaining entries with last flag */
11988 while (idx < 3)
11989 {
11990 new_wim_flags[idx + 1] = new_wim_flags[idx];
11991 ++idx;
11992 }
11993
11994 /* only when there are no errors, wim_flags[] is changed */
11995 for (i = 0; i < 4; ++i)
11996 wim_flags[i] = new_wim_flags[i];
11997 return OK;
11998}
11999
12000/*
12001 * Check if backspacing over something is allowed.
12002 */
12003 int
12004can_bs(what)
12005 int what; /* BS_INDENT, BS_EOL or BS_START */
12006{
12007 switch (*p_bs)
12008 {
12009 case '2': return TRUE;
12010 case '1': return (what != BS_START);
12011 case '0': return FALSE;
12012 }
12013 return vim_strchr(p_bs, what) != NULL;
12014}
12015
12016/*
12017 * Save the current values of 'fileformat' and 'fileencoding', so that we know
12018 * the file must be considered changed when the value is different.
12019 */
12020 void
12021save_file_ff(buf)
12022 buf_T *buf;
12023{
12024 buf->b_start_ffc = *buf->b_p_ff;
12025 buf->b_start_eol = buf->b_p_eol;
12026#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012027 buf->b_start_bomb = buf->b_p_bomb;
12028
Bram Moolenaar071d4272004-06-13 20:20:40 +000012029 /* Only use free/alloc when necessary, they take time. */
12030 if (buf->b_start_fenc == NULL
12031 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
12032 {
12033 vim_free(buf->b_start_fenc);
12034 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
12035 }
12036#endif
12037}
12038
12039/*
12040 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
12041 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012042 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
12043 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012044 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012045 * When "ignore_empty" is true don't consider a new, empty buffer to be
12046 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012047 */
12048 int
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012049file_ff_differs(buf, ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012050 buf_T *buf;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012051 int ignore_empty;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012052{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012053 /* In a buffer that was never loaded the options are not valid. */
12054 if (buf->b_flags & BF_NEVERLOADED)
12055 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012056 if (ignore_empty
12057 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012058 && buf->b_ml.ml_line_count == 1
12059 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12060 return FALSE;
12061 if (buf->b_start_ffc != *buf->b_p_ff)
12062 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012063 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012064 return TRUE;
12065#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012066 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12067 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012068 if (buf->b_start_fenc == NULL)
12069 return (*buf->b_p_fenc != NUL);
12070 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12071#else
12072 return FALSE;
12073#endif
12074}
12075
12076/*
12077 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12078 */
12079 int
12080check_ff_value(p)
12081 char_u *p;
12082{
12083 return check_opt_strings(p, p_ff_values, FALSE);
12084}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012085
12086/*
12087 * Return the effective shiftwidth value for current buffer, using the
12088 * 'tabstop' value when 'shiftwidth' is zero.
12089 */
12090 long
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012091get_sw_value(buf)
12092 buf_T *buf;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012093{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012094 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012095}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012096
12097/*
12098 * Return the effective softtabstop value for the current buffer, using the
12099 * 'tabstop' value when 'softtabstop' is negative.
12100 */
12101 long
12102get_sts_value()
12103{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012104 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012105}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012106
12107/*
12108 * Check matchpairs option for "*initc".
12109 * If there is a match set "*initc" to the matching character and "*findc" to
12110 * the opposite character. Set "*backwards" to the direction.
12111 * When "switchit" is TRUE swap the direction.
12112 */
12113 void
12114find_mps_values(initc, findc, backwards, switchit)
12115 int *initc;
12116 int *findc;
12117 int *backwards;
12118 int switchit;
12119{
12120 char_u *ptr;
12121
12122 ptr = curbuf->b_p_mps;
12123 while (*ptr != NUL)
12124 {
12125#ifdef FEAT_MBYTE
12126 if (has_mbyte)
12127 {
12128 char_u *prev;
12129
12130 if (mb_ptr2char(ptr) == *initc)
12131 {
12132 if (switchit)
12133 {
12134 *findc = *initc;
12135 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12136 *backwards = TRUE;
12137 }
12138 else
12139 {
12140 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12141 *backwards = FALSE;
12142 }
12143 return;
12144 }
12145 prev = ptr;
12146 ptr += mb_ptr2len(ptr) + 1;
12147 if (mb_ptr2char(ptr) == *initc)
12148 {
12149 if (switchit)
12150 {
12151 *findc = *initc;
12152 *initc = mb_ptr2char(prev);
12153 *backwards = FALSE;
12154 }
12155 else
12156 {
12157 *findc = mb_ptr2char(prev);
12158 *backwards = TRUE;
12159 }
12160 return;
12161 }
12162 ptr += mb_ptr2len(ptr);
12163 }
12164 else
12165#endif
12166 {
12167 if (*ptr == *initc)
12168 {
12169 if (switchit)
12170 {
12171 *backwards = TRUE;
12172 *findc = *initc;
12173 *initc = ptr[2];
12174 }
12175 else
12176 {
12177 *backwards = FALSE;
12178 *findc = ptr[2];
12179 }
12180 return;
12181 }
12182 ptr += 2;
12183 if (*ptr == *initc)
12184 {
12185 if (switchit)
12186 {
12187 *backwards = FALSE;
12188 *findc = *initc;
12189 *initc = ptr[-2];
12190 }
12191 else
12192 {
12193 *backwards = TRUE;
12194 *findc = ptr[-2];
12195 }
12196 return;
12197 }
12198 ++ptr;
12199 }
12200 if (*ptr == ',')
12201 ++ptr;
12202 }
12203}
Bram Moolenaar597a4222014-06-25 14:39:50 +020012204
12205#if defined(FEAT_LINEBREAK) || defined(PROTO)
12206/*
12207 * This is called when 'breakindentopt' is changed and when a window is
12208 * initialized.
12209 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012210 static int
12211briopt_check(wp)
12212 win_T *wp;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012213{
12214 char_u *p;
12215 int bri_shift = 0;
12216 long bri_min = 20;
12217 int bri_sbr = FALSE;
12218
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012219 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012220 while (*p != NUL)
12221 {
12222 if (STRNCMP(p, "shift:", 6) == 0
12223 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
12224 {
12225 p += 6;
12226 bri_shift = getdigits(&p);
12227 }
12228 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
12229 {
12230 p += 4;
12231 bri_min = getdigits(&p);
12232 }
12233 else if (STRNCMP(p, "sbr", 3) == 0)
12234 {
12235 p += 3;
12236 bri_sbr = TRUE;
12237 }
12238 if (*p != ',' && *p != NUL)
12239 return FAIL;
12240 if (*p == ',')
12241 ++p;
12242 }
12243
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012244 wp->w_p_brishift = bri_shift;
12245 wp->w_p_brimin = bri_min;
12246 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012247
12248 return OK;
12249}
12250#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012251
12252/*
12253 * Get the local or global value of 'backupcopy'.
12254 */
12255 unsigned int
12256get_bkc_value(buf)
12257 buf_T *buf;
12258{
12259 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
12260}