blob: 35cfd2b006ec07eb7ad6cf267cb118b15e8d5c59 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001/* vi:set ts=8 sts=4 sw=4:
2 *
3 * VIM - Vi IMproved by Bram Moolenaar
4 *
5 * Do ":help uganda" in Vim to read copying and usage conditions.
6 * Do ":help credits" in Vim to see a list of people who contributed.
7 * See README.txt for an overview of the Vim source code.
8 */
9
10/*
11 * Code to handle user-settable options. This is all pretty much table-
12 * driven. Checklist for adding a new option:
13 * - Put it in the options array below (copy an existing entry).
14 * - For a global option: Add a variable for it in option.h.
15 * - For a buffer or window local option:
16 * - Add a PV_XX entry to the enum below.
17 * - Add a variable to the window or buffer struct in structs.h.
18 * - For a window option, add some code to copy_winopt().
19 * - For a buffer option, add some code to buf_copy_options().
20 * - For a buffer string option, add code to check_buf_options().
21 * - If it's a numeric option, add any necessary bounds checks to do_set().
22 * - If it's a list of flags, add some code in do_set(), search for WW_ALL.
23 * - When adding an option with expansion (P_EXPAND), but with a different
24 * default for Vi and Vim (no P_VI_DEF), add some code at VIMEXP.
25 * - Add documentation! One line in doc/help.txt, full description in
26 * options.txt, and any other related places.
27 * - Add an entry in runtime/optwin.vim.
28 * When making changes:
29 * - Adjust the help for the option in doc/option.txt.
30 * - When an entry has the P_VIM flag, or is lacking the P_VI_DEF flag, add a
31 * comment at the help for the 'compatible' option.
32 */
33
34#define IN_OPTION_C
35#include "vim.h"
36
37/*
38 * The options that are local to a window or buffer have "indir" set to one of
39 * these values. Special values:
40 * PV_NONE: global option.
Bram Moolenaara23ccb82006-02-27 00:08:02 +000041 * PV_WIN is added: window-local option
42 * PV_BUF is added: buffer-local option
Bram Moolenaar071d4272004-06-13 20:20:40 +000043 * PV_BOTH is added: global option which also has a local value.
44 */
45#define PV_BOTH 0x1000
Bram Moolenaara23ccb82006-02-27 00:08:02 +000046#define PV_WIN 0x2000
47#define PV_BUF 0x4000
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000048#define PV_MASK 0x0fff
Bram Moolenaara23ccb82006-02-27 00:08:02 +000049#define OPT_WIN(x) (idopt_T)(PV_WIN + (int)(x))
50#define OPT_BUF(x) (idopt_T)(PV_BUF + (int)(x))
Bram Moolenaar071d4272004-06-13 20:20:40 +000051#define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x))
52
Bram Moolenaara23ccb82006-02-27 00:08:02 +000053/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000054 * Definition of the PV_ values for buffer-local options.
55 * The BV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +000056 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +000057#define PV_AI OPT_BUF(BV_AI)
58#define PV_AR OPT_BOTH(OPT_BUF(BV_AR))
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020059#define PV_BKC OPT_BOTH(OPT_BUF(BV_BKC))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000060#ifdef FEAT_QUICKFIX
Bram Moolenaara23ccb82006-02-27 00:08:02 +000061# define PV_BH OPT_BUF(BV_BH)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000062# define PV_BT OPT_BUF(BV_BT)
63# define PV_EFM OPT_BOTH(OPT_BUF(BV_EFM))
64# define PV_GP OPT_BOTH(OPT_BUF(BV_GP))
65# define PV_MP OPT_BOTH(OPT_BUF(BV_MP))
Bram Moolenaara23ccb82006-02-27 00:08:02 +000066#endif
67#define PV_BIN OPT_BUF(BV_BIN)
68#define PV_BL OPT_BUF(BV_BL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000069#ifdef FEAT_MBYTE
70# define PV_BOMB OPT_BUF(BV_BOMB)
71#endif
72#define PV_CI OPT_BUF(BV_CI)
73#ifdef FEAT_CINDENT
74# define PV_CIN OPT_BUF(BV_CIN)
75# define PV_CINK OPT_BUF(BV_CINK)
76# define PV_CINO OPT_BUF(BV_CINO)
77#endif
78#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
79# define PV_CINW OPT_BUF(BV_CINW)
80#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020081#define PV_CM OPT_BOTH(OPT_BUF(BV_CM))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000082#ifdef FEAT_FOLDING
83# define PV_CMS OPT_BUF(BV_CMS)
84#endif
85#ifdef FEAT_COMMENTS
86# define PV_COM OPT_BUF(BV_COM)
87#endif
88#ifdef FEAT_INS_EXPAND
89# define PV_CPT OPT_BUF(BV_CPT)
90# define PV_DICT OPT_BOTH(OPT_BUF(BV_DICT))
91# define PV_TSR OPT_BOTH(OPT_BUF(BV_TSR))
92#endif
93#ifdef FEAT_COMPL_FUNC
94# define PV_CFU OPT_BUF(BV_CFU)
95#endif
96#ifdef FEAT_FIND_ID
97# define PV_DEF OPT_BOTH(OPT_BUF(BV_DEF))
98# define PV_INC OPT_BOTH(OPT_BUF(BV_INC))
99#endif
100#define PV_EOL OPT_BUF(BV_EOL)
Bram Moolenaar34d72d42015-07-17 14:18:08 +0200101#define PV_FIXEOL OPT_BUF(BV_FIXEOL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000102#define PV_EP OPT_BOTH(OPT_BUF(BV_EP))
103#define PV_ET OPT_BUF(BV_ET)
104#ifdef FEAT_MBYTE
105# define PV_FENC OPT_BUF(BV_FENC)
106#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000107#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
108# define PV_BEXPR OPT_BOTH(OPT_BUF(BV_BEXPR))
109#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000110#ifdef FEAT_EVAL
111# define PV_FEX OPT_BUF(BV_FEX)
112#endif
113#define PV_FF OPT_BUF(BV_FF)
114#define PV_FLP OPT_BUF(BV_FLP)
115#define PV_FO OPT_BUF(BV_FO)
116#ifdef FEAT_AUTOCMD
117# define PV_FT OPT_BUF(BV_FT)
118#endif
119#define PV_IMI OPT_BUF(BV_IMI)
120#define PV_IMS OPT_BUF(BV_IMS)
121#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
122# define PV_INDE OPT_BUF(BV_INDE)
123# define PV_INDK OPT_BUF(BV_INDK)
124#endif
125#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
126# define PV_INEX OPT_BUF(BV_INEX)
127#endif
128#define PV_INF OPT_BUF(BV_INF)
129#define PV_ISK OPT_BUF(BV_ISK)
130#ifdef FEAT_CRYPT
131# define PV_KEY OPT_BUF(BV_KEY)
132#endif
133#ifdef FEAT_KEYMAP
134# define PV_KMAP OPT_BUF(BV_KMAP)
135#endif
136#define PV_KP OPT_BOTH(OPT_BUF(BV_KP))
137#ifdef FEAT_LISP
138# define PV_LISP OPT_BUF(BV_LISP)
Bram Moolenaaraf6c1312014-03-12 18:55:58 +0100139# define PV_LW OPT_BOTH(OPT_BUF(BV_LW))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000140#endif
141#define PV_MA OPT_BUF(BV_MA)
142#define PV_ML OPT_BUF(BV_ML)
143#define PV_MOD OPT_BUF(BV_MOD)
144#define PV_MPS OPT_BUF(BV_MPS)
145#define PV_NF OPT_BUF(BV_NF)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000146#ifdef FEAT_COMPL_FUNC
147# define PV_OFU OPT_BUF(BV_OFU)
148#endif
149#define PV_PATH OPT_BOTH(OPT_BUF(BV_PATH))
150#define PV_PI OPT_BUF(BV_PI)
151#ifdef FEAT_TEXTOBJ
152# define PV_QE OPT_BUF(BV_QE)
153#endif
154#define PV_RO OPT_BUF(BV_RO)
155#ifdef FEAT_SMARTINDENT
156# define PV_SI OPT_BUF(BV_SI)
157#endif
158#ifndef SHORT_FNAME
159# define PV_SN OPT_BUF(BV_SN)
160#endif
161#ifdef FEAT_SYN_HL
162# define PV_SMC OPT_BUF(BV_SMC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000163# define PV_SYN OPT_BUF(BV_SYN)
164#endif
165#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000166# define PV_SPC OPT_BUF(BV_SPC)
167# define PV_SPF OPT_BUF(BV_SPF)
168# define PV_SPL OPT_BUF(BV_SPL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000169#endif
170#define PV_STS OPT_BUF(BV_STS)
171#ifdef FEAT_SEARCHPATH
172# define PV_SUA OPT_BUF(BV_SUA)
173#endif
174#define PV_SW OPT_BUF(BV_SW)
175#define PV_SWF OPT_BUF(BV_SWF)
176#define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS))
177#define PV_TS OPT_BUF(BV_TS)
178#define PV_TW OPT_BUF(BV_TW)
179#define PV_TX OPT_BUF(BV_TX)
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200180#ifdef FEAT_PERSISTENT_UNDO
181# define PV_UDF OPT_BUF(BV_UDF)
182#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000183#define PV_WM OPT_BUF(BV_WM)
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000184
185/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000186 * Definition of the PV_ values for window-local options.
187 * The WV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000188 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000189#define PV_LIST OPT_WIN(WV_LIST)
190#ifdef FEAT_ARABIC
191# define PV_ARAB OPT_WIN(WV_ARAB)
192#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +0200193#ifdef FEAT_LINEBREAK
194# define PV_BRI OPT_WIN(WV_BRI)
195# define PV_BRIOPT OPT_WIN(WV_BRIOPT)
196#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000197#ifdef FEAT_DIFF
198# define PV_DIFF OPT_WIN(WV_DIFF)
199#endif
200#ifdef FEAT_FOLDING
201# define PV_FDC OPT_WIN(WV_FDC)
202# define PV_FEN OPT_WIN(WV_FEN)
203# define PV_FDI OPT_WIN(WV_FDI)
204# define PV_FDL OPT_WIN(WV_FDL)
205# define PV_FDM OPT_WIN(WV_FDM)
206# define PV_FML OPT_WIN(WV_FML)
207# define PV_FDN OPT_WIN(WV_FDN)
208# ifdef FEAT_EVAL
209# define PV_FDE OPT_WIN(WV_FDE)
210# define PV_FDT OPT_WIN(WV_FDT)
211# endif
212# define PV_FMR OPT_WIN(WV_FMR)
213#endif
214#ifdef FEAT_LINEBREAK
215# define PV_LBR OPT_WIN(WV_LBR)
216#endif
217#define PV_NU OPT_WIN(WV_NU)
Bram Moolenaar64486672010-05-16 15:46:46 +0200218#define PV_RNU OPT_WIN(WV_RNU)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000219#ifdef FEAT_LINEBREAK
220# define PV_NUW OPT_WIN(WV_NUW)
221#endif
222#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
223# define PV_PVW OPT_WIN(WV_PVW)
224#endif
225#ifdef FEAT_RIGHTLEFT
226# define PV_RL OPT_WIN(WV_RL)
227# define PV_RLC OPT_WIN(WV_RLC)
228#endif
229#ifdef FEAT_SCROLLBIND
230# define PV_SCBIND OPT_WIN(WV_SCBIND)
231#endif
232#define PV_SCROLL OPT_WIN(WV_SCROLL)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000233#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000234# define PV_SPELL OPT_WIN(WV_SPELL)
235#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000236#ifdef FEAT_SYN_HL
237# define PV_CUC OPT_WIN(WV_CUC)
238# define PV_CUL OPT_WIN(WV_CUL)
Bram Moolenaar1a384422010-07-14 19:53:30 +0200239# define PV_CC OPT_WIN(WV_CC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000240#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000241#ifdef FEAT_STL_OPT
242# define PV_STL OPT_BOTH(OPT_WIN(WV_STL))
243#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +0100244#define PV_UL OPT_BOTH(OPT_BUF(BV_UL))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000245#ifdef FEAT_WINDOWS
246# define PV_WFH OPT_WIN(WV_WFH)
247#endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +0000248#ifdef FEAT_VERTSPLIT
249# define PV_WFW OPT_WIN(WV_WFW)
250#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000251#define PV_WRAP OPT_WIN(WV_WRAP)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200252#ifdef FEAT_CURSORBIND
253# define PV_CRBIND OPT_WIN(WV_CRBIND)
254#endif
255#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200256# define PV_COCU OPT_WIN(WV_COCU)
257# define PV_COLE OPT_WIN(WV_COLE)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200258#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000259
260/* WV_ and BV_ values get typecasted to this for the "indir" field */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000261typedef enum
262{
Bram Moolenaar7d96acd2008-06-09 15:07:54 +0000263 PV_NONE = 0,
264 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000265} idopt_T;
266
267/*
268 * Options local to a window have a value local to a buffer and global to all
269 * buffers. Indicate this by setting "var" to VAR_WIN.
270 */
271#define VAR_WIN ((char_u *)-1)
272
273/*
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000274 * These are the global values for options which are also local to a buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000275 * Only to be used in option.c!
276 */
277static int p_ai;
278static int p_bin;
279#ifdef FEAT_MBYTE
280static int p_bomb;
281#endif
282#if defined(FEAT_QUICKFIX)
283static char_u *p_bh;
284static char_u *p_bt;
285#endif
286static int p_bl;
287static int p_ci;
288#ifdef FEAT_CINDENT
289static int p_cin;
290static char_u *p_cink;
291static char_u *p_cino;
292#endif
293#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
294static char_u *p_cinw;
295#endif
296#ifdef FEAT_COMMENTS
297static char_u *p_com;
298#endif
299#ifdef FEAT_FOLDING
300static char_u *p_cms;
301#endif
302#ifdef FEAT_INS_EXPAND
303static char_u *p_cpt;
304#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000305#ifdef FEAT_COMPL_FUNC
306static char_u *p_cfu;
Bram Moolenaare344bea2005-09-01 20:46:49 +0000307static char_u *p_ofu;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000308#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000309static int p_eol;
Bram Moolenaar34d72d42015-07-17 14:18:08 +0200310static int p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000311static int p_et;
312#ifdef FEAT_MBYTE
313static char_u *p_fenc;
314#endif
315static char_u *p_ff;
316static char_u *p_fo;
Bram Moolenaar86b68352004-12-27 21:59:20 +0000317static char_u *p_flp;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000318#ifdef FEAT_AUTOCMD
319static char_u *p_ft;
320#endif
321static long p_iminsert;
322static long p_imsearch;
323#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
324static char_u *p_inex;
325#endif
326#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
327static char_u *p_inde;
328static char_u *p_indk;
329#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +0000330#if defined(FEAT_EVAL)
331static char_u *p_fex;
332#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000333static int p_inf;
334static char_u *p_isk;
335#ifdef FEAT_CRYPT
336static char_u *p_key;
337#endif
338#ifdef FEAT_LISP
339static int p_lisp;
340#endif
341static int p_ml;
342static int p_ma;
343static int p_mod;
344static char_u *p_mps;
345static char_u *p_nf;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000346static int p_pi;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000347#ifdef FEAT_TEXTOBJ
348static char_u *p_qe;
349#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000350static int p_ro;
351#ifdef FEAT_SMARTINDENT
352static int p_si;
353#endif
354#ifndef SHORT_FNAME
355static int p_sn;
356#endif
357static long p_sts;
358#if defined(FEAT_SEARCHPATH)
359static char_u *p_sua;
360#endif
361static long p_sw;
362static int p_swf;
363#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +0000364static long p_smc;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000365static char_u *p_syn;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000366#endif
367#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000368static char_u *p_spc;
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000369static char_u *p_spf;
Bram Moolenaar217ad922005-03-20 22:37:15 +0000370static char_u *p_spl;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000371#endif
372static long p_ts;
373static long p_tw;
374static int p_tx;
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200375#ifdef FEAT_PERSISTENT_UNDO
376static int p_udf;
377#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000378static long p_wm;
379#ifdef FEAT_KEYMAP
380static char_u *p_keymap;
381#endif
382
383/* Saved values for when 'bin' is set. */
384static int p_et_nobin;
385static int p_ml_nobin;
386static long p_tw_nobin;
387static long p_wm_nobin;
388
389/* Saved values for when 'paste' is set */
390static long p_tw_nopaste;
391static long p_wm_nopaste;
392static long p_sts_nopaste;
393static int p_ai_nopaste;
394
395struct vimoption
396{
397 char *fullname; /* full option name */
398 char *shortname; /* permissible abbreviation */
399 long_u flags; /* see below */
400 char_u *var; /* global option: pointer to variable;
401 * window-local option: VAR_WIN;
402 * buffer-local option: global value */
403 idopt_T indir; /* global option: PV_NONE;
404 * local option: indirect option index */
405 char_u *def_val[2]; /* default values for variable (vi and vim) */
406#ifdef FEAT_EVAL
407 scid_T scriptID; /* script in which the option was last set */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000408# define SCRIPTID_INIT , 0
409#else
410# define SCRIPTID_INIT
Bram Moolenaar071d4272004-06-13 20:20:40 +0000411#endif
412};
413
414#define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */
415#define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */
416
417/*
418 * Flags
419 */
420#define P_BOOL 0x01 /* the option is boolean */
421#define P_NUM 0x02 /* the option is numeric */
422#define P_STRING 0x04 /* the option is a string */
423#define P_ALLOCED 0x08 /* the string option is in allocated memory,
Bram Moolenaar363cb672009-07-22 12:28:17 +0000424 must use free_string_option() when
425 assigning new value. Not set if default is
426 the same. */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000427#define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
428 never be used for local or hidden options! */
429#define P_NODEFAULT 0x40 /* don't set to default value */
430#define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must
431 use vim_free() when assigning new value */
432#define P_WAS_SET 0x100 /* option has been set/reset */
433#define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */
434#define P_VI_DEF 0x400 /* Use Vi default for Vim */
435#define P_VIM 0x800 /* Vim option, reset when 'cp' set */
436
437 /* when option changed, what to display: */
438#define P_RSTAT 0x1000 /* redraw status lines */
439#define P_RWIN 0x2000 /* redraw current window */
440#define P_RBUF 0x4000 /* redraw current buffer */
441#define P_RALL 0x6000 /* redraw all windows */
442#define P_RCLR 0x7000 /* clear and redraw all */
443
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200444#define P_COMMA 0x8000 /* comma separated list */
445#define P_ONECOMMA 0x18000L /* P_COMMA and cannot have two consecutive
446 * commas */
447#define P_NODUP 0x20000L /* don't allow duplicate strings */
448#define P_FLAGLIST 0x40000L /* list of single-char flags */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000449
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200450#define P_SECURE 0x80000L /* cannot change in modeline or secure mode */
451#define P_GETTEXT 0x100000L /* expand default value with _() */
452#define P_NOGLOB 0x200000L /* do not use local value for global vimrc */
453#define P_NFNAME 0x400000L /* only normal file name chars allowed */
454#define P_INSECURE 0x800000L /* option was set from a modeline */
455#define P_PRI_MKRC 0x1000000L /* priority for :mkvimrc (setting option has
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000456 side effects) */
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200457#define P_NO_ML 0x2000000L /* not allowed in modeline */
458#define P_CURSWANT 0x4000000L /* update curswant required; not needed when
Bram Moolenaar913077c2012-03-28 19:59:04 +0200459 * there is a redraw flag */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000460
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000461#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
462
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000463/* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used
464 * for the currency sign. */
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000465#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000466# define ISP_LATIN1 (char_u *)"@,~-255"
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000467#else
468# define ISP_LATIN1 (char_u *)"@,161-255"
469#endif
470
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000471/* The 16 bit MS-DOS version is low on space, make the string as short as
472 * possible when compiling with few features. */
473#if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
474 || defined(FEAT_VERTSPLIT) || defined(FEAT_CLIPBOARD) \
Bram Moolenaar860cae12010-06-05 23:22:07 +0200475 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) || defined(FEAT_CONCEAL)
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100476# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000477#else
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100478# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000479#endif
480
Bram Moolenaar071d4272004-06-13 20:20:40 +0000481/*
482 * options[] is initialized here.
483 * The order of the options MUST be alphabetic for ":set all" and findoption().
484 * All option names MUST start with a lowercase letter (for findoption()).
485 * Exception: "t_" options are at the end.
486 * The options with a NULL variable are 'hidden': a set command for them is
487 * ignored and they are not printed.
488 */
489static struct vimoption
490#ifdef FEAT_GUI_W16
491 _far
492#endif
493 options[] =
494{
Bram Moolenaar913077c2012-03-28 19:59:04 +0200495 {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000496#ifdef FEAT_RIGHTLEFT
497 (char_u *)&p_aleph, PV_NONE,
498#else
499 (char_u *)NULL, PV_NONE,
500#endif
501 {
502#if (defined(MSDOS) || defined(WIN3264) || defined(OS2)) && !defined(FEAT_GUI_W32)
503 (char_u *)128L,
504#else
505 (char_u *)224L,
506#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000507 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000508 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
509#if defined(FEAT_GUI) && defined(MACOS_X)
510 (char_u *)&p_antialias, PV_NONE,
511 {(char_u *)FALSE, (char_u *)FALSE}
512#else
513 (char_u *)NULL, PV_NONE,
514 {(char_u *)FALSE, (char_u *)FALSE}
515#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000516 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200517 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000518#ifdef FEAT_ARABIC
519 (char_u *)VAR_WIN, PV_ARAB,
520#else
521 (char_u *)NULL, PV_NONE,
522#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000523 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000524 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
525#ifdef FEAT_ARABIC
526 (char_u *)&p_arshape, PV_NONE,
527#else
528 (char_u *)NULL, PV_NONE,
529#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000530 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000531 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
532#ifdef FEAT_RIGHTLEFT
533 (char_u *)&p_ari, PV_NONE,
534#else
535 (char_u *)NULL, PV_NONE,
536#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000537 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000538 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
539#ifdef FEAT_FKMAP
540 (char_u *)&p_altkeymap, PV_NONE,
541#else
542 (char_u *)NULL, PV_NONE,
543#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000544 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000545 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
546#if defined(FEAT_MBYTE)
547 (char_u *)&p_ambw, PV_NONE,
548 {(char_u *)"single", (char_u *)0L}
549#else
550 (char_u *)NULL, PV_NONE,
551 {(char_u *)0L, (char_u *)0L}
552#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000553 SCRIPTID_INIT},
Bram Moolenaar8dff8182006-04-06 20:18:50 +0000554#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +0000555 {"autochdir", "acd", P_BOOL|P_VI_DEF,
556 (char_u *)&p_acd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000557 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000558#endif
559 {"autoindent", "ai", P_BOOL|P_VI_DEF,
560 (char_u *)&p_ai, PV_AI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000561 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000562 {"autoprint", "ap", P_BOOL|P_VI_DEF,
563 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000564 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000565 {"autoread", "ar", P_BOOL|P_VI_DEF,
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000566 (char_u *)&p_ar, PV_AR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000567 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000568 {"autowrite", "aw", P_BOOL|P_VI_DEF,
569 (char_u *)&p_aw, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000570 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000571 {"autowriteall","awa", P_BOOL|P_VI_DEF,
572 (char_u *)&p_awa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000573 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000574 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
575 (char_u *)&p_bg, PV_NONE,
576 {
577#if (defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI)
578 (char_u *)"dark",
579#else
580 (char_u *)"light",
581#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000582 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200583 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000584 (char_u *)&p_bs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000585 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000586 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
587 (char_u *)&p_bk, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000588 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200589 {"backupcopy", "bkc", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +0200590 (char_u *)&p_bkc, PV_BKC,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000591#ifdef UNIX
592 {(char_u *)"yes", (char_u *)"auto"}
593#else
594 {(char_u *)"auto", (char_u *)"auto"}
595#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000596 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200597 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
598 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000599 (char_u *)&p_bdir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000600 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000601 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000602 (char_u *)&p_bex, PV_NONE,
603 {
604#ifdef VMS
605 (char_u *)"_",
606#else
607 (char_u *)"~",
608#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000609 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200610 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000611#ifdef FEAT_WILDIGN
612 (char_u *)&p_bsk, PV_NONE,
613 {(char_u *)"", (char_u *)0L}
614#else
615 (char_u *)NULL, PV_NONE,
616 {(char_u *)0L, (char_u *)0L}
617#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000618 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000619#ifdef FEAT_BEVAL
620 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
621 (char_u *)&p_bdlay, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000622 {(char_u *)600L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000623 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
624 (char_u *)&p_beval, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000625 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000626# ifdef FEAT_EVAL
Bram Moolenaar39f05632006-03-19 22:15:26 +0000627 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000628 (char_u *)&p_bexpr, PV_BEXPR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000629 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000630# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000631#endif
632 {"beautify", "bf", P_BOOL|P_VI_DEF,
633 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000634 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000635 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
636 (char_u *)&p_bin, PV_BIN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000637 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000638 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
639#ifdef MSDOS
640 (char_u *)&p_biosk, PV_NONE,
641#else
642 (char_u *)NULL, PV_NONE,
643#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000644 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000645 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
646#ifdef FEAT_MBYTE
647 (char_u *)&p_bomb, PV_BOMB,
648#else
649 (char_u *)NULL, PV_NONE,
650#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000651 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000652 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
653#ifdef FEAT_LINEBREAK
654 (char_u *)&p_breakat, PV_NONE,
655 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
656#else
657 (char_u *)NULL, PV_NONE,
658 {(char_u *)0L, (char_u *)0L}
659#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000660 SCRIPTID_INIT},
Bram Moolenaar597a4222014-06-25 14:39:50 +0200661 {"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
662#ifdef FEAT_LINEBREAK
663 (char_u *)VAR_WIN, PV_BRI,
664 {(char_u *)FALSE, (char_u *)0L}
665#else
666 (char_u *)NULL, PV_NONE,
667 {(char_u *)0L, (char_u *)0L}
668#endif
669 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200670 {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF
671 |P_ONECOMMA|P_NODUP,
Bram Moolenaar597a4222014-06-25 14:39:50 +0200672#ifdef FEAT_LINEBREAK
673 (char_u *)VAR_WIN, PV_BRIOPT,
674 {(char_u *)"", (char_u *)NULL}
675#else
676 (char_u *)NULL, PV_NONE,
677 {(char_u *)"", (char_u *)NULL}
678#endif
679 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000680 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
681#ifdef FEAT_BROWSE
682 (char_u *)&p_bsdir, PV_NONE,
683 {(char_u *)"last", (char_u *)0L}
684#else
685 (char_u *)NULL, PV_NONE,
686 {(char_u *)0L, (char_u *)0L}
687#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000688 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000689 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
690#if defined(FEAT_QUICKFIX)
691 (char_u *)&p_bh, PV_BH,
692 {(char_u *)"", (char_u *)0L}
693#else
694 (char_u *)NULL, PV_NONE,
695 {(char_u *)0L, (char_u *)0L}
696#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000697 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000698 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
699 (char_u *)&p_bl, PV_BL,
700 {(char_u *)1L, (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000701 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000702 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
703#if defined(FEAT_QUICKFIX)
704 (char_u *)&p_bt, PV_BT,
705 {(char_u *)"", (char_u *)0L}
706#else
707 (char_u *)NULL, PV_NONE,
708 {(char_u *)0L, (char_u *)0L}
709#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000710 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200711 {"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000712#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000713 (char_u *)&p_cmp, PV_NONE,
714 {(char_u *)"internal,keepascii", (char_u *)0L}
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000715#else
716 (char_u *)NULL, PV_NONE,
717 {(char_u *)0L, (char_u *)0L}
718#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000719 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000720 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
721#ifdef FEAT_SEARCHPATH
722 (char_u *)&p_cdpath, PV_NONE,
723 {(char_u *)",,", (char_u *)0L}
724#else
725 (char_u *)NULL, PV_NONE,
726 {(char_u *)0L, (char_u *)0L}
727#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000728 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000729 {"cedit", NULL, P_STRING,
730#ifdef FEAT_CMDWIN
731 (char_u *)&p_cedit, PV_NONE,
732 {(char_u *)"", (char_u *)CTRL_F_STR}
733#else
734 (char_u *)NULL, PV_NONE,
735 {(char_u *)0L, (char_u *)0L}
736#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000737 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000738 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
739#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
740 (char_u *)&p_ccv, PV_NONE,
741 {(char_u *)"", (char_u *)0L}
742#else
743 (char_u *)NULL, PV_NONE,
744 {(char_u *)0L, (char_u *)0L}
745#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000746 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000747 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
748#ifdef FEAT_CINDENT
749 (char_u *)&p_cin, PV_CIN,
750#else
751 (char_u *)NULL, PV_NONE,
752#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000753 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200754 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000755#ifdef FEAT_CINDENT
756 (char_u *)&p_cink, PV_CINK,
757 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
758#else
759 (char_u *)NULL, PV_NONE,
760 {(char_u *)0L, (char_u *)0L}
761#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000762 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200763 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000764#ifdef FEAT_CINDENT
765 (char_u *)&p_cino, PV_CINO,
766#else
767 (char_u *)NULL, PV_NONE,
768#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000769 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200770 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000771#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
772 (char_u *)&p_cinw, PV_CINW,
773 {(char_u *)"if,else,while,do,for,switch",
774 (char_u *)0L}
775#else
776 (char_u *)NULL, PV_NONE,
777 {(char_u *)0L, (char_u *)0L}
778#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000779 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200780 {"clipboard", "cb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000781#ifdef FEAT_CLIPBOARD
782 (char_u *)&p_cb, PV_NONE,
783# ifdef FEAT_XCLIPBOARD
784 {(char_u *)"autoselect,exclude:cons\\|linux",
785 (char_u *)0L}
786# else
787 {(char_u *)"", (char_u *)0L}
788# endif
789#else
790 (char_u *)NULL, PV_NONE,
791 {(char_u *)"", (char_u *)0L}
792#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000793 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000794 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
795 (char_u *)&p_ch, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000796 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000797 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
798#ifdef FEAT_CMDWIN
799 (char_u *)&p_cwh, PV_NONE,
800#else
801 (char_u *)NULL, PV_NONE,
802#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000803 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200804 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar1a384422010-07-14 19:53:30 +0200805#ifdef FEAT_SYN_HL
806 (char_u *)VAR_WIN, PV_CC,
807#else
808 (char_u *)NULL, PV_NONE,
809#endif
810 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000811 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
812 (char_u *)&Columns, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000813 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200814 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
815 |P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000816#ifdef FEAT_COMMENTS
817 (char_u *)&p_com, PV_COM,
818 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
819 (char_u *)0L}
820#else
821 (char_u *)NULL, PV_NONE,
822 {(char_u *)0L, (char_u *)0L}
823#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000824 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200825 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000826#ifdef FEAT_FOLDING
827 (char_u *)&p_cms, PV_CMS,
828 {(char_u *)"/*%s*/", (char_u *)0L}
829#else
830 (char_u *)NULL, PV_NONE,
831 {(char_u *)0L, (char_u *)0L}
832#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000833 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000834 /* P_PRI_MKRC isn't needed here, optval_default()
835 * always returns TRUE for 'compatible' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000836 {"compatible", "cp", P_BOOL|P_RALL,
837 (char_u *)&p_cp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000838 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200839 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000840#ifdef FEAT_INS_EXPAND
841 (char_u *)&p_cpt, PV_CPT,
842 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
843#else
844 (char_u *)NULL, PV_NONE,
845 {(char_u *)0L, (char_u *)0L}
846#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000847 SCRIPTID_INIT},
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200848 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200849#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200850 (char_u *)VAR_WIN, PV_COCU,
851 {(char_u *)"", (char_u *)NULL}
852#else
853 (char_u *)NULL, PV_NONE,
854 {(char_u *)NULL, (char_u *)0L}
855#endif
856 SCRIPTID_INIT},
857 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
858#ifdef FEAT_CONCEAL
859 (char_u *)VAR_WIN, PV_COLE,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200860#else
861 (char_u *)NULL, PV_NONE,
862#endif
863 {(char_u *)0L, (char_u *)0L}
864 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000865 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
866#ifdef FEAT_COMPL_FUNC
867 (char_u *)&p_cfu, PV_CFU,
868 {(char_u *)"", (char_u *)0L}
869#else
870 (char_u *)NULL, PV_NONE,
871 {(char_u *)0L, (char_u *)0L}
872#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000873 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200874 {"completeopt", "cot", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000875#ifdef FEAT_INS_EXPAND
876 (char_u *)&p_cot, PV_NONE,
Bram Moolenaarc270d802006-03-11 21:29:41 +0000877 {(char_u *)"menu,preview", (char_u *)0L}
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000878#else
879 (char_u *)NULL, PV_NONE,
880 {(char_u *)0L, (char_u *)0L}
881#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000882 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000883 {"confirm", "cf", P_BOOL|P_VI_DEF,
884#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
885 (char_u *)&p_confirm, PV_NONE,
886#else
887 (char_u *)NULL, PV_NONE,
888#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000889 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000890 {"conskey", "consk",P_BOOL|P_VI_DEF,
891#ifdef MSDOS
892 (char_u *)&p_consk, PV_NONE,
893#else
894 (char_u *)NULL, PV_NONE,
895#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000896 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000897 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
898 (char_u *)&p_ci, PV_CI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000899 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000900 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
901 (char_u *)&p_cpo, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000902 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
903 SCRIPTID_INIT},
Bram Moolenaar49771f42010-07-20 17:32:38 +0200904 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200905#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200906 (char_u *)&p_cm, PV_CM,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200907 {(char_u *)"zip", (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200908#else
909 (char_u *)NULL, PV_NONE,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200910 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200911#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +0200912 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000913 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
914#ifdef FEAT_CSCOPE
915 (char_u *)&p_cspc, PV_NONE,
916#else
917 (char_u *)NULL, PV_NONE,
918#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000919 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000920 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
921#ifdef FEAT_CSCOPE
922 (char_u *)&p_csprg, PV_NONE,
923 {(char_u *)"cscope", (char_u *)0L}
924#else
925 (char_u *)NULL, PV_NONE,
926 {(char_u *)0L, (char_u *)0L}
927#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000928 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200929 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000930#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
931 (char_u *)&p_csqf, PV_NONE,
932 {(char_u *)"", (char_u *)0L}
933#else
934 (char_u *)NULL, PV_NONE,
935 {(char_u *)0L, (char_u *)0L}
936#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000937 SCRIPTID_INIT},
Bram Moolenaarf7befa92011-06-12 22:13:40 +0200938 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM,
939#ifdef FEAT_CSCOPE
940 (char_u *)&p_csre, PV_NONE,
941#else
942 (char_u *)NULL, PV_NONE,
943#endif
944 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000945 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
946#ifdef FEAT_CSCOPE
947 (char_u *)&p_cst, PV_NONE,
948#else
949 (char_u *)NULL, PV_NONE,
950#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000951 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000952 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
953#ifdef FEAT_CSCOPE
954 (char_u *)&p_csto, PV_NONE,
955#else
956 (char_u *)NULL, PV_NONE,
957#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000958 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000959 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
960#ifdef FEAT_CSCOPE
961 (char_u *)&p_csverbose, PV_NONE,
962#else
963 (char_u *)NULL, PV_NONE,
964#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000965 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200966 {"cursorbind", "crb", P_BOOL|P_VI_DEF,
967#ifdef FEAT_CURSORBIND
968 (char_u *)VAR_WIN, PV_CRBIND,
969#else
970 (char_u *)NULL, PV_NONE,
971#endif
972 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000973 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
974#ifdef FEAT_SYN_HL
975 (char_u *)VAR_WIN, PV_CUC,
976#else
977 (char_u *)NULL, PV_NONE,
978#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000979 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000980 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWIN,
981#ifdef FEAT_SYN_HL
982 (char_u *)VAR_WIN, PV_CUL,
983#else
984 (char_u *)NULL, PV_NONE,
985#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000986 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000987 {"debug", NULL, P_STRING|P_VI_DEF,
988 (char_u *)&p_debug, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000989 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200990 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000991#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000992 (char_u *)&p_def, PV_DEF,
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000993 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000994#else
995 (char_u *)NULL, PV_NONE,
996 {(char_u *)NULL, (char_u *)0L}
997#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000998 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000999 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
1000#ifdef FEAT_MBYTE
1001 (char_u *)&p_deco, PV_NONE,
1002#else
1003 (char_u *)NULL, PV_NONE,
1004#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001005 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001006 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001007#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001008 (char_u *)&p_dict, PV_DICT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001009#else
1010 (char_u *)NULL, PV_NONE,
1011#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001012 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001013 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
1014#ifdef FEAT_DIFF
1015 (char_u *)VAR_WIN, PV_DIFF,
1016#else
1017 (char_u *)NULL, PV_NONE,
1018#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001019 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001020 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001021#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1022 (char_u *)&p_dex, PV_NONE,
1023 {(char_u *)"", (char_u *)0L}
1024#else
1025 (char_u *)NULL, PV_NONE,
1026 {(char_u *)0L, (char_u *)0L}
1027#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001028 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001029 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_ONECOMMA
1030 |P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001031#ifdef FEAT_DIFF
1032 (char_u *)&p_dip, PV_NONE,
1033 {(char_u *)"filler", (char_u *)NULL}
1034#else
1035 (char_u *)NULL, PV_NONE,
1036 {(char_u *)"", (char_u *)NULL}
1037#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001038 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001039 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
1040#ifdef FEAT_DIGRAPHS
1041 (char_u *)&p_dg, PV_NONE,
1042#else
1043 (char_u *)NULL, PV_NONE,
1044#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001045 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001046 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
1047 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001048 (char_u *)&p_dir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001049 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001050 {"display", "dy", P_STRING|P_VI_DEF|P_ONECOMMA|P_RALL|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001051 (char_u *)&p_dy, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001052 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001053 {"eadirection", "ead", P_STRING|P_VI_DEF,
1054#ifdef FEAT_VERTSPLIT
1055 (char_u *)&p_ead, PV_NONE,
1056 {(char_u *)"both", (char_u *)0L}
1057#else
1058 (char_u *)NULL, PV_NONE,
1059 {(char_u *)NULL, (char_u *)0L}
1060#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001061 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001062 {"edcompatible","ed", P_BOOL|P_VI_DEF,
1063 (char_u *)&p_ed, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001064 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar865242e2010-07-14 21:12:05 +02001065 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001066#ifdef FEAT_MBYTE
1067 (char_u *)&p_enc, PV_NONE,
1068 {(char_u *)ENC_DFLT, (char_u *)0L}
1069#else
1070 (char_u *)NULL, PV_NONE,
1071 {(char_u *)0L, (char_u *)0L}
1072#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001073 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001074 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1075 (char_u *)&p_eol, PV_EOL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001076 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001077 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1078 (char_u *)&p_ea, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001079 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001080 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001081 (char_u *)&p_ep, PV_EP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001082 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001083 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1084 (char_u *)&p_eb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001085 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001086 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1087#ifdef FEAT_QUICKFIX
1088 (char_u *)&p_ef, PV_NONE,
1089 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1090#else
1091 (char_u *)NULL, PV_NONE,
1092 {(char_u *)NULL, (char_u *)0L}
1093#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001094 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001095 {"errorformat", "efm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001096#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001097 (char_u *)&p_efm, PV_EFM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001098 {(char_u *)DFLT_EFM, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001099#else
1100 (char_u *)NULL, PV_NONE,
1101 {(char_u *)NULL, (char_u *)0L}
1102#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001103 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001104 {"esckeys", "ek", P_BOOL|P_VIM,
1105 (char_u *)&p_ek, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001106 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001107 {"eventignore", "ei", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001108#ifdef FEAT_AUTOCMD
1109 (char_u *)&p_ei, PV_NONE,
1110#else
1111 (char_u *)NULL, PV_NONE,
1112#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001113 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001114 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1115 (char_u *)&p_et, PV_ET,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001116 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001117 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1118 (char_u *)&p_exrc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001119 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001120 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF
1121 |P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001122#ifdef FEAT_MBYTE
1123 (char_u *)&p_fenc, PV_FENC,
1124 {(char_u *)"", (char_u *)0L}
1125#else
1126 (char_u *)NULL, PV_NONE,
1127 {(char_u *)0L, (char_u *)0L}
1128#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001129 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001130 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001131#ifdef FEAT_MBYTE
1132 (char_u *)&p_fencs, PV_NONE,
1133 {(char_u *)"ucs-bom", (char_u *)0L}
1134#else
1135 (char_u *)NULL, PV_NONE,
1136 {(char_u *)0L, (char_u *)0L}
1137#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001138 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001139 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC
1140 |P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001141 (char_u *)&p_ff, PV_FF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001142 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001143 {"fileformats", "ffs", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001144 (char_u *)&p_ffs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001145 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1146 SCRIPTID_INIT},
Bram Moolenaar71afbfe2013-03-19 16:49:16 +01001147 {"fileignorecase", "fic", P_BOOL|P_VI_DEF,
1148 (char_u *)&p_fic, PV_NONE,
1149 {
1150#ifdef CASE_INSENSITIVE_FILENAME
1151 (char_u *)TRUE,
1152#else
1153 (char_u *)FALSE,
1154#endif
1155 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001156 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001157#ifdef FEAT_AUTOCMD
1158 (char_u *)&p_ft, PV_FT,
1159 {(char_u *)"", (char_u *)0L}
1160#else
1161 (char_u *)NULL, PV_NONE,
1162 {(char_u *)0L, (char_u *)0L}
1163#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001164 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001165 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001166#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1167 (char_u *)&p_fcs, PV_NONE,
1168 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1169#else
1170 (char_u *)NULL, PV_NONE,
1171 {(char_u *)"", (char_u *)0L}
1172#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001173 SCRIPTID_INIT},
Bram Moolenaar34d72d42015-07-17 14:18:08 +02001174 {"fixendofline", "fixeol", P_BOOL|P_VI_DEF|P_RSTAT,
1175 (char_u *)&p_fixeol, PV_FIXEOL,
1176 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001177 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1178#ifdef FEAT_FKMAP
1179 (char_u *)&p_fkmap, PV_NONE,
1180#else
1181 (char_u *)NULL, PV_NONE,
1182#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001183 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001184 {"flash", "fl", P_BOOL|P_VI_DEF,
1185 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001186 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001187#ifdef FEAT_FOLDING
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001188 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001189 (char_u *)&p_fcl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001190 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001191 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1192 (char_u *)VAR_WIN, PV_FDC,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001193 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001194 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1195 (char_u *)VAR_WIN, PV_FEN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001196 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001197 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1198# ifdef FEAT_EVAL
1199 (char_u *)VAR_WIN, PV_FDE,
1200 {(char_u *)"0", (char_u *)NULL}
1201# else
1202 (char_u *)NULL, PV_NONE,
1203 {(char_u *)NULL, (char_u *)0L}
1204# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001205 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001206 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1207 (char_u *)VAR_WIN, PV_FDI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001208 {(char_u *)"#", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001209 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
1210 (char_u *)VAR_WIN, PV_FDL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001211 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001212 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001213 (char_u *)&p_fdls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001214 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001215 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001216 P_RWIN|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001217 (char_u *)VAR_WIN, PV_FMR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001218 {(char_u *)"{{{,}}}", (char_u *)NULL}
1219 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001220 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1221 (char_u *)VAR_WIN, PV_FDM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001222 {(char_u *)"manual", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001223 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1224 (char_u *)VAR_WIN, PV_FML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001225 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001226 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1227 (char_u *)VAR_WIN, PV_FDN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001228 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001229 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001230 (char_u *)&p_fdo, PV_NONE,
1231 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001232 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001233 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1234# ifdef FEAT_EVAL
1235 (char_u *)VAR_WIN, PV_FDT,
1236 {(char_u *)"foldtext()", (char_u *)NULL}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001237# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001238 (char_u *)NULL, PV_NONE,
1239 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001240# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001241 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001242#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001243 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001244#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001245 (char_u *)&p_fex, PV_FEX,
1246 {(char_u *)"", (char_u *)0L}
1247#else
1248 (char_u *)NULL, PV_NONE,
1249 {(char_u *)0L, (char_u *)0L}
1250#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001251 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001252 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1253 (char_u *)&p_fo, PV_FO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001254 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1255 SCRIPTID_INIT},
Bram Moolenaar86b68352004-12-27 21:59:20 +00001256 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1257 (char_u *)&p_flp, PV_FLP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001258 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1259 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001260 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1261 (char_u *)&p_fp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001262 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001263 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1264#ifdef HAVE_FSYNC
1265 (char_u *)&p_fs, PV_NONE,
1266 {(char_u *)TRUE, (char_u *)0L}
1267#else
1268 (char_u *)NULL, PV_NONE,
1269 {(char_u *)FALSE, (char_u *)0L}
1270#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001271 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001272 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1273 (char_u *)&p_gd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001274 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001275 {"graphic", "gr", P_BOOL|P_VI_DEF,
1276 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001277 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001278 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001279#ifdef FEAT_QUICKFIX
1280 (char_u *)&p_gefm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001281 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001282#else
1283 (char_u *)NULL, PV_NONE,
1284 {(char_u *)NULL, (char_u *)0L}
1285#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001286 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001287 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1288#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001289 (char_u *)&p_gp, PV_GP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001290 {
1291# ifdef WIN3264
1292 /* may be changed to "grep -n" in os_win32.c */
1293 (char_u *)"findstr /n",
1294# else
1295# ifdef UNIX
1296 /* Add an extra file name so that grep will always
1297 * insert a file name in the match line. */
1298 (char_u *)"grep -n $* /dev/null",
1299# else
1300# ifdef VMS
1301 (char_u *)"SEARCH/NUMBERS ",
1302# else
1303 (char_u *)"grep -n ",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001304# endif
1305# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001306# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001307 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001308#else
1309 (char_u *)NULL, PV_NONE,
1310 {(char_u *)NULL, (char_u *)0L}
1311#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001312 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001313 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001314#ifdef CURSOR_SHAPE
1315 (char_u *)&p_guicursor, PV_NONE,
1316 {
1317# ifdef FEAT_GUI
1318 (char_u *)"n-v-c:block-Cursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor,sm:block-Cursor-blinkwait175-blinkoff150-blinkon175",
1319# else /* MSDOS or Win32 console */
1320 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1321# endif
1322 (char_u *)0L}
1323#else
1324 (char_u *)NULL, PV_NONE,
1325 {(char_u *)NULL, (char_u *)0L}
1326#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001327 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001328 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001329#ifdef FEAT_GUI
1330 (char_u *)&p_guifont, PV_NONE,
1331 {(char_u *)"", (char_u *)0L}
1332#else
1333 (char_u *)NULL, PV_NONE,
1334 {(char_u *)NULL, (char_u *)0L}
1335#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001336 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001337 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001338#if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1339 (char_u *)&p_guifontset, PV_NONE,
1340 {(char_u *)"", (char_u *)0L}
1341#else
1342 (char_u *)NULL, PV_NONE,
1343 {(char_u *)NULL, (char_u *)0L}
1344#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001345 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001346 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001347#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1348 (char_u *)&p_guifontwide, PV_NONE,
1349 {(char_u *)"", (char_u *)0L}
1350#else
1351 (char_u *)NULL, PV_NONE,
1352 {(char_u *)NULL, (char_u *)0L}
1353#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001354 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001355 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001356#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001357 (char_u *)&p_ghr, PV_NONE,
1358#else
1359 (char_u *)NULL, PV_NONE,
1360#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001361 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001362 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001363#if defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001364 (char_u *)&p_go, PV_NONE,
1365# if defined(UNIX) && !defined(MACOS)
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001366 {(char_u *)"aegimrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001367# else
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001368 {(char_u *)"egmrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001369# endif
1370#else
1371 (char_u *)NULL, PV_NONE,
1372 {(char_u *)NULL, (char_u *)0L}
1373#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001374 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001375 {"guipty", NULL, P_BOOL|P_VI_DEF,
1376#if defined(FEAT_GUI)
1377 (char_u *)&p_guipty, PV_NONE,
1378#else
1379 (char_u *)NULL, PV_NONE,
1380#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001381 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar18144c82006-04-12 21:52:12 +00001382 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00001383#if defined(FEAT_GUI_TABLINE)
1384 (char_u *)&p_gtl, PV_NONE,
1385 {(char_u *)"", (char_u *)0L}
1386#else
1387 (char_u *)NULL, PV_NONE,
1388 {(char_u *)NULL, (char_u *)0L}
1389#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001390 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001391 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar57657d82006-04-21 22:12:41 +00001392#if defined(FEAT_GUI_TABLINE)
1393 (char_u *)&p_gtt, PV_NONE,
1394 {(char_u *)"", (char_u *)0L}
1395#else
1396 (char_u *)NULL, PV_NONE,
1397 {(char_u *)NULL, (char_u *)0L}
1398#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001399 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001400 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1401 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001402 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001403 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1404 (char_u *)&p_hf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001405 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1406 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001407 {"helpheight", "hh", P_NUM|P_VI_DEF,
1408#ifdef FEAT_WINDOWS
1409 (char_u *)&p_hh, PV_NONE,
1410#else
1411 (char_u *)NULL, PV_NONE,
1412#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001413 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001414 {"helplang", "hlg", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001415#ifdef FEAT_MULTI_LANG
1416 (char_u *)&p_hlg, PV_NONE,
1417 {(char_u *)"", (char_u *)0L}
1418#else
1419 (char_u *)NULL, PV_NONE,
1420 {(char_u *)0L, (char_u *)0L}
1421#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001422 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001423 {"hidden", "hid", P_BOOL|P_VI_DEF,
1424 (char_u *)&p_hid, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001425 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001426 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001427 (char_u *)&p_hl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001428 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1429 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001430 {"history", "hi", P_NUM|P_VIM,
1431 (char_u *)&p_hi, PV_NONE,
Bram Moolenaar78159bb2014-06-25 11:48:54 +02001432 {(char_u *)0L, (char_u *)50L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001433 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1434#ifdef FEAT_RIGHTLEFT
1435 (char_u *)&p_hkmap, PV_NONE,
1436#else
1437 (char_u *)NULL, PV_NONE,
1438#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001439 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001440 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1441#ifdef FEAT_RIGHTLEFT
1442 (char_u *)&p_hkmapp, PV_NONE,
1443#else
1444 (char_u *)NULL, PV_NONE,
1445#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001446 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001447 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1448 (char_u *)&p_hls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001449 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001450 {"icon", NULL, P_BOOL|P_VI_DEF,
1451#ifdef FEAT_TITLE
1452 (char_u *)&p_icon, PV_NONE,
1453#else
1454 (char_u *)NULL, PV_NONE,
1455#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001456 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001457 {"iconstring", NULL, P_STRING|P_VI_DEF,
1458#ifdef FEAT_TITLE
1459 (char_u *)&p_iconstring, PV_NONE,
1460#else
1461 (char_u *)NULL, PV_NONE,
1462#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001463 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001464 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1465 (char_u *)&p_ic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001466 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001467 {"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
1468# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1469 (char_u *)&p_imaf, PV_NONE,
1470 {(char_u *)"", (char_u *)NULL}
1471# else
1472 (char_u *)NULL, PV_NONE,
1473 {(char_u *)NULL, (char_u *)0L}
1474# endif
1475 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001476 {"imactivatekey","imak",P_STRING|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001477#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001478 (char_u *)&p_imak, PV_NONE,
1479#else
1480 (char_u *)NULL, PV_NONE,
1481#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001482 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001483 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1484#ifdef USE_IM_CONTROL
1485 (char_u *)&p_imcmdline, PV_NONE,
1486#else
1487 (char_u *)NULL, PV_NONE,
1488#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001489 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001490 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1491#ifdef USE_IM_CONTROL
1492 (char_u *)&p_imdisable, PV_NONE,
1493#else
1494 (char_u *)NULL, PV_NONE,
1495#endif
1496#ifdef __sgi
1497 {(char_u *)TRUE, (char_u *)0L}
1498#else
1499 {(char_u *)FALSE, (char_u *)0L}
1500#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001501 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001502 {"iminsert", "imi", P_NUM|P_VI_DEF,
1503 (char_u *)&p_iminsert, PV_IMI,
1504#ifdef B_IMODE_IM
1505 {(char_u *)B_IMODE_IM, (char_u *)0L}
1506#else
1507 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1508#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001509 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001510 {"imsearch", "ims", P_NUM|P_VI_DEF,
1511 (char_u *)&p_imsearch, PV_IMS,
1512#ifdef B_IMODE_IM
1513 {(char_u *)B_IMODE_IM, (char_u *)0L}
1514#else
1515 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1516#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001517 SCRIPTID_INIT},
Bram Moolenaar4a460702013-06-29 14:42:26 +02001518 {"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001519# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1520 (char_u *)&p_imsf, PV_NONE,
1521 {(char_u *)"", (char_u *)NULL}
1522# else
1523 (char_u *)NULL, PV_NONE,
1524 {(char_u *)NULL, (char_u *)0L}
1525# endif
1526 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001527 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1528#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001529 (char_u *)&p_inc, PV_INC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001530 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1531#else
1532 (char_u *)NULL, PV_NONE,
1533 {(char_u *)0L, (char_u *)0L}
1534#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001535 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001536 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1537#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1538 (char_u *)&p_inex, PV_INEX,
1539 {(char_u *)"", (char_u *)0L}
1540#else
1541 (char_u *)NULL, PV_NONE,
1542 {(char_u *)0L, (char_u *)0L}
1543#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001544 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001545 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1546 (char_u *)&p_is, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001547 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001548 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1549#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1550 (char_u *)&p_inde, PV_INDE,
1551 {(char_u *)"", (char_u *)0L}
1552#else
1553 (char_u *)NULL, PV_NONE,
1554 {(char_u *)0L, (char_u *)0L}
1555#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001556 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001557 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001558#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1559 (char_u *)&p_indk, PV_INDK,
1560 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1561#else
1562 (char_u *)NULL, PV_NONE,
1563 {(char_u *)0L, (char_u *)0L}
1564#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001565 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001566 {"infercase", "inf", P_BOOL|P_VI_DEF,
1567 (char_u *)&p_inf, PV_INF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001568 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001569 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1570 (char_u *)&p_im, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001571 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001572 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1573 (char_u *)&p_isf, PV_NONE,
1574 {
1575#ifdef BACKSLASH_IN_FILENAME
1576 /* Excluded are: & and ^ are special in cmd.exe
1577 * ( and ) are used in text separating fnames */
1578 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1579#else
1580# ifdef AMIGA
1581 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1582# else
1583# ifdef VMS
1584 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1585# else /* UNIX et al. */
1586# ifdef EBCDIC
1587 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1588# else
1589 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1590# endif
1591# endif
1592# endif
1593#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001594 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001595 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1596 (char_u *)&p_isi, PV_NONE,
1597 {
1598#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1599 (char_u *)"@,48-57,_,128-167,224-235",
1600#else
1601# ifdef EBCDIC
1602 /* TODO: EBCDIC Check this! @ == isalpha()*/
1603 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1604 "112-120,128,140-142,156,158,172,"
1605 "174,186,191,203-207,219-225,235-239,"
1606 "251-254",
1607# else
1608 (char_u *)"@,48-57,_,192-255",
1609# endif
1610#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001611 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001612 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1613 (char_u *)&p_isk, PV_ISK,
1614 {
1615#ifdef EBCDIC
1616 (char_u *)"@,240-249,_",
1617 /* TODO: EBCDIC Check this! @ == isalpha()*/
1618 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1619 "112-120,128,140-142,156,158,172,"
1620 "174,186,191,203-207,219-225,235-239,"
1621 "251-254",
1622#else
1623 (char_u *)"@,48-57,_",
1624# if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1625 (char_u *)"@,48-57,_,128-167,224-235"
1626# else
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001627 ISK_LATIN1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001628# endif
1629#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001630 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001631 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1632 (char_u *)&p_isp, PV_NONE,
1633 {
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001634#if defined(MSDOS) || defined(MSWIN) || defined(OS2) \
1635 || (defined(MACOS) && !defined(MACOS_X)) \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001636 || defined(VMS)
1637 (char_u *)"@,~-255",
1638#else
1639# ifdef EBCDIC
1640 /* all chars above 63 are printable */
1641 (char_u *)"63-255",
1642# else
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00001643 ISP_LATIN1,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001644# endif
1645#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001646 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001647 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1648 (char_u *)&p_js, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001649 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001650 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1651#ifdef FEAT_CRYPT
1652 (char_u *)&p_key, PV_KEY,
1653 {(char_u *)"", (char_u *)0L}
1654#else
1655 (char_u *)NULL, PV_NONE,
1656 {(char_u *)0L, (char_u *)0L}
1657#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001658 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001659 {"keymap", "kmp", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001660#ifdef FEAT_KEYMAP
1661 (char_u *)&p_keymap, PV_KMAP,
1662 {(char_u *)"", (char_u *)0L}
1663#else
1664 (char_u *)NULL, PV_NONE,
1665 {(char_u *)"", (char_u *)0L}
1666#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001667 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001668 {"keymodel", "km", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001669 (char_u *)&p_km, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001670 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001671 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001672 (char_u *)&p_kp, PV_KP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001673 {
1674#if defined(MSDOS) || defined(MSWIN)
1675 (char_u *)":help",
1676#else
1677#ifdef VMS
1678 (char_u *)"help",
1679#else
1680# if defined(OS2)
1681 (char_u *)"view /",
1682# else
1683# ifdef USEMAN_S
1684 (char_u *)"man -s",
1685# else
1686 (char_u *)"man",
1687# endif
1688# endif
1689#endif
1690#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001691 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001692 {"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001693#ifdef FEAT_LANGMAP
1694 (char_u *)&p_langmap, PV_NONE,
1695 {(char_u *)"", /* unmatched } */
1696#else
1697 (char_u *)NULL, PV_NONE,
1698 {(char_u *)NULL,
1699#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001700 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001701 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001702#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1703 (char_u *)&p_lm, PV_NONE,
1704#else
1705 (char_u *)NULL, PV_NONE,
1706#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001707 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar4391cf92014-11-05 17:44:52 +01001708 {"langnoremap", "lnr", P_BOOL|P_VI_DEF,
1709#ifdef FEAT_LANGMAP
1710 (char_u *)&p_lnr, PV_NONE,
1711#else
1712 (char_u *)NULL, PV_NONE,
1713#endif
1714 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001715 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1716#ifdef FEAT_WINDOWS
1717 (char_u *)&p_ls, PV_NONE,
1718#else
1719 (char_u *)NULL, PV_NONE,
1720#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001721 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001722 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1723 (char_u *)&p_lz, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001724 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001725 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1726#ifdef FEAT_LINEBREAK
1727 (char_u *)VAR_WIN, PV_LBR,
1728#else
1729 (char_u *)NULL, PV_NONE,
1730#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001731 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001732 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1733 (char_u *)&Rows, PV_NONE,
1734 {
1735#if defined(MSDOS) || defined(WIN3264) || defined(OS2)
1736 (char_u *)25L,
1737#else
1738 (char_u *)24L,
1739#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001740 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001741 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1742#ifdef FEAT_GUI
1743 (char_u *)&p_linespace, PV_NONE,
1744#else
1745 (char_u *)NULL, PV_NONE,
1746#endif
1747#ifdef FEAT_GUI_W32
1748 {(char_u *)1L, (char_u *)0L}
1749#else
1750 {(char_u *)0L, (char_u *)0L}
1751#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001752 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001753 {"lisp", NULL, P_BOOL|P_VI_DEF,
1754#ifdef FEAT_LISP
1755 (char_u *)&p_lisp, PV_LISP,
1756#else
1757 (char_u *)NULL, PV_NONE,
1758#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001759 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001760 {"lispwords", "lw", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001761#ifdef FEAT_LISP
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01001762 (char_u *)&p_lispwords, PV_LW,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001763 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1764#else
1765 (char_u *)NULL, PV_NONE,
1766 {(char_u *)"", (char_u *)0L}
1767#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001768 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001769 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1770 (char_u *)VAR_WIN, PV_LIST,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001771 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001772 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001773 (char_u *)&p_lcs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001774 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001775 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1776 (char_u *)&p_lpl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001777 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001778#ifdef FEAT_GUI_MAC
1779 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
1780 (char_u *)&p_macatsui, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001781 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001782#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001783 {"magic", NULL, P_BOOL|P_VI_DEF,
1784 (char_u *)&p_magic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001785 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00001786 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001787#ifdef FEAT_QUICKFIX
1788 (char_u *)&p_mef, PV_NONE,
1789 {(char_u *)"", (char_u *)0L}
1790#else
1791 (char_u *)NULL, PV_NONE,
1792 {(char_u *)NULL, (char_u *)0L}
1793#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001794 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001795 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1796#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001797 (char_u *)&p_mp, PV_MP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001798# ifdef VMS
1799 {(char_u *)"MMS", (char_u *)0L}
1800# else
1801 {(char_u *)"make", (char_u *)0L}
1802# endif
1803#else
1804 (char_u *)NULL, PV_NONE,
1805 {(char_u *)NULL, (char_u *)0L}
1806#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001807 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001808 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001809 (char_u *)&p_mps, PV_MPS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001810 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1811 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001812 {"matchtime", "mat", P_NUM|P_VI_DEF,
1813 (char_u *)&p_mat, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001814 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001815 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001816#ifdef FEAT_MBYTE
1817 (char_u *)&p_mco, PV_NONE,
1818#else
1819 (char_u *)NULL, PV_NONE,
1820#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001821 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001822 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1823#ifdef FEAT_EVAL
1824 (char_u *)&p_mfd, PV_NONE,
1825#else
1826 (char_u *)NULL, PV_NONE,
1827#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001828 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001829 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1830 (char_u *)&p_mmd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001831 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001832 {"maxmem", "mm", P_NUM|P_VI_DEF,
1833 (char_u *)&p_mm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001834 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1835 SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00001836 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1837 (char_u *)&p_mmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001838 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001839 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1840 (char_u *)&p_mmt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001841 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1842 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001843 {"menuitems", "mis", P_NUM|P_VI_DEF,
1844#ifdef FEAT_MENU
1845 (char_u *)&p_mis, PV_NONE,
1846#else
1847 (char_u *)NULL, PV_NONE,
1848#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001849 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001850 {"mesg", NULL, P_BOOL|P_VI_DEF,
1851 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001852 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001853 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001854#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001855 (char_u *)&p_msm, PV_NONE,
1856 {(char_u *)"460000,2000,500", (char_u *)0L}
1857#else
1858 (char_u *)NULL, PV_NONE,
1859 {(char_u *)0L, (char_u *)0L}
1860#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001861 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001862 {"modeline", "ml", P_BOOL|P_VIM,
1863 (char_u *)&p_ml, PV_ML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001864 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001865 {"modelines", "mls", P_NUM|P_VI_DEF,
1866 (char_u *)&p_mls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001867 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001868 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1869 (char_u *)&p_ma, PV_MA,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001870 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001871 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1872 (char_u *)&p_mod, PV_MOD,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001873 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001874 {"more", NULL, P_BOOL|P_VIM,
1875 (char_u *)&p_more, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001876 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001877 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
1878 (char_u *)&p_mouse, PV_NONE,
1879 {
1880#if defined(MSDOS) || defined(WIN3264)
1881 (char_u *)"a",
1882#else
1883 (char_u *)"",
1884#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001885 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001886 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
1887#ifdef FEAT_GUI
1888 (char_u *)&p_mousef, PV_NONE,
1889#else
1890 (char_u *)NULL, PV_NONE,
1891#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001892 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001893 {"mousehide", "mh", P_BOOL|P_VI_DEF,
1894#ifdef FEAT_GUI
1895 (char_u *)&p_mh, PV_NONE,
1896#else
1897 (char_u *)NULL, PV_NONE,
1898#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001899 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001900 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
1901 (char_u *)&p_mousem, PV_NONE,
1902 {
1903#if defined(MSDOS) || defined(MSWIN)
1904 (char_u *)"popup",
1905#else
1906# if defined(MACOS)
1907 (char_u *)"popup_setpos",
1908# else
1909 (char_u *)"extend",
1910# endif
1911#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001912 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001913 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001914#ifdef FEAT_MOUSESHAPE
1915 (char_u *)&p_mouseshape, PV_NONE,
1916 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
1917#else
1918 (char_u *)NULL, PV_NONE,
1919 {(char_u *)NULL, (char_u *)0L}
1920#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001921 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001922 {"mousetime", "mouset", P_NUM|P_VI_DEF,
1923 (char_u *)&p_mouset, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001924 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001925 {"mzquantum", "mzq", P_NUM,
1926#ifdef FEAT_MZSCHEME
1927 (char_u *)&p_mzq, PV_NONE,
1928#else
1929 (char_u *)NULL, PV_NONE,
1930#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001931 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001932 {"novice", NULL, P_BOOL|P_VI_DEF,
1933 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001934 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001935 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001936 (char_u *)&p_nf, PV_NF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001937 {(char_u *)"octal,hex", (char_u *)0L}
1938 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001939 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
1940 (char_u *)VAR_WIN, PV_NU,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001941 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00001942 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
1943#ifdef FEAT_LINEBREAK
1944 (char_u *)VAR_WIN, PV_NUW,
1945#else
1946 (char_u *)NULL, PV_NONE,
1947#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001948 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
Bram Moolenaarf75a9632005-09-13 21:20:47 +00001949 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
Bram Moolenaare344bea2005-09-01 20:46:49 +00001950#ifdef FEAT_COMPL_FUNC
1951 (char_u *)&p_ofu, PV_OFU,
1952 {(char_u *)"", (char_u *)0L}
1953#else
1954 (char_u *)NULL, PV_NONE,
1955 {(char_u *)0L, (char_u *)0L}
1956#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001957 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001958 {"open", NULL, P_BOOL|P_VI_DEF,
1959 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001960 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar043545e2006-10-10 16:44:07 +00001961 {"opendevice", "odev", P_BOOL|P_VI_DEF,
1962#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1963 (char_u *)&p_odev, PV_NONE,
1964#else
1965 (char_u *)NULL, PV_NONE,
1966#endif
1967 {(char_u *)FALSE, (char_u *)FALSE}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001968 SCRIPTID_INIT},
Bram Moolenaar2c7a29c2005-12-12 22:02:31 +00001969 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
1970 (char_u *)&p_opfunc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001971 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001972 {"optimize", "opt", P_BOOL|P_VI_DEF,
1973 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001974 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001975 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001976 (char_u *)NULL, PV_NONE,
Bram Moolenaarb07269a2011-05-19 13:41:14 +02001977 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001978 {"paragraphs", "para", P_STRING|P_VI_DEF,
1979 (char_u *)&p_para, PV_NONE,
Bram Moolenaar57e48462008-03-12 16:38:55 +00001980 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001981 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001982 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001983 (char_u *)&p_paste, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001984 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001985 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
1986 (char_u *)&p_pt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001987 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001988 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
1989#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1990 (char_u *)&p_pex, PV_NONE,
1991 {(char_u *)"", (char_u *)0L}
1992#else
1993 (char_u *)NULL, PV_NONE,
1994 {(char_u *)0L, (char_u *)0L}
1995#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001996 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001997 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001998 (char_u *)&p_pm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001999 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002000 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002001 (char_u *)&p_path, PV_PATH,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002002 {
2003#if defined AMIGA || defined MSDOS || defined MSWIN
2004 (char_u *)".,,",
2005#else
2006# if defined(__EMX__)
2007 (char_u *)".,/emx/include,,",
2008# else /* Unix, probably */
2009 (char_u *)".,/usr/include,,",
2010# endif
2011#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002012 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002013 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
2014 (char_u *)&p_pi, PV_PI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002015 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002016 {"previewheight", "pvh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002017#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2018 (char_u *)&p_pvh, PV_NONE,
2019#else
2020 (char_u *)NULL, PV_NONE,
2021#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002022 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002023 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2024#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2025 (char_u *)VAR_WIN, PV_PVW,
2026#else
2027 (char_u *)NULL, PV_NONE,
2028#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002029 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002030 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002031#ifdef FEAT_PRINTER
2032 (char_u *)&p_pdev, PV_NONE,
2033 {(char_u *)"", (char_u *)0L}
2034#else
2035 (char_u *)NULL, PV_NONE,
2036 {(char_u *)NULL, (char_u *)0L}
2037#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002038 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002039 {"printencoding", "penc", P_STRING|P_VI_DEF,
2040#ifdef FEAT_POSTSCRIPT
2041 (char_u *)&p_penc, PV_NONE,
2042 {(char_u *)"", (char_u *)0L}
2043#else
2044 (char_u *)NULL, PV_NONE,
2045 {(char_u *)NULL, (char_u *)0L}
2046#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002047 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002048 {"printexpr", "pexpr", P_STRING|P_VI_DEF,
2049#ifdef FEAT_POSTSCRIPT
2050 (char_u *)&p_pexpr, PV_NONE,
2051 {(char_u *)"", (char_u *)0L}
2052#else
2053 (char_u *)NULL, PV_NONE,
2054 {(char_u *)NULL, (char_u *)0L}
2055#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002056 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002057 {"printfont", "pfn", P_STRING|P_VI_DEF,
2058#ifdef FEAT_PRINTER
2059 (char_u *)&p_pfn, PV_NONE,
2060 {
2061# ifdef MSWIN
2062 (char_u *)"Courier_New:h10",
2063# else
2064 (char_u *)"courier",
2065# endif
2066 (char_u *)0L}
2067#else
2068 (char_u *)NULL, PV_NONE,
2069 {(char_u *)NULL, (char_u *)0L}
2070#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002071 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002072 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
2073#ifdef FEAT_PRINTER
2074 (char_u *)&p_header, PV_NONE,
2075 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
2076#else
2077 (char_u *)NULL, PV_NONE,
2078 {(char_u *)NULL, (char_u *)0L}
2079#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002080 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002081 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
2082#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2083 (char_u *)&p_pmcs, PV_NONE,
2084 {(char_u *)"", (char_u *)0L}
2085#else
2086 (char_u *)NULL, PV_NONE,
2087 {(char_u *)NULL, (char_u *)0L}
2088#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002089 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002090 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2091#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2092 (char_u *)&p_pmfn, PV_NONE,
2093 {(char_u *)"", (char_u *)0L}
2094#else
2095 (char_u *)NULL, PV_NONE,
2096 {(char_u *)NULL, (char_u *)0L}
2097#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002098 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002099 {"printoptions", "popt", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002100#ifdef FEAT_PRINTER
2101 (char_u *)&p_popt, PV_NONE,
2102 {(char_u *)"", (char_u *)0L}
2103#else
2104 (char_u *)NULL, PV_NONE,
2105 {(char_u *)NULL, (char_u *)0L}
2106#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002107 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002108 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002109 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002110 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002111 {"pumheight", "ph", P_NUM|P_VI_DEF,
2112#ifdef FEAT_INS_EXPAND
2113 (char_u *)&p_ph, PV_NONE,
2114#else
2115 (char_u *)NULL, PV_NONE,
2116#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002117 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002118 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2119#ifdef FEAT_TEXTOBJ
2120 (char_u *)&p_qe, PV_QE,
2121 {(char_u *)"\\", (char_u *)0L}
2122#else
2123 (char_u *)NULL, PV_NONE,
2124 {(char_u *)NULL, (char_u *)0L}
2125#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002126 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002127 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2128 (char_u *)&p_ro, PV_RO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002129 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002130 {"redraw", NULL, P_BOOL|P_VI_DEF,
2131 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002132 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002133 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2134#ifdef FEAT_RELTIME
2135 (char_u *)&p_rdt, PV_NONE,
2136#else
2137 (char_u *)NULL, PV_NONE,
2138#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002139 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02002140 {"regexpengine", "re", P_NUM|P_VI_DEF,
2141 (char_u *)&p_re, PV_NONE,
2142 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002143 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2144 (char_u *)VAR_WIN, PV_RNU,
2145 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002146 {"remap", NULL, P_BOOL|P_VI_DEF,
2147 (char_u *)&p_remap, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002148 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002149 {"renderoptions", "rop", P_STRING|P_ONECOMMA|P_RCLR|P_VI_DEF,
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02002150#ifdef FEAT_RENDER_OPTIONS
2151 (char_u *)&p_rop, PV_NONE,
2152 {(char_u *)"", (char_u *)0L}
2153#else
2154 (char_u *)NULL, PV_NONE,
2155 {(char_u *)NULL, (char_u *)0L}
2156#endif
2157 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002158 {"report", NULL, P_NUM|P_VI_DEF,
2159 (char_u *)&p_report, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002160 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002161 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2162#ifdef WIN3264
2163 (char_u *)&p_rs, PV_NONE,
2164#else
2165 (char_u *)NULL, PV_NONE,
2166#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002167 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002168 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2169#ifdef FEAT_RIGHTLEFT
2170 (char_u *)&p_ri, PV_NONE,
2171#else
2172 (char_u *)NULL, PV_NONE,
2173#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002174 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002175 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2176#ifdef FEAT_RIGHTLEFT
2177 (char_u *)VAR_WIN, PV_RL,
2178#else
2179 (char_u *)NULL, PV_NONE,
2180#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002181 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002182 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2183#ifdef FEAT_RIGHTLEFT
2184 (char_u *)VAR_WIN, PV_RLC,
2185 {(char_u *)"search", (char_u *)NULL}
2186#else
2187 (char_u *)NULL, PV_NONE,
2188 {(char_u *)NULL, (char_u *)0L}
2189#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002190 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002191 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2192#ifdef FEAT_CMDL_INFO
2193 (char_u *)&p_ru, PV_NONE,
2194#else
2195 (char_u *)NULL, PV_NONE,
2196#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002197 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002198 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2199#ifdef FEAT_STL_OPT
2200 (char_u *)&p_ruf, PV_NONE,
2201#else
2202 (char_u *)NULL, PV_NONE,
2203#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002204 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002205 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2206 |P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002207 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002208 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2209 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002210 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2211 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002212 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002213 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2214#ifdef FEAT_SCROLLBIND
2215 (char_u *)VAR_WIN, PV_SCBIND,
2216#else
2217 (char_u *)NULL, PV_NONE,
2218#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002219 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002220 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2221 (char_u *)&p_sj, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002222 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002223 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2224 (char_u *)&p_so, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002225 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002226 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002227#ifdef FEAT_SCROLLBIND
2228 (char_u *)&p_sbo, PV_NONE,
2229 {(char_u *)"ver,jump", (char_u *)0L}
2230#else
2231 (char_u *)NULL, PV_NONE,
2232 {(char_u *)0L, (char_u *)0L}
2233#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002234 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002235 {"sections", "sect", P_STRING|P_VI_DEF,
2236 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002237 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2238 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002239 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2240 (char_u *)&p_secure, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002241 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002242 {"selection", "sel", P_STRING|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002243 (char_u *)&p_sel, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002244 {(char_u *)"inclusive", (char_u *)0L}
2245 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002246 {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002247 (char_u *)&p_slm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002248 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002249 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002250#ifdef FEAT_SESSION
2251 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002252 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002253 (char_u *)0L}
2254#else
2255 (char_u *)NULL, PV_NONE,
2256 {(char_u *)0L, (char_u *)0L}
2257#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002258 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002259 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2260 (char_u *)&p_sh, PV_NONE,
2261 {
2262#ifdef VMS
2263 (char_u *)"-",
2264#else
2265# if defined(MSDOS)
2266 (char_u *)"command",
2267# else
2268# if defined(WIN16)
2269 (char_u *)"command.com",
2270# else
2271# if defined(WIN3264)
2272 (char_u *)"", /* set in set_init_1() */
2273# else
2274# if defined(OS2)
2275 (char_u *)"cmd.exe",
2276# else
2277# if defined(ARCHIE)
2278 (char_u *)"gos",
2279# else
2280 (char_u *)"sh",
2281# endif
2282# endif
2283# endif
2284# endif
2285# endif
2286#endif /* VMS */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002287 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002288 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2289 (char_u *)&p_shcf, PV_NONE,
2290 {
2291#if defined(MSDOS) || defined(MSWIN)
2292 (char_u *)"/c",
2293#else
2294# if defined(OS2)
2295 (char_u *)"/c",
2296# else
2297 (char_u *)"-c",
2298# endif
2299#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002300 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002301 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2302#ifdef FEAT_QUICKFIX
2303 (char_u *)&p_sp, PV_NONE,
2304 {
2305#if defined(UNIX) || defined(OS2)
2306# ifdef ARCHIE
2307 (char_u *)"2>",
2308# else
2309 (char_u *)"| tee",
2310# endif
2311#else
2312 (char_u *)">",
2313#endif
2314 (char_u *)0L}
2315#else
2316 (char_u *)NULL, PV_NONE,
2317 {(char_u *)0L, (char_u *)0L}
2318#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002319 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002320 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2321 (char_u *)&p_shq, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002322 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002323 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2324 (char_u *)&p_srr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002325 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002326 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2327#ifdef BACKSLASH_IN_FILENAME
2328 (char_u *)&p_ssl, PV_NONE,
2329#else
2330 (char_u *)NULL, PV_NONE,
2331#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002332 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002333 {"shelltemp", "stmp", P_BOOL,
2334 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002335 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002336 {"shelltype", "st", P_NUM|P_VI_DEF,
2337#ifdef AMIGA
2338 (char_u *)&p_st, PV_NONE,
2339#else
2340 (char_u *)NULL, PV_NONE,
2341#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002342 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002343 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2344 (char_u *)&p_sxq, PV_NONE,
2345 {
2346#if defined(UNIX) && defined(USE_SYSTEM) && !defined(__EMX__)
2347 (char_u *)"\"",
2348#else
2349 (char_u *)"",
2350#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002351 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002352 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
2353 (char_u *)&p_sxe, PV_NONE,
2354 {
2355#if defined(MSDOS) || defined(WIN16) || defined(WIN3264)
2356 (char_u *)"\"&|<>()@^",
2357#else
2358 (char_u *)"",
2359#endif
2360 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002361 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2362 (char_u *)&p_sr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002363 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002364 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2365 (char_u *)&p_sw, PV_SW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002366 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002367 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2368 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002369 {(char_u *)"", (char_u *)"filnxtToO"}
2370 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002371 {"shortname", "sn", P_BOOL|P_VI_DEF,
2372#ifdef SHORT_FNAME
2373 (char_u *)NULL, PV_NONE,
2374#else
2375 (char_u *)&p_sn, PV_SN,
2376#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002377 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002378 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2379#ifdef FEAT_LINEBREAK
2380 (char_u *)&p_sbr, PV_NONE,
2381#else
2382 (char_u *)NULL, PV_NONE,
2383#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002384 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002385 {"showcmd", "sc", P_BOOL|P_VIM,
2386#ifdef FEAT_CMDL_INFO
2387 (char_u *)&p_sc, PV_NONE,
2388#else
2389 (char_u *)NULL, PV_NONE,
2390#endif
2391 {(char_u *)FALSE,
2392#ifdef UNIX
2393 (char_u *)FALSE
2394#else
2395 (char_u *)TRUE
2396#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002397 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002398 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2399 (char_u *)&p_sft, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002400 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002401 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2402 (char_u *)&p_sm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002403 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002404 {"showmode", "smd", P_BOOL|P_VIM,
2405 (char_u *)&p_smd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002406 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002407 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2408#ifdef FEAT_WINDOWS
2409 (char_u *)&p_stal, PV_NONE,
2410#else
2411 (char_u *)NULL, PV_NONE,
2412#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002413 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002414 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2415 (char_u *)&p_ss, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002416 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002417 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2418 (char_u *)&p_siso, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002419 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002420 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2421 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002422 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002423 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2424 (char_u *)&p_scs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002425 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002426 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2427#ifdef FEAT_SMARTINDENT
2428 (char_u *)&p_si, PV_SI,
2429#else
2430 (char_u *)NULL, PV_NONE,
2431#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002432 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002433 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2434 (char_u *)&p_sta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002435 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002436 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2437 (char_u *)&p_sts, PV_STS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002438 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002439 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2440 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002441 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002442 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002443#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002444 (char_u *)VAR_WIN, PV_SPELL,
2445#else
2446 (char_u *)NULL, PV_NONE,
2447#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002448 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002449 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002450#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002451 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002452 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002453#else
2454 (char_u *)NULL, PV_NONE,
2455 {(char_u *)0L, (char_u *)0L}
2456#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002457 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002458 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE
2459 |P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002460#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002461 (char_u *)&p_spf, PV_SPF,
2462 {(char_u *)"", (char_u *)0L}
2463#else
2464 (char_u *)NULL, PV_NONE,
2465 {(char_u *)0L, (char_u *)0L}
2466#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002467 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002468 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
2469 |P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002470#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002471 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002472 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002473#else
2474 (char_u *)NULL, PV_NONE,
2475 {(char_u *)0L, (char_u *)0L}
2476#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002477 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002478 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002479#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002480 (char_u *)&p_sps, PV_NONE,
2481 {(char_u *)"best", (char_u *)0L}
2482#else
2483 (char_u *)NULL, PV_NONE,
2484 {(char_u *)0L, (char_u *)0L}
2485#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002486 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002487 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2488#ifdef FEAT_WINDOWS
2489 (char_u *)&p_sb, PV_NONE,
2490#else
2491 (char_u *)NULL, PV_NONE,
2492#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002493 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002494 {"splitright", "spr", P_BOOL|P_VI_DEF,
2495#ifdef FEAT_VERTSPLIT
2496 (char_u *)&p_spr, PV_NONE,
2497#else
2498 (char_u *)NULL, PV_NONE,
2499#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002500 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002501 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2502 (char_u *)&p_sol, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002503 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002504 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2505#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002506 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002507#else
2508 (char_u *)NULL, PV_NONE,
2509#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002510 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002511 {"suffixes", "su", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002512 (char_u *)&p_su, PV_NONE,
2513 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002514 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002515 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002516#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002517 (char_u *)&p_sua, PV_SUA,
2518 {(char_u *)"", (char_u *)0L}
2519#else
2520 (char_u *)NULL, PV_NONE,
2521 {(char_u *)0L, (char_u *)0L}
2522#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002523 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002524 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2525 (char_u *)&p_swf, PV_SWF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002526 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002527 {"swapsync", "sws", P_STRING|P_VI_DEF,
2528 (char_u *)&p_sws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002529 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002530 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002531 (char_u *)&p_swb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002532 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002533 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2534#ifdef FEAT_SYN_HL
2535 (char_u *)&p_smc, PV_SMC,
2536 {(char_u *)3000L, (char_u *)0L}
2537#else
2538 (char_u *)NULL, PV_NONE,
2539 {(char_u *)0L, (char_u *)0L}
2540#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002541 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002542 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002543#ifdef FEAT_SYN_HL
2544 (char_u *)&p_syn, PV_SYN,
2545 {(char_u *)"", (char_u *)0L}
2546#else
2547 (char_u *)NULL, PV_NONE,
2548 {(char_u *)0L, (char_u *)0L}
2549#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002550 SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002551 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2552#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002553 (char_u *)&p_tal, PV_NONE,
2554#else
2555 (char_u *)NULL, PV_NONE,
2556#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002557 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002558 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2559#ifdef FEAT_WINDOWS
2560 (char_u *)&p_tpm, PV_NONE,
2561#else
2562 (char_u *)NULL, PV_NONE,
2563#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002564 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002565 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2566 (char_u *)&p_ts, PV_TS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002567 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002568 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2569 (char_u *)&p_tbs, PV_NONE,
2570#ifdef VMS /* binary searching doesn't appear to work on VMS */
2571 {(char_u *)0L, (char_u *)0L}
2572#else
2573 {(char_u *)TRUE, (char_u *)0L}
2574#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002575 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002576 {"taglength", "tl", P_NUM|P_VI_DEF,
2577 (char_u *)&p_tl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002578 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002579 {"tagrelative", "tr", P_BOOL|P_VIM,
2580 (char_u *)&p_tr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002581 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002582 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002583 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002584 {
2585#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2586 (char_u *)"./tags,./TAGS,tags,TAGS",
2587#else
2588 (char_u *)"./tags,tags",
2589#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002590 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002591 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2592 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002593 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002594 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2595 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002596 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002597 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2598#ifdef FEAT_ARABIC
2599 (char_u *)&p_tbidi, PV_NONE,
2600#else
2601 (char_u *)NULL, PV_NONE,
2602#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002603 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002604 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2605#ifdef FEAT_MBYTE
2606 (char_u *)&p_tenc, PV_NONE,
2607 {(char_u *)"", (char_u *)0L}
2608#else
2609 (char_u *)NULL, PV_NONE,
2610 {(char_u *)0L, (char_u *)0L}
2611#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002612 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002613 {"terse", NULL, P_BOOL|P_VI_DEF,
2614 (char_u *)&p_terse, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002615 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002616 {"textauto", "ta", P_BOOL|P_VIM,
2617 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002618 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2619 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002620 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2621 (char_u *)&p_tx, PV_TX,
2622 {
2623#ifdef USE_CRNL
2624 (char_u *)TRUE,
2625#else
2626 (char_u *)FALSE,
2627#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002628 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +02002629 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002630 (char_u *)&p_tw, PV_TW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002631 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002632 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002633#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002634 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002635#else
2636 (char_u *)NULL, PV_NONE,
2637#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002638 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002639 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2640 (char_u *)&p_to, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002641 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002642 {"timeout", "to", P_BOOL|P_VI_DEF,
2643 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002644 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002645 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2646 (char_u *)&p_tm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002647 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002648 {"title", NULL, P_BOOL|P_VI_DEF,
2649#ifdef FEAT_TITLE
2650 (char_u *)&p_title, PV_NONE,
2651#else
2652 (char_u *)NULL, PV_NONE,
2653#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002654 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002655 {"titlelen", NULL, P_NUM|P_VI_DEF,
2656#ifdef FEAT_TITLE
2657 (char_u *)&p_titlelen, PV_NONE,
2658#else
2659 (char_u *)NULL, PV_NONE,
2660#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002661 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002662 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002663#ifdef FEAT_TITLE
2664 (char_u *)&p_titleold, PV_NONE,
2665 {(char_u *)N_("Thanks for flying Vim"),
2666 (char_u *)0L}
2667#else
2668 (char_u *)NULL, PV_NONE,
2669 {(char_u *)0L, (char_u *)0L}
2670#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002671 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002672 {"titlestring", NULL, P_STRING|P_VI_DEF,
2673#ifdef FEAT_TITLE
2674 (char_u *)&p_titlestring, PV_NONE,
2675#else
2676 (char_u *)NULL, PV_NONE,
2677#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002678 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002679#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002680 {"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002681 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002682 {(char_u *)"icons,tooltips", (char_u *)0L}
2683 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002684#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002685#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002686 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
2687 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002688 {(char_u *)"small", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002689#endif
2690 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2691 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002692 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002693 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2694 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002695 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002696 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2697 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002698 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002699 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2700 (char_u *)&p_tf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002701 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002702 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2703#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2704 (char_u *)&p_ttym, PV_NONE,
2705#else
2706 (char_u *)NULL, PV_NONE,
2707#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002708 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002709 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2710 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002711 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002712 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2713 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002714 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002715 {"undodir", "udir", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP|P_SECURE
2716 |P_VI_DEF,
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002717#ifdef FEAT_PERSISTENT_UNDO
2718 (char_u *)&p_udir, PV_NONE,
2719 {(char_u *)".", (char_u *)0L}
2720#else
2721 (char_u *)NULL, PV_NONE,
2722 {(char_u *)0L, (char_u *)0L}
2723#endif
2724 SCRIPTID_INIT},
2725 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2726#ifdef FEAT_PERSISTENT_UNDO
2727 (char_u *)&p_udf, PV_UDF,
2728#else
2729 (char_u *)NULL, PV_NONE,
2730#endif
2731 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002732 {"undolevels", "ul", P_NUM|P_VI_DEF,
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01002733 (char_u *)&p_ul, PV_UL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002734 {
2735#if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS)
2736 (char_u *)1000L,
2737#else
2738 (char_u *)100L,
2739#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002740 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar59f931e2010-07-24 20:27:03 +02002741 {"undoreload", "ur", P_NUM|P_VI_DEF,
2742 (char_u *)&p_ur, PV_NONE,
2743 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002744 {"updatecount", "uc", P_NUM|P_VI_DEF,
2745 (char_u *)&p_uc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002746 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002747 {"updatetime", "ut", P_NUM|P_VI_DEF,
2748 (char_u *)&p_ut, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002749 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002750 {"verbose", "vbs", P_NUM|P_VI_DEF,
2751 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002752 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002753 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2754 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002755 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002756 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2757#ifdef FEAT_SESSION
2758 (char_u *)&p_vdir, PV_NONE,
2759 {(char_u *)DFLT_VDIR, (char_u *)0L}
2760#else
2761 (char_u *)NULL, PV_NONE,
2762 {(char_u *)0L, (char_u *)0L}
2763#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002764 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002765 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002766#ifdef FEAT_SESSION
2767 (char_u *)&p_vop, PV_NONE,
2768 {(char_u *)"folds,options,cursor", (char_u *)0L}
2769#else
2770 (char_u *)NULL, PV_NONE,
2771 {(char_u *)0L, (char_u *)0L}
2772#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002773 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002774 {"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002775#ifdef FEAT_VIMINFO
2776 (char_u *)&p_viminfo, PV_NONE,
2777#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
Bram Moolenaard812df62008-11-09 12:46:09 +00002778 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002779#else
2780# ifdef AMIGA
2781 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002782 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002783# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002784 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002785# endif
2786#endif
2787#else
2788 (char_u *)NULL, PV_NONE,
2789 {(char_u *)0L, (char_u *)0L}
2790#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002791 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002792 {"virtualedit", "ve", P_STRING|P_ONECOMMA|P_NODUP|P_VI_DEF
2793 |P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002794#ifdef FEAT_VIRTUALEDIT
2795 (char_u *)&p_ve, PV_NONE,
2796 {(char_u *)"", (char_u *)""}
2797#else
2798 (char_u *)NULL, PV_NONE,
2799 {(char_u *)0L, (char_u *)0L}
2800#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002801 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002802 {"visualbell", "vb", P_BOOL|P_VI_DEF,
2803 (char_u *)&p_vb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002804 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002805 {"w300", NULL, P_NUM|P_VI_DEF,
2806 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002807 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002808 {"w1200", NULL, P_NUM|P_VI_DEF,
2809 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002810 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002811 {"w9600", NULL, P_NUM|P_VI_DEF,
2812 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002813 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002814 {"warn", NULL, P_BOOL|P_VI_DEF,
2815 (char_u *)&p_warn, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002816 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002817 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
2818 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002819 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002820 {"whichwrap", "ww", P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002821 (char_u *)&p_ww, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002822 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002823 {"wildchar", "wc", P_NUM|P_VIM,
2824 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002825 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
2826 SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002827 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002828 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002829 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002830 {"wildignore", "wig", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002831#ifdef FEAT_WILDIGN
2832 (char_u *)&p_wig, PV_NONE,
2833#else
2834 (char_u *)NULL, PV_NONE,
2835#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002836 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002837 {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
2838 (char_u *)&p_wic, PV_NONE,
2839 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002840 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
2841#ifdef FEAT_WILDMENU
2842 (char_u *)&p_wmnu, PV_NONE,
2843#else
2844 (char_u *)NULL, PV_NONE,
2845#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002846 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002847 {"wildmode", "wim", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002848 (char_u *)&p_wim, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002849 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00002850 {"wildoptions", "wop", P_STRING|P_VI_DEF,
2851#ifdef FEAT_CMDL_COMPL
2852 (char_u *)&p_wop, PV_NONE,
2853 {(char_u *)"", (char_u *)0L}
2854#else
2855 (char_u *)NULL, PV_NONE,
2856 {(char_u *)NULL, (char_u *)0L}
2857#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002858 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002859 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
2860#ifdef FEAT_WAK
2861 (char_u *)&p_wak, PV_NONE,
2862 {(char_u *)"menu", (char_u *)0L}
2863#else
2864 (char_u *)NULL, PV_NONE,
2865 {(char_u *)NULL, (char_u *)0L}
2866#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002867 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002868 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00002869 (char_u *)&p_window, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002870 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002871 {"winheight", "wh", P_NUM|P_VI_DEF,
2872#ifdef FEAT_WINDOWS
2873 (char_u *)&p_wh, PV_NONE,
2874#else
2875 (char_u *)NULL, PV_NONE,
2876#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002877 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002878 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002879#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002880 (char_u *)VAR_WIN, PV_WFH,
2881#else
2882 (char_u *)NULL, PV_NONE,
2883#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002884 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002885 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
2886#ifdef FEAT_VERTSPLIT
2887 (char_u *)VAR_WIN, PV_WFW,
2888#else
2889 (char_u *)NULL, PV_NONE,
2890#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002891 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002892 {"winminheight", "wmh", P_NUM|P_VI_DEF,
2893#ifdef FEAT_WINDOWS
2894 (char_u *)&p_wmh, PV_NONE,
2895#else
2896 (char_u *)NULL, PV_NONE,
2897#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002898 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002899 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
2900#ifdef FEAT_VERTSPLIT
2901 (char_u *)&p_wmw, PV_NONE,
2902#else
2903 (char_u *)NULL, PV_NONE,
2904#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002905 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002906 {"winwidth", "wiw", P_NUM|P_VI_DEF,
2907#ifdef FEAT_VERTSPLIT
2908 (char_u *)&p_wiw, PV_NONE,
2909#else
2910 (char_u *)NULL, PV_NONE,
2911#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002912 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002913 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
2914 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002915 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002916 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
2917 (char_u *)&p_wm, PV_WM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002918 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002919 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
2920 (char_u *)&p_ws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002921 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002922 {"write", NULL, P_BOOL|P_VI_DEF,
2923 (char_u *)&p_write, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002924 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002925 {"writeany", "wa", P_BOOL|P_VI_DEF,
2926 (char_u *)&p_wa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002927 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002928 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
2929 (char_u *)&p_wb, PV_NONE,
2930 {
2931#ifdef FEAT_WRITEBACKUP
2932 (char_u *)TRUE,
2933#else
2934 (char_u *)FALSE,
2935#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002936 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002937 {"writedelay", "wd", P_NUM|P_VI_DEF,
2938 (char_u *)&p_wd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002939 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002940
2941/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002942#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00002943 (char_u *)&vvv, PV_NONE, \
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002944 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002945
2946 p_term("t_AB", T_CAB)
2947 p_term("t_AF", T_CAF)
2948 p_term("t_AL", T_CAL)
2949 p_term("t_al", T_AL)
2950 p_term("t_bc", T_BC)
2951 p_term("t_cd", T_CD)
2952 p_term("t_ce", T_CE)
2953 p_term("t_cl", T_CL)
2954 p_term("t_cm", T_CM)
2955 p_term("t_Co", T_CCO)
2956 p_term("t_CS", T_CCS)
2957 p_term("t_cs", T_CS)
2958#ifdef FEAT_VERTSPLIT
2959 p_term("t_CV", T_CSV)
2960#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002961 p_term("t_da", T_DA)
2962 p_term("t_db", T_DB)
2963 p_term("t_DL", T_CDL)
2964 p_term("t_dl", T_DL)
Bram Moolenaare5401222015-06-25 19:16:56 +02002965 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002966 p_term("t_fs", T_FS)
2967 p_term("t_IE", T_CIE)
2968 p_term("t_IS", T_CIS)
2969 p_term("t_ke", T_KE)
2970 p_term("t_ks", T_KS)
2971 p_term("t_le", T_LE)
2972 p_term("t_mb", T_MB)
2973 p_term("t_md", T_MD)
2974 p_term("t_me", T_ME)
2975 p_term("t_mr", T_MR)
2976 p_term("t_ms", T_MS)
2977 p_term("t_nd", T_ND)
2978 p_term("t_op", T_OP)
Bram Moolenaare5401222015-06-25 19:16:56 +02002979 p_term("t_RB", T_RBG)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002980 p_term("t_RI", T_CRI)
2981 p_term("t_RV", T_CRV)
2982 p_term("t_Sb", T_CSB)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002983 p_term("t_se", T_SE)
Bram Moolenaare5401222015-06-25 19:16:56 +02002984 p_term("t_Sf", T_CSF)
2985 p_term("t_SI", T_CSI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002986 p_term("t_so", T_SO)
Bram Moolenaare5401222015-06-25 19:16:56 +02002987 p_term("t_SR", T_CSR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002988 p_term("t_sr", T_SR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002989 p_term("t_te", T_TE)
2990 p_term("t_ti", T_TI)
Bram Moolenaare5401222015-06-25 19:16:56 +02002991 p_term("t_ts", T_TS)
2992 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002993 p_term("t_ue", T_UE)
2994 p_term("t_us", T_US)
Bram Moolenaare5401222015-06-25 19:16:56 +02002995 p_term("t_ut", T_UT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002996 p_term("t_vb", T_VB)
2997 p_term("t_ve", T_VE)
2998 p_term("t_vi", T_VI)
2999 p_term("t_vs", T_VS)
3000 p_term("t_WP", T_CWP)
3001 p_term("t_WS", T_CWS)
Bram Moolenaar494838a2015-02-10 19:20:37 +01003002 p_term("t_xn", T_XN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003003 p_term("t_xs", T_XS)
3004 p_term("t_ZH", T_CZH)
3005 p_term("t_ZR", T_CZR)
3006
3007/* terminal key codes are not in here */
3008
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003009 /* end marker */
3010 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00003011};
3012
3013#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
3014
3015#ifdef FEAT_MBYTE
3016static char *(p_ambw_values[]) = {"single", "double", NULL};
3017#endif
3018static char *(p_bg_values[]) = {"light", "dark", NULL};
3019static char *(p_nf_values[]) = {"octal", "hex", "alpha", NULL};
3020static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003021#ifdef FEAT_CRYPT
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02003022static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2", NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003023#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003024#ifdef FEAT_CMDL_COMPL
3025static char *(p_wop_values[]) = {"tagfile", NULL};
3026#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003027#ifdef FEAT_WAK
3028static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
3029#endif
3030static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003031static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
3032static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003033static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003034#ifdef FEAT_BROWSE
3035static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
3036#endif
3037#ifdef FEAT_SCROLLBIND
3038static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
3039#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00003040static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003041#ifdef FEAT_VERTSPLIT
3042static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
3043#endif
3044#if defined(FEAT_QUICKFIX)
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003045# ifdef FEAT_AUTOCMD
3046static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
3047# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003048static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003049# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003050static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
3051#endif
3052static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
3053#ifdef FEAT_FOLDING
3054static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003055# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00003056 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003057# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003058 NULL};
3059static char *(p_fcl_values[]) = {"all", NULL};
3060#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003061#ifdef FEAT_INS_EXPAND
Bram Moolenaarb6be1e22015-07-10 18:18:40 +02003062static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003063#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003064
3065static void set_option_default __ARGS((int, int opt_flags, int compatible));
3066static void set_options_default __ARGS((int opt_flags));
Bram Moolenaarf740b292006-02-16 22:11:02 +00003067static char_u *term_bg_default __ARGS((void));
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003068static void did_set_option __ARGS((int opt_idx, int opt_flags, int new_value));
Bram Moolenaar071d4272004-06-13 20:20:40 +00003069static char_u *illegal_char __ARGS((char_u *, int));
3070static int string_to_key __ARGS((char_u *arg));
3071#ifdef FEAT_CMDWIN
3072static char_u *check_cedit __ARGS((void));
3073#endif
3074#ifdef FEAT_TITLE
3075static void did_set_title __ARGS((int icon));
3076#endif
3077static char_u *option_expand __ARGS((int opt_idx, char_u *val));
3078static void didset_options __ARGS((void));
3079static void check_string_option __ARGS((char_u **pp));
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003080#if defined(FEAT_EVAL) || defined(PROTO)
3081static long_u *insecure_flag __ARGS((int opt_idx, int opt_flags));
3082#else
3083# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3084#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003085static void set_string_option_global __ARGS((int opt_idx, char_u **varp));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02003086static char_u *set_string_option __ARGS((int opt_idx, char_u *value, int opt_flags));
Bram Moolenaar071d4272004-06-13 20:20:40 +00003087static char_u *did_set_string_option __ARGS((int opt_idx, char_u **varp, int new_value_alloced, char_u *oldval, char_u *errbuf, int opt_flags));
3088static char_u *set_chars_option __ARGS((char_u **varp));
Bram Moolenaar1a384422010-07-14 19:53:30 +02003089#ifdef FEAT_SYN_HL
3090static int int_cmp __ARGS((const void *a, const void *b));
3091#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003092#ifdef FEAT_CLIPBOARD
3093static char_u *check_clipboard_option __ARGS((void));
3094#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003095#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02003096static char_u *compile_cap_prog __ARGS((synblock_T *synblock));
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003097#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003098#ifdef FEAT_EVAL
3099static void set_option_scriptID_idx __ARGS((int opt_idx, int opt_flags, int id));
3100#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003101static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value, int opt_flags));
Bram Moolenaar555b2802005-05-19 21:08:39 +00003102static char_u *set_num_option __ARGS((int opt_idx, char_u *varp, long value, char_u *errbuf, size_t errbuflen, int opt_flags));
Bram Moolenaar071d4272004-06-13 20:20:40 +00003103static void check_redraw __ARGS((long_u flags));
3104static int findoption __ARGS((char_u *));
3105static int find_key_option __ARGS((char_u *));
3106static void showoptions __ARGS((int all, int opt_flags));
3107static int optval_default __ARGS((struct vimoption *, char_u *varp));
3108static void showoneopt __ARGS((struct vimoption *, int opt_flags));
3109static int put_setstring __ARGS((FILE *fd, char *cmd, char *name, char_u **valuep, int expand));
3110static int put_setnum __ARGS((FILE *fd, char *cmd, char *name, long *valuep));
3111static int put_setbool __ARGS((FILE *fd, char *cmd, char *name, int value));
3112static int istermoption __ARGS((struct vimoption *));
3113static char_u *get_varp_scope __ARGS((struct vimoption *p, int opt_flags));
3114static char_u *get_varp __ARGS((struct vimoption *));
3115static void option_value2string __ARGS((struct vimoption *, int opt_flags));
Bram Moolenaar8dc907d2014-06-25 14:44:10 +02003116static void check_winopt __ARGS((winopt_T *wop));
Bram Moolenaar071d4272004-06-13 20:20:40 +00003117static int wc_use_keyname __ARGS((char_u *varp, long *wcp));
3118#ifdef FEAT_LANGMAP
3119static void langmap_init __ARGS((void));
3120static void langmap_set __ARGS((void));
3121#endif
3122static void paste_option_changed __ARGS((void));
3123static void compatible_set __ARGS((void));
3124#ifdef FEAT_LINEBREAK
3125static void fill_breakat_flags __ARGS((void));
3126#endif
3127static int opt_strings_flags __ARGS((char_u *val, char **values, unsigned *flagp, int list));
3128static int check_opt_strings __ARGS((char_u *val, char **values, int));
3129static int check_opt_wim __ARGS((void));
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003130#ifdef FEAT_LINEBREAK
3131static int briopt_check __ARGS((win_T *wp));
3132#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003133
3134/*
3135 * Initialize the options, first part.
3136 *
3137 * Called only once from main(), just after creating the first buffer.
3138 */
3139 void
3140set_init_1()
3141{
3142 char_u *p;
3143 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003144 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003145
3146#ifdef FEAT_LANGMAP
3147 langmap_init();
3148#endif
3149
3150 /* Be Vi compatible by default */
3151 p_cp = TRUE;
3152
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003153 /* Use POSIX compatibility when $VIM_POSIX is set. */
3154 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003155 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003156 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003157 set_string_default("shm", (char_u *)"A");
3158 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003159
Bram Moolenaar071d4272004-06-13 20:20:40 +00003160 /*
3161 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003162 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003163 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003164 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003165#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
3166# ifdef __EMX__
Bram Moolenaar7c626922005-02-07 22:01:03 +00003167 || ((p = mch_getenv((char_u *)"EMXSHELL")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003168# endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003169 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003170# ifdef WIN3264
Bram Moolenaar7c626922005-02-07 22:01:03 +00003171 || ((p = default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003172# endif
3173#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003174 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003175 set_string_default("sh", p);
3176
3177#ifdef FEAT_WILDIGN
3178 /*
3179 * Set the default for 'backupskip' to include environment variables for
3180 * temp files.
3181 */
3182 {
3183# ifdef UNIX
3184 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3185# else
3186 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3187# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003188 int len;
3189 garray_T ga;
3190 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003191
3192 ga_init2(&ga, 1, 100);
3193 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3194 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003195 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003196# ifdef UNIX
3197 if (*names[n] == NUL)
3198 p = (char_u *)"/tmp";
3199 else
3200# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003201 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003202 if (p != NULL && *p != NUL)
3203 {
3204 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003205 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003206 if (ga_grow(&ga, len) == OK)
3207 {
3208 if (ga.ga_len > 0)
3209 STRCAT(ga.ga_data, ",");
3210 STRCAT(ga.ga_data, p);
3211 add_pathsep(ga.ga_data);
3212 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003213 ga.ga_len += len;
3214 }
3215 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003216 if (mustfree)
3217 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003218 }
3219 if (ga.ga_data != NULL)
3220 {
3221 set_string_default("bsk", ga.ga_data);
3222 vim_free(ga.ga_data);
3223 }
3224 }
3225#endif
3226
3227 /*
3228 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3229 */
3230 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003231 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003232 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003233#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3234 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3235#endif
3236 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003237#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003238 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003239 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003240#else
3241# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003242 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003243 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003244# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003245 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003246# endif
3247#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003248 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003249 opt_idx = findoption((char_u *)"maxmem");
3250 if (opt_idx >= 0)
3251 {
3252#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
Bram Moolenaar427d51c2013-06-16 16:01:25 +02003253 if ((long)options[opt_idx].def_val[VI_DEFAULT] > (long)n
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003254 || (long)options[opt_idx].def_val[VI_DEFAULT] == 0L)
3255#endif
3256 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3257 }
3258 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003259 }
3260
3261#ifdef FEAT_GUI_W32
3262 /* force 'shortname' for Win32s */
3263 if (gui_is_win32s())
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003264 {
3265 opt_idx = findoption((char_u *)"shortname");
3266 if (opt_idx >= 0)
3267 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)TRUE;
3268 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003269#endif
3270
3271#ifdef FEAT_SEARCHPATH
3272 {
3273 char_u *cdpath;
3274 char_u *buf;
3275 int i;
3276 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003277 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003278
3279 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003280 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003281 if (cdpath != NULL)
3282 {
3283 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3284 if (buf != NULL)
3285 {
3286 buf[0] = ','; /* start with ",", current dir first */
3287 j = 1;
3288 for (i = 0; cdpath[i] != NUL; ++i)
3289 {
3290 if (vim_ispathlistsep(cdpath[i]))
3291 buf[j++] = ',';
3292 else
3293 {
3294 if (cdpath[i] == ' ' || cdpath[i] == ',')
3295 buf[j++] = '\\';
3296 buf[j++] = cdpath[i];
3297 }
3298 }
3299 buf[j] = NUL;
3300 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003301 if (opt_idx >= 0)
3302 {
3303 options[opt_idx].def_val[VI_DEFAULT] = buf;
3304 options[opt_idx].flags |= P_DEF_ALLOCED;
3305 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003306 else
3307 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003308 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003309 if (mustfree)
3310 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003311 }
3312 }
3313#endif
3314
3315#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(OS2) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
3316 /* Set print encoding on platforms that don't default to latin1 */
3317 set_string_default("penc",
3318# if defined(MSWIN) || defined(OS2)
3319 (char_u *)"cp1252"
3320# else
3321# ifdef VMS
3322 (char_u *)"dec-mcs"
3323# else
3324# ifdef EBCDIC
3325 (char_u *)"ebcdic-uk"
3326# else
3327# ifdef MAC
3328 (char_u *)"mac-roman"
3329# else /* HPUX */
3330 (char_u *)"hp-roman8"
3331# endif
3332# endif
3333# endif
3334# endif
3335 );
3336#endif
3337
3338#ifdef FEAT_POSTSCRIPT
3339 /* 'printexpr' must be allocated to be able to evaluate it. */
3340 set_string_default("pexpr",
Bram Moolenaared203462004-06-16 11:19:22 +00003341# if defined(MSWIN) || defined(MSDOS) || defined(OS2)
3342 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003343# else
3344# ifdef VMS
3345 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3346
3347# else
3348 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3349# endif
3350# endif
3351 );
3352#endif
3353
3354 /*
3355 * Set all the options (except the terminal options) to their default
3356 * value. Also set the global value for local options.
3357 */
3358 set_options_default(0);
3359
3360#ifdef FEAT_GUI
3361 if (found_reverse_arg)
3362 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3363#endif
3364
3365 curbuf->b_p_initialized = TRUE;
3366 curbuf->b_p_ar = -1; /* no local 'autoread' value */
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01003367 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003368 check_buf_options(curbuf);
3369 check_win_options(curwin);
3370 check_options();
3371
3372 /* Must be before option_expand(), because that one needs vim_isIDc() */
3373 didset_options();
3374
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003375#ifdef FEAT_SPELL
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003376 /* Use the current chartab for the generic chartab. */
3377 init_spell_chartab();
3378#endif
3379
Bram Moolenaar071d4272004-06-13 20:20:40 +00003380#ifdef FEAT_LINEBREAK
3381 /*
3382 * initialize the table for 'breakat'.
3383 */
3384 fill_breakat_flags();
3385#endif
3386
3387 /*
3388 * Expand environment variables and things like "~" for the defaults.
3389 * If option_expand() returns non-NULL the variable is expanded. This can
3390 * only happen for non-indirect options.
3391 * Also set the default to the expanded value, so ":set" does not list
3392 * them.
3393 * Don't set the P_ALLOCED flag, because we don't want to free the
3394 * default.
3395 */
3396 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3397 {
3398 if ((options[opt_idx].flags & P_GETTEXT)
3399 && options[opt_idx].var != NULL)
3400 p = (char_u *)_(*(char **)options[opt_idx].var);
3401 else
3402 p = option_expand(opt_idx, NULL);
3403 if (p != NULL && (p = vim_strsave(p)) != NULL)
3404 {
3405 *(char_u **)options[opt_idx].var = p;
3406 /* VIMEXP
3407 * Defaults for all expanded options are currently the same for Vi
3408 * and Vim. When this changes, add some code here! Also need to
3409 * split P_DEF_ALLOCED in two.
3410 */
3411 if (options[opt_idx].flags & P_DEF_ALLOCED)
3412 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3413 options[opt_idx].def_val[VI_DEFAULT] = p;
3414 options[opt_idx].flags |= P_DEF_ALLOCED;
3415 }
3416 }
3417
3418 /* Initialize the highlight_attr[] table. */
3419 highlight_changed();
3420
3421 save_file_ff(curbuf); /* Buffer is unchanged */
3422
3423 /* Parse default for 'wildmode' */
3424 check_opt_wim();
3425
3426#if defined(FEAT_ARABIC)
3427 /* Detect use of mlterm.
3428 * Mlterm is a terminal emulator akin to xterm that has some special
3429 * abilities (bidi namely).
3430 * NOTE: mlterm's author is being asked to 'set' a variable
3431 * instead of an environment variable due to inheritance.
3432 */
3433 if (mch_getenv((char_u *)"MLTERM") != NULL)
3434 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3435#endif
3436
3437#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
3438 /* Parse default for 'fillchars'. */
3439 (void)set_chars_option(&p_fcs);
3440#endif
3441
3442#ifdef FEAT_CLIPBOARD
3443 /* Parse default for 'clipboard' */
3444 (void)check_clipboard_option();
3445#endif
3446
3447#ifdef FEAT_MBYTE
3448# if defined(WIN3264) && defined(FEAT_GETTEXT)
3449 /*
3450 * If $LANG isn't set, try to get a good value for it. This makes the
3451 * right language be used automatically. Don't do this for English.
3452 */
3453 if (mch_getenv((char_u *)"LANG") == NULL)
3454 {
3455 char buf[20];
3456
3457 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3458 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3459 * only the first two. */
3460 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3461 (LPTSTR)buf, 20);
3462 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3463 {
3464 /* There are a few exceptions (probably more) */
3465 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3466 STRCPY(buf, "zh_TW");
3467 else if (STRNICMP(buf, "chs", 3) == 0
3468 || STRNICMP(buf, "zhc", 3) == 0)
3469 STRCPY(buf, "zh_CN");
3470 else if (STRNICMP(buf, "jp", 2) == 0)
3471 STRCPY(buf, "ja");
3472 else
3473 buf[2] = NUL; /* truncate to two-letter code */
3474 vim_setenv("LANG", buf);
3475 }
3476 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003477# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003478# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003479 /* Moved to os_mac_conv.c to avoid dependency problems. */
3480 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003481# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003482# endif
3483
3484 /* enc_locale() will try to find the encoding of the current locale. */
3485 p = enc_locale();
3486 if (p != NULL)
3487 {
3488 char_u *save_enc;
3489
3490 /* Try setting 'encoding' and check if the value is valid.
3491 * If not, go back to the default "latin1". */
3492 save_enc = p_enc;
3493 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003494 if (STRCMP(p_enc, "gb18030") == 0)
3495 {
3496 /* We don't support "gb18030", but "cp936" is a good substitute
3497 * for practical purposes, thus use that. It's not an alias to
3498 * still support conversion between gb18030 and utf-8. */
3499 p_enc = vim_strsave((char_u *)"cp936");
3500 vim_free(p);
3501 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003502 if (mb_init() == NULL)
3503 {
3504 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003505 if (opt_idx >= 0)
3506 {
3507 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3508 options[opt_idx].flags |= P_DEF_ALLOCED;
3509 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003510
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003511#if defined(MSDOS) || defined(MSWIN) || defined(OS2) || defined(MACOS) \
3512 || defined(VMS)
3513 if (STRCMP(p_enc, "latin1") == 0
3514# ifdef FEAT_MBYTE
3515 || enc_utf8
3516# endif
3517 )
3518 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003519 /* Adjust the default for 'isprint' and 'iskeyword' to match
3520 * latin1. Also set the defaults for when 'nocompatible' is
3521 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003522 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003523 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003524 set_string_option_direct((char_u *)"isk", -1,
3525 ISK_LATIN1, OPT_FREE, SID_NONE);
3526 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003527 if (opt_idx >= 0)
3528 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003529 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003530 if (opt_idx >= 0)
3531 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003532 (void)init_chartab();
3533 }
3534#endif
3535
Bram Moolenaar071d4272004-06-13 20:20:40 +00003536# if defined(WIN3264) && !defined(FEAT_GUI)
3537 /* Win32 console: When GetACP() returns a different value from
3538 * GetConsoleCP() set 'termencoding'. */
3539 if (GetACP() != GetConsoleCP())
3540 {
3541 char buf[50];
3542
3543 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3544 p_tenc = vim_strsave((char_u *)buf);
3545 if (p_tenc != NULL)
3546 {
3547 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003548 if (opt_idx >= 0)
3549 {
3550 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3551 options[opt_idx].flags |= P_DEF_ALLOCED;
3552 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003553 convert_setup(&input_conv, p_tenc, p_enc);
3554 convert_setup(&output_conv, p_enc, p_tenc);
3555 }
3556 else
3557 p_tenc = empty_option;
3558 }
3559# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003560# if defined(WIN3264) && defined(FEAT_MBYTE)
3561 /* $HOME may have characters in active code page. */
3562 init_homedir();
3563# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003564 }
3565 else
3566 {
3567 vim_free(p_enc);
3568 p_enc = save_enc;
3569 }
3570 }
3571#endif
3572
3573#ifdef FEAT_MULTI_LANG
3574 /* Set the default for 'helplang'. */
3575 set_helplang_default(get_mess_lang());
3576#endif
3577}
3578
3579/*
3580 * Set an option to its default value.
3581 * This does not take care of side effects!
3582 */
3583 static void
3584set_option_default(opt_idx, opt_flags, compatible)
3585 int opt_idx;
3586 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3587 int compatible; /* use Vi default value */
3588{
3589 char_u *varp; /* pointer to variable for current option */
3590 int dvi; /* index in def_val[] */
3591 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003592 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003593 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3594
3595 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3596 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003597 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003598 {
3599 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3600 if (flags & P_STRING)
3601 {
3602 /* Use set_string_option_direct() for local options to handle
3603 * freeing and allocating the value. */
3604 if (options[opt_idx].indir != PV_NONE)
3605 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003606 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003607 else
3608 {
3609 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3610 free_string_option(*(char_u **)(varp));
3611 *(char_u **)varp = options[opt_idx].def_val[dvi];
3612 options[opt_idx].flags &= ~P_ALLOCED;
3613 }
3614 }
3615 else if (flags & P_NUM)
3616 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003617 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003618 win_comp_scroll(curwin);
3619 else
3620 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003621 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003622 /* May also set global value for local option. */
3623 if (both)
3624 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3625 *(long *)varp;
3626 }
3627 }
3628 else /* P_BOOL */
3629 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003630 /* the cast to long is required for Manx C, long_i is needed for
3631 * MSVC */
3632 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003633#ifdef UNIX
3634 /* 'modeline' defaults to off for root */
3635 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3636 *(int *)varp = FALSE;
3637#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003638 /* May also set global value for local option. */
3639 if (both)
3640 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3641 *(int *)varp;
3642 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003643
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003644 /* The default value is not insecure. */
3645 flagsp = insecure_flag(opt_idx, opt_flags);
3646 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003647 }
3648
3649#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003650 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003651#endif
3652}
3653
3654/*
3655 * Set all options (except terminal options) to their default value.
3656 */
3657 static void
3658set_options_default(opt_flags)
3659 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3660{
3661 int i;
3662#ifdef FEAT_WINDOWS
3663 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003664 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003665#endif
3666
3667 for (i = 0; !istermoption(&options[i]); i++)
3668 if (!(options[i].flags & P_NODEFAULT))
3669 set_option_default(i, opt_flags, p_cp);
3670
3671#ifdef FEAT_WINDOWS
3672 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003673 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003674 win_comp_scroll(wp);
3675#else
3676 win_comp_scroll(curwin);
3677#endif
Bram Moolenaar5a4eceb2014-09-09 17:33:07 +02003678#ifdef FEAT_CINDENT
3679 parse_cino(curbuf);
3680#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003681}
3682
3683/*
3684 * Set the Vi-default value of a string option.
3685 * Used for 'sh', 'backupskip' and 'term'.
3686 */
3687 void
3688set_string_default(name, val)
3689 char *name;
3690 char_u *val;
3691{
3692 char_u *p;
3693 int opt_idx;
3694
3695 p = vim_strsave(val);
3696 if (p != NULL) /* we don't want a NULL */
3697 {
3698 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003699 if (opt_idx >= 0)
3700 {
3701 if (options[opt_idx].flags & P_DEF_ALLOCED)
3702 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3703 options[opt_idx].def_val[VI_DEFAULT] = p;
3704 options[opt_idx].flags |= P_DEF_ALLOCED;
3705 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003706 }
3707}
3708
3709/*
3710 * Set the Vi-default value of a number option.
3711 * Used for 'lines' and 'columns'.
3712 */
3713 void
3714set_number_default(name, val)
3715 char *name;
3716 long val;
3717{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003718 int opt_idx;
3719
3720 opt_idx = findoption((char_u *)name);
3721 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003722 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003723}
3724
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003725#if defined(EXITFREE) || defined(PROTO)
3726/*
3727 * Free all options.
3728 */
3729 void
3730free_all_options()
3731{
3732 int i;
3733
3734 for (i = 0; !istermoption(&options[i]); i++)
3735 {
3736 if (options[i].indir == PV_NONE)
3737 {
3738 /* global option: free value and default value. */
3739 if (options[i].flags & P_ALLOCED && options[i].var != NULL)
3740 free_string_option(*(char_u **)options[i].var);
3741 if (options[i].flags & P_DEF_ALLOCED)
3742 free_string_option(options[i].def_val[VI_DEFAULT]);
3743 }
3744 else if (options[i].var != VAR_WIN
3745 && (options[i].flags & P_STRING))
3746 /* buffer-local option: free global value */
3747 free_string_option(*(char_u **)options[i].var);
3748 }
3749}
3750#endif
3751
3752
Bram Moolenaar071d4272004-06-13 20:20:40 +00003753/*
3754 * Initialize the options, part two: After getting Rows and Columns and
3755 * setting 'term'.
3756 */
3757 void
3758set_init_2()
3759{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003760 int idx;
3761
Bram Moolenaar071d4272004-06-13 20:20:40 +00003762 /*
3763 * 'scroll' defaults to half the window height. Note that this default is
3764 * wrong when the window height changes.
3765 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003766 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003767 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003768 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003769 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003770 comp_col();
3771
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003772 /*
3773 * 'window' is only for backwards compatibility with Vi.
3774 * Default is Rows - 1.
3775 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003776 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003777 p_window = Rows - 1;
3778 set_number_default("window", Rows - 1);
3779
Bram Moolenaarf740b292006-02-16 22:11:02 +00003780 /* For DOS console the default is always black. */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003781#if !((defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003782 /*
3783 * If 'background' wasn't set by the user, try guessing the value,
3784 * depending on the terminal name. Only need to check for terminals
3785 * with a dark background, that can handle color.
3786 */
3787 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003788 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3789 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003790 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003791 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003792 /* don't mark it as set, when starting the GUI it may be
3793 * changed again */
3794 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003795 }
3796#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003797
3798#ifdef CURSOR_SHAPE
3799 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3800#endif
3801#ifdef FEAT_MOUSESHAPE
3802 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3803#endif
3804#ifdef FEAT_PRINTER
3805 (void)parse_printoptions(); /* parse 'printoptions' default value */
3806#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003807}
3808
3809/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00003810 * Return "dark" or "light" depending on the kind of terminal.
3811 * This is just guessing! Recognized are:
3812 * "linux" Linux console
3813 * "screen.linux" Linux console with screen
3814 * "cygwin" Cygwin shell
3815 * "putty" Putty program
3816 * We also check the COLORFGBG environment variable, which is set by
3817 * rxvt and derivatives. This variable contains either two or three
3818 * values separated by semicolons; we want the last value in either
3819 * case. If this value is 0-6 or 8, our background is dark.
3820 */
3821 static char_u *
3822term_bg_default()
3823{
Bram Moolenaarf740b292006-02-16 22:11:02 +00003824#if defined(MSDOS) || defined(OS2) || defined(WIN3264)
3825 /* DOS console nearly always black */
3826 return (char_u *)"dark";
3827#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00003828 char_u *p;
3829
Bram Moolenaarf740b292006-02-16 22:11:02 +00003830 if (STRCMP(T_NAME, "linux") == 0
3831 || STRCMP(T_NAME, "screen.linux") == 0
3832 || STRCMP(T_NAME, "cygwin") == 0
3833 || STRCMP(T_NAME, "putty") == 0
3834 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
3835 && (p = vim_strrchr(p, ';')) != NULL
3836 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
3837 && p[2] == NUL))
3838 return (char_u *)"dark";
3839 return (char_u *)"light";
3840#endif
3841}
3842
3843/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00003844 * Initialize the options, part three: After reading the .vimrc
3845 */
3846 void
3847set_init_3()
3848{
3849#if defined(UNIX) || defined(OS2) || defined(WIN3264)
3850/*
3851 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
3852 * This is done after other initializations, where 'shell' might have been
3853 * set, but only if they have not been set before.
3854 */
3855 char_u *p;
3856 int idx_srr;
3857 int do_srr;
3858#ifdef FEAT_QUICKFIX
3859 int idx_sp;
3860 int do_sp;
3861#endif
3862
3863 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003864 if (idx_srr < 0)
3865 do_srr = FALSE;
3866 else
3867 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003868#ifdef FEAT_QUICKFIX
3869 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003870 if (idx_sp < 0)
3871 do_sp = FALSE;
3872 else
3873 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003874#endif
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003875 p = get_isolated_shell_name();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003876 if (p != NULL)
3877 {
3878 /*
3879 * Default for p_sp is "| tee", for p_srr is ">".
3880 * For known shells it is changed here to include stderr.
3881 */
3882 if ( fnamecmp(p, "csh") == 0
3883 || fnamecmp(p, "tcsh") == 0
3884# if defined(OS2) || defined(WIN3264) /* also check with .exe extension */
3885 || fnamecmp(p, "csh.exe") == 0
3886 || fnamecmp(p, "tcsh.exe") == 0
3887# endif
3888 )
3889 {
3890#if defined(FEAT_QUICKFIX)
3891 if (do_sp)
3892 {
3893# ifdef WIN3264
3894 p_sp = (char_u *)">&";
3895# else
3896 p_sp = (char_u *)"|& tee";
3897# endif
3898 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3899 }
3900#endif
3901 if (do_srr)
3902 {
3903 p_srr = (char_u *)">&";
3904 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3905 }
3906 }
3907 else
3908# ifndef OS2 /* Always use bourne shell style redirection if we reach this */
3909 if ( fnamecmp(p, "sh") == 0
3910 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003911 || fnamecmp(p, "mksh") == 0
3912 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003913 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003914 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003915 || fnamecmp(p, "bash") == 0
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003916 || fnamecmp(p, "fish") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003917# ifdef WIN3264
3918 || fnamecmp(p, "cmd") == 0
3919 || fnamecmp(p, "sh.exe") == 0
3920 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003921 || fnamecmp(p, "mksh.exe") == 0
3922 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003923 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003924 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003925 || fnamecmp(p, "bash.exe") == 0
3926 || fnamecmp(p, "cmd.exe") == 0
3927# endif
3928 )
3929# endif
3930 {
3931#if defined(FEAT_QUICKFIX)
3932 if (do_sp)
3933 {
3934# ifdef WIN3264
3935 p_sp = (char_u *)">%s 2>&1";
3936# else
3937 p_sp = (char_u *)"2>&1| tee";
3938# endif
3939 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3940 }
3941#endif
3942 if (do_srr)
3943 {
3944 p_srr = (char_u *)">%s 2>&1";
3945 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3946 }
3947 }
3948 vim_free(p);
3949 }
3950#endif
3951
3952#if defined(MSDOS) || defined(WIN3264) || defined(OS2)
3953 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01003954 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
3955 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003956 * This is done after other initializations, where 'shell' might have been
3957 * set, but only if they have not been set before. Default for p_shcf is
3958 * "/c", for p_shq is "". For "sh" like shells it is changed here to
3959 * "-c" and "\"", but not for DJGPP, because it starts the shell without
3960 * command.com. And for Win32 we need to set p_sxq instead.
3961 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00003962 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003963 {
3964 int idx3;
3965
3966 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003967 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003968 {
3969 p_shcf = (char_u *)"-c";
3970 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3971 }
3972
3973# ifndef DJGPP
3974# ifdef WIN3264
3975 /* Somehow Win32 requires the quotes around the redirection too */
3976 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003977 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003978 {
3979 p_sxq = (char_u *)"\"";
3980 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3981 }
3982# else
3983 idx3 = findoption((char_u *)"shq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003984 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003985 {
3986 p_shq = (char_u *)"\"";
3987 options[idx3].def_val[VI_DEFAULT] = p_shq;
3988 }
3989# endif
3990# endif
3991 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01003992 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
3993 {
3994 int idx3;
3995
3996 /*
3997 * cmd.exe on Windows will strip the first and last double quote given
3998 * on the command line, e.g. most of the time things like:
3999 * cmd /c "my path/to/echo" "my args to echo"
4000 * become:
4001 * my path/to/echo" "my args to echo
4002 * when executed.
4003 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01004004 * To avoid this, set shellxquote to surround the command in
4005 * parenthesis. This appears to make most commands work, without
4006 * breaking commands that worked previously, such as
4007 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01004008 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01004009 idx3 = findoption((char_u *)"sxq");
4010 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4011 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004012 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004013 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4014 }
4015
Bram Moolenaara64ba222012-02-12 23:23:31 +01004016 idx3 = findoption((char_u *)"shcf");
4017 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4018 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004019 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004020 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4021 }
4022 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004023#endif
4024
4025#ifdef FEAT_TITLE
4026 set_title_defaults();
4027#endif
4028}
4029
4030#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4031/*
4032 * When 'helplang' is still at its default value, set it to "lang".
4033 * Only the first two characters of "lang" are used.
4034 */
4035 void
4036set_helplang_default(lang)
4037 char_u *lang;
4038{
4039 int idx;
4040
4041 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4042 return;
4043 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004044 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004045 {
4046 if (options[idx].flags & P_ALLOCED)
4047 free_string_option(p_hlg);
4048 p_hlg = vim_strsave(lang);
4049 if (p_hlg == NULL)
4050 p_hlg = empty_option;
4051 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004052 {
4053 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4054 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4055 {
4056 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4057 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4058 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004059 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004060 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004061 options[idx].flags |= P_ALLOCED;
4062 }
4063}
4064#endif
4065
4066#ifdef FEAT_GUI
4067static char_u *gui_bg_default __ARGS((void));
4068
4069 static char_u *
4070gui_bg_default()
4071{
4072 if (gui_get_lightness(gui.back_pixel) < 127)
4073 return (char_u *)"dark";
4074 return (char_u *)"light";
4075}
4076
4077/*
4078 * Option initializations that can only be done after opening the GUI window.
4079 */
4080 void
4081init_gui_options()
4082{
4083 /* Set the 'background' option according to the lightness of the
4084 * background color, unless the user has set it already. */
4085 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4086 {
4087 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4088 highlight_changed();
4089 }
4090}
4091#endif
4092
4093#ifdef FEAT_TITLE
4094/*
4095 * 'title' and 'icon' only default to true if they have not been set or reset
4096 * in .vimrc and we can read the old value.
4097 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4098 * they can be reset. This reduces startup time when using X on a remote
4099 * machine.
4100 */
4101 void
4102set_title_defaults()
4103{
4104 int idx1;
4105 long val;
4106
4107 /*
4108 * If GUI is (going to be) used, we can always set the window title and
4109 * icon name. Saves a bit of time, because the X11 display server does
4110 * not need to be contacted.
4111 */
4112 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004113 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004114 {
4115#ifdef FEAT_GUI
4116 if (gui.starting || gui.in_use)
4117 val = TRUE;
4118 else
4119#endif
4120 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004121 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004122 p_title = val;
4123 }
4124 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004125 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004126 {
4127#ifdef FEAT_GUI
4128 if (gui.starting || gui.in_use)
4129 val = TRUE;
4130 else
4131#endif
4132 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004133 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004134 p_icon = val;
4135 }
4136}
4137#endif
4138
4139/*
4140 * Parse 'arg' for option settings.
4141 *
4142 * 'arg' may be IObuff, but only when no errors can be present and option
4143 * does not need to be expanded with option_expand().
4144 * "opt_flags":
4145 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004146 * OPT_GLOBAL for ":setglobal"
4147 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004148 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004149 * OPT_WINONLY to only set window-local options
4150 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004151 *
4152 * returns FAIL if an error is detected, OK otherwise
4153 */
4154 int
4155do_set(arg, opt_flags)
4156 char_u *arg; /* option string (may be written to!) */
4157 int opt_flags;
4158{
4159 int opt_idx;
4160 char_u *errmsg;
4161 char_u errbuf[80];
4162 char_u *startarg;
4163 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4164 int nextchar; /* next non-white char after option name */
4165 int afterchar; /* character just after option name */
4166 int len;
4167 int i;
4168 long value;
4169 int key;
4170 long_u flags; /* flags for current option */
4171 char_u *varp = NULL; /* pointer to variable for current option */
4172 int did_show = FALSE; /* already showed one value */
4173 int adding; /* "opt+=arg" */
4174 int prepending; /* "opt^=arg" */
4175 int removing; /* "opt-=arg" */
4176 int cp_val = 0;
4177 char_u key_name[2];
4178
4179 if (*arg == NUL)
4180 {
4181 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004182 did_show = TRUE;
4183 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004184 }
4185
4186 while (*arg != NUL) /* loop to process all options */
4187 {
4188 errmsg = NULL;
4189 startarg = arg; /* remember for error message */
4190
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004191 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4192 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004193 {
4194 /*
4195 * ":set all" show all options.
4196 * ":set all&" set all options to their default value.
4197 */
4198 arg += 3;
4199 if (*arg == '&')
4200 {
4201 ++arg;
4202 /* Only for :set command set global value of local options. */
4203 set_options_default(OPT_FREE | opt_flags);
4204 }
4205 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004206 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004207 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004208 did_show = TRUE;
4209 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004210 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004211 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004212 {
4213 showoptions(2, opt_flags);
4214 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004215 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004216 arg += 7;
4217 }
4218 else
4219 {
4220 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004221 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004222 {
4223 prefix = 0;
4224 arg += 2;
4225 }
4226 else if (STRNCMP(arg, "inv", 3) == 0)
4227 {
4228 prefix = 2;
4229 arg += 3;
4230 }
4231
4232 /* find end of name */
4233 key = 0;
4234 if (*arg == '<')
4235 {
4236 nextchar = 0;
4237 opt_idx = -1;
4238 /* look out for <t_>;> */
4239 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4240 len = 5;
4241 else
4242 {
4243 len = 1;
4244 while (arg[len] != NUL && arg[len] != '>')
4245 ++len;
4246 }
4247 if (arg[len] != '>')
4248 {
4249 errmsg = e_invarg;
4250 goto skip;
4251 }
4252 arg[len] = NUL; /* put NUL after name */
4253 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4254 opt_idx = findoption(arg + 1);
4255 arg[len++] = '>'; /* restore '>' */
4256 if (opt_idx == -1)
4257 key = find_key_option(arg + 1);
4258 }
4259 else
4260 {
4261 len = 0;
4262 /*
4263 * The two characters after "t_" may not be alphanumeric.
4264 */
4265 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4266 len = 4;
4267 else
4268 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4269 ++len;
4270 nextchar = arg[len];
4271 arg[len] = NUL; /* put NUL after name */
4272 opt_idx = findoption(arg);
4273 arg[len] = nextchar; /* restore nextchar */
4274 if (opt_idx == -1)
4275 key = find_key_option(arg);
4276 }
4277
4278 /* remember character after option name */
4279 afterchar = arg[len];
4280
4281 /* skip white space, allow ":set ai ?" */
4282 while (vim_iswhite(arg[len]))
4283 ++len;
4284
4285 adding = FALSE;
4286 prepending = FALSE;
4287 removing = FALSE;
4288 if (arg[len] != NUL && arg[len + 1] == '=')
4289 {
4290 if (arg[len] == '+')
4291 {
4292 adding = TRUE; /* "+=" */
4293 ++len;
4294 }
4295 else if (arg[len] == '^')
4296 {
4297 prepending = TRUE; /* "^=" */
4298 ++len;
4299 }
4300 else if (arg[len] == '-')
4301 {
4302 removing = TRUE; /* "-=" */
4303 ++len;
4304 }
4305 }
4306 nextchar = arg[len];
4307
4308 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4309 {
4310 errmsg = (char_u *)N_("E518: Unknown option");
4311 goto skip;
4312 }
4313
4314 if (opt_idx >= 0)
4315 {
4316 if (options[opt_idx].var == NULL) /* hidden option: skip */
4317 {
4318 /* Only give an error message when requesting the value of
4319 * a hidden option, ignore setting it. */
4320 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4321 && (!(options[opt_idx].flags & P_BOOL)
4322 || nextchar == '?'))
4323 errmsg = (char_u *)N_("E519: Option not supported");
4324 goto skip;
4325 }
4326
4327 flags = options[opt_idx].flags;
4328 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4329 }
4330 else
4331 {
4332 flags = P_STRING;
4333 if (key < 0)
4334 {
4335 key_name[0] = KEY2TERMCAP0(key);
4336 key_name[1] = KEY2TERMCAP1(key);
4337 }
4338 else
4339 {
4340 key_name[0] = KS_KEY;
4341 key_name[1] = (key & 0xff);
4342 }
4343 }
4344
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004345 /* Skip all options that are not window-local (used when showing
4346 * an already loaded buffer in a window). */
4347 if ((opt_flags & OPT_WINONLY)
4348 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4349 goto skip;
4350
Bram Moolenaara3227e22006-03-08 21:32:40 +00004351 /* Skip all options that are window-local (used for :vimgrep). */
4352 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4353 && options[opt_idx].var == VAR_WIN)
4354 goto skip;
4355
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004356 /* Disallow changing some options from modelines. */
4357 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004358 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004359 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004360 {
4361 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4362 goto skip;
4363 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004364#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004365 /* In diff mode some options are overruled. This avoids that
4366 * 'foldmethod' becomes "marker" instead of "diff" and that
4367 * "wrap" gets set. */
4368 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004369 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004370 && (options[opt_idx].indir == PV_FDM
4371 || options[opt_idx].indir == PV_WRAP))
4372 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004373#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004374 }
4375
4376#ifdef HAVE_SANDBOX
4377 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004378 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004379 {
4380 errmsg = (char_u *)_(e_sandbox);
4381 goto skip;
4382 }
4383#endif
4384
4385 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4386 {
4387 arg += len;
4388 cp_val = p_cp;
4389 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4390 {
4391 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4392 {
4393 cp_val = FALSE;
4394 arg += 3;
4395 }
4396 else /* "opt&vi": set to Vi default */
4397 {
4398 cp_val = TRUE;
4399 arg += 2;
4400 }
4401 }
4402 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
4403 && arg[1] != NUL && !vim_iswhite(arg[1]))
4404 {
4405 errmsg = e_trailing;
4406 goto skip;
4407 }
4408 }
4409
4410 /*
4411 * allow '=' and ':' as MSDOS command.com allows only one
4412 * '=' character per "set" command line. grrr. (jw)
4413 */
4414 if (nextchar == '?'
4415 || (prefix == 1
4416 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4417 && !(flags & P_BOOL)))
4418 {
4419 /*
4420 * print value
4421 */
4422 if (did_show)
4423 msg_putchar('\n'); /* cursor below last one */
4424 else
4425 {
4426 gotocmdline(TRUE); /* cursor at status line */
4427 did_show = TRUE; /* remember that we did a line */
4428 }
4429 if (opt_idx >= 0)
4430 {
4431 showoneopt(&options[opt_idx], opt_flags);
4432#ifdef FEAT_EVAL
4433 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004434 {
4435 /* Mention where the option was last set. */
4436 if (varp == options[opt_idx].var)
4437 last_set_msg(options[opt_idx].scriptID);
4438 else if ((int)options[opt_idx].indir & PV_WIN)
4439 last_set_msg(curwin->w_p_scriptID[
4440 (int)options[opt_idx].indir & PV_MASK]);
4441 else if ((int)options[opt_idx].indir & PV_BUF)
4442 last_set_msg(curbuf->b_p_scriptID[
4443 (int)options[opt_idx].indir & PV_MASK]);
4444 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004445#endif
4446 }
4447 else
4448 {
4449 char_u *p;
4450
4451 p = find_termcode(key_name);
4452 if (p == NULL)
4453 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004454 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004455 goto skip;
4456 }
4457 else
4458 (void)show_one_termcode(key_name, p, TRUE);
4459 }
4460 if (nextchar != '?'
4461 && nextchar != NUL && !vim_iswhite(afterchar))
4462 errmsg = e_trailing;
4463 }
4464 else
4465 {
4466 if (flags & P_BOOL) /* boolean */
4467 {
4468 if (nextchar == '=' || nextchar == ':')
4469 {
4470 errmsg = e_invarg;
4471 goto skip;
4472 }
4473
4474 /*
4475 * ":set opt!": invert
4476 * ":set opt&": reset to default value
4477 * ":set opt<": reset to global value
4478 */
4479 if (nextchar == '!')
4480 value = *(int *)(varp) ^ 1;
4481 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004482 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004483 ((flags & P_VI_DEF) || cp_val)
4484 ? VI_DEFAULT : VIM_DEFAULT];
4485 else if (nextchar == '<')
4486 {
4487 /* For 'autoread' -1 means to use global value. */
4488 if ((int *)varp == &curbuf->b_p_ar
4489 && opt_flags == OPT_LOCAL)
4490 value = -1;
4491 else
4492 value = *(int *)get_varp_scope(&(options[opt_idx]),
4493 OPT_GLOBAL);
4494 }
4495 else
4496 {
4497 /*
4498 * ":set invopt": invert
4499 * ":set opt" or ":set noopt": set or reset
4500 */
4501 if (nextchar != NUL && !vim_iswhite(afterchar))
4502 {
4503 errmsg = e_trailing;
4504 goto skip;
4505 }
4506 if (prefix == 2) /* inv */
4507 value = *(int *)(varp) ^ 1;
4508 else
4509 value = prefix;
4510 }
4511
4512 errmsg = set_bool_option(opt_idx, varp, (int)value,
4513 opt_flags);
4514 }
4515 else /* numeric or string */
4516 {
4517 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4518 || prefix != 1)
4519 {
4520 errmsg = e_invarg;
4521 goto skip;
4522 }
4523
4524 if (flags & P_NUM) /* numeric */
4525 {
4526 /*
4527 * Different ways to set a number option:
4528 * & set to default value
4529 * < set to global value
4530 * <xx> accept special key codes for 'wildchar'
4531 * c accept any non-digit for 'wildchar'
4532 * [-]0-9 set number
4533 * other error
4534 */
4535 ++arg;
4536 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004537 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004538 ((flags & P_VI_DEF) || cp_val)
4539 ? VI_DEFAULT : VIM_DEFAULT];
4540 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004541 {
4542 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4543 * use the global value. */
4544 if ((long *)varp == &curbuf->b_p_ul
4545 && opt_flags == OPT_LOCAL)
4546 value = NO_LOCAL_UNDOLEVEL;
4547 else
4548 value = *(long *)get_varp_scope(
4549 &(options[opt_idx]), OPT_GLOBAL);
4550 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004551 else if (((long *)varp == &p_wc
4552 || (long *)varp == &p_wcm)
4553 && (*arg == '<'
4554 || *arg == '^'
4555 || ((!arg[1] || vim_iswhite(arg[1]))
4556 && !VIM_ISDIGIT(*arg))))
4557 {
4558 value = string_to_key(arg);
4559 if (value == 0 && (long *)varp != &p_wcm)
4560 {
4561 errmsg = e_invarg;
4562 goto skip;
4563 }
4564 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004565 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4566 {
Bram Moolenaar18400e62015-01-27 15:58:40 +01004567 /* Allow negative (for 'undolevels'), octal and
4568 * hex numbers. */
Bram Moolenaar5d1bc782015-07-17 13:03:48 +02004569 vim_str2nr(arg, NULL, &i, TRUE, TRUE, &value, NULL, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004570 if (arg[i] != NUL && !vim_iswhite(arg[i]))
4571 {
4572 errmsg = e_invarg;
4573 goto skip;
4574 }
4575 }
4576 else
4577 {
4578 errmsg = (char_u *)N_("E521: Number required after =");
4579 goto skip;
4580 }
4581
4582 if (adding)
4583 value = *(long *)varp + value;
4584 if (prepending)
4585 value = *(long *)varp * value;
4586 if (removing)
4587 value = *(long *)varp - value;
4588 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004589 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004590 }
4591 else if (opt_idx >= 0) /* string */
4592 {
4593 char_u *save_arg = NULL;
4594 char_u *s = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004595 char_u *oldval = NULL; /* previous value if *varp */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004596 char_u *newval;
Bram Moolenaar53744302015-07-17 17:38:22 +02004597 char_u *origval = NULL;
4598#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4599 char_u *saved_origval = NULL;
4600#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004601 unsigned newlen;
4602 int comma;
4603 int bs;
4604 int new_value_alloced; /* new string option
4605 was allocated */
4606
4607 /* When using ":set opt=val" for a global option
4608 * with a local value the local value will be
4609 * reset, use the global value here. */
4610 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004611 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004612 varp = options[opt_idx].var;
4613
4614 /* The old value is kept until we are sure that the
4615 * new value is valid. */
4616 oldval = *(char_u **)varp;
4617 if (nextchar == '&') /* set to default val */
4618 {
4619 newval = options[opt_idx].def_val[
4620 ((flags & P_VI_DEF) || cp_val)
4621 ? VI_DEFAULT : VIM_DEFAULT];
4622 if ((char_u **)varp == &p_bg)
4623 {
4624 /* guess the value of 'background' */
4625#ifdef FEAT_GUI
4626 if (gui.in_use)
4627 newval = gui_bg_default();
4628 else
4629#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004630 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004631 }
4632
4633 /* expand environment variables and ~ (since the
4634 * default value was already expanded, only
4635 * required when an environment variable was set
4636 * later */
4637 if (newval == NULL)
4638 newval = empty_option;
4639 else
4640 {
4641 s = option_expand(opt_idx, newval);
4642 if (s == NULL)
4643 s = newval;
4644 newval = vim_strsave(s);
4645 }
4646 new_value_alloced = TRUE;
4647 }
4648 else if (nextchar == '<') /* set to global val */
4649 {
4650 newval = vim_strsave(*(char_u **)get_varp_scope(
4651 &(options[opt_idx]), OPT_GLOBAL));
4652 new_value_alloced = TRUE;
4653 }
4654 else
4655 {
4656 ++arg; /* jump to after the '=' or ':' */
4657
4658 /*
4659 * Set 'keywordprg' to ":help" if an empty
4660 * value was passed to :set by the user.
4661 * Misuse errbuf[] for the resulting string.
4662 */
4663 if (varp == (char_u *)&p_kp
4664 && (*arg == NUL || *arg == ' '))
4665 {
4666 STRCPY(errbuf, ":help");
4667 save_arg = arg;
4668 arg = errbuf;
4669 }
4670 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004671 * Convert 'backspace' number to string, for
4672 * adding, prepending and removing string.
4673 */
4674 else if (varp == (char_u *)&p_bs
4675 && VIM_ISDIGIT(**(char_u **)varp))
4676 {
4677 i = getdigits((char_u **)varp);
4678 switch (i)
4679 {
4680 case 0:
4681 *(char_u **)varp = empty_option;
4682 break;
4683 case 1:
4684 *(char_u **)varp = vim_strsave(
4685 (char_u *)"indent,eol");
4686 break;
4687 case 2:
4688 *(char_u **)varp = vim_strsave(
4689 (char_u *)"indent,eol,start");
4690 break;
4691 }
4692 vim_free(oldval);
4693 oldval = *(char_u **)varp;
4694 }
4695 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004696 * Convert 'whichwrap' number to string, for
4697 * backwards compatibility with Vim 3.0.
4698 * Misuse errbuf[] for the resulting string.
4699 */
4700 else if (varp == (char_u *)&p_ww
4701 && VIM_ISDIGIT(*arg))
4702 {
4703 *errbuf = NUL;
4704 i = getdigits(&arg);
4705 if (i & 1)
4706 STRCAT(errbuf, "b,");
4707 if (i & 2)
4708 STRCAT(errbuf, "s,");
4709 if (i & 4)
4710 STRCAT(errbuf, "h,l,");
4711 if (i & 8)
4712 STRCAT(errbuf, "<,>,");
4713 if (i & 16)
4714 STRCAT(errbuf, "[,],");
4715 if (*errbuf != NUL) /* remove trailing , */
4716 errbuf[STRLEN(errbuf) - 1] = NUL;
4717 save_arg = arg;
4718 arg = errbuf;
4719 }
4720 /*
4721 * Remove '>' before 'dir' and 'bdir', for
4722 * backwards compatibility with version 3.0
4723 */
4724 else if ( *arg == '>'
4725 && (varp == (char_u *)&p_dir
4726 || varp == (char_u *)&p_bdir))
4727 {
4728 ++arg;
4729 }
4730
4731 /* When setting the local value of a global
4732 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004733 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004734 && (opt_flags & OPT_LOCAL))
4735 origval = *(char_u **)get_varp(
4736 &options[opt_idx]);
4737 else
4738 origval = oldval;
4739
4740 /*
4741 * Copy the new string into allocated memory.
4742 * Can't use set_string_option_direct(), because
4743 * we need to remove the backslashes.
4744 */
4745 /* get a bit too much */
4746 newlen = (unsigned)STRLEN(arg) + 1;
4747 if (adding || prepending || removing)
4748 newlen += (unsigned)STRLEN(origval) + 1;
4749 newval = alloc(newlen);
4750 if (newval == NULL) /* out of mem, don't change */
4751 break;
4752 s = newval;
4753
4754 /*
4755 * Copy the string, skip over escaped chars.
4756 * For MS-DOS and WIN32 backslashes before normal
4757 * file name characters are not removed, and keep
4758 * backslash at start, for "\\machine\path", but
4759 * do remove it for "\\\\machine\\path".
4760 * The reverse is found in ExpandOldSetting().
4761 */
4762 while (*arg && !vim_iswhite(*arg))
4763 {
4764 if (*arg == '\\' && arg[1] != NUL
4765#ifdef BACKSLASH_IN_FILENAME
4766 && !((flags & P_EXPAND)
4767 && vim_isfilec(arg[1])
4768 && (arg[1] != '\\'
4769 || (s == newval
4770 && arg[2] != '\\')))
4771#endif
4772 )
4773 ++arg; /* remove backslash */
4774#ifdef FEAT_MBYTE
4775 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00004776 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004777 {
4778 /* copy multibyte char */
4779 mch_memmove(s, arg, (size_t)i);
4780 arg += i;
4781 s += i;
4782 }
4783 else
4784#endif
4785 *s++ = *arg++;
4786 }
4787 *s = NUL;
4788
4789 /*
4790 * Expand environment variables and ~.
4791 * Don't do it when adding without inserting a
4792 * comma.
4793 */
4794 if (!(adding || prepending || removing)
4795 || (flags & P_COMMA))
4796 {
4797 s = option_expand(opt_idx, newval);
4798 if (s != NULL)
4799 {
4800 vim_free(newval);
4801 newlen = (unsigned)STRLEN(s) + 1;
4802 if (adding || prepending || removing)
4803 newlen += (unsigned)STRLEN(origval) + 1;
4804 newval = alloc(newlen);
4805 if (newval == NULL)
4806 break;
4807 STRCPY(newval, s);
4808 }
4809 }
4810
4811 /* locate newval[] in origval[] when removing it
4812 * and when adding to avoid duplicates */
4813 i = 0; /* init for GCC */
4814 if (removing || (flags & P_NODUP))
4815 {
4816 i = (int)STRLEN(newval);
4817 bs = 0;
4818 for (s = origval; *s; ++s)
4819 {
4820 if ((!(flags & P_COMMA)
4821 || s == origval
4822 || (s[-1] == ',' && !(bs & 1)))
4823 && STRNCMP(s, newval, i) == 0
4824 && (!(flags & P_COMMA)
4825 || s[i] == ','
4826 || s[i] == NUL))
4827 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004828 /* Count backslashes. Only a comma with an
4829 * even number of backslashes before it is
Bram Moolenaar071d4272004-06-13 20:20:40 +00004830 * recognized as a separator */
4831 if (s > origval && s[-1] == '\\')
4832 ++bs;
4833 else
4834 bs = 0;
4835 }
4836
4837 /* do not add if already there */
4838 if ((adding || prepending) && *s)
4839 {
4840 prepending = FALSE;
4841 adding = FALSE;
4842 STRCPY(newval, origval);
4843 }
4844 }
4845
4846 /* concatenate the two strings; add a ',' if
4847 * needed */
4848 if (adding || prepending)
4849 {
4850 comma = ((flags & P_COMMA) && *origval != NUL
4851 && *newval != NUL);
4852 if (adding)
4853 {
4854 i = (int)STRLEN(origval);
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004855 /* strip a trailing comma, would get 2 */
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02004856 if (comma && (flags & P_ONECOMMA) && i > 1
4857 && origval[i - 1] == ','
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004858 && origval[i - 2] != '\\')
4859 i--;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004860 mch_memmove(newval + i + comma, newval,
4861 STRLEN(newval) + 1);
4862 mch_memmove(newval, origval, (size_t)i);
4863 }
4864 else
4865 {
4866 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004867 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004868 }
4869 if (comma)
4870 newval[i] = ',';
4871 }
4872
4873 /* Remove newval[] from origval[]. (Note: "i" has
4874 * been set above and is used here). */
4875 if (removing)
4876 {
4877 STRCPY(newval, origval);
4878 if (*s)
4879 {
4880 /* may need to remove a comma */
4881 if (flags & P_COMMA)
4882 {
4883 if (s == origval)
4884 {
4885 /* include comma after string */
4886 if (s[i] == ',')
4887 ++i;
4888 }
4889 else
4890 {
4891 /* include comma before string */
4892 --s;
4893 ++i;
4894 }
4895 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004896 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004897 }
4898 }
4899
4900 if (flags & P_FLAGLIST)
4901 {
4902 /* Remove flags that appear twice. */
4903 for (s = newval; *s; ++s)
4904 if ((!(flags & P_COMMA) || *s != ',')
4905 && vim_strchr(s + 1, *s) != NULL)
4906 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004907 STRMOVE(s, s + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004908 --s;
4909 }
4910 }
4911
4912 if (save_arg != NULL) /* number for 'whichwrap' */
4913 arg = save_arg;
4914 new_value_alloced = TRUE;
4915 }
4916
4917 /* Set the new value. */
4918 *(char_u **)(varp) = newval;
4919
Bram Moolenaar53744302015-07-17 17:38:22 +02004920#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02004921 if (!starting
4922# ifdef FEAT_CRYPT
4923 && options[opt_idx].indir != PV_KEY
4924# endif
Bram Moolenaar53744302015-07-17 17:38:22 +02004925 && origval != NULL)
4926 /* origval may be freed by
4927 * did_set_string_option(), make a copy. */
4928 saved_origval = vim_strsave(origval);
4929#endif
4930
Bram Moolenaar071d4272004-06-13 20:20:40 +00004931 /* Handle side effects, and set the global value for
4932 * ":set" on local options. */
4933 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
4934 new_value_alloced, oldval, errbuf, opt_flags);
4935
4936 /* If error detected, print the error message. */
4937 if (errmsg != NULL)
4938 goto skip;
Bram Moolenaar53744302015-07-17 17:38:22 +02004939#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4940 if (saved_origval != NULL)
4941 {
4942 char_u buf_type[7];
4943
4944 sprintf((char *)buf_type, "%s",
4945 (opt_flags & OPT_LOCAL) ? "local" : "global");
4946 set_vim_var_string(VV_OPTION_NEW, newval, -1);
4947 set_vim_var_string(VV_OPTION_OLD, saved_origval, -1);
4948 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
4949 apply_autocmds(EVENT_OPTIONSET,
4950 (char_u *)options[opt_idx].fullname,
4951 NULL, FALSE, NULL);
4952 reset_v_option_vars();
4953 vim_free(saved_origval);
4954 }
4955#endif
4956
Bram Moolenaar071d4272004-06-13 20:20:40 +00004957 }
4958 else /* key code option */
4959 {
4960 char_u *p;
4961
4962 if (nextchar == '&')
4963 {
4964 if (add_termcap_entry(key_name, TRUE) == FAIL)
4965 errmsg = (char_u *)N_("E522: Not found in termcap");
4966 }
4967 else
4968 {
4969 ++arg; /* jump to after the '=' or ':' */
4970 for (p = arg; *p && !vim_iswhite(*p); ++p)
4971 if (*p == '\\' && p[1] != NUL)
4972 ++p;
4973 nextchar = *p;
4974 *p = NUL;
4975 add_termcode(key_name, arg, FALSE);
4976 *p = nextchar;
4977 }
4978 if (full_screen)
4979 ttest(FALSE);
4980 redraw_all_later(CLEAR);
4981 }
4982 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004983
Bram Moolenaar071d4272004-06-13 20:20:40 +00004984 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004985 did_set_option(opt_idx, opt_flags,
4986 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004987 }
4988
4989skip:
4990 /*
4991 * Advance to next argument.
4992 * - skip until a blank found, taking care of backslashes
4993 * - skip blanks
4994 * - skip one "=val" argument (for hidden options ":set gfn =xx")
4995 */
4996 for (i = 0; i < 2 ; ++i)
4997 {
4998 while (*arg != NUL && !vim_iswhite(*arg))
4999 if (*arg++ == '\\' && *arg != NUL)
5000 ++arg;
5001 arg = skipwhite(arg);
5002 if (*arg != '=')
5003 break;
5004 }
5005 }
5006
5007 if (errmsg != NULL)
5008 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005009 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005010 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005011 if (i + (arg - startarg) < IOSIZE)
5012 {
5013 /* append the argument with the error */
5014 STRCAT(IObuff, ": ");
5015 mch_memmove(IObuff + i, startarg, (arg - startarg));
5016 IObuff[i + (arg - startarg)] = NUL;
5017 }
5018 /* make sure all characters are printable */
5019 trans_characters(IObuff, IOSIZE);
5020
5021 ++no_wait_return; /* wait_return done later */
5022 emsg(IObuff); /* show error highlighted */
5023 --no_wait_return;
5024
5025 return FAIL;
5026 }
5027
5028 arg = skipwhite(arg);
5029 }
5030
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005031theend:
5032 if (silent_mode && did_show)
5033 {
5034 /* After displaying option values in silent mode. */
5035 silent_mode = FALSE;
5036 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5037 msg_putchar('\n');
5038 cursor_on(); /* msg_start() switches it off */
5039 out_flush();
5040 silent_mode = TRUE;
5041 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5042 }
5043
Bram Moolenaar071d4272004-06-13 20:20:40 +00005044 return OK;
5045}
5046
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005047/*
5048 * Call this when an option has been given a new value through a user command.
5049 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5050 */
5051 static void
5052did_set_option(opt_idx, opt_flags, new_value)
5053 int opt_idx;
5054 int opt_flags; /* possibly with OPT_MODELINE */
5055 int new_value; /* value was replaced completely */
5056{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005057 long_u *p;
5058
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005059 options[opt_idx].flags |= P_WAS_SET;
5060
5061 /* When an option is set in the sandbox, from a modeline or in secure mode
5062 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005063 * flag. */
5064 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005065 if (secure
5066#ifdef HAVE_SANDBOX
5067 || sandbox != 0
5068#endif
5069 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005070 *p = *p | P_INSECURE;
5071 else if (new_value)
5072 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005073}
5074
Bram Moolenaar071d4272004-06-13 20:20:40 +00005075 static char_u *
5076illegal_char(errbuf, c)
5077 char_u *errbuf;
5078 int c;
5079{
5080 if (errbuf == NULL)
5081 return (char_u *)"";
5082 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005083 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005084 return errbuf;
5085}
5086
5087/*
5088 * Convert a key name or string into a key value.
5089 * Used for 'wildchar' and 'cedit' options.
5090 */
5091 static int
5092string_to_key(arg)
5093 char_u *arg;
5094{
5095 if (*arg == '<')
5096 return find_key_option(arg + 1);
5097 if (*arg == '^')
5098 return Ctrl_chr(arg[1]);
5099 return *arg;
5100}
5101
5102#ifdef FEAT_CMDWIN
5103/*
5104 * Check value of 'cedit' and set cedit_key.
5105 * Returns NULL if value is OK, error message otherwise.
5106 */
5107 static char_u *
5108check_cedit()
5109{
5110 int n;
5111
5112 if (*p_cedit == NUL)
5113 cedit_key = -1;
5114 else
5115 {
5116 n = string_to_key(p_cedit);
5117 if (vim_isprintc(n))
5118 return e_invarg;
5119 cedit_key = n;
5120 }
5121 return NULL;
5122}
5123#endif
5124
5125#ifdef FEAT_TITLE
5126/*
5127 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5128 * maketitle() to create and display it.
5129 * When switching the title or icon off, call mch_restore_title() to get
5130 * the old value back.
5131 */
5132 static void
5133did_set_title(icon)
5134 int icon; /* Did set icon instead of title */
5135{
5136 if (starting != NO_SCREEN
5137#ifdef FEAT_GUI
5138 && !gui.starting
5139#endif
5140 )
5141 {
5142 maketitle();
5143 if (icon)
5144 {
5145 if (!p_icon)
5146 mch_restore_title(2);
5147 }
5148 else
5149 {
5150 if (!p_title)
5151 mch_restore_title(1);
5152 }
5153 }
5154}
5155#endif
5156
5157/*
5158 * set_options_bin - called when 'bin' changes value.
5159 */
5160 void
5161set_options_bin(oldval, newval, opt_flags)
5162 int oldval;
5163 int newval;
5164 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5165{
5166 /*
5167 * The option values that are changed when 'bin' changes are
5168 * copied when 'bin is set and restored when 'bin' is reset.
5169 */
5170 if (newval)
5171 {
5172 if (!oldval) /* switched on */
5173 {
5174 if (!(opt_flags & OPT_GLOBAL))
5175 {
5176 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5177 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5178 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5179 curbuf->b_p_et_nobin = curbuf->b_p_et;
5180 }
5181 if (!(opt_flags & OPT_LOCAL))
5182 {
5183 p_tw_nobin = p_tw;
5184 p_wm_nobin = p_wm;
5185 p_ml_nobin = p_ml;
5186 p_et_nobin = p_et;
5187 }
5188 }
5189
5190 if (!(opt_flags & OPT_GLOBAL))
5191 {
5192 curbuf->b_p_tw = 0; /* no automatic line wrap */
5193 curbuf->b_p_wm = 0; /* no automatic line wrap */
5194 curbuf->b_p_ml = 0; /* no modelines */
5195 curbuf->b_p_et = 0; /* no expandtab */
5196 }
5197 if (!(opt_flags & OPT_LOCAL))
5198 {
5199 p_tw = 0;
5200 p_wm = 0;
5201 p_ml = FALSE;
5202 p_et = FALSE;
5203 p_bin = TRUE; /* needed when called for the "-b" argument */
5204 }
5205 }
5206 else if (oldval) /* switched off */
5207 {
5208 if (!(opt_flags & OPT_GLOBAL))
5209 {
5210 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5211 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5212 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5213 curbuf->b_p_et = curbuf->b_p_et_nobin;
5214 }
5215 if (!(opt_flags & OPT_LOCAL))
5216 {
5217 p_tw = p_tw_nobin;
5218 p_wm = p_wm_nobin;
5219 p_ml = p_ml_nobin;
5220 p_et = p_et_nobin;
5221 }
5222 }
5223}
5224
5225#ifdef FEAT_VIMINFO
5226/*
5227 * Find the parameter represented by the given character (eg ', :, ", or /),
5228 * and return its associated value in the 'viminfo' string.
5229 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005230 * If the parameter is not specified in the string or there is no following
5231 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005232 */
5233 int
5234get_viminfo_parameter(type)
5235 int type;
5236{
5237 char_u *p;
5238
5239 p = find_viminfo_parameter(type);
5240 if (p != NULL && VIM_ISDIGIT(*p))
5241 return atoi((char *)p);
5242 return -1;
5243}
5244
5245/*
5246 * Find the parameter represented by the given character (eg ''', ':', '"', or
5247 * '/') in the 'viminfo' option and return a pointer to the string after it.
5248 * Return NULL if the parameter is not specified in the string.
5249 */
5250 char_u *
5251find_viminfo_parameter(type)
5252 int type;
5253{
5254 char_u *p;
5255
5256 for (p = p_viminfo; *p; ++p)
5257 {
5258 if (*p == type)
5259 return p + 1;
5260 if (*p == 'n') /* 'n' is always the last one */
5261 break;
5262 p = vim_strchr(p, ','); /* skip until next ',' */
5263 if (p == NULL) /* hit the end without finding parameter */
5264 break;
5265 }
5266 return NULL;
5267}
5268#endif
5269
5270/*
5271 * Expand environment variables for some string options.
5272 * These string options cannot be indirect!
5273 * If "val" is NULL expand the current value of the option.
5274 * Return pointer to NameBuff, or NULL when not expanded.
5275 */
5276 static char_u *
5277option_expand(opt_idx, val)
5278 int opt_idx;
5279 char_u *val;
5280{
5281 /* if option doesn't need expansion nothing to do */
5282 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5283 return NULL;
5284
5285 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5286 * expand_env() would truncate the string. */
5287 if (val != NULL && STRLEN(val) > MAXPATHL)
5288 return NULL;
5289
5290 if (val == NULL)
5291 val = *(char_u **)options[opt_idx].var;
5292
5293 /*
5294 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5295 * Escape spaces when expanding 'tags', they are used to separate file
5296 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005297 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005298 */
5299 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005300 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005301#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005302 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5303#endif
5304 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005305 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5306 return NULL;
5307
5308 return NameBuff;
5309}
5310
5311/*
5312 * After setting various option values: recompute variables that depend on
5313 * option values.
5314 */
5315 static void
5316didset_options()
5317{
5318 /* initialize the table for 'iskeyword' et.al. */
5319 (void)init_chartab();
5320
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005321#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005322 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005323#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005324 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
5325#ifdef FEAT_SESSION
5326 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5327 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5328#endif
5329#ifdef FEAT_FOLDING
5330 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5331#endif
5332 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
5333#ifdef FEAT_VIRTUALEDIT
5334 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5335#endif
5336#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5337 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5338#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005339#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005340 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005341 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005342 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005343#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005344#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5345 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5346#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005347#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005348 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5349#endif
5350#ifdef FEAT_CMDWIN
5351 /* set cedit_key */
5352 (void)check_cedit();
5353#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005354#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005355 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005356#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005357}
5358
5359/*
5360 * Check for string options that are NULL (normally only termcap options).
5361 */
5362 void
5363check_options()
5364{
5365 int opt_idx;
5366
5367 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5368 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5369 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5370}
5371
5372/*
5373 * Check string options in a buffer for NULL value.
5374 */
5375 void
5376check_buf_options(buf)
5377 buf_T *buf;
5378{
5379#if defined(FEAT_QUICKFIX)
5380 check_string_option(&buf->b_p_bh);
5381 check_string_option(&buf->b_p_bt);
5382#endif
5383#ifdef FEAT_MBYTE
5384 check_string_option(&buf->b_p_fenc);
5385#endif
5386 check_string_option(&buf->b_p_ff);
5387#ifdef FEAT_FIND_ID
5388 check_string_option(&buf->b_p_def);
5389 check_string_option(&buf->b_p_inc);
5390# ifdef FEAT_EVAL
5391 check_string_option(&buf->b_p_inex);
5392# endif
5393#endif
5394#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5395 check_string_option(&buf->b_p_inde);
5396 check_string_option(&buf->b_p_indk);
5397#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005398#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5399 check_string_option(&buf->b_p_bexpr);
5400#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005401#if defined(FEAT_CRYPT)
5402 check_string_option(&buf->b_p_cm);
5403#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005404#if defined(FEAT_EVAL)
5405 check_string_option(&buf->b_p_fex);
5406#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005407#ifdef FEAT_CRYPT
5408 check_string_option(&buf->b_p_key);
5409#endif
5410 check_string_option(&buf->b_p_kp);
5411 check_string_option(&buf->b_p_mps);
5412 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005413 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005414 check_string_option(&buf->b_p_isk);
5415#ifdef FEAT_COMMENTS
5416 check_string_option(&buf->b_p_com);
5417#endif
5418#ifdef FEAT_FOLDING
5419 check_string_option(&buf->b_p_cms);
5420#endif
5421 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005422#ifdef FEAT_TEXTOBJ
5423 check_string_option(&buf->b_p_qe);
5424#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005425#ifdef FEAT_SYN_HL
5426 check_string_option(&buf->b_p_syn);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005427#endif
5428#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005429 check_string_option(&buf->b_s.b_p_spc);
5430 check_string_option(&buf->b_s.b_p_spf);
5431 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005432#endif
5433#ifdef FEAT_SEARCHPATH
5434 check_string_option(&buf->b_p_sua);
5435#endif
5436#ifdef FEAT_CINDENT
5437 check_string_option(&buf->b_p_cink);
5438 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005439 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005440#endif
5441#ifdef FEAT_AUTOCMD
5442 check_string_option(&buf->b_p_ft);
5443#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005444#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5445 check_string_option(&buf->b_p_cinw);
5446#endif
5447#ifdef FEAT_INS_EXPAND
5448 check_string_option(&buf->b_p_cpt);
5449#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005450#ifdef FEAT_COMPL_FUNC
5451 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005452 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005453#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005454#ifdef FEAT_KEYMAP
5455 check_string_option(&buf->b_p_keymap);
5456#endif
5457#ifdef FEAT_QUICKFIX
5458 check_string_option(&buf->b_p_gp);
5459 check_string_option(&buf->b_p_mp);
5460 check_string_option(&buf->b_p_efm);
5461#endif
5462 check_string_option(&buf->b_p_ep);
5463 check_string_option(&buf->b_p_path);
5464 check_string_option(&buf->b_p_tags);
5465#ifdef FEAT_INS_EXPAND
5466 check_string_option(&buf->b_p_dict);
5467 check_string_option(&buf->b_p_tsr);
5468#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005469#ifdef FEAT_LISP
5470 check_string_option(&buf->b_p_lw);
5471#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005472 check_string_option(&buf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005473}
5474
5475/*
5476 * Free the string allocated for an option.
5477 * Checks for the string being empty_option. This may happen if we're out of
5478 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5479 * check_options().
5480 * Does NOT check for P_ALLOCED flag!
5481 */
5482 void
5483free_string_option(p)
5484 char_u *p;
5485{
5486 if (p != empty_option)
5487 vim_free(p);
5488}
5489
5490 void
5491clear_string_option(pp)
5492 char_u **pp;
5493{
5494 if (*pp != empty_option)
5495 vim_free(*pp);
5496 *pp = empty_option;
5497}
5498
5499 static void
5500check_string_option(pp)
5501 char_u **pp;
5502{
5503 if (*pp == NULL)
5504 *pp = empty_option;
5505}
5506
5507/*
5508 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5509 */
5510 void
5511set_term_option_alloced(p)
5512 char_u **p;
5513{
5514 int opt_idx;
5515
5516 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5517 if (options[opt_idx].var == (char_u *)p)
5518 {
5519 options[opt_idx].flags |= P_ALLOCED;
5520 return;
5521 }
5522 return; /* cannot happen: didn't find it! */
5523}
5524
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005525#if defined(FEAT_EVAL) || defined(PROTO)
5526/*
5527 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5528 * Return FALSE when it wasn't.
5529 * Return -1 for an unknown option.
5530 */
5531 int
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005532was_set_insecurely(opt, opt_flags)
5533 char_u *opt;
5534 int opt_flags;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005535{
5536 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005537 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005538
5539 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005540 {
5541 flagp = insecure_flag(idx, opt_flags);
5542 return (*flagp & P_INSECURE) != 0;
5543 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005544 EMSG2(_(e_intern2), "was_set_insecurely()");
5545 return -1;
5546}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005547
5548/*
5549 * Get a pointer to the flags used for the P_INSECURE flag of option
5550 * "opt_idx". For some local options a local flags field is used.
5551 */
5552 static long_u *
5553insecure_flag(opt_idx, opt_flags)
5554 int opt_idx;
5555 int opt_flags;
5556{
5557 if (opt_flags & OPT_LOCAL)
5558 switch ((int)options[opt_idx].indir)
5559 {
5560#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005561 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005562#endif
5563#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005564# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005565 case PV_FDE: return &curwin->w_p_fde_flags;
5566 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005567# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005568# ifdef FEAT_BEVAL
5569 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5570# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005571# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005572 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005573# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005574 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005575# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005576 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005577# endif
5578#endif
5579 }
5580
5581 /* Nothing special, return global flags field. */
5582 return &options[opt_idx].flags;
5583}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005584#endif
5585
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005586#ifdef FEAT_TITLE
5587static void redraw_titles __ARGS((void));
5588
5589/*
5590 * Redraw the window title and/or tab page text later.
5591 */
5592static void redraw_titles()
5593{
5594 need_maketitle = TRUE;
5595# ifdef FEAT_WINDOWS
5596 redraw_tabline = TRUE;
5597# endif
5598}
5599#endif
5600
Bram Moolenaar071d4272004-06-13 20:20:40 +00005601/*
5602 * Set a string option to a new value (without checking the effect).
5603 * The string is copied into allocated memory.
5604 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005605 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005606 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005607 */
5608 void
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005609set_string_option_direct(name, opt_idx, val, opt_flags, set_sid)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005610 char_u *name;
5611 int opt_idx;
5612 char_u *val;
5613 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar78a15312009-05-15 19:33:18 +00005614 int set_sid UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005615{
5616 char_u *s;
5617 char_u **varp;
5618 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005619 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005620
Bram Moolenaar89d40322006-08-29 15:30:07 +00005621 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005622 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005623 idx = findoption(name);
5624 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005625 {
5626 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar0b105412014-11-30 13:34:23 +01005627 EMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005628 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005629 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005630 }
5631
Bram Moolenaar89d40322006-08-29 15:30:07 +00005632 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005633 return;
5634
5635 s = vim_strsave(val);
5636 if (s != NULL)
5637 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005638 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005639 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005640 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005641 free_string_option(*varp);
5642 *varp = s;
5643
5644 /* For buffer/window local option may also set the global value. */
5645 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005646 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005647
Bram Moolenaar89d40322006-08-29 15:30:07 +00005648 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005649
5650 /* When setting both values of a global option with a local value,
5651 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005652 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005653 {
5654 free_string_option(*varp);
5655 *varp = empty_option;
5656 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005657# ifdef FEAT_EVAL
5658 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005659 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005660 set_sid == 0 ? current_SID : set_sid);
5661# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005662 }
5663}
5664
5665/*
5666 * Set global value for string option when it's a local option.
5667 */
5668 static void
5669set_string_option_global(opt_idx, varp)
5670 int opt_idx; /* option index */
5671 char_u **varp; /* pointer to option variable */
5672{
5673 char_u **p, *s;
5674
5675 /* the global value is always allocated */
5676 if (options[opt_idx].var == VAR_WIN)
5677 p = (char_u **)GLOBAL_WO(varp);
5678 else
5679 p = (char_u **)options[opt_idx].var;
5680 if (options[opt_idx].indir != PV_NONE
5681 && p != varp
5682 && (s = vim_strsave(*varp)) != NULL)
5683 {
5684 free_string_option(*p);
5685 *p = s;
5686 }
5687}
5688
5689/*
5690 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005691 *
5692 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005693 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005694 static char_u *
Bram Moolenaar071d4272004-06-13 20:20:40 +00005695set_string_option(opt_idx, value, opt_flags)
5696 int opt_idx;
5697 char_u *value;
5698 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5699{
5700 char_u *s;
5701 char_u **varp;
5702 char_u *oldval;
Bram Moolenaar53744302015-07-17 17:38:22 +02005703#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5704 char_u *saved_oldval = NULL;
5705#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005706 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005707
5708 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005709 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005710
5711 s = vim_strsave(value);
5712 if (s != NULL)
5713 {
5714 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5715 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005716 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005717 ? OPT_GLOBAL : OPT_LOCAL)
5718 : opt_flags);
5719 oldval = *varp;
5720 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02005721
5722#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005723 if (!starting
5724# ifdef FEAT_CRYPT
5725 && options[opt_idx].indir != PV_KEY
5726# endif
5727 )
Bram Moolenaar53744302015-07-17 17:38:22 +02005728 saved_oldval = vim_strsave(oldval);
5729#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005730 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5731 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005732 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02005733
5734 /* call autocomamnd after handling side effects */
5735#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5736 if (saved_oldval != NULL)
5737 {
5738 char_u buf_type[7];
5739 sprintf((char *)buf_type, "%s",
5740 (opt_flags & OPT_LOCAL) ? "local" : "global");
5741 set_vim_var_string(VV_OPTION_NEW, s, -1);
5742 set_vim_var_string(VV_OPTION_OLD, oldval, -1);
5743 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
5744 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
5745 reset_v_option_vars();
5746 vim_free(saved_oldval);
5747 }
5748#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005749 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005750 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005751}
5752
5753/*
5754 * Handle string options that need some action to perform when changed.
5755 * Returns NULL for success, or an error message for an error.
5756 */
5757 static char_u *
5758did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
5759 opt_flags)
5760 int opt_idx; /* index in options[] table */
5761 char_u **varp; /* pointer to the option variable */
5762 int new_value_alloced; /* new value was allocated */
5763 char_u *oldval; /* previous value of the option */
5764 char_u *errbuf; /* buffer for errors, or NULL */
5765 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5766{
5767 char_u *errmsg = NULL;
5768 char_u *s, *p;
5769 int did_chartab = FALSE;
5770 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005771 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00005772#ifdef FEAT_GUI
5773 /* set when changing an option that only requires a redraw in the GUI */
5774 int redraw_gui_only = FALSE;
5775#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005776
5777 /* Get the global option to compare with, otherwise we would have to check
5778 * two values for all local options. */
5779 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
5780
5781 /* Disallow changing some options from secure mode */
5782 if ((secure
5783#ifdef HAVE_SANDBOX
5784 || sandbox != 0
5785#endif
5786 ) && (options[opt_idx].flags & P_SECURE))
5787 {
5788 errmsg = e_secure;
5789 }
5790
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005791 /* Check for a "normal" file name in some options. Disallow a path
5792 * separator (slash and/or backslash), wildcards and characters that are
5793 * often illegal in a file name. */
5794 else if ((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005795 && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL)
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005796 {
5797 errmsg = e_invarg;
5798 }
5799
Bram Moolenaar071d4272004-06-13 20:20:40 +00005800 /* 'term' */
5801 else if (varp == &T_NAME)
5802 {
5803 if (T_NAME[0] == NUL)
5804 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
5805#ifdef FEAT_GUI
5806 if (gui.in_use)
5807 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
5808 else if (term_is_gui(T_NAME))
5809 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
5810#endif
5811 else if (set_termname(T_NAME) == FAIL)
5812 errmsg = (char_u *)N_("E522: Not found in termcap");
5813 else
5814 /* Screen colors may have changed. */
5815 redraw_later_clear();
5816 }
5817
5818 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005819 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005820 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005821 char_u *bkc = p_bkc;
5822 unsigned int *flags = &bkc_flags;
5823
5824 if (opt_flags & OPT_LOCAL)
5825 {
5826 bkc = curbuf->b_p_bkc;
5827 flags = &curbuf->b_bkc_flags;
5828 }
5829
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005830 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
5831 /* make the local value empty: use the global value */
5832 *flags = 0;
5833 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00005834 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005835 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
5836 errmsg = e_invarg;
5837 if ((((int)*flags & BKC_AUTO) != 0)
5838 + (((int)*flags & BKC_YES) != 0)
5839 + (((int)*flags & BKC_NO) != 0) != 1)
5840 {
5841 /* Must have exactly one of "auto", "yes" and "no". */
5842 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
5843 errmsg = e_invarg;
5844 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005845 }
5846 }
5847
5848 /* 'backupext' and 'patchmode' */
5849 else if (varp == &p_bex || varp == &p_pm)
5850 {
5851 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
5852 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
5853 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
5854 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02005855#ifdef FEAT_LINEBREAK
5856 /* 'breakindentopt' */
5857 else if (varp == &curwin->w_p_briopt)
5858 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005859 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02005860 errmsg = e_invarg;
5861 }
5862#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005863
5864 /*
5865 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[]
5866 * If the new option is invalid, use old value. 'lisp' option: refill
5867 * chartab[] for '-' char
5868 */
5869 else if ( varp == &p_isi
5870 || varp == &(curbuf->b_p_isk)
5871 || varp == &p_isp
5872 || varp == &p_isf)
5873 {
5874 if (init_chartab() == FAIL)
5875 {
5876 did_chartab = TRUE; /* need to restore it below */
5877 errmsg = e_invarg; /* error in value */
5878 }
5879 }
5880
5881 /* 'helpfile' */
5882 else if (varp == &p_hf)
5883 {
5884 /* May compute new values for $VIM and $VIMRUNTIME */
5885 if (didset_vim)
5886 {
5887 vim_setenv((char_u *)"VIM", (char_u *)"");
5888 didset_vim = FALSE;
5889 }
5890 if (didset_vimruntime)
5891 {
5892 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
5893 didset_vimruntime = FALSE;
5894 }
5895 }
5896
Bram Moolenaar1a384422010-07-14 19:53:30 +02005897#ifdef FEAT_SYN_HL
5898 /* 'colorcolumn' */
5899 else if (varp == &curwin->w_p_cc)
5900 errmsg = check_colorcolumn(curwin);
5901#endif
5902
Bram Moolenaar071d4272004-06-13 20:20:40 +00005903#ifdef FEAT_MULTI_LANG
5904 /* 'helplang' */
5905 else if (varp == &p_hlg)
5906 {
5907 /* Check for "", "ab", "ab,cd", etc. */
5908 for (s = p_hlg; *s != NUL; s += 3)
5909 {
5910 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
5911 {
5912 errmsg = e_invarg;
5913 break;
5914 }
5915 if (s[2] == NUL)
5916 break;
5917 }
5918 }
5919#endif
5920
5921 /* 'highlight' */
5922 else if (varp == &p_hl)
5923 {
5924 if (highlight_changed() == FAIL)
5925 errmsg = e_invarg; /* invalid flags */
5926 }
5927
5928 /* 'nrformats' */
5929 else if (gvarp == &p_nf)
5930 {
5931 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
5932 errmsg = e_invarg;
5933 }
5934
5935#ifdef FEAT_SESSION
5936 /* 'sessionoptions' */
5937 else if (varp == &p_ssop)
5938 {
5939 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
5940 errmsg = e_invarg;
5941 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
5942 {
5943 /* Don't allow both "sesdir" and "curdir". */
5944 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
5945 errmsg = e_invarg;
5946 }
5947 }
5948 /* 'viewoptions' */
5949 else if (varp == &p_vop)
5950 {
5951 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
5952 errmsg = e_invarg;
5953 }
5954#endif
5955
5956 /* 'scrollopt' */
5957#ifdef FEAT_SCROLLBIND
5958 else if (varp == &p_sbo)
5959 {
5960 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
5961 errmsg = e_invarg;
5962 }
5963#endif
5964
5965 /* 'ambiwidth' */
5966#ifdef FEAT_MBYTE
5967 else if (varp == &p_ambw)
5968 {
5969 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
5970 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02005971 else if (set_chars_option(&p_lcs) != NULL)
5972 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
5973# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5974 else if (set_chars_option(&p_fcs) != NULL)
5975 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
5976# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005977 }
5978#endif
5979
5980 /* 'background' */
5981 else if (varp == &p_bg)
5982 {
5983 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
5984 {
5985#ifdef FEAT_EVAL
5986 int dark = (*p_bg == 'd');
5987#endif
5988
5989 init_highlight(FALSE, FALSE);
5990
5991#ifdef FEAT_EVAL
5992 if (dark != (*p_bg == 'd')
5993 && get_var_value((char_u *)"g:colors_name") != NULL)
5994 {
5995 /* The color scheme must have set 'background' back to another
5996 * value, that's not what we want here. Disable the color
5997 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00005998 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005999 free_string_option(p_bg);
6000 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
6001 check_string_option(&p_bg);
6002 init_highlight(FALSE, FALSE);
6003 }
6004#endif
6005 }
6006 else
6007 errmsg = e_invarg;
6008 }
6009
6010 /* 'wildmode' */
6011 else if (varp == &p_wim)
6012 {
6013 if (check_opt_wim() == FAIL)
6014 errmsg = e_invarg;
6015 }
6016
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006017#ifdef FEAT_CMDL_COMPL
6018 /* 'wildoptions' */
6019 else if (varp == &p_wop)
6020 {
6021 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6022 errmsg = e_invarg;
6023 }
6024#endif
6025
Bram Moolenaar071d4272004-06-13 20:20:40 +00006026#ifdef FEAT_WAK
6027 /* 'winaltkeys' */
6028 else if (varp == &p_wak)
6029 {
6030 if (*p_wak == NUL
6031 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6032 errmsg = e_invarg;
6033# ifdef FEAT_MENU
6034# ifdef FEAT_GUI_MOTIF
6035 else if (gui.in_use)
6036 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6037# else
6038# ifdef FEAT_GUI_GTK
6039 else if (gui.in_use)
6040 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6041# endif
6042# endif
6043# endif
6044 }
6045#endif
6046
6047#ifdef FEAT_AUTOCMD
6048 /* 'eventignore' */
6049 else if (varp == &p_ei)
6050 {
6051 if (check_ei() == FAIL)
6052 errmsg = e_invarg;
6053 }
6054#endif
6055
6056#ifdef FEAT_MBYTE
6057 /* 'encoding' and 'fileencoding' */
6058 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc)
6059 {
6060 if (gvarp == &p_fenc)
6061 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006062 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006063 errmsg = e_modifiable;
6064 else if (vim_strchr(*varp, ',') != NULL)
6065 /* No comma allowed in 'fileencoding'; catches confusing it
6066 * with 'fileencodings'. */
6067 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006068 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006069 {
6070# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006071 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006072 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006073# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006074 /* Add 'fileencoding' to the swap file. */
6075 ml_setflags(curbuf);
6076 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006077 }
6078 if (errmsg == NULL)
6079 {
6080 /* canonize the value, so that STRCMP() can be used on it */
6081 p = enc_canonize(*varp);
6082 if (p != NULL)
6083 {
6084 vim_free(*varp);
6085 *varp = p;
6086 }
6087 if (varp == &p_enc)
6088 {
6089 errmsg = mb_init();
6090# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006091 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006092# endif
6093 }
6094 }
6095
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006096# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006097 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6098 {
6099 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6100 if (STRCMP(p_tenc, "utf-8") != 0)
6101 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6102 }
6103# endif
6104
6105 if (errmsg == NULL)
6106 {
6107# ifdef FEAT_KEYMAP
6108 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6109 * (with another encoding). */
6110 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6111 (void)keymap_init();
6112# endif
6113
6114 /* When 'termencoding' is not empty and 'encoding' changes or when
6115 * 'termencoding' changes, need to setup for keyboard input and
6116 * display output conversion. */
6117 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6118 {
6119 convert_setup(&input_conv, p_tenc, p_enc);
6120 convert_setup(&output_conv, p_enc, p_tenc);
6121 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006122
6123# if defined(WIN3264) && defined(FEAT_MBYTE)
6124 /* $HOME may have characters in active code page. */
6125 if (varp == &p_enc)
6126 init_homedir();
6127# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006128 }
6129 }
6130#endif
6131
6132#if defined(FEAT_POSTSCRIPT)
6133 else if (varp == &p_penc)
6134 {
6135 /* Canonize printencoding if VIM standard one */
6136 p = enc_canonize(p_penc);
6137 if (p != NULL)
6138 {
6139 vim_free(p_penc);
6140 p_penc = p;
6141 }
6142 else
6143 {
6144 /* Ensure lower case and '-' for '_' */
6145 for (s = p_penc; *s != NUL; s++)
6146 {
6147 if (*s == '_')
6148 *s = '-';
6149 else
6150 *s = TOLOWER_ASC(*s);
6151 }
6152 }
6153 }
6154#endif
6155
Bram Moolenaar9372a112005-12-06 19:59:18 +00006156#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006157 else if (varp == &p_imak)
6158 {
6159 if (gui.in_use && !im_xim_isvalid_imactivate())
6160 errmsg = e_invarg;
6161 }
6162#endif
6163
6164#ifdef FEAT_KEYMAP
6165 else if (varp == &curbuf->b_p_keymap)
6166 {
6167 /* load or unload key mapping tables */
6168 errmsg = keymap_init();
6169
Bram Moolenaarfab06232009-03-04 03:13:35 +00006170 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006171 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006172 if (*curbuf->b_p_keymap != NUL)
6173 {
6174 /* Installed a new keymap, switch on using it. */
6175 curbuf->b_p_iminsert = B_IMODE_LMAP;
6176 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6177 curbuf->b_p_imsearch = B_IMODE_LMAP;
6178 }
6179 else
6180 {
6181 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6182 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6183 curbuf->b_p_iminsert = B_IMODE_NONE;
6184 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6185 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6186 }
6187 if ((opt_flags & OPT_LOCAL) == 0)
6188 {
6189 set_iminsert_global();
6190 set_imsearch_global();
6191 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006192# ifdef FEAT_WINDOWS
6193 status_redraw_curbuf();
6194# endif
6195 }
6196 }
6197#endif
6198
6199 /* 'fileformat' */
6200 else if (gvarp == &p_ff)
6201 {
6202 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6203 errmsg = e_modifiable;
6204 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6205 errmsg = e_invarg;
6206 else
6207 {
6208 /* may also change 'textmode' */
6209 if (get_fileformat(curbuf) == EOL_DOS)
6210 curbuf->b_p_tx = TRUE;
6211 else
6212 curbuf->b_p_tx = FALSE;
6213#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006214 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006215#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006216 /* update flag in swap file */
6217 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006218 /* Redraw needed when switching to/from "mac": a CR in the text
6219 * will be displayed differently. */
6220 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6221 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006222 }
6223 }
6224
6225 /* 'fileformats' */
6226 else if (varp == &p_ffs)
6227 {
6228 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6229 errmsg = e_invarg;
6230 else
6231 {
6232 /* also change 'textauto' */
6233 if (*p_ffs == NUL)
6234 p_ta = FALSE;
6235 else
6236 p_ta = TRUE;
6237 }
6238 }
6239
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006240#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006241 /* 'cryptkey' */
6242 else if (gvarp == &p_key)
6243 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006244# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006245 /* Make sure the ":set" command doesn't show the new value in the
6246 * history. */
6247 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006248# endif
6249 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6250 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006251 ml_set_crypt_key(curbuf, oldval,
6252 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006253 }
6254
6255 else if (gvarp == &p_cm)
6256 {
6257 if (opt_flags & OPT_LOCAL)
6258 p = curbuf->b_p_cm;
6259 else
6260 p = p_cm;
6261 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6262 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006263 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006264 errmsg = e_invarg;
6265 else
6266 {
6267 /* When setting the global value to empty, make it "zip". */
6268 if (*p_cm == NUL)
6269 {
6270 if (new_value_alloced)
6271 free_string_option(p_cm);
6272 p_cm = vim_strsave((char_u *)"zip");
6273 new_value_alloced = TRUE;
6274 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006275 /* When using ":set cm=name" the local value is going to be empty.
6276 * Do that here, otherwise the crypt functions will still use the
6277 * local value. */
6278 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6279 {
6280 free_string_option(curbuf->b_p_cm);
6281 curbuf->b_p_cm = empty_option;
6282 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006283
6284 /* Need to update the swapfile when the effective method changed.
6285 * Set "s" to the effective old value, "p" to the effective new
6286 * method and compare. */
6287 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6288 s = p_cm; /* was previously using the global value */
6289 else
6290 s = oldval;
6291 if (*curbuf->b_p_cm == NUL)
6292 p = p_cm; /* is now using the global value */
6293 else
6294 p = curbuf->b_p_cm;
6295 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006296 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006297
6298 /* If the global value changes need to update the swapfile for all
6299 * buffers using that value. */
6300 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6301 {
6302 buf_T *buf;
6303
6304 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
6305 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006306 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006307 }
6308 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006309 }
6310#endif
6311
6312 /* 'matchpairs' */
6313 else if (gvarp == &p_mps)
6314 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006315#ifdef FEAT_MBYTE
6316 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006317 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006318 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006319 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006320 int x2 = -1;
6321 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006322
6323 if (*p != NUL)
6324 p += mb_ptr2len(p);
6325 if (*p != NUL)
6326 x2 = *p++;
6327 if (*p != NUL)
6328 {
6329 x3 = mb_ptr2char(p);
6330 p += mb_ptr2len(p);
6331 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006332 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006333 {
6334 errmsg = e_invarg;
6335 break;
6336 }
6337 if (*p == NUL)
6338 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006339 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006340 }
6341 else
6342#endif
6343 {
6344 /* Check for "x:y,x:y" */
6345 for (p = *varp; *p != NUL; p += 4)
6346 {
6347 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6348 {
6349 errmsg = e_invarg;
6350 break;
6351 }
6352 if (p[3] == NUL)
6353 break;
6354 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006355 }
6356 }
6357
6358#ifdef FEAT_COMMENTS
6359 /* 'comments' */
6360 else if (gvarp == &p_com)
6361 {
6362 for (s = *varp; *s; )
6363 {
6364 while (*s && *s != ':')
6365 {
6366 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6367 && !VIM_ISDIGIT(*s) && *s != '-')
6368 {
6369 errmsg = illegal_char(errbuf, *s);
6370 break;
6371 }
6372 ++s;
6373 }
6374 if (*s++ == NUL)
6375 errmsg = (char_u *)N_("E524: Missing colon");
6376 else if (*s == ',' || *s == NUL)
6377 errmsg = (char_u *)N_("E525: Zero length string");
6378 if (errmsg != NULL)
6379 break;
6380 while (*s && *s != ',')
6381 {
6382 if (*s == '\\' && s[1] != NUL)
6383 ++s;
6384 ++s;
6385 }
6386 s = skip_to_option_part(s);
6387 }
6388 }
6389#endif
6390
6391 /* 'listchars' */
6392 else if (varp == &p_lcs)
6393 {
6394 errmsg = set_chars_option(varp);
6395 }
6396
6397#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6398 /* 'fillchars' */
6399 else if (varp == &p_fcs)
6400 {
6401 errmsg = set_chars_option(varp);
6402 }
6403#endif
6404
6405#ifdef FEAT_CMDWIN
6406 /* 'cedit' */
6407 else if (varp == &p_cedit)
6408 {
6409 errmsg = check_cedit();
6410 }
6411#endif
6412
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006413 /* 'verbosefile' */
6414 else if (varp == &p_vfile)
6415 {
6416 verbose_stop();
6417 if (*p_vfile != NUL && verbose_open() == FAIL)
6418 errmsg = e_invarg;
6419 }
6420
Bram Moolenaar071d4272004-06-13 20:20:40 +00006421#ifdef FEAT_VIMINFO
6422 /* 'viminfo' */
6423 else if (varp == &p_viminfo)
6424 {
6425 for (s = p_viminfo; *s;)
6426 {
6427 /* Check it's a valid character */
6428 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6429 {
6430 errmsg = illegal_char(errbuf, *s);
6431 break;
6432 }
6433 if (*s == 'n') /* name is always last one */
6434 {
6435 break;
6436 }
6437 else if (*s == 'r') /* skip until next ',' */
6438 {
6439 while (*++s && *s != ',')
6440 ;
6441 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006442 else if (*s == '%')
6443 {
6444 /* optional number */
6445 while (vim_isdigit(*++s))
6446 ;
6447 }
6448 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006449 ++s; /* no extra chars */
6450 else /* must have a number */
6451 {
6452 while (vim_isdigit(*++s))
6453 ;
6454
6455 if (!VIM_ISDIGIT(*(s - 1)))
6456 {
6457 if (errbuf != NULL)
6458 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006459 sprintf((char *)errbuf,
6460 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006461 transchar_byte(*(s - 1)));
6462 errmsg = errbuf;
6463 }
6464 else
6465 errmsg = (char_u *)"";
6466 break;
6467 }
6468 }
6469 if (*s == ',')
6470 ++s;
6471 else if (*s)
6472 {
6473 if (errbuf != NULL)
6474 errmsg = (char_u *)N_("E527: Missing comma");
6475 else
6476 errmsg = (char_u *)"";
6477 break;
6478 }
6479 }
6480 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6481 errmsg = (char_u *)N_("E528: Must specify a ' value");
6482 }
6483#endif /* FEAT_VIMINFO */
6484
6485 /* terminal options */
6486 else if (istermoption(&options[opt_idx]) && full_screen)
6487 {
6488 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6489 if (varp == &T_CCO)
6490 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006491 int colors = atoi((char *)T_CCO);
6492
6493 /* Only reinitialize colors if t_Co value has really changed to
6494 * avoid expensive reload of colorscheme if t_Co is set to the
6495 * same value multiple times. */
6496 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006497 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006498 t_colors = colors;
6499 if (t_colors <= 1)
6500 {
6501 if (new_value_alloced)
6502 vim_free(T_CCO);
6503 T_CCO = empty_option;
6504 }
6505 /* We now have a different color setup, initialize it again. */
6506 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006507 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006508 }
6509 ttest(FALSE);
6510 if (varp == &T_ME)
6511 {
6512 out_str(T_ME);
6513 redraw_later(CLEAR);
6514#if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32))
6515 /* Since t_me has been set, this probably means that the user
6516 * wants to use this as default colors. Need to reset default
6517 * background/foreground colors. */
6518 mch_set_normal_colors();
6519#endif
6520 }
6521 }
6522
6523#ifdef FEAT_LINEBREAK
6524 /* 'showbreak' */
6525 else if (varp == &p_sbr)
6526 {
6527 for (s = p_sbr; *s; )
6528 {
6529 if (ptr2cells(s) != 1)
6530 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006531 mb_ptr_adv(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006532 }
6533 }
6534#endif
6535
6536#ifdef FEAT_GUI
6537 /* 'guifont' */
6538 else if (varp == &p_guifont)
6539 {
6540 if (gui.in_use)
6541 {
6542 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006543# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006544 /*
6545 * Put up a font dialog and let the user select a new value.
6546 * If this is cancelled go back to the old value but don't
6547 * give an error message.
6548 */
6549 if (STRCMP(p, "*") == 0)
6550 {
6551 p = gui_mch_font_dialog(oldval);
6552
6553 if (new_value_alloced)
6554 free_string_option(p_guifont);
6555
6556 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6557 new_value_alloced = TRUE;
6558 }
6559# endif
6560 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6561 {
6562# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6563 if (STRCMP(p_guifont, "*") == 0)
6564 {
6565 /* Dialog was cancelled: Keep the old value without giving
6566 * an error message. */
6567 if (new_value_alloced)
6568 free_string_option(p_guifont);
6569 p_guifont = vim_strsave(oldval);
6570 new_value_alloced = TRUE;
6571 }
6572 else
6573# endif
6574 errmsg = (char_u *)N_("E596: Invalid font(s)");
6575 }
6576 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006577 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006578 }
6579# ifdef FEAT_XFONTSET
6580 else if (varp == &p_guifontset)
6581 {
6582 if (STRCMP(p_guifontset, "*") == 0)
6583 errmsg = (char_u *)N_("E597: can't select fontset");
6584 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6585 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006586 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006587 }
6588# endif
6589# ifdef FEAT_MBYTE
6590 else if (varp == &p_guifontwide)
6591 {
6592 if (STRCMP(p_guifontwide, "*") == 0)
6593 errmsg = (char_u *)N_("E533: can't select wide font");
6594 else if (gui_get_wide_font() == FAIL)
6595 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006596 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006597 }
6598# endif
6599#endif
6600
6601#ifdef CURSOR_SHAPE
6602 /* 'guicursor' */
6603 else if (varp == &p_guicursor)
6604 errmsg = parse_shape_opt(SHAPE_CURSOR);
6605#endif
6606
6607#ifdef FEAT_MOUSESHAPE
6608 /* 'mouseshape' */
6609 else if (varp == &p_mouseshape)
6610 {
6611 errmsg = parse_shape_opt(SHAPE_MOUSE);
6612 update_mouseshape(-1);
6613 }
6614#endif
6615
6616#ifdef FEAT_PRINTER
6617 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006618 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006619# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006620 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006621 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006622# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006623#endif
6624
6625#ifdef FEAT_LANGMAP
6626 /* 'langmap' */
6627 else if (varp == &p_langmap)
6628 langmap_set();
6629#endif
6630
6631#ifdef FEAT_LINEBREAK
6632 /* 'breakat' */
6633 else if (varp == &p_breakat)
6634 fill_breakat_flags();
6635#endif
6636
6637#ifdef FEAT_TITLE
6638 /* 'titlestring' and 'iconstring' */
6639 else if (varp == &p_titlestring || varp == &p_iconstring)
6640 {
6641# ifdef FEAT_STL_OPT
6642 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6643
6644 /* NULL => statusline syntax */
6645 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6646 stl_syntax |= flagval;
6647 else
6648 stl_syntax &= ~flagval;
6649# endif
6650 did_set_title(varp == &p_iconstring);
6651
6652 }
6653#endif
6654
6655#ifdef FEAT_GUI
6656 /* 'guioptions' */
6657 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006658 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006659 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006660 redraw_gui_only = TRUE;
6661 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006662#endif
6663
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006664#if defined(FEAT_GUI_TABLINE)
6665 /* 'guitablabel' */
6666 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006667 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006668 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006669 redraw_gui_only = TRUE;
6670 }
6671 /* 'guitabtooltip' */
6672 else if (varp == &p_gtt)
6673 {
6674 redraw_gui_only = TRUE;
6675 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006676#endif
6677
Bram Moolenaar071d4272004-06-13 20:20:40 +00006678#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6679 /* 'ttymouse' */
6680 else if (varp == &p_ttym)
6681 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006682 /* Switch the mouse off before changing the escape sequences used for
6683 * that. */
6684 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006685 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6686 errmsg = e_invarg;
6687 else
6688 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006689 if (termcap_active)
6690 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006691 }
6692#endif
6693
Bram Moolenaar071d4272004-06-13 20:20:40 +00006694 /* 'selection' */
6695 else if (varp == &p_sel)
6696 {
6697 if (*p_sel == NUL
6698 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6699 errmsg = e_invarg;
6700 }
6701
6702 /* 'selectmode' */
6703 else if (varp == &p_slm)
6704 {
6705 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6706 errmsg = e_invarg;
6707 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006708
6709#ifdef FEAT_BROWSE
6710 /* 'browsedir' */
6711 else if (varp == &p_bsdir)
6712 {
6713 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
6714 && !mch_isdir(p_bsdir))
6715 errmsg = e_invarg;
6716 }
6717#endif
6718
Bram Moolenaar071d4272004-06-13 20:20:40 +00006719 /* 'keymodel' */
6720 else if (varp == &p_km)
6721 {
6722 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
6723 errmsg = e_invarg;
6724 else
6725 {
6726 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
6727 km_startsel = (vim_strchr(p_km, 'a') != NULL);
6728 }
6729 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006730
6731 /* 'mousemodel' */
6732 else if (varp == &p_mousem)
6733 {
6734 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
6735 errmsg = e_invarg;
6736#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
6737 else if (*p_mousem != *oldval)
6738 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
6739 * to create or delete the popup menus. */
6740 gui_motif_update_mousemodel(root_menu);
6741#endif
6742 }
6743
6744 /* 'switchbuf' */
6745 else if (varp == &p_swb)
6746 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00006747 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006748 errmsg = e_invarg;
6749 }
6750
6751 /* 'debug' */
6752 else if (varp == &p_debug)
6753 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00006754 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006755 errmsg = e_invarg;
6756 }
6757
6758 /* 'display' */
6759 else if (varp == &p_dy)
6760 {
6761 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
6762 errmsg = e_invarg;
6763 else
6764 (void)init_chartab();
6765
6766 }
6767
6768#ifdef FEAT_VERTSPLIT
6769 /* 'eadirection' */
6770 else if (varp == &p_ead)
6771 {
6772 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
6773 errmsg = e_invarg;
6774 }
6775#endif
6776
6777#ifdef FEAT_CLIPBOARD
6778 /* 'clipboard' */
6779 else if (varp == &p_cb)
6780 errmsg = check_clipboard_option();
6781#endif
6782
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00006783#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006784 /* When 'spelllang' or 'spellfile' is set and there is a window for this
6785 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006786 else if (varp == &(curwin->w_s->b_p_spl)
6787 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00006788 {
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006789 win_T *wp;
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006790 int l;
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006791
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006792 if (varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006793 {
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006794 l = (int)STRLEN(curwin->w_s->b_p_spf);
6795 if (l > 0 && (l < 4 || STRCMP(curwin->w_s->b_p_spf + l - 4,
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006796 ".add") != 0))
6797 errmsg = e_invarg;
6798 }
6799
6800 if (errmsg == NULL)
6801 {
6802 FOR_ALL_WINDOWS(wp)
6803 if (wp->w_buffer == curbuf && wp->w_p_spell)
6804 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006805 errmsg = did_set_spelllang(wp);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006806# ifdef FEAT_WINDOWS
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006807 break;
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006808# endif
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006809 }
6810 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006811 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006812 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006813 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006814 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006815 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006816 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006817 /* 'spellsuggest' */
6818 else if (varp == &p_sps)
6819 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00006820 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006821 errmsg = e_invarg;
6822 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00006823 /* 'mkspellmem' */
6824 else if (varp == &p_msm)
6825 {
6826 if (spell_check_msm() != OK)
6827 errmsg = e_invarg;
6828 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006829#endif
6830
Bram Moolenaar071d4272004-06-13 20:20:40 +00006831#ifdef FEAT_QUICKFIX
6832 /* When 'bufhidden' is set, check for valid value. */
6833 else if (gvarp == &p_bh)
6834 {
6835 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
6836 errmsg = e_invarg;
6837 }
6838
6839 /* When 'buftype' is set, check for valid value. */
6840 else if (gvarp == &p_bt)
6841 {
6842 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
6843 errmsg = e_invarg;
6844 else
6845 {
6846# ifdef FEAT_WINDOWS
6847 if (curwin->w_status_height)
6848 {
6849 curwin->w_redr_status = TRUE;
6850 redraw_later(VALID);
6851 }
6852# endif
6853 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar5075aad2010-01-27 15:58:13 +01006854# ifdef FEAT_TITLE
6855 redraw_titles();
6856# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006857 }
6858 }
6859#endif
6860
6861#ifdef FEAT_STL_OPT
6862 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006863 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006864 {
6865 int wid;
6866
6867 if (varp == &p_ruf) /* reset ru_wid first */
6868 ru_wid = 0;
6869 s = *varp;
6870 if (varp == &p_ruf && *s == '%')
6871 {
6872 /* set ru_wid if 'ruf' starts with "%99(" */
6873 if (*++s == '-') /* ignore a '-' */
6874 s++;
6875 wid = getdigits(&s);
6876 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
6877 ru_wid = wid;
6878 else
6879 errmsg = check_stl_option(p_ruf);
6880 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00006881 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00006882 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006883 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006884 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006885 comp_col();
6886 }
6887#endif
6888
6889#ifdef FEAT_INS_EXPAND
6890 /* check if it is a valid value for 'complete' -- Acevedo */
6891 else if (gvarp == &p_cpt)
6892 {
6893 for (s = *varp; *s;)
6894 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02006895 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006896 s++;
6897 if (!*s)
6898 break;
6899 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
6900 {
6901 errmsg = illegal_char(errbuf, *s);
6902 break;
6903 }
6904 if (*++s != NUL && *s != ',' && *s != ' ')
6905 {
6906 if (s[-1] == 'k' || s[-1] == 's')
6907 {
6908 /* skip optional filename after 'k' and 's' */
6909 while (*s && *s != ',' && *s != ' ')
6910 {
6911 if (*s == '\\')
6912 ++s;
6913 ++s;
6914 }
6915 }
6916 else
6917 {
6918 if (errbuf != NULL)
6919 {
6920 sprintf((char *)errbuf,
6921 _("E535: Illegal character after <%c>"),
6922 *--s);
6923 errmsg = errbuf;
6924 }
6925 else
6926 errmsg = (char_u *)"";
6927 break;
6928 }
6929 }
6930 }
6931 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00006932
6933 /* 'completeopt' */
6934 else if (varp == &p_cot)
6935 {
6936 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
6937 errmsg = e_invarg;
6938 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006939#endif /* FEAT_INS_EXPAND */
6940
6941
6942#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
6943 else if (varp == &p_toolbar)
6944 {
6945 if (opt_strings_flags(p_toolbar, p_toolbar_values,
6946 &toolbar_flags, TRUE) != OK)
6947 errmsg = e_invarg;
6948 else
6949 {
6950 out_flush();
6951 gui_mch_show_toolbar((toolbar_flags &
6952 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6953 }
6954 }
6955#endif
6956
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006957#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006958 /* 'toolbariconsize': GTK+ 2 only */
6959 else if (varp == &p_tbis)
6960 {
6961 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
6962 errmsg = e_invarg;
6963 else
6964 {
6965 out_flush();
6966 gui_mch_show_toolbar((toolbar_flags &
6967 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6968 }
6969 }
6970#endif
6971
6972 /* 'pastetoggle': translate key codes like in a mapping */
6973 else if (varp == &p_pt)
6974 {
6975 if (*p_pt)
6976 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00006977 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006978 if (p != NULL)
6979 {
6980 if (new_value_alloced)
6981 free_string_option(p_pt);
6982 p_pt = p;
6983 new_value_alloced = TRUE;
6984 }
6985 }
6986 }
6987
6988 /* 'backspace' */
6989 else if (varp == &p_bs)
6990 {
6991 if (VIM_ISDIGIT(*p_bs))
6992 {
6993 if (*p_bs >'2' || p_bs[1] != NUL)
6994 errmsg = e_invarg;
6995 }
6996 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
6997 errmsg = e_invarg;
6998 }
6999
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007000#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007001 /* 'casemap' */
7002 else if (varp == &p_cmp)
7003 {
7004 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
7005 errmsg = e_invarg;
7006 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007007#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007008
7009#ifdef FEAT_DIFF
7010 /* 'diffopt' */
7011 else if (varp == &p_dip)
7012 {
7013 if (diffopt_changed() == FAIL)
7014 errmsg = e_invarg;
7015 }
7016#endif
7017
7018#ifdef FEAT_FOLDING
7019 /* 'foldmethod' */
7020 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7021 {
7022 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7023 || *curwin->w_p_fdm == NUL)
7024 errmsg = e_invarg;
7025 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007026 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007027 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007028 if (foldmethodIsDiff(curwin))
7029 newFoldLevel();
7030 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007031 }
7032# ifdef FEAT_EVAL
7033 /* 'foldexpr' */
7034 else if (varp == &curwin->w_p_fde)
7035 {
7036 if (foldmethodIsExpr(curwin))
7037 foldUpdateAll(curwin);
7038 }
7039# endif
7040 /* 'foldmarker' */
7041 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7042 {
7043 p = vim_strchr(*varp, ',');
7044 if (p == NULL)
7045 errmsg = (char_u *)N_("E536: comma required");
7046 else if (p == *varp || p[1] == NUL)
7047 errmsg = e_invarg;
7048 else if (foldmethodIsMarker(curwin))
7049 foldUpdateAll(curwin);
7050 }
7051 /* 'commentstring' */
7052 else if (gvarp == &p_cms)
7053 {
7054 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7055 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7056 }
7057 /* 'foldopen' */
7058 else if (varp == &p_fdo)
7059 {
7060 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7061 errmsg = e_invarg;
7062 }
7063 /* 'foldclose' */
7064 else if (varp == &p_fcl)
7065 {
7066 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7067 errmsg = e_invarg;
7068 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007069 /* 'foldignore' */
7070 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7071 {
7072 if (foldmethodIsIndent(curwin))
7073 foldUpdateAll(curwin);
7074 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007075#endif
7076
7077#ifdef FEAT_VIRTUALEDIT
7078 /* 'virtualedit' */
7079 else if (varp == &p_ve)
7080 {
7081 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7082 errmsg = e_invarg;
7083 else if (STRCMP(p_ve, oldval) != 0)
7084 {
7085 /* Recompute cursor position in case the new 've' setting
7086 * changes something. */
7087 validate_virtcol();
7088 coladvance(curwin->w_virtcol);
7089 }
7090 }
7091#endif
7092
7093#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7094 else if (varp == &p_csqf)
7095 {
7096 if (p_csqf != NULL)
7097 {
7098 p = p_csqf;
7099 while (*p != NUL)
7100 {
7101 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7102 || p[1] == NUL
7103 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7104 || (p[2] != NUL && p[2] != ','))
7105 {
7106 errmsg = e_invarg;
7107 break;
7108 }
7109 else if (p[2] == NUL)
7110 break;
7111 else
7112 p += 3;
7113 }
7114 }
7115 }
7116#endif
7117
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007118#ifdef FEAT_CINDENT
7119 /* 'cinoptions' */
7120 else if (gvarp == &p_cino)
7121 {
7122 /* TODO: recognize errors */
7123 parse_cino(curbuf);
7124 }
7125#endif
7126
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007127#if defined(FEAT_RENDER_OPTIONS)
7128 else if (varp == &p_rop && gui.in_use)
7129 {
7130 if (!gui_mch_set_rendering_options(p_rop))
7131 errmsg = e_invarg;
7132 }
7133#endif
7134
Bram Moolenaar071d4272004-06-13 20:20:40 +00007135 /* Options that are a list of flags. */
7136 else
7137 {
7138 p = NULL;
7139 if (varp == &p_ww)
7140 p = (char_u *)WW_ALL;
7141 if (varp == &p_shm)
7142 p = (char_u *)SHM_ALL;
7143 else if (varp == &(p_cpo))
7144 p = (char_u *)CPO_ALL;
7145 else if (varp == &(curbuf->b_p_fo))
7146 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007147#ifdef FEAT_CONCEAL
7148 else if (varp == &curwin->w_p_cocu)
7149 p = (char_u *)COCU_ALL;
7150#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007151 else if (varp == &p_mouse)
7152 {
7153#ifdef FEAT_MOUSE
7154 p = (char_u *)MOUSE_ALL;
7155#else
7156 if (*p_mouse != NUL)
7157 errmsg = (char_u *)N_("E538: No mouse support");
7158#endif
7159 }
7160#if defined(FEAT_GUI)
7161 else if (varp == &p_go)
7162 p = (char_u *)GO_ALL;
7163#endif
7164 if (p != NULL)
7165 {
7166 for (s = *varp; *s; ++s)
7167 if (vim_strchr(p, *s) == NULL)
7168 {
7169 errmsg = illegal_char(errbuf, *s);
7170 break;
7171 }
7172 }
7173 }
7174
7175 /*
7176 * If error detected, restore the previous value.
7177 */
7178 if (errmsg != NULL)
7179 {
7180 if (new_value_alloced)
7181 free_string_option(*varp);
7182 *varp = oldval;
7183 /*
7184 * When resetting some values, need to act on it.
7185 */
7186 if (did_chartab)
7187 (void)init_chartab();
7188 if (varp == &p_hl)
7189 (void)highlight_changed();
7190 }
7191 else
7192 {
7193#ifdef FEAT_EVAL
7194 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007195 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007196#endif
7197 /*
7198 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007199 * Use "free_oldval", because recursiveness may change the flags under
7200 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007201 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007202 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007203 free_string_option(oldval);
7204 if (new_value_alloced)
7205 options[opt_idx].flags |= P_ALLOCED;
7206 else
7207 options[opt_idx].flags &= ~P_ALLOCED;
7208
7209 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007210 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007211 {
7212 /* global option with local value set to use global value; free
7213 * the local value and make it empty */
7214 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7215 free_string_option(*(char_u **)p);
7216 *(char_u **)p = empty_option;
7217 }
7218
7219 /* May set global value for local option. */
7220 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7221 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007222
7223#ifdef FEAT_AUTOCMD
7224 /*
7225 * Trigger the autocommand only after setting the flags.
7226 */
7227# ifdef FEAT_SYN_HL
7228 /* When 'syntax' is set, load the syntax of that name */
7229 if (varp == &(curbuf->b_p_syn))
7230 {
7231 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7232 curbuf->b_fname, TRUE, curbuf);
7233 }
7234# endif
7235 else if (varp == &(curbuf->b_p_ft))
7236 {
7237 /* 'filetype' is set, trigger the FileType autocommand */
7238 did_filetype = TRUE;
7239 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
7240 curbuf->b_fname, TRUE, curbuf);
7241 }
7242#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007243#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007244 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007245 {
7246 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007247 char_u *q = curwin->w_s->b_p_spl;
7248
7249 /* Skip the first name if it is "cjk". */
7250 if (STRNCMP(q, "cjk,", 4) == 0)
7251 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007252
7253 /*
7254 * Source the spell/LANG.vim in 'runtimepath'.
7255 * They could set 'spellcapcheck' depending on the language.
7256 * Use the first name in 'spelllang' up to '_region' or
7257 * '.encoding'.
7258 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007259 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007260 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7261 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007262 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007263 source_runtime(fname, TRUE);
7264 }
7265#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007266 }
7267
7268#ifdef FEAT_MOUSE
7269 if (varp == &p_mouse)
7270 {
7271# ifdef FEAT_MOUSE_TTY
7272 if (*p_mouse == NUL)
7273 mch_setmouse(FALSE); /* switch mouse off */
7274 else
7275# endif
7276 setmouse(); /* in case 'mouse' changed */
7277 }
7278#endif
7279
Bram Moolenaar913077c2012-03-28 19:59:04 +02007280 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007281 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007282 curwin->w_set_curswant = TRUE;
7283
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007284#ifdef FEAT_GUI
7285 /* check redraw when it's not a GUI option or the GUI is active. */
7286 if (!redraw_gui_only || gui.in_use)
7287#endif
7288 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007289
7290 return errmsg;
7291}
7292
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007293#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007294/*
7295 * Simple int comparison function for use with qsort()
7296 */
7297 static int
7298int_cmp(a, b)
7299 const void *a;
7300 const void *b;
7301{
7302 return *(const int *)a - *(const int *)b;
7303}
7304
7305/*
7306 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7307 * Returns error message, NULL if it's OK.
7308 */
7309 char_u *
7310check_colorcolumn(wp)
7311 win_T *wp;
7312{
7313 char_u *s;
7314 int col;
7315 int count = 0;
7316 int color_cols[256];
7317 int i;
7318 int j = 0;
7319
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007320 if (wp->w_buffer == NULL)
7321 return NULL; /* buffer was closed */
7322
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007323 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007324 {
7325 if (*s == '-' || *s == '+')
7326 {
7327 /* -N and +N: add to 'textwidth' */
7328 col = (*s == '-') ? -1 : 1;
7329 ++s;
7330 if (!VIM_ISDIGIT(*s))
7331 return e_invarg;
7332 col = col * getdigits(&s);
7333 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007334 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007335 col += wp->w_buffer->b_p_tw;
7336 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007337 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007338 }
7339 else if (VIM_ISDIGIT(*s))
7340 col = getdigits(&s);
7341 else
7342 return e_invarg;
7343 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007344skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007345 if (*s == NUL)
7346 break;
7347 if (*s != ',')
7348 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007349 if (*++s == NUL)
7350 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007351 }
7352
7353 vim_free(wp->w_p_cc_cols);
7354 if (count == 0)
7355 wp->w_p_cc_cols = NULL;
7356 else
7357 {
7358 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7359 if (wp->w_p_cc_cols != NULL)
7360 {
7361 /* sort the columns for faster usage on screen redraw inside
7362 * win_line() */
7363 qsort(color_cols, count, sizeof(int), int_cmp);
7364
7365 for (i = 0; i < count; ++i)
7366 /* skip duplicates */
7367 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7368 wp->w_p_cc_cols[j++] = color_cols[i];
7369 wp->w_p_cc_cols[j] = -1; /* end marker */
7370 }
7371 }
7372
7373 return NULL; /* no error */
7374}
7375#endif
7376
Bram Moolenaar071d4272004-06-13 20:20:40 +00007377/*
7378 * Handle setting 'listchars' or 'fillchars'.
7379 * Returns error message, NULL if it's OK.
7380 */
7381 static char_u *
7382set_chars_option(varp)
7383 char_u **varp;
7384{
7385 int round, i, len, entries;
7386 char_u *p, *s;
7387 int c1, c2 = 0;
7388 struct charstab
7389 {
7390 int *cp;
7391 char *name;
7392 };
7393#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7394 static struct charstab filltab[] =
7395 {
7396 {&fill_stl, "stl"},
7397 {&fill_stlnc, "stlnc"},
7398 {&fill_vert, "vert"},
7399 {&fill_fold, "fold"},
7400 {&fill_diff, "diff"},
7401 };
7402#endif
7403 static struct charstab lcstab[] =
7404 {
7405 {&lcs_eol, "eol"},
7406 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007407 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007408 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007409 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007410 {&lcs_tab2, "tab"},
7411 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007412#ifdef FEAT_CONCEAL
7413 {&lcs_conceal, "conceal"},
7414#else
7415 {NULL, "conceal"},
7416#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007417 };
7418 struct charstab *tab;
7419
7420#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7421 if (varp == &p_lcs)
7422#endif
7423 {
7424 tab = lcstab;
7425 entries = sizeof(lcstab) / sizeof(struct charstab);
7426 }
7427#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7428 else
7429 {
7430 tab = filltab;
7431 entries = sizeof(filltab) / sizeof(struct charstab);
7432 }
7433#endif
7434
7435 /* first round: check for valid value, second round: assign values */
7436 for (round = 0; round <= 1; ++round)
7437 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007438 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007439 {
7440 /* After checking that the value is valid: set defaults: space for
7441 * 'fillchars', NUL for 'listchars' */
7442 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007443 if (tab[i].cp != NULL)
7444 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007445 if (varp == &p_lcs)
7446 lcs_tab1 = NUL;
7447#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7448 else
7449 fill_diff = '-';
7450#endif
7451 }
7452 p = *varp;
7453 while (*p)
7454 {
7455 for (i = 0; i < entries; ++i)
7456 {
7457 len = (int)STRLEN(tab[i].name);
7458 if (STRNCMP(p, tab[i].name, len) == 0
7459 && p[len] == ':'
7460 && p[len + 1] != NUL)
7461 {
7462 s = p + len + 1;
7463#ifdef FEAT_MBYTE
7464 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007465 if (mb_char2cells(c1) > 1)
7466 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007467#else
7468 c1 = *s++;
7469#endif
7470 if (tab[i].cp == &lcs_tab2)
7471 {
7472 if (*s == NUL)
7473 continue;
7474#ifdef FEAT_MBYTE
7475 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007476 if (mb_char2cells(c2) > 1)
7477 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007478#else
7479 c2 = *s++;
7480#endif
7481 }
7482 if (*s == ',' || *s == NUL)
7483 {
7484 if (round)
7485 {
7486 if (tab[i].cp == &lcs_tab2)
7487 {
7488 lcs_tab1 = c1;
7489 lcs_tab2 = c2;
7490 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007491 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007492 *(tab[i].cp) = c1;
7493
7494 }
7495 p = s;
7496 break;
7497 }
7498 }
7499 }
7500
7501 if (i == entries)
7502 return e_invarg;
7503 if (*p == ',')
7504 ++p;
7505 }
7506 }
7507
7508 return NULL; /* no error */
7509}
7510
7511#ifdef FEAT_STL_OPT
7512/*
7513 * Check validity of options with the 'statusline' format.
7514 * Return error message or NULL.
7515 */
7516 char_u *
7517check_stl_option(s)
7518 char_u *s;
7519{
7520 int itemcnt = 0;
7521 int groupdepth = 0;
7522 static char_u errbuf[80];
7523
7524 while (*s && itemcnt < STL_MAX_ITEM)
7525 {
7526 /* Check for valid keys after % sequences */
7527 while (*s && *s != '%')
7528 s++;
7529 if (!*s)
7530 break;
7531 s++;
7532 if (*s != '%' && *s != ')')
7533 ++itemcnt;
7534 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7535 {
7536 s++;
7537 continue;
7538 }
7539 if (*s == ')')
7540 {
7541 s++;
7542 if (--groupdepth < 0)
7543 break;
7544 continue;
7545 }
7546 if (*s == '-')
7547 s++;
7548 while (VIM_ISDIGIT(*s))
7549 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007550 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007551 continue;
7552 if (*s == '.')
7553 {
7554 s++;
7555 while (*s && VIM_ISDIGIT(*s))
7556 s++;
7557 }
7558 if (*s == '(')
7559 {
7560 groupdepth++;
7561 continue;
7562 }
7563 if (vim_strchr(STL_ALL, *s) == NULL)
7564 {
7565 return illegal_char(errbuf, *s);
7566 }
7567 if (*s == '{')
7568 {
7569 s++;
7570 while (*s != '}' && *s)
7571 s++;
7572 if (*s != '}')
7573 return (char_u *)N_("E540: Unclosed expression sequence");
7574 }
7575 }
7576 if (itemcnt >= STL_MAX_ITEM)
7577 return (char_u *)N_("E541: too many items");
7578 if (groupdepth != 0)
7579 return (char_u *)N_("E542: unbalanced groups");
7580 return NULL;
7581}
7582#endif
7583
7584#ifdef FEAT_CLIPBOARD
7585/*
7586 * Extract the items in the 'clipboard' option and set global values.
7587 */
7588 static char_u *
7589check_clipboard_option()
7590{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007591 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007592 int new_autoselect_star = FALSE;
7593 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007594 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007595 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007596 regprog_T *new_exclude_prog = NULL;
7597 char_u *errmsg = NULL;
7598 char_u *p;
7599
7600 for (p = p_cb; *p != NUL; )
7601 {
7602 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7603 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007604 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007605 p += 7;
7606 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007607 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007608 && (p[11] == ',' || p[11] == NUL))
7609 {
7610 new_unnamed |= CLIP_UNNAMED_PLUS;
7611 p += 11;
7612 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007613 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007614 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007615 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007616 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007617 p += 10;
7618 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007619 else if (STRNCMP(p, "autoselectplus", 14) == 0
7620 && (p[14] == ',' || p[14] == NUL))
7621 {
7622 new_autoselect_plus = TRUE;
7623 p += 14;
7624 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007625 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007626 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007627 {
7628 new_autoselectml = TRUE;
7629 p += 12;
7630 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007631 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7632 {
7633 new_html = TRUE;
7634 p += 4;
7635 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007636 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7637 {
7638 p += 8;
7639 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7640 if (new_exclude_prog == NULL)
7641 errmsg = e_invarg;
7642 break;
7643 }
7644 else
7645 {
7646 errmsg = e_invarg;
7647 break;
7648 }
7649 if (*p == ',')
7650 ++p;
7651 }
7652 if (errmsg == NULL)
7653 {
7654 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007655 clip_autoselect_star = new_autoselect_star;
7656 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007657 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007658 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02007659 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007660 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02007661#ifdef FEAT_GUI_GTK
7662 if (gui.in_use)
7663 {
7664 gui_gtk_set_selection_targets();
7665 gui_gtk_set_dnd_targets();
7666 }
7667#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007668 }
7669 else
Bram Moolenaar473de612013-06-08 18:19:48 +02007670 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007671
7672 return errmsg;
7673}
7674#endif
7675
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007676#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007677/*
7678 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
7679 * Return error message when failed, NULL when OK.
7680 */
7681 static char_u *
Bram Moolenaar860cae12010-06-05 23:22:07 +02007682compile_cap_prog(synblock)
7683 synblock_T *synblock;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007684{
Bram Moolenaar860cae12010-06-05 23:22:07 +02007685 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007686 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007687
Bram Moolenaar860cae12010-06-05 23:22:07 +02007688 if (*synblock->b_p_spc == NUL)
7689 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007690 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007691 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007692 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007693 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007694 if (re != NULL)
7695 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007696 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02007697 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02007698 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007699 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007700 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007701 return e_invarg;
7702 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007703 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007704 }
7705
Bram Moolenaar473de612013-06-08 18:19:48 +02007706 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007707 return NULL;
7708}
7709#endif
7710
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007711#if defined(FEAT_EVAL) || defined(PROTO)
7712/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007713 * Set the scriptID for an option, taking care of setting the buffer- or
7714 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007715 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007716 static void
7717set_option_scriptID_idx(opt_idx, opt_flags, id)
7718 int opt_idx;
7719 int opt_flags;
7720 int id;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007721{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007722 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
7723 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007724
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007725 /* Remember where the option was set. For local options need to do that
7726 * in the buffer or window structure. */
7727 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007728 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007729 if (both || (opt_flags & OPT_LOCAL))
7730 {
7731 if (indir & PV_BUF)
7732 curbuf->b_p_scriptID[indir & PV_MASK] = id;
7733 else if (indir & PV_WIN)
7734 curwin->w_p_scriptID[indir & PV_MASK] = id;
7735 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007736}
7737#endif
7738
Bram Moolenaar071d4272004-06-13 20:20:40 +00007739/*
7740 * Set the value of a boolean option, and take care of side effects.
7741 * Returns NULL for success, or an error message for an error.
7742 */
7743 static char_u *
7744set_bool_option(opt_idx, varp, value, opt_flags)
7745 int opt_idx; /* index in options[] table */
7746 char_u *varp; /* pointer to the option variable */
7747 int value; /* new value */
7748 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
7749{
7750 int old_value = *(int *)varp;
7751
Bram Moolenaar071d4272004-06-13 20:20:40 +00007752 /* Disallow changing some options from secure mode */
7753 if ((secure
7754#ifdef HAVE_SANDBOX
7755 || sandbox != 0
7756#endif
7757 ) && (options[opt_idx].flags & P_SECURE))
7758 return e_secure;
7759
7760 *(int *)varp = value; /* set the new value */
7761#ifdef FEAT_EVAL
7762 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007763 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007764#endif
7765
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00007766#ifdef FEAT_GUI
7767 need_mouse_correct = TRUE;
7768#endif
7769
Bram Moolenaar071d4272004-06-13 20:20:40 +00007770 /* May set global value for local option. */
7771 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
7772 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
7773
7774 /*
7775 * Handle side effects of changing a bool option.
7776 */
7777
7778 /* 'compatible' */
7779 if ((int *)varp == &p_cp)
7780 {
7781 compatible_set();
7782 }
7783
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007784#ifdef FEAT_PERSISTENT_UNDO
7785 /* 'undofile' */
7786 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
7787 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007788 /* Only take action when the option was set. When reset we do not
7789 * delete the undo file, the option may be set again without making
7790 * any changes in between. */
7791 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007792 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007793 char_u hash[UNDO_HASH_SIZE];
7794 buf_T *save_curbuf = curbuf;
7795
7796 for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007797 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007798 /* When 'undofile' is set globally: for every buffer, otherwise
7799 * only for the current buffer: Try to read in the undofile,
7800 * if one exists, the buffer wasn't changed and the buffer was
7801 * loaded */
7802 if ((curbuf == save_curbuf
7803 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
7804 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
7805 {
7806 u_compute_hash(hash);
7807 u_read_undo(NULL, hash, curbuf->b_fname);
7808 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007809 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007810 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007811 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007812 }
7813#endif
7814
Bram Moolenaar071d4272004-06-13 20:20:40 +00007815 else if ((int *)varp == &curbuf->b_p_ro)
7816 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007817 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007818 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
7819 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007820
7821 /* when 'readonly' is set may give W10 again */
7822 if (curbuf->b_p_ro)
7823 curbuf->b_did_warn = FALSE;
7824
Bram Moolenaar071d4272004-06-13 20:20:40 +00007825#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007826 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007827#endif
7828 }
7829
Bram Moolenaar9c449722010-07-20 18:44:27 +02007830#ifdef FEAT_GUI
7831 else if ((int *)varp == &p_mh)
7832 {
7833 if (!p_mh)
7834 gui_mch_mousehide(FALSE);
7835 }
7836#endif
7837
Bram Moolenaara539df02010-08-01 14:35:05 +02007838#ifdef FEAT_TITLE
7839 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007840 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007841 {
7842 redraw_titles();
7843 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007844 /* when 'endofline' is changed, redraw the window title */
7845 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007846 {
7847 redraw_titles();
7848 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02007849 /* when 'fixeol' is changed, redraw the window title */
7850 else if ((int *)varp == &curbuf->b_p_fixeol)
7851 {
7852 redraw_titles();
7853 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007854# ifdef FEAT_MBYTE
7855 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00007856 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007857 {
7858 redraw_titles();
7859 }
7860# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007861#endif
7862
7863 /* when 'bin' is set also set some other options */
7864 else if ((int *)varp == &curbuf->b_p_bin)
7865 {
7866 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
7867#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007868 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007869#endif
7870 }
7871
7872#ifdef FEAT_AUTOCMD
7873 /* when 'buflisted' changes, trigger autocommands */
7874 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
7875 {
7876 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
7877 NULL, NULL, TRUE, curbuf);
7878 }
7879#endif
7880
7881 /* when 'swf' is set, create swapfile, when reset remove swapfile */
7882 else if ((int *)varp == &curbuf->b_p_swf)
7883 {
7884 if (curbuf->b_p_swf && p_uc)
7885 ml_open_file(curbuf); /* create the swap file */
7886 else
Bram Moolenaard55de222007-05-06 13:38:48 +00007887 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
7888 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007889 mf_close_file(curbuf, TRUE); /* remove the swap file */
7890 }
7891
7892 /* when 'terse' is set change 'shortmess' */
7893 else if ((int *)varp == &p_terse)
7894 {
7895 char_u *p;
7896
7897 p = vim_strchr(p_shm, SHM_SEARCH);
7898
7899 /* insert 's' in p_shm */
7900 if (p_terse && p == NULL)
7901 {
7902 STRCPY(IObuff, p_shm);
7903 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007904 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007905 }
7906 /* remove 's' from p_shm */
7907 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007908 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007909 }
7910
7911 /* when 'paste' is set or reset also change other options */
7912 else if ((int *)varp == &p_paste)
7913 {
7914 paste_option_changed();
7915 }
7916
7917 /* when 'insertmode' is set from an autocommand need to do work here */
7918 else if ((int *)varp == &p_im)
7919 {
7920 if (p_im)
7921 {
7922 if ((State & INSERT) == 0)
7923 need_start_insertmode = TRUE;
7924 stop_insert_mode = FALSE;
7925 }
7926 else
7927 {
7928 need_start_insertmode = FALSE;
7929 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00007930 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007931 clear_cmdline = TRUE; /* remove "(insert)" */
7932 restart_edit = 0;
7933 }
7934 }
7935
7936 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
7937 else if ((int *)varp == &p_ic && p_hls)
7938 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007939 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007940 }
7941
7942#ifdef FEAT_SEARCH_EXTRA
7943 /* when 'hlsearch' is set or reset: reset no_hlsearch */
7944 else if ((int *)varp == &p_hls)
7945 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01007946 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007947 }
7948#endif
7949
7950#ifdef FEAT_SCROLLBIND
7951 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
7952 * at the end of normal_cmd() */
7953 else if ((int *)varp == &curwin->w_p_scb)
7954 {
7955 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02007956 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007957 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02007958 curwin->w_scbind_pos = curwin->w_topline;
7959 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007960 }
7961#endif
7962
7963#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
7964 /* There can be only one window with 'previewwindow' set. */
7965 else if ((int *)varp == &curwin->w_p_pvw)
7966 {
7967 if (curwin->w_p_pvw)
7968 {
7969 win_T *win;
7970
7971 for (win = firstwin; win != NULL; win = win->w_next)
7972 if (win->w_p_pvw && win != curwin)
7973 {
7974 curwin->w_p_pvw = FALSE;
7975 return (char_u *)N_("E590: A preview window already exists");
7976 }
7977 }
7978 }
7979#endif
7980
7981 /* when 'textmode' is set or reset also change 'fileformat' */
7982 else if ((int *)varp == &curbuf->b_p_tx)
7983 {
7984 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
7985 }
7986
7987 /* when 'textauto' is set or reset also change 'fileformats' */
7988 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007989 set_string_option_direct((char_u *)"ffs", -1,
7990 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007991 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007992
7993 /*
7994 * When 'lisp' option changes include/exclude '-' in
7995 * keyword characters.
7996 */
7997#ifdef FEAT_LISP
7998 else if (varp == (char_u *)&(curbuf->b_p_lisp))
7999 {
8000 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
8001 }
8002#endif
8003
8004#ifdef FEAT_TITLE
8005 /* when 'title' changed, may need to change the title; same for 'icon' */
8006 else if ((int *)varp == &p_title)
8007 {
8008 did_set_title(FALSE);
8009 }
8010
8011 else if ((int *)varp == &p_icon)
8012 {
8013 did_set_title(TRUE);
8014 }
8015#endif
8016
8017 else if ((int *)varp == &curbuf->b_changed)
8018 {
8019 if (!value)
8020 save_file_ff(curbuf); /* Buffer is unchanged */
8021#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008022 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008023#endif
8024#ifdef FEAT_AUTOCMD
8025 modified_was_set = value;
8026#endif
8027 }
8028
8029#ifdef BACKSLASH_IN_FILENAME
8030 else if ((int *)varp == &p_ssl)
8031 {
8032 if (p_ssl)
8033 {
8034 psepc = '/';
8035 psepcN = '\\';
8036 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008037 }
8038 else
8039 {
8040 psepc = '\\';
8041 psepcN = '/';
8042 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008043 }
8044
8045 /* need to adjust the file name arguments and buffer names. */
8046 buflist_slash_adjust();
8047 alist_slash_adjust();
8048# ifdef FEAT_EVAL
8049 scriptnames_slash_adjust();
8050# endif
8051 }
8052#endif
8053
8054 /* If 'wrap' is set, set w_leftcol to zero. */
8055 else if ((int *)varp == &curwin->w_p_wrap)
8056 {
8057 if (curwin->w_p_wrap)
8058 curwin->w_leftcol = 0;
8059 }
8060
8061#ifdef FEAT_WINDOWS
8062 else if ((int *)varp == &p_ea)
8063 {
8064 if (p_ea && !old_value)
8065 win_equal(curwin, FALSE, 0);
8066 }
8067#endif
8068
8069 else if ((int *)varp == &p_wiv)
8070 {
8071 /*
8072 * When 'weirdinvert' changed, set/reset 't_xs'.
8073 * Then set 'weirdinvert' according to value of 't_xs'.
8074 */
8075 if (p_wiv && !old_value)
8076 T_XS = (char_u *)"y";
8077 else if (!p_wiv && old_value)
8078 T_XS = empty_option;
8079 p_wiv = (*T_XS != NUL);
8080 }
8081
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00008082#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00008083 else if ((int *)varp == &p_beval)
8084 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008085 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008086 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008087 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008088 gui_mch_disable_beval_area(balloonEval);
8089 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008090#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008091
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008092#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008093 else if ((int *)varp == &p_acd)
8094 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008095 /* Change directories when the 'acd' option is set now. */
8096 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008097 }
8098#endif
8099
8100#ifdef FEAT_DIFF
8101 /* 'diff' */
8102 else if ((int *)varp == &curwin->w_p_diff)
8103 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008104 /* May add or remove the buffer from the list of diff buffers. */
8105 diff_buf_adjust(curwin);
8106# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008107 if (foldmethodIsDiff(curwin))
8108 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008109# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008110 }
8111#endif
8112
8113#ifdef USE_IM_CONTROL
8114 /* 'imdisable' */
8115 else if ((int *)varp == &p_imdisable)
8116 {
8117 /* Only de-activate it here, it will be enabled when changing mode. */
8118 if (p_imdisable)
8119 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008120 else if (State & INSERT)
8121 /* When the option is set from an autocommand, it may need to take
8122 * effect right away. */
8123 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008124 }
8125#endif
8126
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008127#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008128 /* 'spell' */
8129 else if ((int *)varp == &curwin->w_p_spell)
8130 {
8131 if (curwin->w_p_spell)
8132 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008133 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008134 if (errmsg != NULL)
8135 EMSG(_(errmsg));
8136 }
8137 }
8138#endif
8139
Bram Moolenaar071d4272004-06-13 20:20:40 +00008140#ifdef FEAT_FKMAP
8141 else if ((int *)varp == &p_altkeymap)
8142 {
8143 if (old_value != p_altkeymap)
8144 {
8145 if (!p_altkeymap)
8146 {
8147 p_hkmap = p_fkmap;
8148 p_fkmap = 0;
8149 }
8150 else
8151 {
8152 p_fkmap = p_hkmap;
8153 p_hkmap = 0;
8154 }
8155 (void)init_chartab();
8156 }
8157 }
8158
8159 /*
8160 * In case some second language keymapping options have changed, check
8161 * and correct the setting in a consistent way.
8162 */
8163
8164 /*
8165 * If hkmap or fkmap are set, reset Arabic keymapping.
8166 */
8167 if ((p_hkmap || p_fkmap) && p_altkeymap)
8168 {
8169 p_altkeymap = p_fkmap;
8170# ifdef FEAT_ARABIC
8171 curwin->w_p_arab = FALSE;
8172# endif
8173 (void)init_chartab();
8174 }
8175
8176 /*
8177 * If hkmap set, reset Farsi keymapping.
8178 */
8179 if (p_hkmap && p_altkeymap)
8180 {
8181 p_altkeymap = 0;
8182 p_fkmap = 0;
8183# ifdef FEAT_ARABIC
8184 curwin->w_p_arab = FALSE;
8185# endif
8186 (void)init_chartab();
8187 }
8188
8189 /*
8190 * If fkmap set, reset Hebrew keymapping.
8191 */
8192 if (p_fkmap && !p_altkeymap)
8193 {
8194 p_altkeymap = 1;
8195 p_hkmap = 0;
8196# ifdef FEAT_ARABIC
8197 curwin->w_p_arab = FALSE;
8198# endif
8199 (void)init_chartab();
8200 }
8201#endif
8202
8203#ifdef FEAT_ARABIC
8204 if ((int *)varp == &curwin->w_p_arab)
8205 {
8206 if (curwin->w_p_arab)
8207 {
8208 /*
8209 * 'arabic' is set, handle various sub-settings.
8210 */
8211 if (!p_tbidi)
8212 {
8213 /* set rightleft mode */
8214 if (!curwin->w_p_rl)
8215 {
8216 curwin->w_p_rl = TRUE;
8217 changed_window_setting();
8218 }
8219
8220 /* Enable Arabic shaping (major part of what Arabic requires) */
8221 if (!p_arshape)
8222 {
8223 p_arshape = TRUE;
8224 redraw_later_clear();
8225 }
8226 }
8227
8228 /* Arabic requires a utf-8 encoding, inform the user if its not
8229 * set. */
8230 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008231 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008232 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8233
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008234 msg_source(hl_attr(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008235 MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
8236#ifdef FEAT_EVAL
8237 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8238#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008239 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008240
8241# ifdef FEAT_MBYTE
8242 /* set 'delcombine' */
8243 p_deco = TRUE;
8244# endif
8245
8246# ifdef FEAT_KEYMAP
8247 /* Force-set the necessary keymap for arabic */
8248 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8249 OPT_LOCAL);
8250# endif
8251# ifdef FEAT_FKMAP
8252 p_altkeymap = 0;
8253 p_hkmap = 0;
8254 p_fkmap = 0;
8255 (void)init_chartab();
8256# endif
8257 }
8258 else
8259 {
8260 /*
8261 * 'arabic' is reset, handle various sub-settings.
8262 */
8263 if (!p_tbidi)
8264 {
8265 /* reset rightleft mode */
8266 if (curwin->w_p_rl)
8267 {
8268 curwin->w_p_rl = FALSE;
8269 changed_window_setting();
8270 }
8271
8272 /* 'arabicshape' isn't reset, it is a global option and
8273 * another window may still need it "on". */
8274 }
8275
8276 /* 'delcombine' isn't reset, it is a global option and another
8277 * window may still want it "on". */
8278
8279# ifdef FEAT_KEYMAP
8280 /* Revert to the default keymap */
8281 curbuf->b_p_iminsert = B_IMODE_NONE;
8282 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8283# endif
8284 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008285 }
8286
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008287#endif
8288
Bram Moolenaar071d4272004-06-13 20:20:40 +00008289 /*
8290 * End of handling side effects for bool options.
8291 */
8292
Bram Moolenaar53744302015-07-17 17:38:22 +02008293 /* after handling side effects, call autocommand */
8294
Bram Moolenaar071d4272004-06-13 20:20:40 +00008295 options[opt_idx].flags |= P_WAS_SET;
8296
Bram Moolenaar53744302015-07-17 17:38:22 +02008297#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8298 if (!starting)
8299 {
8300 char_u buf_old[2], buf_new[2], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008301 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8302 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8303 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008304 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8305 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8306 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8307 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8308 reset_v_option_vars();
8309 }
8310#endif
8311
Bram Moolenaar071d4272004-06-13 20:20:40 +00008312 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008313 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008314 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008315 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008316 check_redraw(options[opt_idx].flags);
8317
8318 return NULL;
8319}
8320
8321/*
8322 * Set the value of a number option, and take care of side effects.
8323 * Returns NULL for success, or an error message for an error.
8324 */
8325 static char_u *
Bram Moolenaar555b2802005-05-19 21:08:39 +00008326set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008327 int opt_idx; /* index in options[] table */
8328 char_u *varp; /* pointer to the option variable */
8329 long value; /* new value */
8330 char_u *errbuf; /* buffer for error messages */
Bram Moolenaar555b2802005-05-19 21:08:39 +00008331 size_t errbuflen; /* length of "errbuf" */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008332 int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and
8333 OPT_MODELINE */
8334{
8335 char_u *errmsg = NULL;
8336 long old_value = *(long *)varp;
8337 long old_Rows = Rows; /* remember old Rows */
8338 long old_Columns = Columns; /* remember old Columns */
8339 long *pp = (long *)varp;
8340
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008341 /* Disallow changing some options from secure mode. */
8342 if ((secure
8343#ifdef HAVE_SANDBOX
8344 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008345#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008346 ) && (options[opt_idx].flags & P_SECURE))
8347 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008348
8349 *pp = value;
8350#ifdef FEAT_EVAL
8351 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008352 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008353#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008354#ifdef FEAT_GUI
8355 need_mouse_correct = TRUE;
8356#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008357
Bram Moolenaar14f24742012-08-08 18:01:05 +02008358 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008359 {
8360 errmsg = e_positive;
8361 curbuf->b_p_sw = curbuf->b_p_ts;
8362 }
8363
8364 /*
8365 * Number options that need some action when changed
8366 */
8367#ifdef FEAT_WINDOWS
8368 if (pp == &p_wh || pp == &p_hh)
8369 {
8370 if (p_wh < 1)
8371 {
8372 errmsg = e_positive;
8373 p_wh = 1;
8374 }
8375 if (p_wmh > p_wh)
8376 {
8377 errmsg = e_winheight;
8378 p_wh = p_wmh;
8379 }
8380 if (p_hh < 0)
8381 {
8382 errmsg = e_positive;
8383 p_hh = 0;
8384 }
8385
8386 /* Change window height NOW */
8387 if (lastwin != firstwin)
8388 {
8389 if (pp == &p_wh && curwin->w_height < p_wh)
8390 win_setheight((int)p_wh);
8391 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8392 win_setheight((int)p_hh);
8393 }
8394 }
8395
8396 /* 'winminheight' */
8397 else if (pp == &p_wmh)
8398 {
8399 if (p_wmh < 0)
8400 {
8401 errmsg = e_positive;
8402 p_wmh = 0;
8403 }
8404 if (p_wmh > p_wh)
8405 {
8406 errmsg = e_winheight;
8407 p_wmh = p_wh;
8408 }
8409 win_setminheight();
8410 }
8411
8412# ifdef FEAT_VERTSPLIT
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008413 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008414 {
8415 if (p_wiw < 1)
8416 {
8417 errmsg = e_positive;
8418 p_wiw = 1;
8419 }
8420 if (p_wmw > p_wiw)
8421 {
8422 errmsg = e_winwidth;
8423 p_wiw = p_wmw;
8424 }
8425
8426 /* Change window width NOW */
8427 if (lastwin != firstwin && curwin->w_width < p_wiw)
8428 win_setwidth((int)p_wiw);
8429 }
8430
8431 /* 'winminwidth' */
8432 else if (pp == &p_wmw)
8433 {
8434 if (p_wmw < 0)
8435 {
8436 errmsg = e_positive;
8437 p_wmw = 0;
8438 }
8439 if (p_wmw > p_wiw)
8440 {
8441 errmsg = e_winwidth;
8442 p_wmw = p_wiw;
8443 }
8444 win_setminheight();
8445 }
8446# endif
8447
8448#endif
8449
8450#ifdef FEAT_WINDOWS
8451 /* (re)set last window status line */
8452 else if (pp == &p_ls)
8453 {
8454 last_status(FALSE);
8455 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008456
8457 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008458 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008459 {
8460 shell_new_rows(); /* recompute window positions and heights */
8461 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008462#endif
8463
8464#ifdef FEAT_GUI
8465 else if (pp == &p_linespace)
8466 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008467 /* Recompute gui.char_height and resize the Vim window to keep the
8468 * same number of lines. */
8469 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008470 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008471 }
8472#endif
8473
8474#ifdef FEAT_FOLDING
8475 /* 'foldlevel' */
8476 else if (pp == &curwin->w_p_fdl)
8477 {
8478 if (curwin->w_p_fdl < 0)
8479 curwin->w_p_fdl = 0;
8480 newFoldLevel();
8481 }
8482
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008483 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008484 else if (pp == &curwin->w_p_fml)
8485 {
8486 foldUpdateAll(curwin);
8487 }
8488
8489 /* 'foldnestmax' */
8490 else if (pp == &curwin->w_p_fdn)
8491 {
8492 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8493 foldUpdateAll(curwin);
8494 }
8495
8496 /* 'foldcolumn' */
8497 else if (pp == &curwin->w_p_fdc)
8498 {
8499 if (curwin->w_p_fdc < 0)
8500 {
8501 errmsg = e_positive;
8502 curwin->w_p_fdc = 0;
8503 }
8504 else if (curwin->w_p_fdc > 12)
8505 {
8506 errmsg = e_invarg;
8507 curwin->w_p_fdc = 12;
8508 }
8509 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008510#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008511
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008512#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008513 /* 'shiftwidth' or 'tabstop' */
8514 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8515 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008516# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008517 if (foldmethodIsIndent(curwin))
8518 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008519# endif
8520# ifdef FEAT_CINDENT
8521 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8522 * parse 'cinoptions'. */
8523 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8524 parse_cino(curbuf);
8525# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008526 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008527#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008528
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008529#ifdef FEAT_MBYTE
8530 /* 'maxcombine' */
8531 else if (pp == &p_mco)
8532 {
8533 if (p_mco > MAX_MCO)
8534 p_mco = MAX_MCO;
8535 else if (p_mco < 0)
8536 p_mco = 0;
8537 screenclear(); /* will re-allocate the screen */
8538 }
8539#endif
8540
Bram Moolenaar071d4272004-06-13 20:20:40 +00008541 else if (pp == &curbuf->b_p_iminsert)
8542 {
8543 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8544 {
8545 errmsg = e_invarg;
8546 curbuf->b_p_iminsert = B_IMODE_NONE;
8547 }
8548 p_iminsert = curbuf->b_p_iminsert;
8549 if (termcap_active) /* don't do this in the alternate screen */
8550 showmode();
8551#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8552 /* Show/unshow value of 'keymap' in status lines. */
8553 status_redraw_curbuf();
8554#endif
8555 }
8556
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008557 else if (pp == &p_window)
8558 {
8559 if (p_window < 1)
8560 p_window = 1;
8561 else if (p_window >= Rows)
8562 p_window = Rows - 1;
8563 }
8564
Bram Moolenaar071d4272004-06-13 20:20:40 +00008565 else if (pp == &curbuf->b_p_imsearch)
8566 {
8567 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8568 {
8569 errmsg = e_invarg;
8570 curbuf->b_p_imsearch = B_IMODE_NONE;
8571 }
8572 p_imsearch = curbuf->b_p_imsearch;
8573 }
8574
8575#ifdef FEAT_TITLE
8576 /* if 'titlelen' has changed, redraw the title */
8577 else if (pp == &p_titlelen)
8578 {
8579 if (p_titlelen < 0)
8580 {
8581 errmsg = e_positive;
8582 p_titlelen = 85;
8583 }
8584 if (starting != NO_SCREEN && old_value != p_titlelen)
8585 need_maketitle = TRUE;
8586 }
8587#endif
8588
8589 /* if p_ch changed value, change the command line height */
8590 else if (pp == &p_ch)
8591 {
8592 if (p_ch < 1)
8593 {
8594 errmsg = e_positive;
8595 p_ch = 1;
8596 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008597 if (p_ch > Rows - min_rows() + 1)
8598 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008599
8600 /* Only compute the new window layout when startup has been
8601 * completed. Otherwise the frame sizes may be wrong. */
8602 if (p_ch != old_value && full_screen
8603#ifdef FEAT_GUI
8604 && !gui.starting
8605#endif
8606 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008607 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008608 }
8609
8610 /* when 'updatecount' changes from zero to non-zero, open swap files */
8611 else if (pp == &p_uc)
8612 {
8613 if (p_uc < 0)
8614 {
8615 errmsg = e_positive;
8616 p_uc = 100;
8617 }
8618 if (p_uc && !old_value)
8619 ml_open_files();
8620 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008621#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008622 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008623 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008624 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008625 {
8626 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008627 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008628 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008629 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008630 {
8631 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008632 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008633 }
8634 }
8635#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008636#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008637 else if (pp == &p_mzq)
8638 mzvim_reset_timer();
8639#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008640
8641 /* sync undo before 'undolevels' changes */
8642 else if (pp == &p_ul)
8643 {
8644 /* use the old value, otherwise u_sync() may not work properly */
8645 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00008646 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008647 p_ul = value;
8648 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01008649 else if (pp == &curbuf->b_p_ul)
8650 {
8651 /* use the old value, otherwise u_sync() may not work properly */
8652 curbuf->b_p_ul = old_value;
8653 u_sync(TRUE);
8654 curbuf->b_p_ul = value;
8655 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008656
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008657#ifdef FEAT_LINEBREAK
8658 /* 'numberwidth' must be positive */
8659 else if (pp == &curwin->w_p_nuw)
8660 {
8661 if (curwin->w_p_nuw < 1)
8662 {
8663 errmsg = e_positive;
8664 curwin->w_p_nuw = 1;
8665 }
8666 if (curwin->w_p_nuw > 10)
8667 {
8668 errmsg = e_invarg;
8669 curwin->w_p_nuw = 10;
8670 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02008671 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008672 }
8673#endif
8674
Bram Moolenaar1a384422010-07-14 19:53:30 +02008675 else if (pp == &curbuf->b_p_tw)
8676 {
8677 if (curbuf->b_p_tw < 0)
8678 {
8679 errmsg = e_positive;
8680 curbuf->b_p_tw = 0;
8681 }
8682#ifdef FEAT_SYN_HL
8683# ifdef FEAT_WINDOWS
8684 {
8685 win_T *wp;
8686 tabpage_T *tp;
8687
8688 FOR_ALL_TAB_WINDOWS(tp, wp)
8689 check_colorcolumn(wp);
8690 }
8691# else
8692 check_colorcolumn(curwin);
8693# endif
8694#endif
8695 }
8696
Bram Moolenaar071d4272004-06-13 20:20:40 +00008697 /*
8698 * Check the bounds for numeric options here
8699 */
8700 if (Rows < min_rows() && full_screen)
8701 {
8702 if (errbuf != NULL)
8703 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008704 vim_snprintf((char *)errbuf, errbuflen,
8705 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00008706 errmsg = errbuf;
8707 }
8708 Rows = min_rows();
8709 }
8710 if (Columns < MIN_COLUMNS && full_screen)
8711 {
8712 if (errbuf != NULL)
8713 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008714 vim_snprintf((char *)errbuf, errbuflen,
8715 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008716 errmsg = errbuf;
8717 }
8718 Columns = MIN_COLUMNS;
8719 }
Bram Moolenaare057d402013-06-30 17:51:51 +02008720 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008721
8722#ifdef DJGPP
8723 /* avoid a crash by checking for a too large value of 'columns' */
8724 if (old_Columns != Columns && full_screen && term_console)
8725 mch_check_columns();
8726#endif
8727
8728 /*
8729 * If the screen (shell) height has been changed, assume it is the
8730 * physical screenheight.
8731 */
8732 if (old_Rows != Rows || old_Columns != Columns)
8733 {
8734 /* Changing the screen size is not allowed while updating the screen. */
8735 if (updating_screen)
8736 *pp = old_value;
8737 else if (full_screen
8738#ifdef FEAT_GUI
8739 && !gui.starting
8740#endif
8741 )
8742 set_shellsize((int)Columns, (int)Rows, TRUE);
8743 else
8744 {
8745 /* Postpone the resizing; check the size and cmdline position for
8746 * messages. */
8747 check_shellsize();
8748 if (cmdline_row > Rows - p_ch && Rows > p_ch)
8749 cmdline_row = Rows - p_ch;
8750 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00008751 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008752 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008753 }
8754
Bram Moolenaar071d4272004-06-13 20:20:40 +00008755 if (curbuf->b_p_ts <= 0)
8756 {
8757 errmsg = e_positive;
8758 curbuf->b_p_ts = 8;
8759 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008760 if (p_tm < 0)
8761 {
8762 errmsg = e_positive;
8763 p_tm = 0;
8764 }
8765 if ((curwin->w_p_scr <= 0
8766 || (curwin->w_p_scr > curwin->w_height
8767 && curwin->w_height > 0))
8768 && full_screen)
8769 {
8770 if (pp == &(curwin->w_p_scr))
8771 {
8772 if (curwin->w_p_scr != 0)
8773 errmsg = e_scroll;
8774 win_comp_scroll(curwin);
8775 }
8776 /* If 'scroll' became invalid because of a side effect silently adjust
8777 * it. */
8778 else if (curwin->w_p_scr <= 0)
8779 curwin->w_p_scr = 1;
8780 else /* curwin->w_p_scr > curwin->w_height */
8781 curwin->w_p_scr = curwin->w_height;
8782 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00008783 if (p_hi < 0)
8784 {
8785 errmsg = e_positive;
8786 p_hi = 0;
8787 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02008788 else if (p_hi > 10000)
8789 {
8790 errmsg = e_invarg;
8791 p_hi = 10000;
8792 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02008793 if (p_re < 0 || p_re > 2)
8794 {
8795 errmsg = e_invarg;
8796 p_re = 0;
8797 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008798 if (p_report < 0)
8799 {
8800 errmsg = e_positive;
8801 p_report = 1;
8802 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00008803 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008804 {
8805 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
8806 p_sj = Rows / 2;
8807 else
8808 {
8809 errmsg = e_scroll;
8810 p_sj = 1;
8811 }
8812 }
8813 if (p_so < 0 && full_screen)
8814 {
8815 errmsg = e_scroll;
8816 p_so = 0;
8817 }
8818 if (p_siso < 0 && full_screen)
8819 {
8820 errmsg = e_positive;
8821 p_siso = 0;
8822 }
8823#ifdef FEAT_CMDWIN
8824 if (p_cwh < 1)
8825 {
8826 errmsg = e_positive;
8827 p_cwh = 1;
8828 }
8829#endif
8830 if (p_ut < 0)
8831 {
8832 errmsg = e_positive;
8833 p_ut = 2000;
8834 }
8835 if (p_ss < 0)
8836 {
8837 errmsg = e_positive;
8838 p_ss = 0;
8839 }
8840
8841 /* May set global value for local option. */
8842 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8843 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
8844
8845 options[opt_idx].flags |= P_WAS_SET;
8846
Bram Moolenaar53744302015-07-17 17:38:22 +02008847#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8848 if (!starting && errmsg == NULL)
8849 {
8850 char_u buf_old[11], buf_new[11], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008851 vim_snprintf((char *)buf_old, 10, "%ld", old_value);
8852 vim_snprintf((char *)buf_new, 10, "%ld", value);
8853 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008854 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8855 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8856 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8857 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8858 reset_v_option_vars();
8859 }
8860#endif
8861
Bram Moolenaar071d4272004-06-13 20:20:40 +00008862 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008863 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008864 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008865 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008866 check_redraw(options[opt_idx].flags);
8867
8868 return errmsg;
8869}
8870
8871/*
8872 * Called after an option changed: check if something needs to be redrawn.
8873 */
8874 static void
8875check_redraw(flags)
8876 long_u flags;
8877{
8878 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008879 int doclear = (flags & P_RCLR) == P_RCLR;
8880 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008881
8882#ifdef FEAT_WINDOWS
8883 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
8884 status_redraw_all();
8885#endif
8886
8887 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
8888 changed_window_setting();
8889 if (flags & P_RBUF)
8890 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008891 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008892 redraw_all_later(CLEAR);
8893 else if (all)
8894 redraw_all_later(NOT_VALID);
8895}
8896
8897/*
8898 * Find index for option 'arg'.
8899 * Return -1 if not found.
8900 */
8901 static int
8902findoption(arg)
8903 char_u *arg;
8904{
8905 int opt_idx;
8906 char *s, *p;
8907 static short quick_tab[27] = {0, 0}; /* quick access table */
8908 int is_term_opt;
8909
8910 /*
8911 * For first call: Initialize the quick-access table.
8912 * It contains the index for the first option that starts with a certain
8913 * letter. There are 26 letters, plus the first "t_" option.
8914 */
8915 if (quick_tab[1] == 0)
8916 {
8917 p = options[0].fullname;
8918 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8919 {
8920 if (s[0] != p[0])
8921 {
8922 if (s[0] == 't' && s[1] == '_')
8923 quick_tab[26] = opt_idx;
8924 else
8925 quick_tab[CharOrdLow(s[0])] = opt_idx;
8926 }
8927 p = s;
8928 }
8929 }
8930
8931 /*
8932 * Check for name starting with an illegal character.
8933 */
8934#ifdef EBCDIC
8935 if (!islower(arg[0]))
8936#else
8937 if (arg[0] < 'a' || arg[0] > 'z')
8938#endif
8939 return -1;
8940
8941 is_term_opt = (arg[0] == 't' && arg[1] == '_');
8942 if (is_term_opt)
8943 opt_idx = quick_tab[26];
8944 else
8945 opt_idx = quick_tab[CharOrdLow(arg[0])];
8946 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8947 {
8948 if (STRCMP(arg, s) == 0) /* match full name */
8949 break;
8950 }
8951 if (s == NULL && !is_term_opt)
8952 {
8953 opt_idx = quick_tab[CharOrdLow(arg[0])];
8954 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
8955 {
8956 s = options[opt_idx].shortname;
8957 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
8958 break;
8959 s = NULL;
8960 }
8961 }
8962 if (s == NULL)
8963 opt_idx = -1;
8964 return opt_idx;
8965}
8966
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008967#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008968/*
8969 * Get the value for an option.
8970 *
8971 * Returns:
8972 * Number or Toggle option: 1, *numval gets value.
8973 * String option: 0, *stringval gets allocated string.
8974 * Hidden Number or Toggle option: -1.
8975 * hidden String option: -2.
8976 * unknown option: -3.
8977 */
8978 int
8979get_option_value(name, numval, stringval, opt_flags)
8980 char_u *name;
8981 long *numval;
Bram Moolenaar370df582010-06-22 05:16:38 +02008982 char_u **stringval; /* NULL when only checking existence */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008983 int opt_flags;
8984{
8985 int opt_idx;
8986 char_u *varp;
8987
8988 opt_idx = findoption(name);
8989 if (opt_idx < 0) /* unknown option */
8990 return -3;
8991
8992 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
8993
8994 if (options[opt_idx].flags & P_STRING)
8995 {
8996 if (varp == NULL) /* hidden option */
8997 return -2;
8998 if (stringval != NULL)
8999 {
9000#ifdef FEAT_CRYPT
9001 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00009002 if ((char_u **)varp == &curbuf->b_p_key
9003 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009004 *stringval = vim_strsave((char_u *)"*****");
9005 else
9006#endif
9007 *stringval = vim_strsave(*(char_u **)(varp));
9008 }
9009 return 0;
9010 }
9011
9012 if (varp == NULL) /* hidden option */
9013 return -1;
9014 if (options[opt_idx].flags & P_NUM)
9015 *numval = *(long *)varp;
9016 else
9017 {
9018 /* Special case: 'modified' is b_changed, but we also want to consider
9019 * it set when 'ff' or 'fenc' changed. */
9020 if ((int *)varp == &curbuf->b_changed)
9021 *numval = curbufIsChanged();
9022 else
9023 *numval = *(int *)varp;
9024 }
9025 return 1;
9026}
9027#endif
9028
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009029#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009030/*
9031 * Returns the option attributes and its value. Unlike the above function it
9032 * will return either global value or local value of the option depending on
9033 * what was requested, but it will never return global value if it was
9034 * requested to return local one and vice versa. Neither it will return
9035 * buffer-local value if it was requested to return window-local one.
9036 *
9037 * Pretends that option is absent if it is not present in the requested scope
9038 * (i.e. has no global, window-local or buffer-local value depending on
9039 * opt_type). Uses
9040 *
9041 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009042 * 0 hidden or unknown option, also option that does not have requested
9043 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009044 * see SOPT_* in vim.h for other flags
9045 *
9046 * Possible opt_type values: see SREQ_* in vim.h
9047 */
9048 int
9049get_option_value_strict(name, numval, stringval, opt_type, from)
9050 char_u *name;
9051 long *numval;
9052 char_u **stringval; /* NULL when only obtaining attributes */
9053 int opt_type;
9054 void *from;
9055{
9056 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009057 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009058 struct vimoption *p;
9059 int r = 0;
9060
9061 opt_idx = findoption(name);
9062 if (opt_idx < 0)
9063 return 0;
9064
9065 p = &(options[opt_idx]);
9066
9067 /* Hidden option */
9068 if (p->var == NULL)
9069 return 0;
9070
9071 if (p->flags & P_BOOL)
9072 r |= SOPT_BOOL;
9073 else if (p->flags & P_NUM)
9074 r |= SOPT_NUM;
9075 else if (p->flags & P_STRING)
9076 r |= SOPT_STRING;
9077
9078 if (p->indir == PV_NONE)
9079 {
9080 if (opt_type == SREQ_GLOBAL)
9081 r |= SOPT_GLOBAL;
9082 else
9083 return 0; /* Did not request global-only option */
9084 }
9085 else
9086 {
9087 if (p->indir & PV_BOTH)
9088 r |= SOPT_GLOBAL;
9089 else if (opt_type == SREQ_GLOBAL)
9090 return 0; /* Requested global option */
9091
9092 if (p->indir & PV_WIN)
9093 {
9094 if (opt_type == SREQ_BUF)
9095 return 0; /* Did not request window-local option */
9096 else
9097 r |= SOPT_WIN;
9098 }
9099 else if (p->indir & PV_BUF)
9100 {
9101 if (opt_type == SREQ_WIN)
9102 return 0; /* Did not request buffer-local option */
9103 else
9104 r |= SOPT_BUF;
9105 }
9106 }
9107
9108 if (stringval == NULL)
9109 return r;
9110
9111 if (opt_type == SREQ_GLOBAL)
9112 varp = p->var;
9113 else
9114 {
9115 if (opt_type == SREQ_BUF)
9116 {
9117 /* Special case: 'modified' is b_changed, but we also want to
9118 * consider it set when 'ff' or 'fenc' changed. */
9119 if (p->indir == PV_MOD)
9120 {
9121 *numval = bufIsChanged((buf_T *) from);
9122 varp = NULL;
9123 }
9124#ifdef FEAT_CRYPT
9125 else if (p->indir == PV_KEY)
9126 {
9127 /* never return the value of the crypt key */
9128 *stringval = NULL;
9129 varp = NULL;
9130 }
9131#endif
9132 else
9133 {
9134 aco_save_T aco;
9135 aucmd_prepbuf(&aco, (buf_T *) from);
9136 varp = get_varp(p);
9137 aucmd_restbuf(&aco);
9138 }
9139 }
9140 else if (opt_type == SREQ_WIN)
9141 {
9142 win_T *save_curwin;
9143 save_curwin = curwin;
9144 curwin = (win_T *) from;
9145 curbuf = curwin->w_buffer;
9146 varp = get_varp(p);
9147 curwin = save_curwin;
9148 curbuf = curwin->w_buffer;
9149 }
9150 if (varp == p->var)
9151 return (r | SOPT_UNSET);
9152 }
9153
9154 if (varp != NULL)
9155 {
9156 if (p->flags & P_STRING)
9157 *stringval = vim_strsave(*(char_u **)(varp));
9158 else if (p->flags & P_NUM)
9159 *numval = *(long *) varp;
9160 else
9161 *numval = *(int *)varp;
9162 }
9163
9164 return r;
9165}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009166
9167/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009168 * Iterate over options. First argument is a pointer to a pointer to a
9169 * structure inside options[] array, second is option type like in the above
9170 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009171 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009172 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009173 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009174 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009175 * first argument to NULL.
9176 *
9177 * Returns full option name for current option on each call.
9178 */
9179 char_u *
9180option_iter_next(option, opt_type)
9181 void **option;
9182 int opt_type;
9183{
9184 struct vimoption *ret = NULL;
9185 do
9186 {
9187 if (*option == NULL)
9188 *option = (void *) options;
9189 else if (((struct vimoption *) (*option))->fullname == NULL)
9190 {
9191 *option = NULL;
9192 return NULL;
9193 }
9194 else
9195 *option = (void *) (((struct vimoption *) (*option)) + 1);
9196
9197 ret = ((struct vimoption *) (*option));
9198
9199 /* Hidden option */
9200 if (ret->var == NULL)
9201 {
9202 ret = NULL;
9203 continue;
9204 }
9205
9206 switch (opt_type)
9207 {
9208 case SREQ_GLOBAL:
9209 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9210 ret = NULL;
9211 break;
9212 case SREQ_BUF:
9213 if (!(ret->indir & PV_BUF))
9214 ret = NULL;
9215 break;
9216 case SREQ_WIN:
9217 if (!(ret->indir & PV_WIN))
9218 ret = NULL;
9219 break;
9220 default:
9221 EMSG2(_(e_intern2), "option_iter_next()");
9222 return NULL;
9223 }
9224 }
9225 while (ret == NULL);
9226
9227 return (char_u *)ret->fullname;
9228}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009229#endif
9230
Bram Moolenaar071d4272004-06-13 20:20:40 +00009231/*
9232 * Set the value of option "name".
9233 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009234 *
9235 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009236 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009237 char_u *
Bram Moolenaar071d4272004-06-13 20:20:40 +00009238set_option_value(name, number, string, opt_flags)
9239 char_u *name;
9240 long number;
9241 char_u *string;
9242 int opt_flags; /* OPT_LOCAL or 0 (both) */
9243{
9244 int opt_idx;
9245 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009246 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009247
9248 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009249 if (opt_idx < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009250 EMSG2(_("E355: Unknown option: %s"), name);
9251 else
9252 {
9253 flags = options[opt_idx].flags;
9254#ifdef HAVE_SANDBOX
9255 /* Disallow changing some options in the sandbox */
9256 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009257 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009258 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009259 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009260 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009261#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009262 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009263 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009264 else
9265 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009266 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009267 if (varp != NULL) /* hidden option is not changed */
9268 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009269 if (number == 0 && string != NULL)
9270 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009271 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009272
9273 /* Either we are given a string or we are setting option
9274 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009275 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009276 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009277 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009278 {
9279 /* There's another character after zeros or the string
9280 * is empty. In both cases, we are trying to set a
9281 * num option using a string. */
9282 EMSG3(_("E521: Number required: &%s = '%s'"),
9283 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009284 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009285
9286 }
9287 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009288 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009289 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009290 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009291 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009292 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009293 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009294 }
9295 }
9296 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009297 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009298}
9299
9300/*
9301 * Get the terminal code for a terminal option.
9302 * Returns NULL when not found.
9303 */
9304 char_u *
9305get_term_code(tname)
9306 char_u *tname;
9307{
9308 int opt_idx;
9309 char_u *varp;
9310
9311 if (tname[0] != 't' || tname[1] != '_' ||
9312 tname[2] == NUL || tname[3] == NUL)
9313 return NULL;
9314 if ((opt_idx = findoption(tname)) >= 0)
9315 {
9316 varp = get_varp(&(options[opt_idx]));
9317 if (varp != NULL)
9318 varp = *(char_u **)(varp);
9319 return varp;
9320 }
9321 return find_termcode(tname + 2);
9322}
9323
9324 char_u *
9325get_highlight_default()
9326{
9327 int i;
9328
9329 i = findoption((char_u *)"hl");
9330 if (i >= 0)
9331 return options[i].def_val[VI_DEFAULT];
9332 return (char_u *)NULL;
9333}
9334
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009335#if defined(FEAT_MBYTE) || defined(PROTO)
9336 char_u *
9337get_encoding_default()
9338{
9339 int i;
9340
9341 i = findoption((char_u *)"enc");
9342 if (i >= 0)
9343 return options[i].def_val[VI_DEFAULT];
9344 return (char_u *)NULL;
9345}
9346#endif
9347
Bram Moolenaar071d4272004-06-13 20:20:40 +00009348/*
9349 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9350 */
9351 static int
9352find_key_option(arg)
9353 char_u *arg;
9354{
9355 int key;
9356 int modifiers;
9357
9358 /*
9359 * Don't use get_special_key_code() for t_xx, we don't want it to call
9360 * add_termcap_entry().
9361 */
9362 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9363 key = TERMCAP2KEY(arg[2], arg[3]);
9364 else
9365 {
9366 --arg; /* put arg at the '<' */
9367 modifiers = 0;
Bram Moolenaar2a8ced02008-12-24 11:54:31 +00009368 key = find_special_key(&arg, &modifiers, TRUE, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009369 if (modifiers) /* can't handle modifiers here */
9370 key = 0;
9371 }
9372 return key;
9373}
9374
9375/*
9376 * if 'all' == 0: show changed options
9377 * if 'all' == 1: show all normal options
9378 * if 'all' == 2: show all terminal options
9379 */
9380 static void
9381showoptions(all, opt_flags)
9382 int all;
9383 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
9384{
9385 struct vimoption *p;
9386 int col;
9387 int isterm;
9388 char_u *varp;
9389 struct vimoption **items;
9390 int item_count;
9391 int run;
9392 int row, rows;
9393 int cols;
9394 int i;
9395 int len;
9396
9397#define INC 20
9398#define GAP 3
9399
9400 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9401 PARAM_COUNT));
9402 if (items == NULL)
9403 return;
9404
9405 /* Highlight title */
9406 if (all == 2)
9407 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9408 else if (opt_flags & OPT_GLOBAL)
9409 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9410 else if (opt_flags & OPT_LOCAL)
9411 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9412 else
9413 MSG_PUTS_TITLE(_("\n--- Options ---"));
9414
9415 /*
9416 * do the loop two times:
9417 * 1. display the short items
9418 * 2. display the long items (only strings and numbers)
9419 */
9420 for (run = 1; run <= 2 && !got_int; ++run)
9421 {
9422 /*
9423 * collect the items in items[]
9424 */
9425 item_count = 0;
9426 for (p = &options[0]; p->fullname != NULL; p++)
9427 {
9428 varp = NULL;
9429 isterm = istermoption(p);
9430 if (opt_flags != 0)
9431 {
9432 if (p->indir != PV_NONE && !isterm)
9433 varp = get_varp_scope(p, opt_flags);
9434 }
9435 else
9436 varp = get_varp(p);
9437 if (varp != NULL
9438 && ((all == 2 && isterm)
9439 || (all == 1 && !isterm)
9440 || (all == 0 && !optval_default(p, varp))))
9441 {
9442 if (p->flags & P_BOOL)
9443 len = 1; /* a toggle option fits always */
9444 else
9445 {
9446 option_value2string(p, opt_flags);
9447 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9448 }
9449 if ((len <= INC - GAP && run == 1) ||
9450 (len > INC - GAP && run == 2))
9451 items[item_count++] = p;
9452 }
9453 }
9454
9455 /*
9456 * display the items
9457 */
9458 if (run == 1)
9459 {
9460 cols = (Columns + GAP - 3) / INC;
9461 if (cols == 0)
9462 cols = 1;
9463 rows = (item_count + cols - 1) / cols;
9464 }
9465 else /* run == 2 */
9466 rows = item_count;
9467 for (row = 0; row < rows && !got_int; ++row)
9468 {
9469 msg_putchar('\n'); /* go to next line */
9470 if (got_int) /* 'q' typed in more */
9471 break;
9472 col = 0;
9473 for (i = row; i < item_count; i += rows)
9474 {
9475 msg_col = col; /* make columns */
9476 showoneopt(items[i], opt_flags);
9477 col += INC;
9478 }
9479 out_flush();
9480 ui_breakcheck();
9481 }
9482 }
9483 vim_free(items);
9484}
9485
9486/*
9487 * Return TRUE if option "p" has its default value.
9488 */
9489 static int
9490optval_default(p, varp)
9491 struct vimoption *p;
9492 char_u *varp;
9493{
9494 int dvi;
9495
9496 if (varp == NULL)
9497 return TRUE; /* hidden option is always at default */
9498 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9499 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009500 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009501 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009502 /* the cast to long is required for Manx C, long_i is
9503 * needed for MSVC */
9504 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009505 /* P_STRING */
9506 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9507}
9508
9509/*
9510 * showoneopt: show the value of one option
9511 * must not be called with a hidden option!
9512 */
9513 static void
9514showoneopt(p, opt_flags)
9515 struct vimoption *p;
9516 int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */
9517{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009518 char_u *varp;
9519 int save_silent = silent_mode;
9520
9521 silent_mode = FALSE;
9522 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009523
9524 varp = get_varp_scope(p, opt_flags);
9525
9526 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9527 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9528 ? !curbufIsChanged() : !*(int *)varp))
9529 MSG_PUTS("no");
9530 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9531 MSG_PUTS("--");
9532 else
9533 MSG_PUTS(" ");
9534 MSG_PUTS(p->fullname);
9535 if (!(p->flags & P_BOOL))
9536 {
9537 msg_putchar('=');
9538 /* put value string in NameBuff */
9539 option_value2string(p, opt_flags);
9540 msg_outtrans(NameBuff);
9541 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009542
9543 silent_mode = save_silent;
9544 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009545}
9546
9547/*
9548 * Write modified options as ":set" commands to a file.
9549 *
9550 * There are three values for "opt_flags":
9551 * OPT_GLOBAL: Write global option values and fresh values of
9552 * buffer-local options (used for start of a session
9553 * file).
9554 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
9555 * curwin (used for a vimrc file).
9556 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
9557 * and local values for window-local options of
9558 * curwin. Local values are also written when at the
9559 * default value, because a modeline or autocommand
9560 * may have set them when doing ":edit file" and the
9561 * user has set them back at the default or fresh
9562 * value.
9563 * When "local_only" is TRUE, don't write fresh
9564 * values, only local values (for ":mkview").
9565 * (fresh value = value used for a new buffer or window for a local option).
9566 *
9567 * Return FAIL on error, OK otherwise.
9568 */
9569 int
9570makeset(fd, opt_flags, local_only)
9571 FILE *fd;
9572 int opt_flags;
9573 int local_only;
9574{
9575 struct vimoption *p;
9576 char_u *varp; /* currently used value */
9577 char_u *varp_fresh; /* local value */
9578 char_u *varp_local = NULL; /* fresh value */
9579 char *cmd;
9580 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009581 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009582
9583 /*
9584 * The options that don't have a default (terminal name, columns, lines)
9585 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009586 * Do the loop over "options[]" twice: once for options with the
9587 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009588 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009589 for (pri = 1; pri >= 0; --pri)
9590 {
9591 for (p = &options[0]; !istermoption(p); p++)
9592 if (!(p->flags & P_NO_MKRC)
9593 && !istermoption(p)
9594 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009595 {
9596 /* skip global option when only doing locals */
9597 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
9598 continue;
9599
9600 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
9601 * file, they are always buffer-specific. */
9602 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
9603 continue;
9604
9605 /* Global values are only written when not at the default value. */
9606 varp = get_varp_scope(p, opt_flags);
9607 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
9608 continue;
9609
9610 round = 2;
9611 if (p->indir != PV_NONE)
9612 {
9613 if (p->var == VAR_WIN)
9614 {
9615 /* skip window-local option when only doing globals */
9616 if (!(opt_flags & OPT_LOCAL))
9617 continue;
9618 /* When fresh value of window-local option is not at the
9619 * default, need to write it too. */
9620 if (!(opt_flags & OPT_GLOBAL) && !local_only)
9621 {
9622 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
9623 if (!optval_default(p, varp_fresh))
9624 {
9625 round = 1;
9626 varp_local = varp;
9627 varp = varp_fresh;
9628 }
9629 }
9630 }
9631 }
9632
9633 /* Round 1: fresh value for window-local options.
9634 * Round 2: other values */
9635 for ( ; round <= 2; varp = varp_local, ++round)
9636 {
9637 if (round == 1 || (opt_flags & OPT_GLOBAL))
9638 cmd = "set";
9639 else
9640 cmd = "setlocal";
9641
9642 if (p->flags & P_BOOL)
9643 {
9644 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
9645 return FAIL;
9646 }
9647 else if (p->flags & P_NUM)
9648 {
9649 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
9650 return FAIL;
9651 }
9652 else /* P_STRING */
9653 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009654#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9655 int do_endif = FALSE;
9656
Bram Moolenaar071d4272004-06-13 20:20:40 +00009657 /* Don't set 'syntax' and 'filetype' again if the value is
9658 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009659 if (
9660# if defined(FEAT_SYN_HL)
9661 p->indir == PV_SYN
9662# if defined(FEAT_AUTOCMD)
9663 ||
9664# endif
9665# endif
9666# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009667 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009668# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009669 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00009670 {
9671 if (fprintf(fd, "if &%s != '%s'", p->fullname,
9672 *(char_u **)(varp)) < 0
9673 || put_eol(fd) < 0)
9674 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009675 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009676 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009677#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009678 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
9679 (p->flags & P_EXPAND) != 0) == FAIL)
9680 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009681#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9682 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009683 {
9684 if (put_line(fd, "endif") == FAIL)
9685 return FAIL;
9686 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009687#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009688 }
9689 }
9690 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009691 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009692 return OK;
9693}
9694
9695#if defined(FEAT_FOLDING) || defined(PROTO)
9696/*
9697 * Generate set commands for the local fold options only. Used when
9698 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
9699 */
9700 int
9701makefoldset(fd)
9702 FILE *fd;
9703{
9704 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
9705# ifdef FEAT_EVAL
9706 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
9707 == FAIL
9708# endif
9709 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
9710 == FAIL
9711 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
9712 == FAIL
9713 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
9714 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
9715 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
9716 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
9717 )
9718 return FAIL;
9719
9720 return OK;
9721}
9722#endif
9723
9724 static int
9725put_setstring(fd, cmd, name, valuep, expand)
9726 FILE *fd;
9727 char *cmd;
9728 char *name;
9729 char_u **valuep;
9730 int expand;
9731{
9732 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009733 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009734
9735 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9736 return FAIL;
9737 if (*valuep != NULL)
9738 {
9739 /* Output 'pastetoggle' as key names. For other
9740 * options some characters have to be escaped with
9741 * CTRL-V or backslash */
9742 if (valuep == &p_pt)
9743 {
9744 s = *valuep;
9745 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +00009746 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009747 return FAIL;
9748 }
9749 else if (expand)
9750 {
Bram Moolenaarf8441472011-04-28 17:24:58 +02009751 buf = alloc(MAXPATHL);
9752 if (buf == NULL)
9753 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009754 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
9755 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +02009756 {
9757 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009758 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009759 }
9760 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009761 }
9762 else if (put_escstr(fd, *valuep, 2) == FAIL)
9763 return FAIL;
9764 }
9765 if (put_eol(fd) < 0)
9766 return FAIL;
9767 return OK;
9768}
9769
9770 static int
9771put_setnum(fd, cmd, name, valuep)
9772 FILE *fd;
9773 char *cmd;
9774 char *name;
9775 long *valuep;
9776{
9777 long wc;
9778
9779 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9780 return FAIL;
9781 if (wc_use_keyname((char_u *)valuep, &wc))
9782 {
9783 /* print 'wildchar' and 'wildcharm' as a key name */
9784 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
9785 return FAIL;
9786 }
9787 else if (fprintf(fd, "%ld", *valuep) < 0)
9788 return FAIL;
9789 if (put_eol(fd) < 0)
9790 return FAIL;
9791 return OK;
9792}
9793
9794 static int
9795put_setbool(fd, cmd, name, value)
9796 FILE *fd;
9797 char *cmd;
9798 char *name;
9799 int value;
9800{
Bram Moolenaar893de922007-10-02 18:40:57 +00009801 if (value < 0) /* global/local option using global value */
9802 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009803 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
9804 || put_eol(fd) < 0)
9805 return FAIL;
9806 return OK;
9807}
9808
9809/*
9810 * Clear all the terminal options.
9811 * If the option has been allocated, free the memory.
9812 * Terminal options are never hidden or indirect.
9813 */
9814 void
9815clear_termoptions()
9816{
Bram Moolenaar071d4272004-06-13 20:20:40 +00009817 /*
9818 * Reset a few things before clearing the old options. This may cause
9819 * outputting a few things that the terminal doesn't understand, but the
9820 * screen will be cleared later, so this is OK.
9821 */
9822#ifdef FEAT_MOUSE_TTY
9823 mch_setmouse(FALSE); /* switch mouse off */
9824#endif
9825#ifdef FEAT_TITLE
9826 mch_restore_title(3); /* restore window titles */
9827#endif
9828#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
9829 /* When starting the GUI close the display opened for the clipboard.
9830 * After restoring the title, because that will need the display. */
9831 if (gui.starting)
9832 clear_xterm_clip();
9833#endif
9834#ifdef WIN3264
9835 /*
9836 * Check if this is allowed now.
9837 */
9838 if (can_end_termcap_mode(FALSE) == TRUE)
9839#endif
9840 stoptermcap(); /* stop termcap mode */
9841
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00009842 free_termoptions();
9843}
9844
9845 void
9846free_termoptions()
9847{
9848 struct vimoption *p;
9849
Bram Moolenaar071d4272004-06-13 20:20:40 +00009850 for (p = &options[0]; p->fullname != NULL; p++)
9851 if (istermoption(p))
9852 {
9853 if (p->flags & P_ALLOCED)
9854 free_string_option(*(char_u **)(p->var));
9855 if (p->flags & P_DEF_ALLOCED)
9856 free_string_option(p->def_val[VI_DEFAULT]);
9857 *(char_u **)(p->var) = empty_option;
9858 p->def_val[VI_DEFAULT] = empty_option;
9859 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
9860 }
9861 clear_termcodes();
9862}
9863
9864/*
Bram Moolenaar363cb672009-07-22 12:28:17 +00009865 * Free the string for one term option, if it was allocated.
9866 * Set the string to empty_option and clear allocated flag.
9867 * "var" points to the option value.
9868 */
9869 void
9870free_one_termoption(var)
9871 char_u *var;
9872{
9873 struct vimoption *p;
9874
9875 for (p = &options[0]; p->fullname != NULL; p++)
9876 if (p->var == var)
9877 {
9878 if (p->flags & P_ALLOCED)
9879 free_string_option(*(char_u **)(p->var));
9880 *(char_u **)(p->var) = empty_option;
9881 p->flags &= ~P_ALLOCED;
9882 break;
9883 }
9884}
9885
9886/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00009887 * Set the terminal option defaults to the current value.
9888 * Used after setting the terminal name.
9889 */
9890 void
9891set_term_defaults()
9892{
9893 struct vimoption *p;
9894
9895 for (p = &options[0]; p->fullname != NULL; p++)
9896 {
9897 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
9898 {
9899 if (p->flags & P_DEF_ALLOCED)
9900 {
9901 free_string_option(p->def_val[VI_DEFAULT]);
9902 p->flags &= ~P_DEF_ALLOCED;
9903 }
9904 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
9905 if (p->flags & P_ALLOCED)
9906 {
9907 p->flags |= P_DEF_ALLOCED;
9908 p->flags &= ~P_ALLOCED; /* don't free the value now */
9909 }
9910 }
9911 }
9912}
9913
9914/*
9915 * return TRUE if 'p' starts with 't_'
9916 */
9917 static int
9918istermoption(p)
9919 struct vimoption *p;
9920{
9921 return (p->fullname[0] == 't' && p->fullname[1] == '_');
9922}
9923
9924/*
9925 * Compute columns for ruler and shown command. 'sc_col' is also used to
9926 * decide what the maximum length of a message on the status line can be.
9927 * If there is a status line for the last window, 'sc_col' is independent
9928 * of 'ru_col'.
9929 */
9930
9931#define COL_RULER 17 /* columns needed by standard ruler */
9932
9933 void
9934comp_col()
9935{
9936#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
9937 int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin));
9938
9939 sc_col = 0;
9940 ru_col = 0;
9941 if (p_ru)
9942 {
9943#ifdef FEAT_STL_OPT
9944 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
9945#else
9946 ru_col = COL_RULER + 1;
9947#endif
9948 /* no last status line, adjust sc_col */
9949 if (!last_has_status)
9950 sc_col = ru_col;
9951 }
9952 if (p_sc)
9953 {
9954 sc_col += SHOWCMD_COLS;
9955 if (!p_ru || last_has_status) /* no need for separating space */
9956 ++sc_col;
9957 }
9958 sc_col = Columns - sc_col;
9959 ru_col = Columns - ru_col;
9960 if (sc_col <= 0) /* screen too narrow, will become a mess */
9961 sc_col = 1;
9962 if (ru_col <= 0)
9963 ru_col = 1;
9964#else
9965 sc_col = Columns;
9966 ru_col = Columns;
9967#endif
9968}
9969
9970/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009971 * Unset local option value, similar to ":set opt<".
9972 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009973 void
9974unset_global_local_option(name, from)
9975 char_u *name;
9976 void *from;
9977{
9978 struct vimoption *p;
9979 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009980 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009981
9982 opt_idx = findoption(name);
9983 p = &(options[opt_idx]);
9984
9985 switch ((int)p->indir)
9986 {
9987 /* global option with local value: use local value if it's been set */
9988 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009989 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009990 break;
9991 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009992 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009993 break;
9994 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009995 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009996 break;
9997 case PV_AR:
9998 buf->b_p_ar = -1;
9999 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010000 case PV_BKC:
10001 clear_string_option(&buf->b_p_bkc);
10002 buf->b_bkc_flags = 0;
10003 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010004 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010005 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010006 break;
10007#ifdef FEAT_FIND_ID
10008 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010009 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010010 break;
10011 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010012 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010013 break;
10014#endif
10015#ifdef FEAT_INS_EXPAND
10016 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010017 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010018 break;
10019 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010020 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010021 break;
10022#endif
10023#ifdef FEAT_QUICKFIX
10024 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010025 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010026 break;
10027 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010028 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010029 break;
10030 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010031 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010032 break;
10033#endif
10034#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10035 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010036 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010037 break;
10038#endif
10039#if defined(FEAT_CRYPT)
10040 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010041 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010042 break;
10043#endif
10044#ifdef FEAT_STL_OPT
10045 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010046 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010047 break;
10048#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010049 case PV_UL:
10050 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10051 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010052#ifdef FEAT_LISP
10053 case PV_LW:
10054 clear_string_option(&buf->b_p_lw);
10055 break;
10056#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010057 }
10058}
10059
10060/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010061 * Get pointer to option variable, depending on local or global scope.
10062 */
10063 static char_u *
10064get_varp_scope(p, opt_flags)
10065 struct vimoption *p;
10066 int opt_flags;
10067{
10068 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10069 {
10070 if (p->var == VAR_WIN)
10071 return (char_u *)GLOBAL_WO(get_varp(p));
10072 return p->var;
10073 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010074 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010075 {
10076 switch ((int)p->indir)
10077 {
10078#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010079 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10080 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10081 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010082#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010083 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10084 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10085 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010086 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010087 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010088#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010089 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10090 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010091#endif
10092#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010093 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10094 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010095#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010096#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10097 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10098#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010099#if defined(FEAT_CRYPT)
10100 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10101#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010102#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010103 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010104#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010105 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010106#ifdef FEAT_LISP
10107 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10108#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010109 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010110 }
10111 return NULL; /* "cannot happen" */
10112 }
10113 return get_varp(p);
10114}
10115
10116/*
10117 * Get pointer to option variable.
10118 */
10119 static char_u *
10120get_varp(p)
10121 struct vimoption *p;
10122{
10123 /* hidden option, always return NULL */
10124 if (p->var == NULL)
10125 return NULL;
10126
10127 switch ((int)p->indir)
10128 {
10129 case PV_NONE: return p->var;
10130
10131 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010132 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010133 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010134 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010135 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010136 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010137 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010138 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010139 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010140 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010141 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010142 case PV_BKC: return *curbuf->b_p_bkc != NUL
10143 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010144#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010145 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010146 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010147 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010148 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10149#endif
10150#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010151 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010152 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010153 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010154 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10155#endif
10156#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010157 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010158 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010159 case PV_GP: return *curbuf->b_p_gp != NUL
10160 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10161 case PV_MP: return *curbuf->b_p_mp != NUL
10162 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010163#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010164#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10165 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10166 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10167#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010168#if defined(FEAT_CRYPT)
10169 case PV_CM: return *curbuf->b_p_cm != NUL
10170 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10171#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010172#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010173 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010174 ? (char_u *)&(curwin->w_p_stl) : p->var;
10175#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010176 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10177 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010178#ifdef FEAT_LISP
10179 case PV_LW: return *curbuf->b_p_lw != NUL
10180 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10181#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010182
10183#ifdef FEAT_ARABIC
10184 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10185#endif
10186 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010187#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010188 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10189#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010190#ifdef FEAT_SYN_HL
10191 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10192 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010193 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010194#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010195#ifdef FEAT_DIFF
10196 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10197#endif
10198#ifdef FEAT_FOLDING
10199 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10200 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10201 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10202 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10203 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10204 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10205 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10206# ifdef FEAT_EVAL
10207 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10208 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10209# endif
10210 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10211#endif
10212 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010213 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010214#ifdef FEAT_LINEBREAK
10215 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10216#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010217#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010218 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
10219#endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010220#ifdef FEAT_VERTSPLIT
10221 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10222#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010223#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10224 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10225#endif
10226#ifdef FEAT_RIGHTLEFT
10227 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10228 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10229#endif
10230 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10231 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10232#ifdef FEAT_LINEBREAK
10233 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010234 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10235 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010236#endif
10237#ifdef FEAT_SCROLLBIND
10238 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10239#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010240#ifdef FEAT_CURSORBIND
10241 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10242#endif
10243#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010244 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10245 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010246#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010247
10248 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10249 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10250#ifdef FEAT_MBYTE
10251 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10252#endif
10253#if defined(FEAT_QUICKFIX)
10254 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10255 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
10256#endif
10257 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10258 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10259#ifdef FEAT_CINDENT
10260 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10261 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10262 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10263#endif
10264#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10265 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10266#endif
10267#ifdef FEAT_COMMENTS
10268 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10269#endif
10270#ifdef FEAT_FOLDING
10271 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10272#endif
10273#ifdef FEAT_INS_EXPAND
10274 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10275#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010276#ifdef FEAT_COMPL_FUNC
10277 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010278 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010279#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010280 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010281 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010282 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10283#ifdef FEAT_MBYTE
10284 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10285#endif
10286 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10287#ifdef FEAT_AUTOCMD
10288 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10289#endif
10290 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010291 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010292 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10293 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10294 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10295 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10296#ifdef FEAT_FIND_ID
10297# ifdef FEAT_EVAL
10298 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10299# endif
10300#endif
10301#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10302 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10303 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10304#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010305#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010306 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10307#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010308#ifdef FEAT_CRYPT
10309 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10310#endif
10311#ifdef FEAT_LISP
10312 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10313#endif
10314 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10315 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10316 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10317 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10318 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010319 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010320#ifdef FEAT_TEXTOBJ
10321 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10322#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010323 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10324#ifdef FEAT_SMARTINDENT
10325 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10326#endif
10327#ifndef SHORT_FNAME
10328 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
10329#endif
10330 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10331#ifdef FEAT_SEARCHPATH
10332 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10333#endif
10334 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10335#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010336 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010337 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10338#endif
10339#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010340 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10341 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10342 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010343#endif
10344 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10345 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10346 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10347 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010348#ifdef FEAT_PERSISTENT_UNDO
10349 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10350#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010351 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10352#ifdef FEAT_KEYMAP
10353 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10354#endif
10355 default: EMSG(_("E356: get_varp ERROR"));
10356 }
10357 /* always return a valid pointer to avoid a crash! */
10358 return (char_u *)&(curbuf->b_p_wm);
10359}
10360
10361/*
10362 * Get the value of 'equalprg', either the buffer-local one or the global one.
10363 */
10364 char_u *
10365get_equalprg()
10366{
10367 if (*curbuf->b_p_ep == NUL)
10368 return p_ep;
10369 return curbuf->b_p_ep;
10370}
10371
10372#if defined(FEAT_WINDOWS) || defined(PROTO)
10373/*
10374 * Copy options from one window to another.
10375 * Used when splitting a window.
10376 */
10377 void
10378win_copy_options(wp_from, wp_to)
10379 win_T *wp_from;
10380 win_T *wp_to;
10381{
10382 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10383 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10384# ifdef FEAT_RIGHTLEFT
10385# ifdef FEAT_FKMAP
10386 /* Is this right? */
10387 wp_to->w_farsi = wp_from->w_farsi;
10388# endif
10389# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020010390#if defined(FEAT_LINEBREAK)
10391 briopt_check(wp_to);
10392#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010393}
10394#endif
10395
10396/*
10397 * Copy the options from one winopt_T to another.
10398 * Doesn't free the old option values in "to", use clear_winopt() for that.
10399 * The 'scroll' option is not copied, because it depends on the window height.
10400 * The 'previewwindow' option is reset, there can be only one preview window.
10401 */
10402 void
10403copy_winopt(from, to)
10404 winopt_T *from;
10405 winopt_T *to;
10406{
10407#ifdef FEAT_ARABIC
10408 to->wo_arab = from->wo_arab;
10409#endif
10410 to->wo_list = from->wo_list;
10411 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010412 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010413#ifdef FEAT_LINEBREAK
10414 to->wo_nuw = from->wo_nuw;
10415#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010416#ifdef FEAT_RIGHTLEFT
10417 to->wo_rl = from->wo_rl;
10418 to->wo_rlc = vim_strsave(from->wo_rlc);
10419#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010420#ifdef FEAT_STL_OPT
10421 to->wo_stl = vim_strsave(from->wo_stl);
10422#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010423 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010424#ifdef FEAT_DIFF
10425 to->wo_wrap_save = from->wo_wrap_save;
10426#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010427#ifdef FEAT_LINEBREAK
10428 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020010429 to->wo_bri = from->wo_bri;
10430 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010431#endif
10432#ifdef FEAT_SCROLLBIND
10433 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010434 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010435#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010436#ifdef FEAT_CURSORBIND
10437 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010438 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010439#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010440#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010441 to->wo_spell = from->wo_spell;
10442#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010443#ifdef FEAT_SYN_HL
10444 to->wo_cuc = from->wo_cuc;
10445 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010446 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010447#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010448#ifdef FEAT_DIFF
10449 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010450 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010451#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010452#ifdef FEAT_CONCEAL
10453 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010454 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010455#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010456#ifdef FEAT_FOLDING
10457 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010458 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010459 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010460 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010461 to->wo_fdi = vim_strsave(from->wo_fdi);
10462 to->wo_fml = from->wo_fml;
10463 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010464 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010465 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010466 to->wo_fdm_save = from->wo_diff_saved
10467 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010468 to->wo_fdn = from->wo_fdn;
10469# ifdef FEAT_EVAL
10470 to->wo_fde = vim_strsave(from->wo_fde);
10471 to->wo_fdt = vim_strsave(from->wo_fdt);
10472# endif
10473 to->wo_fmr = vim_strsave(from->wo_fmr);
10474#endif
10475 check_winopt(to); /* don't want NULL pointers */
10476}
10477
10478/*
10479 * Check string options in a window for a NULL value.
10480 */
10481 void
10482check_win_options(win)
10483 win_T *win;
10484{
10485 check_winopt(&win->w_onebuf_opt);
10486 check_winopt(&win->w_allbuf_opt);
10487}
10488
10489/*
10490 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10491 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020010492 static void
Bram Moolenaar071d4272004-06-13 20:20:40 +000010493check_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010494 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010495{
10496#ifdef FEAT_FOLDING
10497 check_string_option(&wop->wo_fdi);
10498 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010499 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010500# ifdef FEAT_EVAL
10501 check_string_option(&wop->wo_fde);
10502 check_string_option(&wop->wo_fdt);
10503# endif
10504 check_string_option(&wop->wo_fmr);
10505#endif
10506#ifdef FEAT_RIGHTLEFT
10507 check_string_option(&wop->wo_rlc);
10508#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010509#ifdef FEAT_STL_OPT
10510 check_string_option(&wop->wo_stl);
10511#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010512#ifdef FEAT_SYN_HL
10513 check_string_option(&wop->wo_cc);
10514#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010515#ifdef FEAT_CONCEAL
10516 check_string_option(&wop->wo_cocu);
10517#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010518#ifdef FEAT_LINEBREAK
10519 check_string_option(&wop->wo_briopt);
10520#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010521}
10522
10523/*
10524 * Free the allocated memory inside a winopt_T.
10525 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010526 void
10527clear_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010528 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010529{
10530#ifdef FEAT_FOLDING
10531 clear_string_option(&wop->wo_fdi);
10532 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010533 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010534# ifdef FEAT_EVAL
10535 clear_string_option(&wop->wo_fde);
10536 clear_string_option(&wop->wo_fdt);
10537# endif
10538 clear_string_option(&wop->wo_fmr);
10539#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010540#ifdef FEAT_LINEBREAK
10541 clear_string_option(&wop->wo_briopt);
10542#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010543#ifdef FEAT_RIGHTLEFT
10544 clear_string_option(&wop->wo_rlc);
10545#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010546#ifdef FEAT_STL_OPT
10547 clear_string_option(&wop->wo_stl);
10548#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010549#ifdef FEAT_SYN_HL
10550 clear_string_option(&wop->wo_cc);
10551#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010552#ifdef FEAT_CONCEAL
10553 clear_string_option(&wop->wo_cocu);
10554#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010555}
10556
10557/*
10558 * Copy global option values to local options for one buffer.
10559 * Used when creating a new buffer and sometimes when entering a buffer.
10560 * flags:
10561 * BCO_ENTER We will enter the buf buffer.
10562 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
10563 * appropriate.
10564 * BCO_NOHELP Don't copy the values to a help buffer.
10565 */
10566 void
10567buf_copy_options(buf, flags)
10568 buf_T *buf;
10569 int flags;
10570{
10571 int should_copy = TRUE;
10572 char_u *save_p_isk = NULL; /* init for GCC */
10573 int dont_do_help;
10574 int did_isk = FALSE;
10575
10576 /*
Bram Moolenaar1a384422010-07-14 19:53:30 +020010577 * Don't do anything if the buffer is invalid.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010578 */
10579 if (buf == NULL || !buf_valid(buf))
10580 return;
10581
10582 /*
10583 * Skip this when the option defaults have not been set yet. Happens when
10584 * main() allocates the first buffer.
10585 */
10586 if (p_cpo != NULL)
10587 {
10588 /*
10589 * Always copy when entering and 'cpo' contains 'S'.
10590 * Don't copy when already initialized.
10591 * Don't copy when 'cpo' contains 's' and not entering.
10592 * 'S' BCO_ENTER initialized 's' should_copy
10593 * yes yes X X TRUE
10594 * yes no yes X FALSE
10595 * no X yes X FALSE
10596 * X no no yes FALSE
10597 * X no no no TRUE
10598 * no yes no X TRUE
10599 */
10600 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
10601 && (buf->b_p_initialized
10602 || (!(flags & BCO_ENTER)
10603 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
10604 should_copy = FALSE;
10605
10606 if (should_copy || (flags & BCO_ALWAYS))
10607 {
10608 /* Don't copy the options specific to a help buffer when
10609 * BCO_NOHELP is given or the options were initialized already
10610 * (jumping back to a help file with CTRL-T or CTRL-O) */
10611 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
10612 || buf->b_p_initialized;
10613 if (dont_do_help) /* don't free b_p_isk */
10614 {
10615 save_p_isk = buf->b_p_isk;
10616 buf->b_p_isk = NULL;
10617 }
10618 /*
10619 * Always free the allocated strings.
10620 * If not already initialized, set 'readonly' and copy 'fileformat'.
10621 */
10622 if (!buf->b_p_initialized)
10623 {
10624 free_buf_options(buf, TRUE);
10625 buf->b_p_ro = FALSE; /* don't copy readonly */
10626 buf->b_p_tx = p_tx;
10627#ifdef FEAT_MBYTE
10628 buf->b_p_fenc = vim_strsave(p_fenc);
10629#endif
10630 buf->b_p_ff = vim_strsave(p_ff);
10631#if defined(FEAT_QUICKFIX)
10632 buf->b_p_bh = empty_option;
10633 buf->b_p_bt = empty_option;
10634#endif
10635 }
10636 else
10637 free_buf_options(buf, FALSE);
10638
10639 buf->b_p_ai = p_ai;
10640 buf->b_p_ai_nopaste = p_ai_nopaste;
10641 buf->b_p_sw = p_sw;
10642 buf->b_p_tw = p_tw;
10643 buf->b_p_tw_nopaste = p_tw_nopaste;
10644 buf->b_p_tw_nobin = p_tw_nobin;
10645 buf->b_p_wm = p_wm;
10646 buf->b_p_wm_nopaste = p_wm_nopaste;
10647 buf->b_p_wm_nobin = p_wm_nobin;
10648 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000010649#ifdef FEAT_MBYTE
10650 buf->b_p_bomb = p_bomb;
10651#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010652 buf->b_p_et = p_et;
10653 buf->b_p_et_nobin = p_et_nobin;
10654 buf->b_p_ml = p_ml;
10655 buf->b_p_ml_nobin = p_ml_nobin;
10656 buf->b_p_inf = p_inf;
10657 buf->b_p_swf = p_swf;
10658#ifdef FEAT_INS_EXPAND
10659 buf->b_p_cpt = vim_strsave(p_cpt);
10660#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010661#ifdef FEAT_COMPL_FUNC
10662 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010663 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010664#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010665 buf->b_p_sts = p_sts;
10666 buf->b_p_sts_nopaste = p_sts_nopaste;
10667#ifndef SHORT_FNAME
10668 buf->b_p_sn = p_sn;
10669#endif
10670#ifdef FEAT_COMMENTS
10671 buf->b_p_com = vim_strsave(p_com);
10672#endif
10673#ifdef FEAT_FOLDING
10674 buf->b_p_cms = vim_strsave(p_cms);
10675#endif
10676 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010677 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010678 buf->b_p_nf = vim_strsave(p_nf);
10679 buf->b_p_mps = vim_strsave(p_mps);
10680#ifdef FEAT_SMARTINDENT
10681 buf->b_p_si = p_si;
10682#endif
10683 buf->b_p_ci = p_ci;
10684#ifdef FEAT_CINDENT
10685 buf->b_p_cin = p_cin;
10686 buf->b_p_cink = vim_strsave(p_cink);
10687 buf->b_p_cino = vim_strsave(p_cino);
10688#endif
10689#ifdef FEAT_AUTOCMD
10690 /* Don't copy 'filetype', it must be detected */
10691 buf->b_p_ft = empty_option;
10692#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010693 buf->b_p_pi = p_pi;
10694#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10695 buf->b_p_cinw = vim_strsave(p_cinw);
10696#endif
10697#ifdef FEAT_LISP
10698 buf->b_p_lisp = p_lisp;
10699#endif
10700#ifdef FEAT_SYN_HL
10701 /* Don't copy 'syntax', it must be set */
10702 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010703 buf->b_p_smc = p_smc;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010704#endif
10705#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020010706 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010707 (void)compile_cap_prog(&buf->b_s);
10708 buf->b_s.b_p_spf = vim_strsave(p_spf);
10709 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010710#endif
10711#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10712 buf->b_p_inde = vim_strsave(p_inde);
10713 buf->b_p_indk = vim_strsave(p_indk);
10714#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010715#if defined(FEAT_EVAL)
10716 buf->b_p_fex = vim_strsave(p_fex);
10717#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010718#ifdef FEAT_CRYPT
10719 buf->b_p_key = vim_strsave(p_key);
10720#endif
10721#ifdef FEAT_SEARCHPATH
10722 buf->b_p_sua = vim_strsave(p_sua);
10723#endif
10724#ifdef FEAT_KEYMAP
10725 buf->b_p_keymap = vim_strsave(p_keymap);
10726 buf->b_kmap_state |= KEYMAP_INIT;
10727#endif
10728 /* This isn't really an option, but copying the langmap and IME
10729 * state from the current buffer is better than resetting it. */
10730 buf->b_p_iminsert = p_iminsert;
10731 buf->b_p_imsearch = p_imsearch;
10732
10733 /* options that are normally global but also have a local value
10734 * are not copied, start using the global value */
10735 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010736 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010737 buf->b_p_bkc = empty_option;
10738 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010739#ifdef FEAT_QUICKFIX
10740 buf->b_p_gp = empty_option;
10741 buf->b_p_mp = empty_option;
10742 buf->b_p_efm = empty_option;
10743#endif
10744 buf->b_p_ep = empty_option;
10745 buf->b_p_kp = empty_option;
10746 buf->b_p_path = empty_option;
10747 buf->b_p_tags = empty_option;
10748#ifdef FEAT_FIND_ID
10749 buf->b_p_def = empty_option;
10750 buf->b_p_inc = empty_option;
10751# ifdef FEAT_EVAL
10752 buf->b_p_inex = vim_strsave(p_inex);
10753# endif
10754#endif
10755#ifdef FEAT_INS_EXPAND
10756 buf->b_p_dict = empty_option;
10757 buf->b_p_tsr = empty_option;
10758#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010759#ifdef FEAT_TEXTOBJ
10760 buf->b_p_qe = vim_strsave(p_qe);
10761#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010762#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10763 buf->b_p_bexpr = empty_option;
10764#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010765#if defined(FEAT_CRYPT)
10766 buf->b_p_cm = empty_option;
10767#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010768#ifdef FEAT_PERSISTENT_UNDO
10769 buf->b_p_udf = p_udf;
10770#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010771#ifdef FEAT_LISP
10772 buf->b_p_lw = empty_option;
10773#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010774
10775 /*
10776 * Don't copy the options set by ex_help(), use the saved values,
10777 * when going from a help buffer to a non-help buffer.
10778 * Don't touch these at all when BCO_NOHELP is used and going from
10779 * or to a help buffer.
10780 */
10781 if (dont_do_help)
10782 buf->b_p_isk = save_p_isk;
10783 else
10784 {
10785 buf->b_p_isk = vim_strsave(p_isk);
10786 did_isk = TRUE;
10787 buf->b_p_ts = p_ts;
10788 buf->b_help = FALSE;
10789#ifdef FEAT_QUICKFIX
10790 if (buf->b_p_bt[0] == 'h')
10791 clear_string_option(&buf->b_p_bt);
10792#endif
10793 buf->b_p_ma = p_ma;
10794 }
10795 }
10796
10797 /*
10798 * When the options should be copied (ignoring BCO_ALWAYS), set the
10799 * flag that indicates that the options have been initialized.
10800 */
10801 if (should_copy)
10802 buf->b_p_initialized = TRUE;
10803 }
10804
10805 check_buf_options(buf); /* make sure we don't have NULLs */
10806 if (did_isk)
10807 (void)buf_init_chartab(buf, FALSE);
10808}
10809
10810/*
10811 * Reset the 'modifiable' option and its default value.
10812 */
10813 void
10814reset_modifiable()
10815{
10816 int opt_idx;
10817
10818 curbuf->b_p_ma = FALSE;
10819 p_ma = FALSE;
10820 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000010821 if (opt_idx >= 0)
10822 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010823}
10824
10825/*
10826 * Set the global value for 'iminsert' to the local value.
10827 */
10828 void
10829set_iminsert_global()
10830{
10831 p_iminsert = curbuf->b_p_iminsert;
10832}
10833
10834/*
10835 * Set the global value for 'imsearch' to the local value.
10836 */
10837 void
10838set_imsearch_global()
10839{
10840 p_imsearch = curbuf->b_p_imsearch;
10841}
10842
10843#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
10844static int expand_option_idx = -1;
10845static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
10846static int expand_option_flags = 0;
10847
10848 void
10849set_context_in_set_cmd(xp, arg, opt_flags)
10850 expand_T *xp;
10851 char_u *arg;
10852 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
10853{
10854 int nextchar;
10855 long_u flags = 0; /* init for GCC */
10856 int opt_idx = 0; /* init for GCC */
10857 char_u *p;
10858 char_u *s;
10859 int is_term_option = FALSE;
10860 int key;
10861
10862 expand_option_flags = opt_flags;
10863
10864 xp->xp_context = EXPAND_SETTINGS;
10865 if (*arg == NUL)
10866 {
10867 xp->xp_pattern = arg;
10868 return;
10869 }
10870 p = arg + STRLEN(arg) - 1;
10871 if (*p == ' ' && *(p - 1) != '\\')
10872 {
10873 xp->xp_pattern = p + 1;
10874 return;
10875 }
10876 while (p > arg)
10877 {
10878 s = p;
10879 /* count number of backslashes before ' ' or ',' */
10880 if (*p == ' ' || *p == ',')
10881 {
10882 while (s > arg && *(s - 1) == '\\')
10883 --s;
10884 }
10885 /* break at a space with an even number of backslashes */
10886 if (*p == ' ' && ((p - s) & 1) == 0)
10887 {
10888 ++p;
10889 break;
10890 }
10891 --p;
10892 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000010893 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010894 {
10895 xp->xp_context = EXPAND_BOOL_SETTINGS;
10896 p += 2;
10897 }
10898 if (STRNCMP(p, "inv", 3) == 0)
10899 {
10900 xp->xp_context = EXPAND_BOOL_SETTINGS;
10901 p += 3;
10902 }
10903 xp->xp_pattern = arg = p;
10904 if (*arg == '<')
10905 {
10906 while (*p != '>')
10907 if (*p++ == NUL) /* expand terminal option name */
10908 return;
10909 key = get_special_key_code(arg + 1);
10910 if (key == 0) /* unknown name */
10911 {
10912 xp->xp_context = EXPAND_NOTHING;
10913 return;
10914 }
10915 nextchar = *++p;
10916 is_term_option = TRUE;
10917 expand_option_name[2] = KEY2TERMCAP0(key);
10918 expand_option_name[3] = KEY2TERMCAP1(key);
10919 }
10920 else
10921 {
10922 if (p[0] == 't' && p[1] == '_')
10923 {
10924 p += 2;
10925 if (*p != NUL)
10926 ++p;
10927 if (*p == NUL)
10928 return; /* expand option name */
10929 nextchar = *++p;
10930 is_term_option = TRUE;
10931 expand_option_name[2] = p[-2];
10932 expand_option_name[3] = p[-1];
10933 }
10934 else
10935 {
10936 /* Allow * wildcard */
10937 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
10938 p++;
10939 if (*p == NUL)
10940 return;
10941 nextchar = *p;
10942 *p = NUL;
10943 opt_idx = findoption(arg);
10944 *p = nextchar;
10945 if (opt_idx == -1 || options[opt_idx].var == NULL)
10946 {
10947 xp->xp_context = EXPAND_NOTHING;
10948 return;
10949 }
10950 flags = options[opt_idx].flags;
10951 if (flags & P_BOOL)
10952 {
10953 xp->xp_context = EXPAND_NOTHING;
10954 return;
10955 }
10956 }
10957 }
10958 /* handle "-=" and "+=" */
10959 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
10960 {
10961 ++p;
10962 nextchar = '=';
10963 }
10964 if ((nextchar != '=' && nextchar != ':')
10965 || xp->xp_context == EXPAND_BOOL_SETTINGS)
10966 {
10967 xp->xp_context = EXPAND_UNSUCCESSFUL;
10968 return;
10969 }
10970 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
10971 {
10972 xp->xp_context = EXPAND_OLD_SETTING;
10973 if (is_term_option)
10974 expand_option_idx = -1;
10975 else
10976 expand_option_idx = opt_idx;
10977 xp->xp_pattern = p + 1;
10978 return;
10979 }
10980 xp->xp_context = EXPAND_NOTHING;
10981 if (is_term_option || (flags & P_NUM))
10982 return;
10983
10984 xp->xp_pattern = p + 1;
10985
10986 if (flags & P_EXPAND)
10987 {
10988 p = options[opt_idx].var;
10989 if (p == (char_u *)&p_bdir
10990 || p == (char_u *)&p_dir
10991 || p == (char_u *)&p_path
10992 || p == (char_u *)&p_rtp
10993#ifdef FEAT_SEARCHPATH
10994 || p == (char_u *)&p_cdpath
10995#endif
10996#ifdef FEAT_SESSION
10997 || p == (char_u *)&p_vdir
10998#endif
10999 )
11000 {
11001 xp->xp_context = EXPAND_DIRECTORIES;
11002 if (p == (char_u *)&p_path
11003#ifdef FEAT_SEARCHPATH
11004 || p == (char_u *)&p_cdpath
11005#endif
11006 )
11007 xp->xp_backslash = XP_BS_THREE;
11008 else
11009 xp->xp_backslash = XP_BS_ONE;
11010 }
11011 else
11012 {
11013 xp->xp_context = EXPAND_FILES;
11014 /* for 'tags' need three backslashes for a space */
11015 if (p == (char_u *)&p_tags)
11016 xp->xp_backslash = XP_BS_THREE;
11017 else
11018 xp->xp_backslash = XP_BS_ONE;
11019 }
11020 }
11021
11022 /* For an option that is a list of file names, find the start of the
11023 * last file name. */
11024 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11025 {
11026 /* count number of backslashes before ' ' or ',' */
11027 if (*p == ' ' || *p == ',')
11028 {
11029 s = p;
11030 while (s > xp->xp_pattern && *(s - 1) == '\\')
11031 --s;
11032 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11033 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11034 {
11035 xp->xp_pattern = p + 1;
11036 break;
11037 }
11038 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011039
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011040#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011041 /* for 'spellsuggest' start at "file:" */
11042 if (options[opt_idx].var == (char_u *)&p_sps
11043 && STRNCMP(p, "file:", 5) == 0)
11044 {
11045 xp->xp_pattern = p + 5;
11046 break;
11047 }
11048#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011049 }
11050
11051 return;
11052}
11053
11054 int
11055ExpandSettings(xp, regmatch, num_file, file)
11056 expand_T *xp;
11057 regmatch_T *regmatch;
11058 int *num_file;
11059 char_u ***file;
11060{
11061 int num_normal = 0; /* Nr of matching non-term-code settings */
11062 int num_term = 0; /* Nr of matching terminal code settings */
11063 int opt_idx;
11064 int match;
11065 int count = 0;
11066 char_u *str;
11067 int loop;
11068 int is_term_opt;
11069 char_u name_buf[MAX_KEY_NAME_LEN];
11070 static char *(names[]) = {"all", "termcap"};
11071 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11072
11073 /* do this loop twice:
11074 * loop == 0: count the number of matching options
11075 * loop == 1: copy the matching options into allocated memory
11076 */
11077 for (loop = 0; loop <= 1; ++loop)
11078 {
11079 regmatch->rm_ic = ic;
11080 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11081 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011082 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11083 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011084 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11085 {
11086 if (loop == 0)
11087 num_normal++;
11088 else
11089 (*file)[count++] = vim_strsave((char_u *)names[match]);
11090 }
11091 }
11092 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11093 opt_idx++)
11094 {
11095 if (options[opt_idx].var == NULL)
11096 continue;
11097 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11098 && !(options[opt_idx].flags & P_BOOL))
11099 continue;
11100 is_term_opt = istermoption(&options[opt_idx]);
11101 if (is_term_opt && num_normal > 0)
11102 continue;
11103 match = FALSE;
11104 if (vim_regexec(regmatch, str, (colnr_T)0)
11105 || (options[opt_idx].shortname != NULL
11106 && vim_regexec(regmatch,
11107 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11108 match = TRUE;
11109 else if (is_term_opt)
11110 {
11111 name_buf[0] = '<';
11112 name_buf[1] = 't';
11113 name_buf[2] = '_';
11114 name_buf[3] = str[2];
11115 name_buf[4] = str[3];
11116 name_buf[5] = '>';
11117 name_buf[6] = NUL;
11118 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11119 {
11120 match = TRUE;
11121 str = name_buf;
11122 }
11123 }
11124 if (match)
11125 {
11126 if (loop == 0)
11127 {
11128 if (is_term_opt)
11129 num_term++;
11130 else
11131 num_normal++;
11132 }
11133 else
11134 (*file)[count++] = vim_strsave(str);
11135 }
11136 }
11137 /*
11138 * Check terminal key codes, these are not in the option table
11139 */
11140 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11141 {
11142 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11143 {
11144 if (!isprint(str[0]) || !isprint(str[1]))
11145 continue;
11146
11147 name_buf[0] = 't';
11148 name_buf[1] = '_';
11149 name_buf[2] = str[0];
11150 name_buf[3] = str[1];
11151 name_buf[4] = NUL;
11152
11153 match = FALSE;
11154 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11155 match = TRUE;
11156 else
11157 {
11158 name_buf[0] = '<';
11159 name_buf[1] = 't';
11160 name_buf[2] = '_';
11161 name_buf[3] = str[0];
11162 name_buf[4] = str[1];
11163 name_buf[5] = '>';
11164 name_buf[6] = NUL;
11165
11166 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11167 match = TRUE;
11168 }
11169 if (match)
11170 {
11171 if (loop == 0)
11172 num_term++;
11173 else
11174 (*file)[count++] = vim_strsave(name_buf);
11175 }
11176 }
11177
11178 /*
11179 * Check special key names.
11180 */
11181 regmatch->rm_ic = TRUE; /* ignore case here */
11182 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11183 {
11184 name_buf[0] = '<';
11185 STRCPY(name_buf + 1, str);
11186 STRCAT(name_buf, ">");
11187
11188 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11189 {
11190 if (loop == 0)
11191 num_term++;
11192 else
11193 (*file)[count++] = vim_strsave(name_buf);
11194 }
11195 }
11196 }
11197 if (loop == 0)
11198 {
11199 if (num_normal > 0)
11200 *num_file = num_normal;
11201 else if (num_term > 0)
11202 *num_file = num_term;
11203 else
11204 return OK;
11205 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11206 if (*file == NULL)
11207 {
11208 *file = (char_u **)"";
11209 return FAIL;
11210 }
11211 }
11212 }
11213 return OK;
11214}
11215
11216 int
11217ExpandOldSetting(num_file, file)
11218 int *num_file;
11219 char_u ***file;
11220{
11221 char_u *var = NULL; /* init for GCC */
11222 char_u *buf;
11223
11224 *num_file = 0;
11225 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11226 if (*file == NULL)
11227 return FAIL;
11228
11229 /*
11230 * For a terminal key code expand_option_idx is < 0.
11231 */
11232 if (expand_option_idx < 0)
11233 {
11234 var = find_termcode(expand_option_name + 2);
11235 if (var == NULL)
11236 expand_option_idx = findoption(expand_option_name);
11237 }
11238
11239 if (expand_option_idx >= 0)
11240 {
11241 /* put string of option value in NameBuff */
11242 option_value2string(&options[expand_option_idx], expand_option_flags);
11243 var = NameBuff;
11244 }
11245 else if (var == NULL)
11246 var = (char_u *)"";
11247
11248 /* A backslash is required before some characters. This is the reverse of
11249 * what happens in do_set(). */
11250 buf = vim_strsave_escaped(var, escape_chars);
11251
11252 if (buf == NULL)
11253 {
11254 vim_free(*file);
11255 *file = NULL;
11256 return FAIL;
11257 }
11258
11259#ifdef BACKSLASH_IN_FILENAME
11260 /* For MS-Windows et al. we don't double backslashes at the start and
11261 * before a file name character. */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011262 for (var = buf; *var != NUL; mb_ptr_adv(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011263 if (var[0] == '\\' && var[1] == '\\'
11264 && expand_option_idx >= 0
11265 && (options[expand_option_idx].flags & P_EXPAND)
11266 && vim_isfilec(var[2])
11267 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011268 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011269#endif
11270
11271 *file[0] = buf;
11272 *num_file = 1;
11273 return OK;
11274}
11275#endif
11276
11277/*
11278 * Get the value for the numeric or string option *opp in a nice format into
11279 * NameBuff[]. Must not be called with a hidden option!
11280 */
11281 static void
11282option_value2string(opp, opt_flags)
11283 struct vimoption *opp;
11284 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
11285{
11286 char_u *varp;
11287
11288 varp = get_varp_scope(opp, opt_flags);
11289
11290 if (opp->flags & P_NUM)
11291 {
11292 long wc = 0;
11293
11294 if (wc_use_keyname(varp, &wc))
11295 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11296 else if (wc != 0)
11297 STRCPY(NameBuff, transchar((int)wc));
11298 else
11299 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11300 }
11301 else /* P_STRING */
11302 {
11303 varp = *(char_u **)(varp);
11304 if (varp == NULL) /* just in case */
11305 NameBuff[0] = NUL;
11306#ifdef FEAT_CRYPT
11307 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011308 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011309 STRCPY(NameBuff, "*****");
11310#endif
11311 else if (opp->flags & P_EXPAND)
11312 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11313 /* Translate 'pastetoggle' into special key names */
11314 else if ((char_u **)opp->var == &p_pt)
11315 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11316 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011317 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011318 }
11319}
11320
11321/*
11322 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11323 * printed as a keyname.
11324 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11325 */
11326 static int
11327wc_use_keyname(varp, wcp)
11328 char_u *varp;
11329 long *wcp;
11330{
11331 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11332 {
11333 *wcp = *(long *)varp;
11334 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11335 return TRUE;
11336 }
11337 return FALSE;
11338}
11339
Bram Moolenaar01615492015-02-03 13:00:38 +010011340#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011341/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011342 * Any character has an equivalent 'langmap' character. This is used for
11343 * keyboards that have a special language mode that sends characters above
11344 * 128 (although other characters can be translated too). The "to" field is a
11345 * Vim command character. This avoids having to switch the keyboard back to
11346 * ASCII mode when leaving Insert mode.
11347 *
11348 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11349 * commands.
11350 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11351 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11352 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011353 */
Bram Moolenaar01615492015-02-03 13:00:38 +010011354# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011355/*
11356 * With multi-byte support use growarray for 'langmap' chars >= 256
11357 */
11358typedef struct
11359{
11360 int from;
11361 int to;
11362} langmap_entry_T;
11363
11364static garray_T langmap_mapga;
11365static void langmap_set_entry __ARGS((int from, int to));
Bram Moolenaar071d4272004-06-13 20:20:40 +000011366
11367/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011368 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11369 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011370 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011371 static void
11372langmap_set_entry(from, to)
11373 int from;
11374 int to;
11375{
11376 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011377 int a = 0;
11378 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011379
11380 /* Do a binary search for an existing entry. */
11381 while (a != b)
11382 {
11383 int i = (a + b) / 2;
11384 int d = entries[i].from - from;
11385
11386 if (d == 0)
11387 {
11388 entries[i].to = to;
11389 return;
11390 }
11391 if (d < 0)
11392 a = i + 1;
11393 else
11394 b = i;
11395 }
11396
11397 if (ga_grow(&langmap_mapga, 1) != OK)
11398 return; /* out of memory */
11399
11400 /* insert new entry at position "a" */
11401 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11402 mch_memmove(entries + 1, entries,
11403 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11404 ++langmap_mapga.ga_len;
11405 entries[0].from = from;
11406 entries[0].to = to;
11407}
11408
11409/*
11410 * Apply 'langmap' to multi-byte character "c" and return the result.
11411 */
11412 int
11413langmap_adjust_mb(c)
11414 int c;
11415{
11416 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11417 int a = 0;
11418 int b = langmap_mapga.ga_len;
11419
11420 while (a != b)
11421 {
11422 int i = (a + b) / 2;
11423 int d = entries[i].from - c;
11424
11425 if (d == 0)
11426 return entries[i].to; /* found matching entry */
11427 if (d < 0)
11428 a = i + 1;
11429 else
11430 b = i;
11431 }
11432 return c; /* no entry found, return "c" unmodified */
11433}
11434# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011435
11436 static void
11437langmap_init()
11438{
11439 int i;
11440
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011441 for (i = 0; i < 256; i++)
11442 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11443# ifdef FEAT_MBYTE
11444 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11445# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011446}
11447
11448/*
11449 * Called when langmap option is set; the language map can be
11450 * changed at any time!
11451 */
11452 static void
11453langmap_set()
11454{
11455 char_u *p;
11456 char_u *p2;
11457 int from, to;
11458
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011459#ifdef FEAT_MBYTE
11460 ga_clear(&langmap_mapga); /* clear the previous map first */
11461#endif
11462 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011463
11464 for (p = p_langmap; p[0] != NUL; )
11465 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011466 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
11467 mb_ptr_adv(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011468 {
11469 if (p2[0] == '\\' && p2[1] != NUL)
11470 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011471 }
11472 if (p2[0] == ';')
11473 ++p2; /* abcd;ABCD form, p2 points to A */
11474 else
11475 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11476 while (p[0])
11477 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011478 if (p[0] == ',')
11479 {
11480 ++p;
11481 break;
11482 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011483 if (p[0] == '\\' && p[1] != NUL)
11484 ++p;
11485#ifdef FEAT_MBYTE
11486 from = (*mb_ptr2char)(p);
11487#else
11488 from = p[0];
11489#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011490 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011491 if (p2 == NULL)
11492 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011493 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011494 if (p[0] != ',')
11495 {
11496 if (p[0] == '\\')
11497 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011498#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011499 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011500#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011501 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011502#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011503 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011504 }
11505 else
11506 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011507 if (p2[0] != ',')
11508 {
11509 if (p2[0] == '\\')
11510 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011511#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011512 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011513#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011514 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011515#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011516 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011517 }
11518 if (to == NUL)
11519 {
11520 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
11521 transchar(from));
11522 return;
11523 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011524
11525#ifdef FEAT_MBYTE
11526 if (from >= 256)
11527 langmap_set_entry(from, to);
11528 else
11529#endif
11530 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011531
11532 /* Advance to next pair */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011533 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011534 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011535 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011536 mb_ptr_adv(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011537 if (*p == ';')
11538 {
11539 p = p2;
11540 if (p[0] != NUL)
11541 {
11542 if (p[0] != ',')
11543 {
11544 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
11545 return;
11546 }
11547 ++p;
11548 }
11549 break;
11550 }
11551 }
11552 }
11553 }
11554}
11555#endif
11556
11557/*
11558 * Return TRUE if format option 'x' is in effect.
11559 * Take care of no formatting when 'paste' is set.
11560 */
11561 int
11562has_format_option(x)
11563 int x;
11564{
11565 if (p_paste)
11566 return FALSE;
11567 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
11568}
11569
11570/*
11571 * Return TRUE if "x" is present in 'shortmess' option, or
11572 * 'shortmess' contains 'a' and "x" is present in SHM_A.
11573 */
11574 int
11575shortmess(x)
11576 int x;
11577{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010011578 return p_shm != NULL &&
11579 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000011580 || (vim_strchr(p_shm, 'a') != NULL
11581 && vim_strchr((char_u *)SHM_A, x) != NULL));
11582}
11583
11584/*
11585 * paste_option_changed() - Called after p_paste was set or reset.
11586 */
11587 static void
11588paste_option_changed()
11589{
11590 static int old_p_paste = FALSE;
11591 static int save_sm = 0;
11592#ifdef FEAT_CMDL_INFO
11593 static int save_ru = 0;
11594#endif
11595#ifdef FEAT_RIGHTLEFT
11596 static int save_ri = 0;
11597 static int save_hkmap = 0;
11598#endif
11599 buf_T *buf;
11600
11601 if (p_paste)
11602 {
11603 /*
11604 * Paste switched from off to on.
11605 * Save the current values, so they can be restored later.
11606 */
11607 if (!old_p_paste)
11608 {
11609 /* save options for each buffer */
11610 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11611 {
11612 buf->b_p_tw_nopaste = buf->b_p_tw;
11613 buf->b_p_wm_nopaste = buf->b_p_wm;
11614 buf->b_p_sts_nopaste = buf->b_p_sts;
11615 buf->b_p_ai_nopaste = buf->b_p_ai;
11616 }
11617
11618 /* save global options */
11619 save_sm = p_sm;
11620#ifdef FEAT_CMDL_INFO
11621 save_ru = p_ru;
11622#endif
11623#ifdef FEAT_RIGHTLEFT
11624 save_ri = p_ri;
11625 save_hkmap = p_hkmap;
11626#endif
11627 /* save global values for local buffer options */
11628 p_tw_nopaste = p_tw;
11629 p_wm_nopaste = p_wm;
11630 p_sts_nopaste = p_sts;
11631 p_ai_nopaste = p_ai;
11632 }
11633
11634 /*
11635 * Always set the option values, also when 'paste' is set when it is
11636 * already on.
11637 */
11638 /* set options for each buffer */
11639 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11640 {
11641 buf->b_p_tw = 0; /* textwidth is 0 */
11642 buf->b_p_wm = 0; /* wrapmargin is 0 */
11643 buf->b_p_sts = 0; /* softtabstop is 0 */
11644 buf->b_p_ai = 0; /* no auto-indent */
11645 }
11646
11647 /* set global options */
11648 p_sm = 0; /* no showmatch */
11649#ifdef FEAT_CMDL_INFO
11650# ifdef FEAT_WINDOWS
11651 if (p_ru)
11652 status_redraw_all(); /* redraw to remove the ruler */
11653# endif
11654 p_ru = 0; /* no ruler */
11655#endif
11656#ifdef FEAT_RIGHTLEFT
11657 p_ri = 0; /* no reverse insert */
11658 p_hkmap = 0; /* no Hebrew keyboard */
11659#endif
11660 /* set global values for local buffer options */
11661 p_tw = 0;
11662 p_wm = 0;
11663 p_sts = 0;
11664 p_ai = 0;
11665 }
11666
11667 /*
11668 * Paste switched from on to off: Restore saved values.
11669 */
11670 else if (old_p_paste)
11671 {
11672 /* restore options for each buffer */
11673 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11674 {
11675 buf->b_p_tw = buf->b_p_tw_nopaste;
11676 buf->b_p_wm = buf->b_p_wm_nopaste;
11677 buf->b_p_sts = buf->b_p_sts_nopaste;
11678 buf->b_p_ai = buf->b_p_ai_nopaste;
11679 }
11680
11681 /* restore global options */
11682 p_sm = save_sm;
11683#ifdef FEAT_CMDL_INFO
11684# ifdef FEAT_WINDOWS
11685 if (p_ru != save_ru)
11686 status_redraw_all(); /* redraw to draw the ruler */
11687# endif
11688 p_ru = save_ru;
11689#endif
11690#ifdef FEAT_RIGHTLEFT
11691 p_ri = save_ri;
11692 p_hkmap = save_hkmap;
11693#endif
11694 /* set global values for local buffer options */
11695 p_tw = p_tw_nopaste;
11696 p_wm = p_wm_nopaste;
11697 p_sts = p_sts_nopaste;
11698 p_ai = p_ai_nopaste;
11699 }
11700
11701 old_p_paste = p_paste;
11702}
11703
11704/*
11705 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
11706 *
11707 * Reset 'compatible' and set the values for options that didn't get set yet
11708 * to the Vim defaults.
11709 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011710 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011711 */
11712 void
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011713vimrc_found(fname, envname)
11714 char_u *fname;
11715 char_u *envname;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011716{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011717 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000011718 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011719 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011720
11721 if (!option_was_set((char_u *)"cp"))
11722 {
11723 p_cp = FALSE;
11724 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11725 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
11726 set_option_default(opt_idx, OPT_FREE, FALSE);
11727 didset_options();
11728 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011729
11730 if (fname != NULL)
11731 {
11732 p = vim_getenv(envname, &dofree);
11733 if (p == NULL)
11734 {
11735 /* Set $MYVIMRC to the first vimrc file found. */
11736 p = FullName_save(fname, FALSE);
11737 if (p != NULL)
11738 {
11739 vim_setenv(envname, p);
11740 vim_free(p);
11741 }
11742 }
11743 else if (dofree)
11744 vim_free(p);
11745 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011746}
11747
11748/*
11749 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
11750 */
11751 void
11752change_compatible(on)
11753 int on;
11754{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011755 int opt_idx;
11756
Bram Moolenaar071d4272004-06-13 20:20:40 +000011757 if (p_cp != on)
11758 {
11759 p_cp = on;
11760 compatible_set();
11761 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011762 opt_idx = findoption((char_u *)"cp");
11763 if (opt_idx >= 0)
11764 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011765}
11766
11767/*
11768 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020011769 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011770 */
11771 int
11772option_was_set(name)
11773 char_u *name;
11774{
11775 int idx;
11776
11777 idx = findoption(name);
11778 if (idx < 0) /* unknown option */
11779 return FALSE;
11780 if (options[idx].flags & P_WAS_SET)
11781 return TRUE;
11782 return FALSE;
11783}
11784
11785/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010011786 * Reset the flag indicating option "name" was set.
11787 */
11788 void
11789reset_option_was_set(name)
11790 char_u *name;
11791{
11792 int idx = findoption(name);
11793
11794 if (idx >= 0)
11795 options[idx].flags &= ~P_WAS_SET;
11796}
11797
11798/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011799 * compatible_set() - Called when 'compatible' has been set or unset.
11800 *
11801 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
11802 * flag) to a Vi compatible value.
11803 * When 'compatible' is unset: Set all options that have a different default
11804 * for Vim (without the P_VI_DEF flag) to that default.
11805 */
11806 static void
11807compatible_set()
11808{
11809 int opt_idx;
11810
11811 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11812 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
11813 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
11814 set_option_default(opt_idx, OPT_FREE, p_cp);
11815 didset_options();
11816}
11817
11818#ifdef FEAT_LINEBREAK
11819
11820# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
11821 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011822 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011823# endif
11824
11825/*
11826 * fill_breakat_flags() -- called when 'breakat' changes value.
11827 */
11828 static void
11829fill_breakat_flags()
11830{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011831 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011832 int i;
11833
11834 for (i = 0; i < 256; i++)
11835 breakat_flags[i] = FALSE;
11836
11837 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011838 for (p = p_breakat; *p; p++)
11839 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011840}
11841
11842# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011843 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011844# endif
11845
11846#endif
11847
11848/*
11849 * Check an option that can be a range of string values.
11850 *
11851 * Return OK for correct value, FAIL otherwise.
11852 * Empty is always OK.
11853 */
11854 static int
11855check_opt_strings(val, values, list)
11856 char_u *val;
11857 char **values;
11858 int list; /* when TRUE: accept a list of values */
11859{
11860 return opt_strings_flags(val, values, NULL, list);
11861}
11862
11863/*
11864 * Handle an option that can be a range of string values.
11865 * Set a flag in "*flagp" for each string present.
11866 *
11867 * Return OK for correct value, FAIL otherwise.
11868 * Empty is always OK.
11869 */
11870 static int
11871opt_strings_flags(val, values, flagp, list)
11872 char_u *val; /* new value */
11873 char **values; /* array of valid string values */
11874 unsigned *flagp;
11875 int list; /* when TRUE: accept a list of values */
11876{
11877 int i;
11878 int len;
11879 unsigned new_flags = 0;
11880
11881 while (*val)
11882 {
11883 for (i = 0; ; ++i)
11884 {
11885 if (values[i] == NULL) /* val not found in values[] */
11886 return FAIL;
11887
11888 len = (int)STRLEN(values[i]);
11889 if (STRNCMP(values[i], val, len) == 0
11890 && ((list && val[len] == ',') || val[len] == NUL))
11891 {
11892 val += len + (val[len] == ',');
11893 new_flags |= (1 << i);
11894 break; /* check next item in val list */
11895 }
11896 }
11897 }
11898 if (flagp != NULL)
11899 *flagp = new_flags;
11900
11901 return OK;
11902}
11903
11904/*
11905 * Read the 'wildmode' option, fill wim_flags[].
11906 */
11907 static int
11908check_opt_wim()
11909{
11910 char_u new_wim_flags[4];
11911 char_u *p;
11912 int i;
11913 int idx = 0;
11914
11915 for (i = 0; i < 4; ++i)
11916 new_wim_flags[i] = 0;
11917
11918 for (p = p_wim; *p; ++p)
11919 {
11920 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
11921 ;
11922 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
11923 return FAIL;
11924 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
11925 new_wim_flags[idx] |= WIM_LONGEST;
11926 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
11927 new_wim_flags[idx] |= WIM_FULL;
11928 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
11929 new_wim_flags[idx] |= WIM_LIST;
11930 else
11931 return FAIL;
11932 p += i;
11933 if (*p == NUL)
11934 break;
11935 if (*p == ',')
11936 {
11937 if (idx == 3)
11938 return FAIL;
11939 ++idx;
11940 }
11941 }
11942
11943 /* fill remaining entries with last flag */
11944 while (idx < 3)
11945 {
11946 new_wim_flags[idx + 1] = new_wim_flags[idx];
11947 ++idx;
11948 }
11949
11950 /* only when there are no errors, wim_flags[] is changed */
11951 for (i = 0; i < 4; ++i)
11952 wim_flags[i] = new_wim_flags[i];
11953 return OK;
11954}
11955
11956/*
11957 * Check if backspacing over something is allowed.
11958 */
11959 int
11960can_bs(what)
11961 int what; /* BS_INDENT, BS_EOL or BS_START */
11962{
11963 switch (*p_bs)
11964 {
11965 case '2': return TRUE;
11966 case '1': return (what != BS_START);
11967 case '0': return FALSE;
11968 }
11969 return vim_strchr(p_bs, what) != NULL;
11970}
11971
11972/*
11973 * Save the current values of 'fileformat' and 'fileencoding', so that we know
11974 * the file must be considered changed when the value is different.
11975 */
11976 void
11977save_file_ff(buf)
11978 buf_T *buf;
11979{
11980 buf->b_start_ffc = *buf->b_p_ff;
11981 buf->b_start_eol = buf->b_p_eol;
11982#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011983 buf->b_start_bomb = buf->b_p_bomb;
11984
Bram Moolenaar071d4272004-06-13 20:20:40 +000011985 /* Only use free/alloc when necessary, they take time. */
11986 if (buf->b_start_fenc == NULL
11987 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
11988 {
11989 vim_free(buf->b_start_fenc);
11990 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
11991 }
11992#endif
11993}
11994
11995/*
11996 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
11997 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011998 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
11999 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012000 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012001 * When "ignore_empty" is true don't consider a new, empty buffer to be
12002 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012003 */
12004 int
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012005file_ff_differs(buf, ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012006 buf_T *buf;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012007 int ignore_empty;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012008{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012009 /* In a buffer that was never loaded the options are not valid. */
12010 if (buf->b_flags & BF_NEVERLOADED)
12011 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012012 if (ignore_empty
12013 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012014 && buf->b_ml.ml_line_count == 1
12015 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12016 return FALSE;
12017 if (buf->b_start_ffc != *buf->b_p_ff)
12018 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012019 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012020 return TRUE;
12021#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012022 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12023 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012024 if (buf->b_start_fenc == NULL)
12025 return (*buf->b_p_fenc != NUL);
12026 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12027#else
12028 return FALSE;
12029#endif
12030}
12031
12032/*
12033 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12034 */
12035 int
12036check_ff_value(p)
12037 char_u *p;
12038{
12039 return check_opt_strings(p, p_ff_values, FALSE);
12040}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012041
12042/*
12043 * Return the effective shiftwidth value for current buffer, using the
12044 * 'tabstop' value when 'shiftwidth' is zero.
12045 */
12046 long
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012047get_sw_value(buf)
12048 buf_T *buf;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012049{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012050 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012051}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012052
12053/*
12054 * Return the effective softtabstop value for the current buffer, using the
12055 * 'tabstop' value when 'softtabstop' is negative.
12056 */
12057 long
12058get_sts_value()
12059{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012060 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012061}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012062
12063/*
12064 * Check matchpairs option for "*initc".
12065 * If there is a match set "*initc" to the matching character and "*findc" to
12066 * the opposite character. Set "*backwards" to the direction.
12067 * When "switchit" is TRUE swap the direction.
12068 */
12069 void
12070find_mps_values(initc, findc, backwards, switchit)
12071 int *initc;
12072 int *findc;
12073 int *backwards;
12074 int switchit;
12075{
12076 char_u *ptr;
12077
12078 ptr = curbuf->b_p_mps;
12079 while (*ptr != NUL)
12080 {
12081#ifdef FEAT_MBYTE
12082 if (has_mbyte)
12083 {
12084 char_u *prev;
12085
12086 if (mb_ptr2char(ptr) == *initc)
12087 {
12088 if (switchit)
12089 {
12090 *findc = *initc;
12091 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12092 *backwards = TRUE;
12093 }
12094 else
12095 {
12096 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12097 *backwards = FALSE;
12098 }
12099 return;
12100 }
12101 prev = ptr;
12102 ptr += mb_ptr2len(ptr) + 1;
12103 if (mb_ptr2char(ptr) == *initc)
12104 {
12105 if (switchit)
12106 {
12107 *findc = *initc;
12108 *initc = mb_ptr2char(prev);
12109 *backwards = FALSE;
12110 }
12111 else
12112 {
12113 *findc = mb_ptr2char(prev);
12114 *backwards = TRUE;
12115 }
12116 return;
12117 }
12118 ptr += mb_ptr2len(ptr);
12119 }
12120 else
12121#endif
12122 {
12123 if (*ptr == *initc)
12124 {
12125 if (switchit)
12126 {
12127 *backwards = TRUE;
12128 *findc = *initc;
12129 *initc = ptr[2];
12130 }
12131 else
12132 {
12133 *backwards = FALSE;
12134 *findc = ptr[2];
12135 }
12136 return;
12137 }
12138 ptr += 2;
12139 if (*ptr == *initc)
12140 {
12141 if (switchit)
12142 {
12143 *backwards = FALSE;
12144 *findc = *initc;
12145 *initc = ptr[-2];
12146 }
12147 else
12148 {
12149 *backwards = TRUE;
12150 *findc = ptr[-2];
12151 }
12152 return;
12153 }
12154 ++ptr;
12155 }
12156 if (*ptr == ',')
12157 ++ptr;
12158 }
12159}
Bram Moolenaar597a4222014-06-25 14:39:50 +020012160
12161#if defined(FEAT_LINEBREAK) || defined(PROTO)
12162/*
12163 * This is called when 'breakindentopt' is changed and when a window is
12164 * initialized.
12165 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012166 static int
12167briopt_check(wp)
12168 win_T *wp;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012169{
12170 char_u *p;
12171 int bri_shift = 0;
12172 long bri_min = 20;
12173 int bri_sbr = FALSE;
12174
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012175 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012176 while (*p != NUL)
12177 {
12178 if (STRNCMP(p, "shift:", 6) == 0
12179 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
12180 {
12181 p += 6;
12182 bri_shift = getdigits(&p);
12183 }
12184 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
12185 {
12186 p += 4;
12187 bri_min = getdigits(&p);
12188 }
12189 else if (STRNCMP(p, "sbr", 3) == 0)
12190 {
12191 p += 3;
12192 bri_sbr = TRUE;
12193 }
12194 if (*p != ',' && *p != NUL)
12195 return FAIL;
12196 if (*p == ',')
12197 ++p;
12198 }
12199
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012200 wp->w_p_brishift = bri_shift;
12201 wp->w_p_brimin = bri_min;
12202 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012203
12204 return OK;
12205}
12206#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012207
12208/*
12209 * Get the local or global value of 'backupcopy'.
12210 */
12211 unsigned int
12212get_bkc_value(buf)
12213 buf_T *buf;
12214{
12215 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
12216}