blob: b0f28d2593c07fb73b90bd1c4d7ad530fe10bbae [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001/* vi:set ts=8 sts=4 sw=4:
2 *
3 * VIM - Vi IMproved by Bram Moolenaar
4 *
5 * Do ":help uganda" in Vim to read copying and usage conditions.
6 * Do ":help credits" in Vim to see a list of people who contributed.
7 * See README.txt for an overview of the Vim source code.
8 */
9
10/*
11 * Code to handle user-settable options. This is all pretty much table-
12 * driven. Checklist for adding a new option:
13 * - Put it in the options array below (copy an existing entry).
14 * - For a global option: Add a variable for it in option.h.
15 * - For a buffer or window local option:
16 * - Add a PV_XX entry to the enum below.
17 * - Add a variable to the window or buffer struct in structs.h.
18 * - For a window option, add some code to copy_winopt().
19 * - For a buffer option, add some code to buf_copy_options().
20 * - For a buffer string option, add code to check_buf_options().
21 * - If it's a numeric option, add any necessary bounds checks to do_set().
22 * - If it's a list of flags, add some code in do_set(), search for WW_ALL.
23 * - When adding an option with expansion (P_EXPAND), but with a different
24 * default for Vi and Vim (no P_VI_DEF), add some code at VIMEXP.
25 * - Add documentation! One line in doc/help.txt, full description in
26 * options.txt, and any other related places.
27 * - Add an entry in runtime/optwin.vim.
28 * When making changes:
29 * - Adjust the help for the option in doc/option.txt.
30 * - When an entry has the P_VIM flag, or is lacking the P_VI_DEF flag, add a
31 * comment at the help for the 'compatible' option.
32 */
33
34#define IN_OPTION_C
35#include "vim.h"
36
37/*
38 * The options that are local to a window or buffer have "indir" set to one of
39 * these values. Special values:
40 * PV_NONE: global option.
Bram Moolenaara23ccb82006-02-27 00:08:02 +000041 * PV_WIN is added: window-local option
42 * PV_BUF is added: buffer-local option
Bram Moolenaar071d4272004-06-13 20:20:40 +000043 * PV_BOTH is added: global option which also has a local value.
44 */
45#define PV_BOTH 0x1000
Bram Moolenaara23ccb82006-02-27 00:08:02 +000046#define PV_WIN 0x2000
47#define PV_BUF 0x4000
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000048#define PV_MASK 0x0fff
Bram Moolenaara23ccb82006-02-27 00:08:02 +000049#define OPT_WIN(x) (idopt_T)(PV_WIN + (int)(x))
50#define OPT_BUF(x) (idopt_T)(PV_BUF + (int)(x))
Bram Moolenaar071d4272004-06-13 20:20:40 +000051#define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x))
52
Bram Moolenaara23ccb82006-02-27 00:08:02 +000053/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000054 * Definition of the PV_ values for buffer-local options.
55 * The BV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +000056 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +000057#define PV_AI OPT_BUF(BV_AI)
58#define PV_AR OPT_BOTH(OPT_BUF(BV_AR))
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020059#define PV_BKC OPT_BOTH(OPT_BUF(BV_BKC))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000060#ifdef FEAT_QUICKFIX
Bram Moolenaara23ccb82006-02-27 00:08:02 +000061# define PV_BH OPT_BUF(BV_BH)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000062# define PV_BT OPT_BUF(BV_BT)
63# define PV_EFM OPT_BOTH(OPT_BUF(BV_EFM))
64# define PV_GP OPT_BOTH(OPT_BUF(BV_GP))
65# define PV_MP OPT_BOTH(OPT_BUF(BV_MP))
Bram Moolenaara23ccb82006-02-27 00:08:02 +000066#endif
67#define PV_BIN OPT_BUF(BV_BIN)
68#define PV_BL OPT_BUF(BV_BL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000069#ifdef FEAT_MBYTE
70# define PV_BOMB OPT_BUF(BV_BOMB)
71#endif
72#define PV_CI OPT_BUF(BV_CI)
73#ifdef FEAT_CINDENT
74# define PV_CIN OPT_BUF(BV_CIN)
75# define PV_CINK OPT_BUF(BV_CINK)
76# define PV_CINO OPT_BUF(BV_CINO)
77#endif
78#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
79# define PV_CINW OPT_BUF(BV_CINW)
80#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020081#define PV_CM OPT_BOTH(OPT_BUF(BV_CM))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000082#ifdef FEAT_FOLDING
83# define PV_CMS OPT_BUF(BV_CMS)
84#endif
85#ifdef FEAT_COMMENTS
86# define PV_COM OPT_BUF(BV_COM)
87#endif
88#ifdef FEAT_INS_EXPAND
89# define PV_CPT OPT_BUF(BV_CPT)
90# define PV_DICT OPT_BOTH(OPT_BUF(BV_DICT))
91# define PV_TSR OPT_BOTH(OPT_BUF(BV_TSR))
92#endif
93#ifdef FEAT_COMPL_FUNC
94# define PV_CFU OPT_BUF(BV_CFU)
95#endif
96#ifdef FEAT_FIND_ID
97# define PV_DEF OPT_BOTH(OPT_BUF(BV_DEF))
98# define PV_INC OPT_BOTH(OPT_BUF(BV_INC))
99#endif
100#define PV_EOL OPT_BUF(BV_EOL)
Bram Moolenaar34d72d42015-07-17 14:18:08 +0200101#define PV_FIXEOL OPT_BUF(BV_FIXEOL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000102#define PV_EP OPT_BOTH(OPT_BUF(BV_EP))
103#define PV_ET OPT_BUF(BV_ET)
104#ifdef FEAT_MBYTE
105# define PV_FENC OPT_BUF(BV_FENC)
106#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000107#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
108# define PV_BEXPR OPT_BOTH(OPT_BUF(BV_BEXPR))
109#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000110#ifdef FEAT_EVAL
111# define PV_FEX OPT_BUF(BV_FEX)
112#endif
113#define PV_FF OPT_BUF(BV_FF)
114#define PV_FLP OPT_BUF(BV_FLP)
115#define PV_FO OPT_BUF(BV_FO)
116#ifdef FEAT_AUTOCMD
117# define PV_FT OPT_BUF(BV_FT)
118#endif
119#define PV_IMI OPT_BUF(BV_IMI)
120#define PV_IMS OPT_BUF(BV_IMS)
121#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
122# define PV_INDE OPT_BUF(BV_INDE)
123# define PV_INDK OPT_BUF(BV_INDK)
124#endif
125#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
126# define PV_INEX OPT_BUF(BV_INEX)
127#endif
128#define PV_INF OPT_BUF(BV_INF)
129#define PV_ISK OPT_BUF(BV_ISK)
130#ifdef FEAT_CRYPT
131# define PV_KEY OPT_BUF(BV_KEY)
132#endif
133#ifdef FEAT_KEYMAP
134# define PV_KMAP OPT_BUF(BV_KMAP)
135#endif
136#define PV_KP OPT_BOTH(OPT_BUF(BV_KP))
137#ifdef FEAT_LISP
138# define PV_LISP OPT_BUF(BV_LISP)
Bram Moolenaaraf6c1312014-03-12 18:55:58 +0100139# define PV_LW OPT_BOTH(OPT_BUF(BV_LW))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000140#endif
141#define PV_MA OPT_BUF(BV_MA)
142#define PV_ML OPT_BUF(BV_ML)
143#define PV_MOD OPT_BUF(BV_MOD)
144#define PV_MPS OPT_BUF(BV_MPS)
145#define PV_NF OPT_BUF(BV_NF)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000146#ifdef FEAT_COMPL_FUNC
147# define PV_OFU OPT_BUF(BV_OFU)
148#endif
149#define PV_PATH OPT_BOTH(OPT_BUF(BV_PATH))
150#define PV_PI OPT_BUF(BV_PI)
151#ifdef FEAT_TEXTOBJ
152# define PV_QE OPT_BUF(BV_QE)
153#endif
154#define PV_RO OPT_BUF(BV_RO)
155#ifdef FEAT_SMARTINDENT
156# define PV_SI OPT_BUF(BV_SI)
157#endif
158#ifndef SHORT_FNAME
159# define PV_SN OPT_BUF(BV_SN)
160#endif
161#ifdef FEAT_SYN_HL
162# define PV_SMC OPT_BUF(BV_SMC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000163# define PV_SYN OPT_BUF(BV_SYN)
164#endif
165#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000166# define PV_SPC OPT_BUF(BV_SPC)
167# define PV_SPF OPT_BUF(BV_SPF)
168# define PV_SPL OPT_BUF(BV_SPL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000169#endif
170#define PV_STS OPT_BUF(BV_STS)
171#ifdef FEAT_SEARCHPATH
172# define PV_SUA OPT_BUF(BV_SUA)
173#endif
174#define PV_SW OPT_BUF(BV_SW)
175#define PV_SWF OPT_BUF(BV_SWF)
176#define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS))
177#define PV_TS OPT_BUF(BV_TS)
178#define PV_TW OPT_BUF(BV_TW)
179#define PV_TX OPT_BUF(BV_TX)
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200180#ifdef FEAT_PERSISTENT_UNDO
181# define PV_UDF OPT_BUF(BV_UDF)
182#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000183#define PV_WM OPT_BUF(BV_WM)
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000184
185/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000186 * Definition of the PV_ values for window-local options.
187 * The WV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000188 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000189#define PV_LIST OPT_WIN(WV_LIST)
190#ifdef FEAT_ARABIC
191# define PV_ARAB OPT_WIN(WV_ARAB)
192#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +0200193#ifdef FEAT_LINEBREAK
194# define PV_BRI OPT_WIN(WV_BRI)
195# define PV_BRIOPT OPT_WIN(WV_BRIOPT)
196#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000197#ifdef FEAT_DIFF
198# define PV_DIFF OPT_WIN(WV_DIFF)
199#endif
200#ifdef FEAT_FOLDING
201# define PV_FDC OPT_WIN(WV_FDC)
202# define PV_FEN OPT_WIN(WV_FEN)
203# define PV_FDI OPT_WIN(WV_FDI)
204# define PV_FDL OPT_WIN(WV_FDL)
205# define PV_FDM OPT_WIN(WV_FDM)
206# define PV_FML OPT_WIN(WV_FML)
207# define PV_FDN OPT_WIN(WV_FDN)
208# ifdef FEAT_EVAL
209# define PV_FDE OPT_WIN(WV_FDE)
210# define PV_FDT OPT_WIN(WV_FDT)
211# endif
212# define PV_FMR OPT_WIN(WV_FMR)
213#endif
214#ifdef FEAT_LINEBREAK
215# define PV_LBR OPT_WIN(WV_LBR)
216#endif
217#define PV_NU OPT_WIN(WV_NU)
Bram Moolenaar64486672010-05-16 15:46:46 +0200218#define PV_RNU OPT_WIN(WV_RNU)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000219#ifdef FEAT_LINEBREAK
220# define PV_NUW OPT_WIN(WV_NUW)
221#endif
222#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
223# define PV_PVW OPT_WIN(WV_PVW)
224#endif
225#ifdef FEAT_RIGHTLEFT
226# define PV_RL OPT_WIN(WV_RL)
227# define PV_RLC OPT_WIN(WV_RLC)
228#endif
229#ifdef FEAT_SCROLLBIND
230# define PV_SCBIND OPT_WIN(WV_SCBIND)
231#endif
232#define PV_SCROLL OPT_WIN(WV_SCROLL)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000233#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000234# define PV_SPELL OPT_WIN(WV_SPELL)
235#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000236#ifdef FEAT_SYN_HL
237# define PV_CUC OPT_WIN(WV_CUC)
238# define PV_CUL OPT_WIN(WV_CUL)
Bram Moolenaar1a384422010-07-14 19:53:30 +0200239# define PV_CC OPT_WIN(WV_CC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000240#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000241#ifdef FEAT_STL_OPT
242# define PV_STL OPT_BOTH(OPT_WIN(WV_STL))
243#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +0100244#define PV_UL OPT_BOTH(OPT_BUF(BV_UL))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000245#ifdef FEAT_WINDOWS
246# define PV_WFH OPT_WIN(WV_WFH)
247#endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +0000248#ifdef FEAT_VERTSPLIT
249# define PV_WFW OPT_WIN(WV_WFW)
250#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000251#define PV_WRAP OPT_WIN(WV_WRAP)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200252#ifdef FEAT_CURSORBIND
253# define PV_CRBIND OPT_WIN(WV_CRBIND)
254#endif
255#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200256# define PV_COCU OPT_WIN(WV_COCU)
257# define PV_COLE OPT_WIN(WV_COLE)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200258#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000259
260/* WV_ and BV_ values get typecasted to this for the "indir" field */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000261typedef enum
262{
Bram Moolenaar7d96acd2008-06-09 15:07:54 +0000263 PV_NONE = 0,
264 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000265} idopt_T;
266
267/*
268 * Options local to a window have a value local to a buffer and global to all
269 * buffers. Indicate this by setting "var" to VAR_WIN.
270 */
271#define VAR_WIN ((char_u *)-1)
272
273/*
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000274 * These are the global values for options which are also local to a buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000275 * Only to be used in option.c!
276 */
277static int p_ai;
278static int p_bin;
279#ifdef FEAT_MBYTE
280static int p_bomb;
281#endif
282#if defined(FEAT_QUICKFIX)
283static char_u *p_bh;
284static char_u *p_bt;
285#endif
286static int p_bl;
287static int p_ci;
288#ifdef FEAT_CINDENT
289static int p_cin;
290static char_u *p_cink;
291static char_u *p_cino;
292#endif
293#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
294static char_u *p_cinw;
295#endif
296#ifdef FEAT_COMMENTS
297static char_u *p_com;
298#endif
299#ifdef FEAT_FOLDING
300static char_u *p_cms;
301#endif
302#ifdef FEAT_INS_EXPAND
303static char_u *p_cpt;
304#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000305#ifdef FEAT_COMPL_FUNC
306static char_u *p_cfu;
Bram Moolenaare344bea2005-09-01 20:46:49 +0000307static char_u *p_ofu;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000308#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000309static int p_eol;
Bram Moolenaar34d72d42015-07-17 14:18:08 +0200310static int p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000311static int p_et;
312#ifdef FEAT_MBYTE
313static char_u *p_fenc;
314#endif
315static char_u *p_ff;
316static char_u *p_fo;
Bram Moolenaar86b68352004-12-27 21:59:20 +0000317static char_u *p_flp;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000318#ifdef FEAT_AUTOCMD
319static char_u *p_ft;
320#endif
321static long p_iminsert;
322static long p_imsearch;
323#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
324static char_u *p_inex;
325#endif
326#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
327static char_u *p_inde;
328static char_u *p_indk;
329#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +0000330#if defined(FEAT_EVAL)
331static char_u *p_fex;
332#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000333static int p_inf;
334static char_u *p_isk;
335#ifdef FEAT_CRYPT
336static char_u *p_key;
337#endif
338#ifdef FEAT_LISP
339static int p_lisp;
340#endif
341static int p_ml;
342static int p_ma;
343static int p_mod;
344static char_u *p_mps;
345static char_u *p_nf;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000346static int p_pi;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000347#ifdef FEAT_TEXTOBJ
348static char_u *p_qe;
349#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000350static int p_ro;
351#ifdef FEAT_SMARTINDENT
352static int p_si;
353#endif
354#ifndef SHORT_FNAME
355static int p_sn;
356#endif
357static long p_sts;
358#if defined(FEAT_SEARCHPATH)
359static char_u *p_sua;
360#endif
361static long p_sw;
362static int p_swf;
363#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +0000364static long p_smc;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000365static char_u *p_syn;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000366#endif
367#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000368static char_u *p_spc;
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000369static char_u *p_spf;
Bram Moolenaar217ad922005-03-20 22:37:15 +0000370static char_u *p_spl;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000371#endif
372static long p_ts;
373static long p_tw;
374static int p_tx;
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200375#ifdef FEAT_PERSISTENT_UNDO
376static int p_udf;
377#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000378static long p_wm;
379#ifdef FEAT_KEYMAP
380static char_u *p_keymap;
381#endif
382
383/* Saved values for when 'bin' is set. */
384static int p_et_nobin;
385static int p_ml_nobin;
386static long p_tw_nobin;
387static long p_wm_nobin;
388
389/* Saved values for when 'paste' is set */
390static long p_tw_nopaste;
391static long p_wm_nopaste;
392static long p_sts_nopaste;
393static int p_ai_nopaste;
394
395struct vimoption
396{
397 char *fullname; /* full option name */
398 char *shortname; /* permissible abbreviation */
399 long_u flags; /* see below */
400 char_u *var; /* global option: pointer to variable;
401 * window-local option: VAR_WIN;
402 * buffer-local option: global value */
403 idopt_T indir; /* global option: PV_NONE;
404 * local option: indirect option index */
405 char_u *def_val[2]; /* default values for variable (vi and vim) */
406#ifdef FEAT_EVAL
407 scid_T scriptID; /* script in which the option was last set */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000408# define SCRIPTID_INIT , 0
409#else
410# define SCRIPTID_INIT
Bram Moolenaar071d4272004-06-13 20:20:40 +0000411#endif
412};
413
414#define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */
415#define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */
416
417/*
418 * Flags
419 */
420#define P_BOOL 0x01 /* the option is boolean */
421#define P_NUM 0x02 /* the option is numeric */
422#define P_STRING 0x04 /* the option is a string */
423#define P_ALLOCED 0x08 /* the string option is in allocated memory,
Bram Moolenaar363cb672009-07-22 12:28:17 +0000424 must use free_string_option() when
425 assigning new value. Not set if default is
426 the same. */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000427#define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
428 never be used for local or hidden options! */
429#define P_NODEFAULT 0x40 /* don't set to default value */
430#define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must
431 use vim_free() when assigning new value */
432#define P_WAS_SET 0x100 /* option has been set/reset */
433#define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */
434#define P_VI_DEF 0x400 /* Use Vi default for Vim */
435#define P_VIM 0x800 /* Vim option, reset when 'cp' set */
436
437 /* when option changed, what to display: */
438#define P_RSTAT 0x1000 /* redraw status lines */
439#define P_RWIN 0x2000 /* redraw current window */
440#define P_RBUF 0x4000 /* redraw current buffer */
441#define P_RALL 0x6000 /* redraw all windows */
442#define P_RCLR 0x7000 /* clear and redraw all */
443
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200444#define P_COMMA 0x8000 /* comma separated list */
445#define P_ONECOMMA 0x18000L /* P_COMMA and cannot have two consecutive
446 * commas */
447#define P_NODUP 0x20000L /* don't allow duplicate strings */
448#define P_FLAGLIST 0x40000L /* list of single-char flags */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000449
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200450#define P_SECURE 0x80000L /* cannot change in modeline or secure mode */
451#define P_GETTEXT 0x100000L /* expand default value with _() */
452#define P_NOGLOB 0x200000L /* do not use local value for global vimrc */
453#define P_NFNAME 0x400000L /* only normal file name chars allowed */
454#define P_INSECURE 0x800000L /* option was set from a modeline */
455#define P_PRI_MKRC 0x1000000L /* priority for :mkvimrc (setting option has
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000456 side effects) */
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200457#define P_NO_ML 0x2000000L /* not allowed in modeline */
458#define P_CURSWANT 0x4000000L /* update curswant required; not needed when
Bram Moolenaar913077c2012-03-28 19:59:04 +0200459 * there is a redraw flag */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000460
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000461#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
462
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000463/* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used
464 * for the currency sign. */
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000465#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000466# define ISP_LATIN1 (char_u *)"@,~-255"
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000467#else
468# define ISP_LATIN1 (char_u *)"@,161-255"
469#endif
470
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000471/* The 16 bit MS-DOS version is low on space, make the string as short as
472 * possible when compiling with few features. */
473#if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
474 || defined(FEAT_VERTSPLIT) || defined(FEAT_CLIPBOARD) \
Bram Moolenaar860cae12010-06-05 23:22:07 +0200475 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) || defined(FEAT_CONCEAL)
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100476# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000477#else
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100478# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000479#endif
480
Bram Moolenaar071d4272004-06-13 20:20:40 +0000481/*
482 * options[] is initialized here.
483 * The order of the options MUST be alphabetic for ":set all" and findoption().
484 * All option names MUST start with a lowercase letter (for findoption()).
485 * Exception: "t_" options are at the end.
486 * The options with a NULL variable are 'hidden': a set command for them is
487 * ignored and they are not printed.
488 */
489static struct vimoption
490#ifdef FEAT_GUI_W16
491 _far
492#endif
493 options[] =
494{
Bram Moolenaar913077c2012-03-28 19:59:04 +0200495 {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000496#ifdef FEAT_RIGHTLEFT
497 (char_u *)&p_aleph, PV_NONE,
498#else
499 (char_u *)NULL, PV_NONE,
500#endif
501 {
502#if (defined(MSDOS) || defined(WIN3264) || defined(OS2)) && !defined(FEAT_GUI_W32)
503 (char_u *)128L,
504#else
505 (char_u *)224L,
506#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000507 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000508 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
509#if defined(FEAT_GUI) && defined(MACOS_X)
510 (char_u *)&p_antialias, PV_NONE,
511 {(char_u *)FALSE, (char_u *)FALSE}
512#else
513 (char_u *)NULL, PV_NONE,
514 {(char_u *)FALSE, (char_u *)FALSE}
515#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000516 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200517 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000518#ifdef FEAT_ARABIC
519 (char_u *)VAR_WIN, PV_ARAB,
520#else
521 (char_u *)NULL, PV_NONE,
522#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000523 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000524 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
525#ifdef FEAT_ARABIC
526 (char_u *)&p_arshape, PV_NONE,
527#else
528 (char_u *)NULL, PV_NONE,
529#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000530 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000531 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
532#ifdef FEAT_RIGHTLEFT
533 (char_u *)&p_ari, PV_NONE,
534#else
535 (char_u *)NULL, PV_NONE,
536#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000537 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000538 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
539#ifdef FEAT_FKMAP
540 (char_u *)&p_altkeymap, PV_NONE,
541#else
542 (char_u *)NULL, PV_NONE,
543#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000544 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000545 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
546#if defined(FEAT_MBYTE)
547 (char_u *)&p_ambw, PV_NONE,
548 {(char_u *)"single", (char_u *)0L}
549#else
550 (char_u *)NULL, PV_NONE,
551 {(char_u *)0L, (char_u *)0L}
552#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000553 SCRIPTID_INIT},
Bram Moolenaar8dff8182006-04-06 20:18:50 +0000554#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +0000555 {"autochdir", "acd", P_BOOL|P_VI_DEF,
556 (char_u *)&p_acd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000557 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000558#endif
559 {"autoindent", "ai", P_BOOL|P_VI_DEF,
560 (char_u *)&p_ai, PV_AI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000561 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000562 {"autoprint", "ap", P_BOOL|P_VI_DEF,
563 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000564 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000565 {"autoread", "ar", P_BOOL|P_VI_DEF,
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000566 (char_u *)&p_ar, PV_AR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000567 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000568 {"autowrite", "aw", P_BOOL|P_VI_DEF,
569 (char_u *)&p_aw, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000570 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000571 {"autowriteall","awa", P_BOOL|P_VI_DEF,
572 (char_u *)&p_awa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000573 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000574 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
575 (char_u *)&p_bg, PV_NONE,
576 {
577#if (defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI)
578 (char_u *)"dark",
579#else
580 (char_u *)"light",
581#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000582 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200583 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000584 (char_u *)&p_bs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000585 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000586 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
587 (char_u *)&p_bk, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000588 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200589 {"backupcopy", "bkc", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +0200590 (char_u *)&p_bkc, PV_BKC,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000591#ifdef UNIX
592 {(char_u *)"yes", (char_u *)"auto"}
593#else
594 {(char_u *)"auto", (char_u *)"auto"}
595#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000596 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200597 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
598 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000599 (char_u *)&p_bdir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000600 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000601 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000602 (char_u *)&p_bex, PV_NONE,
603 {
604#ifdef VMS
605 (char_u *)"_",
606#else
607 (char_u *)"~",
608#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000609 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200610 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000611#ifdef FEAT_WILDIGN
612 (char_u *)&p_bsk, PV_NONE,
613 {(char_u *)"", (char_u *)0L}
614#else
615 (char_u *)NULL, PV_NONE,
616 {(char_u *)0L, (char_u *)0L}
617#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000618 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000619#ifdef FEAT_BEVAL
620 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
621 (char_u *)&p_bdlay, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000622 {(char_u *)600L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000623 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
624 (char_u *)&p_beval, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000625 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000626# ifdef FEAT_EVAL
Bram Moolenaar39f05632006-03-19 22:15:26 +0000627 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000628 (char_u *)&p_bexpr, PV_BEXPR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000629 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000630# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000631#endif
632 {"beautify", "bf", P_BOOL|P_VI_DEF,
633 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000634 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar165bc692015-07-21 17:53:25 +0200635 {"belloff", "bo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
636 (char_u *)&p_bo, PV_NONE,
637 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000638 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
639 (char_u *)&p_bin, PV_BIN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000640 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000641 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
642#ifdef MSDOS
643 (char_u *)&p_biosk, PV_NONE,
644#else
645 (char_u *)NULL, PV_NONE,
646#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000647 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000648 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
649#ifdef FEAT_MBYTE
650 (char_u *)&p_bomb, PV_BOMB,
651#else
652 (char_u *)NULL, PV_NONE,
653#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000654 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000655 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
656#ifdef FEAT_LINEBREAK
657 (char_u *)&p_breakat, PV_NONE,
658 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
659#else
660 (char_u *)NULL, PV_NONE,
661 {(char_u *)0L, (char_u *)0L}
662#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000663 SCRIPTID_INIT},
Bram Moolenaar597a4222014-06-25 14:39:50 +0200664 {"breakindent", "bri", P_BOOL|P_VI_DEF|P_VIM|P_RWIN,
665#ifdef FEAT_LINEBREAK
666 (char_u *)VAR_WIN, PV_BRI,
667 {(char_u *)FALSE, (char_u *)0L}
668#else
669 (char_u *)NULL, PV_NONE,
670 {(char_u *)0L, (char_u *)0L}
671#endif
672 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200673 {"breakindentopt", "briopt", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF
674 |P_ONECOMMA|P_NODUP,
Bram Moolenaar597a4222014-06-25 14:39:50 +0200675#ifdef FEAT_LINEBREAK
676 (char_u *)VAR_WIN, PV_BRIOPT,
677 {(char_u *)"", (char_u *)NULL}
678#else
679 (char_u *)NULL, PV_NONE,
680 {(char_u *)"", (char_u *)NULL}
681#endif
682 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000683 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
684#ifdef FEAT_BROWSE
685 (char_u *)&p_bsdir, PV_NONE,
686 {(char_u *)"last", (char_u *)0L}
687#else
688 (char_u *)NULL, PV_NONE,
689 {(char_u *)0L, (char_u *)0L}
690#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000691 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000692 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
693#if defined(FEAT_QUICKFIX)
694 (char_u *)&p_bh, PV_BH,
695 {(char_u *)"", (char_u *)0L}
696#else
697 (char_u *)NULL, PV_NONE,
698 {(char_u *)0L, (char_u *)0L}
699#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000700 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000701 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
702 (char_u *)&p_bl, PV_BL,
703 {(char_u *)1L, (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000704 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000705 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
706#if defined(FEAT_QUICKFIX)
707 (char_u *)&p_bt, PV_BT,
708 {(char_u *)"", (char_u *)0L}
709#else
710 (char_u *)NULL, PV_NONE,
711 {(char_u *)0L, (char_u *)0L}
712#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000713 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200714 {"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000715#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000716 (char_u *)&p_cmp, PV_NONE,
717 {(char_u *)"internal,keepascii", (char_u *)0L}
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000718#else
719 (char_u *)NULL, PV_NONE,
720 {(char_u *)0L, (char_u *)0L}
721#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000722 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000723 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
724#ifdef FEAT_SEARCHPATH
725 (char_u *)&p_cdpath, PV_NONE,
726 {(char_u *)",,", (char_u *)0L}
727#else
728 (char_u *)NULL, PV_NONE,
729 {(char_u *)0L, (char_u *)0L}
730#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000731 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000732 {"cedit", NULL, P_STRING,
733#ifdef FEAT_CMDWIN
734 (char_u *)&p_cedit, PV_NONE,
735 {(char_u *)"", (char_u *)CTRL_F_STR}
736#else
737 (char_u *)NULL, PV_NONE,
738 {(char_u *)0L, (char_u *)0L}
739#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000740 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000741 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
742#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
743 (char_u *)&p_ccv, PV_NONE,
744 {(char_u *)"", (char_u *)0L}
745#else
746 (char_u *)NULL, PV_NONE,
747 {(char_u *)0L, (char_u *)0L}
748#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000749 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000750 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
751#ifdef FEAT_CINDENT
752 (char_u *)&p_cin, PV_CIN,
753#else
754 (char_u *)NULL, PV_NONE,
755#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000756 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200757 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000758#ifdef FEAT_CINDENT
759 (char_u *)&p_cink, PV_CINK,
760 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
761#else
762 (char_u *)NULL, PV_NONE,
763 {(char_u *)0L, (char_u *)0L}
764#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000765 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200766 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000767#ifdef FEAT_CINDENT
768 (char_u *)&p_cino, PV_CINO,
769#else
770 (char_u *)NULL, PV_NONE,
771#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000772 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200773 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000774#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
775 (char_u *)&p_cinw, PV_CINW,
776 {(char_u *)"if,else,while,do,for,switch",
777 (char_u *)0L}
778#else
779 (char_u *)NULL, PV_NONE,
780 {(char_u *)0L, (char_u *)0L}
781#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000782 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200783 {"clipboard", "cb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000784#ifdef FEAT_CLIPBOARD
785 (char_u *)&p_cb, PV_NONE,
786# ifdef FEAT_XCLIPBOARD
787 {(char_u *)"autoselect,exclude:cons\\|linux",
788 (char_u *)0L}
789# else
790 {(char_u *)"", (char_u *)0L}
791# endif
792#else
793 (char_u *)NULL, PV_NONE,
794 {(char_u *)"", (char_u *)0L}
795#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000796 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000797 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
798 (char_u *)&p_ch, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000799 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000800 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
801#ifdef FEAT_CMDWIN
802 (char_u *)&p_cwh, PV_NONE,
803#else
804 (char_u *)NULL, PV_NONE,
805#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000806 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200807 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar1a384422010-07-14 19:53:30 +0200808#ifdef FEAT_SYN_HL
809 (char_u *)VAR_WIN, PV_CC,
810#else
811 (char_u *)NULL, PV_NONE,
812#endif
813 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000814 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
815 (char_u *)&Columns, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000816 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200817 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
818 |P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000819#ifdef FEAT_COMMENTS
820 (char_u *)&p_com, PV_COM,
821 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
822 (char_u *)0L}
823#else
824 (char_u *)NULL, PV_NONE,
825 {(char_u *)0L, (char_u *)0L}
826#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000827 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200828 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000829#ifdef FEAT_FOLDING
830 (char_u *)&p_cms, PV_CMS,
831 {(char_u *)"/*%s*/", (char_u *)0L}
832#else
833 (char_u *)NULL, PV_NONE,
834 {(char_u *)0L, (char_u *)0L}
835#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000836 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000837 /* P_PRI_MKRC isn't needed here, optval_default()
838 * always returns TRUE for 'compatible' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000839 {"compatible", "cp", P_BOOL|P_RALL,
840 (char_u *)&p_cp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000841 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200842 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000843#ifdef FEAT_INS_EXPAND
844 (char_u *)&p_cpt, PV_CPT,
845 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
846#else
847 (char_u *)NULL, PV_NONE,
848 {(char_u *)0L, (char_u *)0L}
849#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000850 SCRIPTID_INIT},
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200851 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200852#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200853 (char_u *)VAR_WIN, PV_COCU,
854 {(char_u *)"", (char_u *)NULL}
855#else
856 (char_u *)NULL, PV_NONE,
857 {(char_u *)NULL, (char_u *)0L}
858#endif
859 SCRIPTID_INIT},
860 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
861#ifdef FEAT_CONCEAL
862 (char_u *)VAR_WIN, PV_COLE,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200863#else
864 (char_u *)NULL, PV_NONE,
865#endif
866 {(char_u *)0L, (char_u *)0L}
867 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000868 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
869#ifdef FEAT_COMPL_FUNC
870 (char_u *)&p_cfu, PV_CFU,
871 {(char_u *)"", (char_u *)0L}
872#else
873 (char_u *)NULL, PV_NONE,
874 {(char_u *)0L, (char_u *)0L}
875#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000876 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200877 {"completeopt", "cot", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000878#ifdef FEAT_INS_EXPAND
879 (char_u *)&p_cot, PV_NONE,
Bram Moolenaarc270d802006-03-11 21:29:41 +0000880 {(char_u *)"menu,preview", (char_u *)0L}
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000881#else
882 (char_u *)NULL, PV_NONE,
883 {(char_u *)0L, (char_u *)0L}
884#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000885 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000886 {"confirm", "cf", P_BOOL|P_VI_DEF,
887#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
888 (char_u *)&p_confirm, PV_NONE,
889#else
890 (char_u *)NULL, PV_NONE,
891#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000892 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000893 {"conskey", "consk",P_BOOL|P_VI_DEF,
894#ifdef MSDOS
895 (char_u *)&p_consk, PV_NONE,
896#else
897 (char_u *)NULL, PV_NONE,
898#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000899 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000900 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
901 (char_u *)&p_ci, PV_CI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000902 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000903 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
904 (char_u *)&p_cpo, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000905 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
906 SCRIPTID_INIT},
Bram Moolenaar49771f42010-07-20 17:32:38 +0200907 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200908#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200909 (char_u *)&p_cm, PV_CM,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200910 {(char_u *)"zip", (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200911#else
912 (char_u *)NULL, PV_NONE,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200913 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200914#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +0200915 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000916 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
917#ifdef FEAT_CSCOPE
918 (char_u *)&p_cspc, PV_NONE,
919#else
920 (char_u *)NULL, PV_NONE,
921#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000922 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000923 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
924#ifdef FEAT_CSCOPE
925 (char_u *)&p_csprg, PV_NONE,
926 {(char_u *)"cscope", (char_u *)0L}
927#else
928 (char_u *)NULL, PV_NONE,
929 {(char_u *)0L, (char_u *)0L}
930#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000931 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +0200932 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000933#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
934 (char_u *)&p_csqf, PV_NONE,
935 {(char_u *)"", (char_u *)0L}
936#else
937 (char_u *)NULL, PV_NONE,
938 {(char_u *)0L, (char_u *)0L}
939#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000940 SCRIPTID_INIT},
Bram Moolenaarf7befa92011-06-12 22:13:40 +0200941 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM,
942#ifdef FEAT_CSCOPE
943 (char_u *)&p_csre, PV_NONE,
944#else
945 (char_u *)NULL, PV_NONE,
946#endif
947 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000948 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
949#ifdef FEAT_CSCOPE
950 (char_u *)&p_cst, PV_NONE,
951#else
952 (char_u *)NULL, PV_NONE,
953#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000954 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000955 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
956#ifdef FEAT_CSCOPE
957 (char_u *)&p_csto, PV_NONE,
958#else
959 (char_u *)NULL, PV_NONE,
960#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000961 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000962 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
963#ifdef FEAT_CSCOPE
964 (char_u *)&p_csverbose, PV_NONE,
965#else
966 (char_u *)NULL, PV_NONE,
967#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000968 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200969 {"cursorbind", "crb", P_BOOL|P_VI_DEF,
970#ifdef FEAT_CURSORBIND
971 (char_u *)VAR_WIN, PV_CRBIND,
972#else
973 (char_u *)NULL, PV_NONE,
974#endif
975 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000976 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
977#ifdef FEAT_SYN_HL
978 (char_u *)VAR_WIN, PV_CUC,
979#else
980 (char_u *)NULL, PV_NONE,
981#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000982 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000983 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWIN,
984#ifdef FEAT_SYN_HL
985 (char_u *)VAR_WIN, PV_CUL,
986#else
987 (char_u *)NULL, PV_NONE,
988#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000989 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000990 {"debug", NULL, P_STRING|P_VI_DEF,
991 (char_u *)&p_debug, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000992 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200993 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000994#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000995 (char_u *)&p_def, PV_DEF,
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000996 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000997#else
998 (char_u *)NULL, PV_NONE,
999 {(char_u *)NULL, (char_u *)0L}
1000#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001001 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001002 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
1003#ifdef FEAT_MBYTE
1004 (char_u *)&p_deco, PV_NONE,
1005#else
1006 (char_u *)NULL, PV_NONE,
1007#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001008 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001009 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001010#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001011 (char_u *)&p_dict, PV_DICT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001012#else
1013 (char_u *)NULL, PV_NONE,
1014#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001015 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001016 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
1017#ifdef FEAT_DIFF
1018 (char_u *)VAR_WIN, PV_DIFF,
1019#else
1020 (char_u *)NULL, PV_NONE,
1021#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001022 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001023 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001024#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1025 (char_u *)&p_dex, PV_NONE,
1026 {(char_u *)"", (char_u *)0L}
1027#else
1028 (char_u *)NULL, PV_NONE,
1029 {(char_u *)0L, (char_u *)0L}
1030#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001031 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001032 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_ONECOMMA
1033 |P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001034#ifdef FEAT_DIFF
1035 (char_u *)&p_dip, PV_NONE,
1036 {(char_u *)"filler", (char_u *)NULL}
1037#else
1038 (char_u *)NULL, PV_NONE,
1039 {(char_u *)"", (char_u *)NULL}
1040#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001041 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001042 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
1043#ifdef FEAT_DIGRAPHS
1044 (char_u *)&p_dg, PV_NONE,
1045#else
1046 (char_u *)NULL, PV_NONE,
1047#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001048 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001049 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA
1050 |P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001051 (char_u *)&p_dir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001052 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001053 {"display", "dy", P_STRING|P_VI_DEF|P_ONECOMMA|P_RALL|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001054 (char_u *)&p_dy, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001055 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001056 {"eadirection", "ead", P_STRING|P_VI_DEF,
1057#ifdef FEAT_VERTSPLIT
1058 (char_u *)&p_ead, PV_NONE,
1059 {(char_u *)"both", (char_u *)0L}
1060#else
1061 (char_u *)NULL, PV_NONE,
1062 {(char_u *)NULL, (char_u *)0L}
1063#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001064 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001065 {"edcompatible","ed", P_BOOL|P_VI_DEF,
1066 (char_u *)&p_ed, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001067 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar865242e2010-07-14 21:12:05 +02001068 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001069#ifdef FEAT_MBYTE
1070 (char_u *)&p_enc, PV_NONE,
1071 {(char_u *)ENC_DFLT, (char_u *)0L}
1072#else
1073 (char_u *)NULL, PV_NONE,
1074 {(char_u *)0L, (char_u *)0L}
1075#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001076 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001077 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1078 (char_u *)&p_eol, PV_EOL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001079 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001080 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1081 (char_u *)&p_ea, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001082 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001083 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001084 (char_u *)&p_ep, PV_EP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001085 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001086 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1087 (char_u *)&p_eb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001088 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001089 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1090#ifdef FEAT_QUICKFIX
1091 (char_u *)&p_ef, PV_NONE,
1092 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1093#else
1094 (char_u *)NULL, PV_NONE,
1095 {(char_u *)NULL, (char_u *)0L}
1096#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001097 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001098 {"errorformat", "efm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001099#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001100 (char_u *)&p_efm, PV_EFM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001101 {(char_u *)DFLT_EFM, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001102#else
1103 (char_u *)NULL, PV_NONE,
1104 {(char_u *)NULL, (char_u *)0L}
1105#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001106 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001107 {"esckeys", "ek", P_BOOL|P_VIM,
1108 (char_u *)&p_ek, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001109 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001110 {"eventignore", "ei", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001111#ifdef FEAT_AUTOCMD
1112 (char_u *)&p_ei, PV_NONE,
1113#else
1114 (char_u *)NULL, PV_NONE,
1115#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001116 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001117 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1118 (char_u *)&p_et, PV_ET,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001119 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001120 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1121 (char_u *)&p_exrc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001122 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001123 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF
1124 |P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001125#ifdef FEAT_MBYTE
1126 (char_u *)&p_fenc, PV_FENC,
1127 {(char_u *)"", (char_u *)0L}
1128#else
1129 (char_u *)NULL, PV_NONE,
1130 {(char_u *)0L, (char_u *)0L}
1131#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001132 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001133 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001134#ifdef FEAT_MBYTE
1135 (char_u *)&p_fencs, PV_NONE,
1136 {(char_u *)"ucs-bom", (char_u *)0L}
1137#else
1138 (char_u *)NULL, PV_NONE,
1139 {(char_u *)0L, (char_u *)0L}
1140#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001141 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001142 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC
1143 |P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001144 (char_u *)&p_ff, PV_FF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001145 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001146 {"fileformats", "ffs", P_STRING|P_VIM|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001147 (char_u *)&p_ffs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001148 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1149 SCRIPTID_INIT},
Bram Moolenaar71afbfe2013-03-19 16:49:16 +01001150 {"fileignorecase", "fic", P_BOOL|P_VI_DEF,
1151 (char_u *)&p_fic, PV_NONE,
1152 {
1153#ifdef CASE_INSENSITIVE_FILENAME
1154 (char_u *)TRUE,
1155#else
1156 (char_u *)FALSE,
1157#endif
1158 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001159 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001160#ifdef FEAT_AUTOCMD
1161 (char_u *)&p_ft, PV_FT,
1162 {(char_u *)"", (char_u *)0L}
1163#else
1164 (char_u *)NULL, PV_NONE,
1165 {(char_u *)0L, (char_u *)0L}
1166#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001167 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001168 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001169#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1170 (char_u *)&p_fcs, PV_NONE,
1171 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1172#else
1173 (char_u *)NULL, PV_NONE,
1174 {(char_u *)"", (char_u *)0L}
1175#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001176 SCRIPTID_INIT},
Bram Moolenaar34d72d42015-07-17 14:18:08 +02001177 {"fixendofline", "fixeol", P_BOOL|P_VI_DEF|P_RSTAT,
1178 (char_u *)&p_fixeol, PV_FIXEOL,
1179 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001180 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1181#ifdef FEAT_FKMAP
1182 (char_u *)&p_fkmap, PV_NONE,
1183#else
1184 (char_u *)NULL, PV_NONE,
1185#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001186 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001187 {"flash", "fl", P_BOOL|P_VI_DEF,
1188 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001189 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001190#ifdef FEAT_FOLDING
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001191 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_RWIN,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001192 (char_u *)&p_fcl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001193 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001194 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1195 (char_u *)VAR_WIN, PV_FDC,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001196 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001197 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1198 (char_u *)VAR_WIN, PV_FEN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001199 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001200 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1201# ifdef FEAT_EVAL
1202 (char_u *)VAR_WIN, PV_FDE,
1203 {(char_u *)"0", (char_u *)NULL}
1204# else
1205 (char_u *)NULL, PV_NONE,
1206 {(char_u *)NULL, (char_u *)0L}
1207# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001208 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001209 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1210 (char_u *)VAR_WIN, PV_FDI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001211 {(char_u *)"#", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001212 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
1213 (char_u *)VAR_WIN, PV_FDL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001214 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001215 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001216 (char_u *)&p_fdls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001217 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001218 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001219 P_RWIN|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001220 (char_u *)VAR_WIN, PV_FMR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001221 {(char_u *)"{{{,}}}", (char_u *)NULL}
1222 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001223 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1224 (char_u *)VAR_WIN, PV_FDM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001225 {(char_u *)"manual", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001226 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1227 (char_u *)VAR_WIN, PV_FML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001228 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001229 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1230 (char_u *)VAR_WIN, PV_FDN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001231 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001232 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001233 (char_u *)&p_fdo, PV_NONE,
1234 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001235 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001236 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1237# ifdef FEAT_EVAL
1238 (char_u *)VAR_WIN, PV_FDT,
1239 {(char_u *)"foldtext()", (char_u *)NULL}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001240# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001241 (char_u *)NULL, PV_NONE,
1242 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001243# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001244 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001245#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001246 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001247#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001248 (char_u *)&p_fex, PV_FEX,
1249 {(char_u *)"", (char_u *)0L}
1250#else
1251 (char_u *)NULL, PV_NONE,
1252 {(char_u *)0L, (char_u *)0L}
1253#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001254 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001255 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1256 (char_u *)&p_fo, PV_FO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001257 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1258 SCRIPTID_INIT},
Bram Moolenaar86b68352004-12-27 21:59:20 +00001259 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1260 (char_u *)&p_flp, PV_FLP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001261 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1262 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001263 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1264 (char_u *)&p_fp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001265 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001266 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1267#ifdef HAVE_FSYNC
1268 (char_u *)&p_fs, PV_NONE,
1269 {(char_u *)TRUE, (char_u *)0L}
1270#else
1271 (char_u *)NULL, PV_NONE,
1272 {(char_u *)FALSE, (char_u *)0L}
1273#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001274 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001275 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1276 (char_u *)&p_gd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001277 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001278 {"graphic", "gr", P_BOOL|P_VI_DEF,
1279 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001280 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001281 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001282#ifdef FEAT_QUICKFIX
1283 (char_u *)&p_gefm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001284 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001285#else
1286 (char_u *)NULL, PV_NONE,
1287 {(char_u *)NULL, (char_u *)0L}
1288#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001289 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001290 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1291#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001292 (char_u *)&p_gp, PV_GP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001293 {
1294# ifdef WIN3264
1295 /* may be changed to "grep -n" in os_win32.c */
1296 (char_u *)"findstr /n",
1297# else
1298# ifdef UNIX
1299 /* Add an extra file name so that grep will always
1300 * insert a file name in the match line. */
1301 (char_u *)"grep -n $* /dev/null",
1302# else
1303# ifdef VMS
1304 (char_u *)"SEARCH/NUMBERS ",
1305# else
1306 (char_u *)"grep -n ",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001307# endif
1308# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001309# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001310 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001311#else
1312 (char_u *)NULL, PV_NONE,
1313 {(char_u *)NULL, (char_u *)0L}
1314#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001315 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001316 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001317#ifdef CURSOR_SHAPE
1318 (char_u *)&p_guicursor, PV_NONE,
1319 {
1320# ifdef FEAT_GUI
1321 (char_u *)"n-v-c:block-Cursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor,sm:block-Cursor-blinkwait175-blinkoff150-blinkon175",
1322# else /* MSDOS or Win32 console */
1323 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1324# endif
1325 (char_u *)0L}
1326#else
1327 (char_u *)NULL, PV_NONE,
1328 {(char_u *)NULL, (char_u *)0L}
1329#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001330 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001331 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001332#ifdef FEAT_GUI
1333 (char_u *)&p_guifont, PV_NONE,
1334 {(char_u *)"", (char_u *)0L}
1335#else
1336 (char_u *)NULL, PV_NONE,
1337 {(char_u *)NULL, (char_u *)0L}
1338#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001339 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001340 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001341#if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1342 (char_u *)&p_guifontset, PV_NONE,
1343 {(char_u *)"", (char_u *)0L}
1344#else
1345 (char_u *)NULL, PV_NONE,
1346 {(char_u *)NULL, (char_u *)0L}
1347#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001348 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001349 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001350#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1351 (char_u *)&p_guifontwide, PV_NONE,
1352 {(char_u *)"", (char_u *)0L}
1353#else
1354 (char_u *)NULL, PV_NONE,
1355 {(char_u *)NULL, (char_u *)0L}
1356#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001357 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001358 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001359#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001360 (char_u *)&p_ghr, PV_NONE,
1361#else
1362 (char_u *)NULL, PV_NONE,
1363#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001364 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001365 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001366#if defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001367 (char_u *)&p_go, PV_NONE,
1368# if defined(UNIX) && !defined(MACOS)
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001369 {(char_u *)"aegimrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001370# else
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001371 {(char_u *)"egmrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001372# endif
1373#else
1374 (char_u *)NULL, PV_NONE,
1375 {(char_u *)NULL, (char_u *)0L}
1376#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001377 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001378 {"guipty", NULL, P_BOOL|P_VI_DEF,
1379#if defined(FEAT_GUI)
1380 (char_u *)&p_guipty, PV_NONE,
1381#else
1382 (char_u *)NULL, PV_NONE,
1383#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001384 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar18144c82006-04-12 21:52:12 +00001385 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00001386#if defined(FEAT_GUI_TABLINE)
1387 (char_u *)&p_gtl, PV_NONE,
1388 {(char_u *)"", (char_u *)0L}
1389#else
1390 (char_u *)NULL, PV_NONE,
1391 {(char_u *)NULL, (char_u *)0L}
1392#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001393 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001394 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar57657d82006-04-21 22:12:41 +00001395#if defined(FEAT_GUI_TABLINE)
1396 (char_u *)&p_gtt, PV_NONE,
1397 {(char_u *)"", (char_u *)0L}
1398#else
1399 (char_u *)NULL, PV_NONE,
1400 {(char_u *)NULL, (char_u *)0L}
1401#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001402 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001403 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1404 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001405 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001406 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1407 (char_u *)&p_hf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001408 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1409 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001410 {"helpheight", "hh", P_NUM|P_VI_DEF,
1411#ifdef FEAT_WINDOWS
1412 (char_u *)&p_hh, PV_NONE,
1413#else
1414 (char_u *)NULL, PV_NONE,
1415#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001416 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001417 {"helplang", "hlg", P_STRING|P_VI_DEF|P_ONECOMMA,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001418#ifdef FEAT_MULTI_LANG
1419 (char_u *)&p_hlg, PV_NONE,
1420 {(char_u *)"", (char_u *)0L}
1421#else
1422 (char_u *)NULL, PV_NONE,
1423 {(char_u *)0L, (char_u *)0L}
1424#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001425 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001426 {"hidden", "hid", P_BOOL|P_VI_DEF,
1427 (char_u *)&p_hid, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001428 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001429 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001430 (char_u *)&p_hl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001431 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1432 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001433 {"history", "hi", P_NUM|P_VIM,
1434 (char_u *)&p_hi, PV_NONE,
Bram Moolenaar78159bb2014-06-25 11:48:54 +02001435 {(char_u *)0L, (char_u *)50L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001436 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1437#ifdef FEAT_RIGHTLEFT
1438 (char_u *)&p_hkmap, PV_NONE,
1439#else
1440 (char_u *)NULL, PV_NONE,
1441#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001442 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001443 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1444#ifdef FEAT_RIGHTLEFT
1445 (char_u *)&p_hkmapp, PV_NONE,
1446#else
1447 (char_u *)NULL, PV_NONE,
1448#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001449 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001450 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1451 (char_u *)&p_hls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001452 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001453 {"icon", NULL, P_BOOL|P_VI_DEF,
1454#ifdef FEAT_TITLE
1455 (char_u *)&p_icon, PV_NONE,
1456#else
1457 (char_u *)NULL, PV_NONE,
1458#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001459 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001460 {"iconstring", NULL, P_STRING|P_VI_DEF,
1461#ifdef FEAT_TITLE
1462 (char_u *)&p_iconstring, PV_NONE,
1463#else
1464 (char_u *)NULL, PV_NONE,
1465#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001466 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001467 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1468 (char_u *)&p_ic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001469 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001470 {"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
1471# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1472 (char_u *)&p_imaf, PV_NONE,
1473 {(char_u *)"", (char_u *)NULL}
1474# else
1475 (char_u *)NULL, PV_NONE,
1476 {(char_u *)NULL, (char_u *)0L}
1477# endif
1478 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001479 {"imactivatekey","imak",P_STRING|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001480#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001481 (char_u *)&p_imak, PV_NONE,
1482#else
1483 (char_u *)NULL, PV_NONE,
1484#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001485 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001486 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1487#ifdef USE_IM_CONTROL
1488 (char_u *)&p_imcmdline, PV_NONE,
1489#else
1490 (char_u *)NULL, PV_NONE,
1491#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001492 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001493 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1494#ifdef USE_IM_CONTROL
1495 (char_u *)&p_imdisable, PV_NONE,
1496#else
1497 (char_u *)NULL, PV_NONE,
1498#endif
1499#ifdef __sgi
1500 {(char_u *)TRUE, (char_u *)0L}
1501#else
1502 {(char_u *)FALSE, (char_u *)0L}
1503#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001504 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001505 {"iminsert", "imi", P_NUM|P_VI_DEF,
1506 (char_u *)&p_iminsert, PV_IMI,
1507#ifdef B_IMODE_IM
1508 {(char_u *)B_IMODE_IM, (char_u *)0L}
1509#else
1510 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1511#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001512 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001513 {"imsearch", "ims", P_NUM|P_VI_DEF,
1514 (char_u *)&p_imsearch, PV_IMS,
1515#ifdef B_IMODE_IM
1516 {(char_u *)B_IMODE_IM, (char_u *)0L}
1517#else
1518 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1519#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001520 SCRIPTID_INIT},
Bram Moolenaar4a460702013-06-29 14:42:26 +02001521 {"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001522# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1523 (char_u *)&p_imsf, PV_NONE,
1524 {(char_u *)"", (char_u *)NULL}
1525# else
1526 (char_u *)NULL, PV_NONE,
1527 {(char_u *)NULL, (char_u *)0L}
1528# endif
1529 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001530 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1531#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001532 (char_u *)&p_inc, PV_INC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001533 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1534#else
1535 (char_u *)NULL, PV_NONE,
1536 {(char_u *)0L, (char_u *)0L}
1537#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001538 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001539 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1540#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1541 (char_u *)&p_inex, PV_INEX,
1542 {(char_u *)"", (char_u *)0L}
1543#else
1544 (char_u *)NULL, PV_NONE,
1545 {(char_u *)0L, (char_u *)0L}
1546#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001547 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001548 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1549 (char_u *)&p_is, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001550 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001551 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1552#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1553 (char_u *)&p_inde, PV_INDE,
1554 {(char_u *)"", (char_u *)0L}
1555#else
1556 (char_u *)NULL, PV_NONE,
1557 {(char_u *)0L, (char_u *)0L}
1558#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001559 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001560 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001561#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1562 (char_u *)&p_indk, PV_INDK,
1563 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1564#else
1565 (char_u *)NULL, PV_NONE,
1566 {(char_u *)0L, (char_u *)0L}
1567#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001568 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001569 {"infercase", "inf", P_BOOL|P_VI_DEF,
1570 (char_u *)&p_inf, PV_INF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001571 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001572 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1573 (char_u *)&p_im, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001574 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001575 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1576 (char_u *)&p_isf, PV_NONE,
1577 {
1578#ifdef BACKSLASH_IN_FILENAME
1579 /* Excluded are: & and ^ are special in cmd.exe
1580 * ( and ) are used in text separating fnames */
1581 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1582#else
1583# ifdef AMIGA
1584 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1585# else
1586# ifdef VMS
1587 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1588# else /* UNIX et al. */
1589# ifdef EBCDIC
1590 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1591# else
1592 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1593# endif
1594# endif
1595# endif
1596#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001597 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001598 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1599 (char_u *)&p_isi, PV_NONE,
1600 {
1601#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1602 (char_u *)"@,48-57,_,128-167,224-235",
1603#else
1604# ifdef EBCDIC
1605 /* TODO: EBCDIC Check this! @ == isalpha()*/
1606 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1607 "112-120,128,140-142,156,158,172,"
1608 "174,186,191,203-207,219-225,235-239,"
1609 "251-254",
1610# else
1611 (char_u *)"@,48-57,_,192-255",
1612# endif
1613#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001614 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001615 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1616 (char_u *)&p_isk, PV_ISK,
1617 {
1618#ifdef EBCDIC
1619 (char_u *)"@,240-249,_",
1620 /* TODO: EBCDIC Check this! @ == isalpha()*/
1621 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1622 "112-120,128,140-142,156,158,172,"
1623 "174,186,191,203-207,219-225,235-239,"
1624 "251-254",
1625#else
1626 (char_u *)"@,48-57,_",
1627# if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1628 (char_u *)"@,48-57,_,128-167,224-235"
1629# else
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001630 ISK_LATIN1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001631# endif
1632#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001633 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001634 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1635 (char_u *)&p_isp, PV_NONE,
1636 {
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001637#if defined(MSDOS) || defined(MSWIN) || defined(OS2) \
1638 || (defined(MACOS) && !defined(MACOS_X)) \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001639 || defined(VMS)
1640 (char_u *)"@,~-255",
1641#else
1642# ifdef EBCDIC
1643 /* all chars above 63 are printable */
1644 (char_u *)"63-255",
1645# else
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00001646 ISP_LATIN1,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001647# endif
1648#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001649 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001650 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1651 (char_u *)&p_js, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001652 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001653 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1654#ifdef FEAT_CRYPT
1655 (char_u *)&p_key, PV_KEY,
1656 {(char_u *)"", (char_u *)0L}
1657#else
1658 (char_u *)NULL, PV_NONE,
1659 {(char_u *)0L, (char_u *)0L}
1660#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001661 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001662 {"keymap", "kmp", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF|P_RSTAT|P_NFNAME|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001663#ifdef FEAT_KEYMAP
1664 (char_u *)&p_keymap, PV_KMAP,
1665 {(char_u *)"", (char_u *)0L}
1666#else
1667 (char_u *)NULL, PV_NONE,
1668 {(char_u *)"", (char_u *)0L}
1669#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001670 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001671 {"keymodel", "km", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001672 (char_u *)&p_km, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001673 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001674 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001675 (char_u *)&p_kp, PV_KP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001676 {
1677#if defined(MSDOS) || defined(MSWIN)
1678 (char_u *)":help",
1679#else
1680#ifdef VMS
1681 (char_u *)"help",
1682#else
1683# if defined(OS2)
1684 (char_u *)"view /",
1685# else
1686# ifdef USEMAN_S
1687 (char_u *)"man -s",
1688# else
1689 (char_u *)"man",
1690# endif
1691# endif
1692#endif
1693#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001694 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001695 {"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001696#ifdef FEAT_LANGMAP
1697 (char_u *)&p_langmap, PV_NONE,
1698 {(char_u *)"", /* unmatched } */
1699#else
1700 (char_u *)NULL, PV_NONE,
1701 {(char_u *)NULL,
1702#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001703 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001704 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001705#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1706 (char_u *)&p_lm, PV_NONE,
1707#else
1708 (char_u *)NULL, PV_NONE,
1709#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001710 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar4391cf92014-11-05 17:44:52 +01001711 {"langnoremap", "lnr", P_BOOL|P_VI_DEF,
1712#ifdef FEAT_LANGMAP
1713 (char_u *)&p_lnr, PV_NONE,
1714#else
1715 (char_u *)NULL, PV_NONE,
1716#endif
1717 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001718 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1719#ifdef FEAT_WINDOWS
1720 (char_u *)&p_ls, PV_NONE,
1721#else
1722 (char_u *)NULL, PV_NONE,
1723#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001724 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001725 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1726 (char_u *)&p_lz, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001727 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001728 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1729#ifdef FEAT_LINEBREAK
1730 (char_u *)VAR_WIN, PV_LBR,
1731#else
1732 (char_u *)NULL, PV_NONE,
1733#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001734 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001735 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1736 (char_u *)&Rows, PV_NONE,
1737 {
1738#if defined(MSDOS) || defined(WIN3264) || defined(OS2)
1739 (char_u *)25L,
1740#else
1741 (char_u *)24L,
1742#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001743 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001744 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1745#ifdef FEAT_GUI
1746 (char_u *)&p_linespace, PV_NONE,
1747#else
1748 (char_u *)NULL, PV_NONE,
1749#endif
1750#ifdef FEAT_GUI_W32
1751 {(char_u *)1L, (char_u *)0L}
1752#else
1753 {(char_u *)0L, (char_u *)0L}
1754#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001755 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001756 {"lisp", NULL, P_BOOL|P_VI_DEF,
1757#ifdef FEAT_LISP
1758 (char_u *)&p_lisp, PV_LISP,
1759#else
1760 (char_u *)NULL, PV_NONE,
1761#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001762 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001763 {"lispwords", "lw", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001764#ifdef FEAT_LISP
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01001765 (char_u *)&p_lispwords, PV_LW,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001766 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1767#else
1768 (char_u *)NULL, PV_NONE,
1769 {(char_u *)"", (char_u *)0L}
1770#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001771 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001772 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1773 (char_u *)VAR_WIN, PV_LIST,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001774 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001775 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001776 (char_u *)&p_lcs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001777 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001778 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1779 (char_u *)&p_lpl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001780 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001781#ifdef FEAT_GUI_MAC
1782 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
1783 (char_u *)&p_macatsui, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001784 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001785#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001786 {"magic", NULL, P_BOOL|P_VI_DEF,
1787 (char_u *)&p_magic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001788 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00001789 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001790#ifdef FEAT_QUICKFIX
1791 (char_u *)&p_mef, PV_NONE,
1792 {(char_u *)"", (char_u *)0L}
1793#else
1794 (char_u *)NULL, PV_NONE,
1795 {(char_u *)NULL, (char_u *)0L}
1796#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001797 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001798 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1799#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001800 (char_u *)&p_mp, PV_MP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001801# ifdef VMS
1802 {(char_u *)"MMS", (char_u *)0L}
1803# else
1804 {(char_u *)"make", (char_u *)0L}
1805# endif
1806#else
1807 (char_u *)NULL, PV_NONE,
1808 {(char_u *)NULL, (char_u *)0L}
1809#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001810 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001811 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001812 (char_u *)&p_mps, PV_MPS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001813 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1814 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001815 {"matchtime", "mat", P_NUM|P_VI_DEF,
1816 (char_u *)&p_mat, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001817 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001818 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001819#ifdef FEAT_MBYTE
1820 (char_u *)&p_mco, PV_NONE,
1821#else
1822 (char_u *)NULL, PV_NONE,
1823#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001824 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001825 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1826#ifdef FEAT_EVAL
1827 (char_u *)&p_mfd, PV_NONE,
1828#else
1829 (char_u *)NULL, PV_NONE,
1830#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001831 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001832 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1833 (char_u *)&p_mmd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001834 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001835 {"maxmem", "mm", P_NUM|P_VI_DEF,
1836 (char_u *)&p_mm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001837 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1838 SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00001839 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1840 (char_u *)&p_mmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001841 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001842 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1843 (char_u *)&p_mmt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001844 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1845 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001846 {"menuitems", "mis", P_NUM|P_VI_DEF,
1847#ifdef FEAT_MENU
1848 (char_u *)&p_mis, PV_NONE,
1849#else
1850 (char_u *)NULL, PV_NONE,
1851#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001852 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001853 {"mesg", NULL, P_BOOL|P_VI_DEF,
1854 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001855 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001856 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001857#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001858 (char_u *)&p_msm, PV_NONE,
1859 {(char_u *)"460000,2000,500", (char_u *)0L}
1860#else
1861 (char_u *)NULL, PV_NONE,
1862 {(char_u *)0L, (char_u *)0L}
1863#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001864 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001865 {"modeline", "ml", P_BOOL|P_VIM,
1866 (char_u *)&p_ml, PV_ML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001867 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001868 {"modelines", "mls", P_NUM|P_VI_DEF,
1869 (char_u *)&p_mls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001870 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001871 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1872 (char_u *)&p_ma, PV_MA,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001873 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001874 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1875 (char_u *)&p_mod, PV_MOD,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001876 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001877 {"more", NULL, P_BOOL|P_VIM,
1878 (char_u *)&p_more, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001879 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001880 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
1881 (char_u *)&p_mouse, PV_NONE,
1882 {
1883#if defined(MSDOS) || defined(WIN3264)
1884 (char_u *)"a",
1885#else
1886 (char_u *)"",
1887#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001888 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001889 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
1890#ifdef FEAT_GUI
1891 (char_u *)&p_mousef, PV_NONE,
1892#else
1893 (char_u *)NULL, PV_NONE,
1894#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001895 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001896 {"mousehide", "mh", P_BOOL|P_VI_DEF,
1897#ifdef FEAT_GUI
1898 (char_u *)&p_mh, PV_NONE,
1899#else
1900 (char_u *)NULL, PV_NONE,
1901#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001902 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001903 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
1904 (char_u *)&p_mousem, PV_NONE,
1905 {
1906#if defined(MSDOS) || defined(MSWIN)
1907 (char_u *)"popup",
1908#else
1909# if defined(MACOS)
1910 (char_u *)"popup_setpos",
1911# else
1912 (char_u *)"extend",
1913# endif
1914#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001915 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001916 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001917#ifdef FEAT_MOUSESHAPE
1918 (char_u *)&p_mouseshape, PV_NONE,
1919 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
1920#else
1921 (char_u *)NULL, PV_NONE,
1922 {(char_u *)NULL, (char_u *)0L}
1923#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001924 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001925 {"mousetime", "mouset", P_NUM|P_VI_DEF,
1926 (char_u *)&p_mouset, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001927 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001928 {"mzquantum", "mzq", P_NUM,
1929#ifdef FEAT_MZSCHEME
1930 (char_u *)&p_mzq, PV_NONE,
1931#else
1932 (char_u *)NULL, PV_NONE,
1933#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001934 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001935 {"novice", NULL, P_BOOL|P_VI_DEF,
1936 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001937 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02001938 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001939 (char_u *)&p_nf, PV_NF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001940 {(char_u *)"octal,hex", (char_u *)0L}
1941 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001942 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
1943 (char_u *)VAR_WIN, PV_NU,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001944 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00001945 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
1946#ifdef FEAT_LINEBREAK
1947 (char_u *)VAR_WIN, PV_NUW,
1948#else
1949 (char_u *)NULL, PV_NONE,
1950#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001951 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
Bram Moolenaarf75a9632005-09-13 21:20:47 +00001952 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
Bram Moolenaare344bea2005-09-01 20:46:49 +00001953#ifdef FEAT_COMPL_FUNC
1954 (char_u *)&p_ofu, PV_OFU,
1955 {(char_u *)"", (char_u *)0L}
1956#else
1957 (char_u *)NULL, PV_NONE,
1958 {(char_u *)0L, (char_u *)0L}
1959#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001960 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001961 {"open", NULL, P_BOOL|P_VI_DEF,
1962 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001963 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar043545e2006-10-10 16:44:07 +00001964 {"opendevice", "odev", P_BOOL|P_VI_DEF,
1965#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1966 (char_u *)&p_odev, PV_NONE,
1967#else
1968 (char_u *)NULL, PV_NONE,
1969#endif
1970 {(char_u *)FALSE, (char_u *)FALSE}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001971 SCRIPTID_INIT},
Bram Moolenaar2c7a29c2005-12-12 22:02:31 +00001972 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
1973 (char_u *)&p_opfunc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001974 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001975 {"optimize", "opt", P_BOOL|P_VI_DEF,
1976 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001977 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001978 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001979 (char_u *)NULL, PV_NONE,
Bram Moolenaarb07269a2011-05-19 13:41:14 +02001980 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001981 {"paragraphs", "para", P_STRING|P_VI_DEF,
1982 (char_u *)&p_para, PV_NONE,
Bram Moolenaar57e48462008-03-12 16:38:55 +00001983 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001984 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001985 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001986 (char_u *)&p_paste, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001987 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001988 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
1989 (char_u *)&p_pt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001990 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001991 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
1992#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1993 (char_u *)&p_pex, PV_NONE,
1994 {(char_u *)"", (char_u *)0L}
1995#else
1996 (char_u *)NULL, PV_NONE,
1997 {(char_u *)0L, (char_u *)0L}
1998#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001999 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002000 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002001 (char_u *)&p_pm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002002 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002003 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002004 (char_u *)&p_path, PV_PATH,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002005 {
2006#if defined AMIGA || defined MSDOS || defined MSWIN
2007 (char_u *)".,,",
2008#else
2009# if defined(__EMX__)
2010 (char_u *)".,/emx/include,,",
2011# else /* Unix, probably */
2012 (char_u *)".,/usr/include,,",
2013# endif
2014#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002015 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002016 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
2017 (char_u *)&p_pi, PV_PI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002018 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00002019 {"previewheight", "pvh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002020#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2021 (char_u *)&p_pvh, PV_NONE,
2022#else
2023 (char_u *)NULL, PV_NONE,
2024#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002025 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002026 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2027#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
2028 (char_u *)VAR_WIN, PV_PVW,
2029#else
2030 (char_u *)NULL, PV_NONE,
2031#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002032 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002033 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002034#ifdef FEAT_PRINTER
2035 (char_u *)&p_pdev, PV_NONE,
2036 {(char_u *)"", (char_u *)0L}
2037#else
2038 (char_u *)NULL, PV_NONE,
2039 {(char_u *)NULL, (char_u *)0L}
2040#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002041 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002042 {"printencoding", "penc", P_STRING|P_VI_DEF,
2043#ifdef FEAT_POSTSCRIPT
2044 (char_u *)&p_penc, PV_NONE,
2045 {(char_u *)"", (char_u *)0L}
2046#else
2047 (char_u *)NULL, PV_NONE,
2048 {(char_u *)NULL, (char_u *)0L}
2049#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002050 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002051 {"printexpr", "pexpr", P_STRING|P_VI_DEF,
2052#ifdef FEAT_POSTSCRIPT
2053 (char_u *)&p_pexpr, PV_NONE,
2054 {(char_u *)"", (char_u *)0L}
2055#else
2056 (char_u *)NULL, PV_NONE,
2057 {(char_u *)NULL, (char_u *)0L}
2058#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002059 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002060 {"printfont", "pfn", P_STRING|P_VI_DEF,
2061#ifdef FEAT_PRINTER
2062 (char_u *)&p_pfn, PV_NONE,
2063 {
2064# ifdef MSWIN
2065 (char_u *)"Courier_New:h10",
2066# else
2067 (char_u *)"courier",
2068# endif
2069 (char_u *)0L}
2070#else
2071 (char_u *)NULL, PV_NONE,
2072 {(char_u *)NULL, (char_u *)0L}
2073#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002074 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002075 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
2076#ifdef FEAT_PRINTER
2077 (char_u *)&p_header, PV_NONE,
2078 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
2079#else
2080 (char_u *)NULL, PV_NONE,
2081 {(char_u *)NULL, (char_u *)0L}
2082#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002083 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002084 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
2085#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2086 (char_u *)&p_pmcs, PV_NONE,
2087 {(char_u *)"", (char_u *)0L}
2088#else
2089 (char_u *)NULL, PV_NONE,
2090 {(char_u *)NULL, (char_u *)0L}
2091#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002092 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002093 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2094#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2095 (char_u *)&p_pmfn, PV_NONE,
2096 {(char_u *)"", (char_u *)0L}
2097#else
2098 (char_u *)NULL, PV_NONE,
2099 {(char_u *)NULL, (char_u *)0L}
2100#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002101 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002102 {"printoptions", "popt", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002103#ifdef FEAT_PRINTER
2104 (char_u *)&p_popt, PV_NONE,
2105 {(char_u *)"", (char_u *)0L}
2106#else
2107 (char_u *)NULL, PV_NONE,
2108 {(char_u *)NULL, (char_u *)0L}
2109#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002110 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002111 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002112 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002113 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002114 {"pumheight", "ph", P_NUM|P_VI_DEF,
2115#ifdef FEAT_INS_EXPAND
2116 (char_u *)&p_ph, PV_NONE,
2117#else
2118 (char_u *)NULL, PV_NONE,
2119#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002120 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002121 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2122#ifdef FEAT_TEXTOBJ
2123 (char_u *)&p_qe, PV_QE,
2124 {(char_u *)"\\", (char_u *)0L}
2125#else
2126 (char_u *)NULL, PV_NONE,
2127 {(char_u *)NULL, (char_u *)0L}
2128#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002129 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002130 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2131 (char_u *)&p_ro, PV_RO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002132 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002133 {"redraw", NULL, P_BOOL|P_VI_DEF,
2134 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002135 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002136 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2137#ifdef FEAT_RELTIME
2138 (char_u *)&p_rdt, PV_NONE,
2139#else
2140 (char_u *)NULL, PV_NONE,
2141#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002142 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02002143 {"regexpengine", "re", P_NUM|P_VI_DEF,
2144 (char_u *)&p_re, PV_NONE,
2145 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002146 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2147 (char_u *)VAR_WIN, PV_RNU,
2148 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002149 {"remap", NULL, P_BOOL|P_VI_DEF,
2150 (char_u *)&p_remap, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002151 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002152 {"renderoptions", "rop", P_STRING|P_ONECOMMA|P_RCLR|P_VI_DEF,
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02002153#ifdef FEAT_RENDER_OPTIONS
2154 (char_u *)&p_rop, PV_NONE,
2155 {(char_u *)"", (char_u *)0L}
2156#else
2157 (char_u *)NULL, PV_NONE,
2158 {(char_u *)NULL, (char_u *)0L}
2159#endif
2160 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002161 {"report", NULL, P_NUM|P_VI_DEF,
2162 (char_u *)&p_report, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002163 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002164 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2165#ifdef WIN3264
2166 (char_u *)&p_rs, PV_NONE,
2167#else
2168 (char_u *)NULL, PV_NONE,
2169#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002170 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002171 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2172#ifdef FEAT_RIGHTLEFT
2173 (char_u *)&p_ri, PV_NONE,
2174#else
2175 (char_u *)NULL, PV_NONE,
2176#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002177 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002178 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2179#ifdef FEAT_RIGHTLEFT
2180 (char_u *)VAR_WIN, PV_RL,
2181#else
2182 (char_u *)NULL, PV_NONE,
2183#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002184 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002185 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2186#ifdef FEAT_RIGHTLEFT
2187 (char_u *)VAR_WIN, PV_RLC,
2188 {(char_u *)"search", (char_u *)NULL}
2189#else
2190 (char_u *)NULL, PV_NONE,
2191 {(char_u *)NULL, (char_u *)0L}
2192#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002193 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002194 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2195#ifdef FEAT_CMDL_INFO
2196 (char_u *)&p_ru, PV_NONE,
2197#else
2198 (char_u *)NULL, PV_NONE,
2199#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002200 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002201 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2202#ifdef FEAT_STL_OPT
2203 (char_u *)&p_ruf, PV_NONE,
2204#else
2205 (char_u *)NULL, PV_NONE,
2206#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002207 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002208 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_ONECOMMA|P_NODUP
2209 |P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002210 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002211 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2212 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002213 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2214 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002215 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002216 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2217#ifdef FEAT_SCROLLBIND
2218 (char_u *)VAR_WIN, PV_SCBIND,
2219#else
2220 (char_u *)NULL, PV_NONE,
2221#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002222 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002223 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2224 (char_u *)&p_sj, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002225 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002226 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2227 (char_u *)&p_so, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002228 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002229 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002230#ifdef FEAT_SCROLLBIND
2231 (char_u *)&p_sbo, PV_NONE,
2232 {(char_u *)"ver,jump", (char_u *)0L}
2233#else
2234 (char_u *)NULL, PV_NONE,
2235 {(char_u *)0L, (char_u *)0L}
2236#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002237 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002238 {"sections", "sect", P_STRING|P_VI_DEF,
2239 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002240 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2241 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002242 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2243 (char_u *)&p_secure, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002244 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002245 {"selection", "sel", P_STRING|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002246 (char_u *)&p_sel, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002247 {(char_u *)"inclusive", (char_u *)0L}
2248 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002249 {"selectmode", "slm", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002250 (char_u *)&p_slm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002251 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002252 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002253#ifdef FEAT_SESSION
2254 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002255 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002256 (char_u *)0L}
2257#else
2258 (char_u *)NULL, PV_NONE,
2259 {(char_u *)0L, (char_u *)0L}
2260#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002261 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002262 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2263 (char_u *)&p_sh, PV_NONE,
2264 {
2265#ifdef VMS
2266 (char_u *)"-",
2267#else
2268# if defined(MSDOS)
2269 (char_u *)"command",
2270# else
2271# if defined(WIN16)
2272 (char_u *)"command.com",
2273# else
2274# if defined(WIN3264)
2275 (char_u *)"", /* set in set_init_1() */
2276# else
2277# if defined(OS2)
2278 (char_u *)"cmd.exe",
2279# else
2280# if defined(ARCHIE)
2281 (char_u *)"gos",
2282# else
2283 (char_u *)"sh",
2284# endif
2285# endif
2286# endif
2287# endif
2288# endif
2289#endif /* VMS */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002290 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002291 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2292 (char_u *)&p_shcf, PV_NONE,
2293 {
2294#if defined(MSDOS) || defined(MSWIN)
2295 (char_u *)"/c",
2296#else
2297# if defined(OS2)
2298 (char_u *)"/c",
2299# else
2300 (char_u *)"-c",
2301# endif
2302#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002303 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002304 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2305#ifdef FEAT_QUICKFIX
2306 (char_u *)&p_sp, PV_NONE,
2307 {
2308#if defined(UNIX) || defined(OS2)
2309# ifdef ARCHIE
2310 (char_u *)"2>",
2311# else
2312 (char_u *)"| tee",
2313# endif
2314#else
2315 (char_u *)">",
2316#endif
2317 (char_u *)0L}
2318#else
2319 (char_u *)NULL, PV_NONE,
2320 {(char_u *)0L, (char_u *)0L}
2321#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002322 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002323 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2324 (char_u *)&p_shq, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002325 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002326 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2327 (char_u *)&p_srr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002328 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002329 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2330#ifdef BACKSLASH_IN_FILENAME
2331 (char_u *)&p_ssl, PV_NONE,
2332#else
2333 (char_u *)NULL, PV_NONE,
2334#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002335 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002336 {"shelltemp", "stmp", P_BOOL,
2337 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002338 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002339 {"shelltype", "st", P_NUM|P_VI_DEF,
2340#ifdef AMIGA
2341 (char_u *)&p_st, PV_NONE,
2342#else
2343 (char_u *)NULL, PV_NONE,
2344#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002345 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002346 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2347 (char_u *)&p_sxq, PV_NONE,
2348 {
2349#if defined(UNIX) && defined(USE_SYSTEM) && !defined(__EMX__)
2350 (char_u *)"\"",
2351#else
2352 (char_u *)"",
2353#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002354 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002355 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
2356 (char_u *)&p_sxe, PV_NONE,
2357 {
2358#if defined(MSDOS) || defined(WIN16) || defined(WIN3264)
2359 (char_u *)"\"&|<>()@^",
2360#else
2361 (char_u *)"",
2362#endif
2363 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002364 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2365 (char_u *)&p_sr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002366 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002367 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2368 (char_u *)&p_sw, PV_SW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002369 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002370 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2371 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002372 {(char_u *)"", (char_u *)"filnxtToO"}
2373 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002374 {"shortname", "sn", P_BOOL|P_VI_DEF,
2375#ifdef SHORT_FNAME
2376 (char_u *)NULL, PV_NONE,
2377#else
2378 (char_u *)&p_sn, PV_SN,
2379#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002380 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002381 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2382#ifdef FEAT_LINEBREAK
2383 (char_u *)&p_sbr, PV_NONE,
2384#else
2385 (char_u *)NULL, PV_NONE,
2386#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002387 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002388 {"showcmd", "sc", P_BOOL|P_VIM,
2389#ifdef FEAT_CMDL_INFO
2390 (char_u *)&p_sc, PV_NONE,
2391#else
2392 (char_u *)NULL, PV_NONE,
2393#endif
2394 {(char_u *)FALSE,
2395#ifdef UNIX
2396 (char_u *)FALSE
2397#else
2398 (char_u *)TRUE
2399#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002400 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002401 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2402 (char_u *)&p_sft, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002403 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002404 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2405 (char_u *)&p_sm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002406 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002407 {"showmode", "smd", P_BOOL|P_VIM,
2408 (char_u *)&p_smd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002409 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002410 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2411#ifdef FEAT_WINDOWS
2412 (char_u *)&p_stal, PV_NONE,
2413#else
2414 (char_u *)NULL, PV_NONE,
2415#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002416 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002417 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2418 (char_u *)&p_ss, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002419 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002420 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2421 (char_u *)&p_siso, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002422 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002423 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2424 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002425 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002426 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2427 (char_u *)&p_scs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002428 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002429 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2430#ifdef FEAT_SMARTINDENT
2431 (char_u *)&p_si, PV_SI,
2432#else
2433 (char_u *)NULL, PV_NONE,
2434#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002435 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002436 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2437 (char_u *)&p_sta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002438 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002439 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2440 (char_u *)&p_sts, PV_STS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002441 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002442 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2443 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002444 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002445 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002446#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002447 (char_u *)VAR_WIN, PV_SPELL,
2448#else
2449 (char_u *)NULL, PV_NONE,
2450#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002451 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002452 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002453#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002454 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002455 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002456#else
2457 (char_u *)NULL, PV_NONE,
2458 {(char_u *)0L, (char_u *)0L}
2459#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002460 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002461 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE
2462 |P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002463#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002464 (char_u *)&p_spf, PV_SPF,
2465 {(char_u *)"", (char_u *)0L}
2466#else
2467 (char_u *)NULL, PV_NONE,
2468 {(char_u *)0L, (char_u *)0L}
2469#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002470 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002471 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_ONECOMMA
2472 |P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002473#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002474 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002475 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002476#else
2477 (char_u *)NULL, PV_NONE,
2478 {(char_u *)0L, (char_u *)0L}
2479#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002480 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002481 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_ONECOMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002482#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002483 (char_u *)&p_sps, PV_NONE,
2484 {(char_u *)"best", (char_u *)0L}
2485#else
2486 (char_u *)NULL, PV_NONE,
2487 {(char_u *)0L, (char_u *)0L}
2488#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002489 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002490 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2491#ifdef FEAT_WINDOWS
2492 (char_u *)&p_sb, PV_NONE,
2493#else
2494 (char_u *)NULL, PV_NONE,
2495#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002496 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002497 {"splitright", "spr", P_BOOL|P_VI_DEF,
2498#ifdef FEAT_VERTSPLIT
2499 (char_u *)&p_spr, PV_NONE,
2500#else
2501 (char_u *)NULL, PV_NONE,
2502#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002503 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002504 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2505 (char_u *)&p_sol, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002506 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002507 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2508#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002509 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002510#else
2511 (char_u *)NULL, PV_NONE,
2512#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002513 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002514 {"suffixes", "su", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002515 (char_u *)&p_su, PV_NONE,
2516 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002517 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002518 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002519#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002520 (char_u *)&p_sua, PV_SUA,
2521 {(char_u *)"", (char_u *)0L}
2522#else
2523 (char_u *)NULL, PV_NONE,
2524 {(char_u *)0L, (char_u *)0L}
2525#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002526 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002527 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2528 (char_u *)&p_swf, PV_SWF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002529 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002530 {"swapsync", "sws", P_STRING|P_VI_DEF,
2531 (char_u *)&p_sws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002532 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002533 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002534 (char_u *)&p_swb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002535 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002536 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2537#ifdef FEAT_SYN_HL
2538 (char_u *)&p_smc, PV_SMC,
2539 {(char_u *)3000L, (char_u *)0L}
2540#else
2541 (char_u *)NULL, PV_NONE,
2542 {(char_u *)0L, (char_u *)0L}
2543#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002544 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002545 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002546#ifdef FEAT_SYN_HL
2547 (char_u *)&p_syn, PV_SYN,
2548 {(char_u *)"", (char_u *)0L}
2549#else
2550 (char_u *)NULL, PV_NONE,
2551 {(char_u *)0L, (char_u *)0L}
2552#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002553 SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002554 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2555#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002556 (char_u *)&p_tal, PV_NONE,
2557#else
2558 (char_u *)NULL, PV_NONE,
2559#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002560 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002561 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2562#ifdef FEAT_WINDOWS
2563 (char_u *)&p_tpm, PV_NONE,
2564#else
2565 (char_u *)NULL, PV_NONE,
2566#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002567 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002568 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2569 (char_u *)&p_ts, PV_TS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002570 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002571 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2572 (char_u *)&p_tbs, PV_NONE,
2573#ifdef VMS /* binary searching doesn't appear to work on VMS */
2574 {(char_u *)0L, (char_u *)0L}
2575#else
2576 {(char_u *)TRUE, (char_u *)0L}
2577#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002578 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002579 {"taglength", "tl", P_NUM|P_VI_DEF,
2580 (char_u *)&p_tl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002581 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002582 {"tagrelative", "tr", P_BOOL|P_VIM,
2583 (char_u *)&p_tr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002584 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002585 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002586 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002587 {
2588#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2589 (char_u *)"./tags,./TAGS,tags,TAGS",
2590#else
2591 (char_u *)"./tags,tags",
2592#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002593 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002594 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2595 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002596 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002597 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2598 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002599 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002600 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2601#ifdef FEAT_ARABIC
2602 (char_u *)&p_tbidi, PV_NONE,
2603#else
2604 (char_u *)NULL, PV_NONE,
2605#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002606 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002607 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2608#ifdef FEAT_MBYTE
2609 (char_u *)&p_tenc, PV_NONE,
2610 {(char_u *)"", (char_u *)0L}
2611#else
2612 (char_u *)NULL, PV_NONE,
2613 {(char_u *)0L, (char_u *)0L}
2614#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002615 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002616 {"terse", NULL, P_BOOL|P_VI_DEF,
2617 (char_u *)&p_terse, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002618 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002619 {"textauto", "ta", P_BOOL|P_VIM,
2620 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002621 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2622 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002623 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2624 (char_u *)&p_tx, PV_TX,
2625 {
2626#ifdef USE_CRNL
2627 (char_u *)TRUE,
2628#else
2629 (char_u *)FALSE,
2630#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002631 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +02002632 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002633 (char_u *)&p_tw, PV_TW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002634 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002635 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002636#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002637 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002638#else
2639 (char_u *)NULL, PV_NONE,
2640#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002641 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002642 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2643 (char_u *)&p_to, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002644 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002645 {"timeout", "to", P_BOOL|P_VI_DEF,
2646 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002647 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002648 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2649 (char_u *)&p_tm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002650 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002651 {"title", NULL, P_BOOL|P_VI_DEF,
2652#ifdef FEAT_TITLE
2653 (char_u *)&p_title, PV_NONE,
2654#else
2655 (char_u *)NULL, PV_NONE,
2656#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002657 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002658 {"titlelen", NULL, P_NUM|P_VI_DEF,
2659#ifdef FEAT_TITLE
2660 (char_u *)&p_titlelen, PV_NONE,
2661#else
2662 (char_u *)NULL, PV_NONE,
2663#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002664 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002665 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002666#ifdef FEAT_TITLE
2667 (char_u *)&p_titleold, PV_NONE,
2668 {(char_u *)N_("Thanks for flying Vim"),
2669 (char_u *)0L}
2670#else
2671 (char_u *)NULL, PV_NONE,
2672 {(char_u *)0L, (char_u *)0L}
2673#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002674 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002675 {"titlestring", NULL, P_STRING|P_VI_DEF,
2676#ifdef FEAT_TITLE
2677 (char_u *)&p_titlestring, PV_NONE,
2678#else
2679 (char_u *)NULL, PV_NONE,
2680#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002681 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002682#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002683 {"toolbar", "tb", P_STRING|P_ONECOMMA|P_VI_DEF|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002684 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002685 {(char_u *)"icons,tooltips", (char_u *)0L}
2686 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002687#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002688#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002689 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
2690 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002691 {(char_u *)"small", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002692#endif
2693 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2694 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002695 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002696 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2697 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002698 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002699 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2700 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002701 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002702 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2703 (char_u *)&p_tf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002704 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002705 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2706#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2707 (char_u *)&p_ttym, PV_NONE,
2708#else
2709 (char_u *)NULL, PV_NONE,
2710#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002711 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002712 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2713 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002714 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002715 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2716 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002717 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002718 {"undodir", "udir", P_STRING|P_EXPAND|P_ONECOMMA|P_NODUP|P_SECURE
2719 |P_VI_DEF,
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002720#ifdef FEAT_PERSISTENT_UNDO
2721 (char_u *)&p_udir, PV_NONE,
2722 {(char_u *)".", (char_u *)0L}
2723#else
2724 (char_u *)NULL, PV_NONE,
2725 {(char_u *)0L, (char_u *)0L}
2726#endif
2727 SCRIPTID_INIT},
2728 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2729#ifdef FEAT_PERSISTENT_UNDO
2730 (char_u *)&p_udf, PV_UDF,
2731#else
2732 (char_u *)NULL, PV_NONE,
2733#endif
2734 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002735 {"undolevels", "ul", P_NUM|P_VI_DEF,
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01002736 (char_u *)&p_ul, PV_UL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002737 {
2738#if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS)
2739 (char_u *)1000L,
2740#else
2741 (char_u *)100L,
2742#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002743 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar59f931e2010-07-24 20:27:03 +02002744 {"undoreload", "ur", P_NUM|P_VI_DEF,
2745 (char_u *)&p_ur, PV_NONE,
2746 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002747 {"updatecount", "uc", P_NUM|P_VI_DEF,
2748 (char_u *)&p_uc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002749 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002750 {"updatetime", "ut", P_NUM|P_VI_DEF,
2751 (char_u *)&p_ut, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002752 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002753 {"verbose", "vbs", P_NUM|P_VI_DEF,
2754 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002755 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002756 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2757 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002758 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002759 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2760#ifdef FEAT_SESSION
2761 (char_u *)&p_vdir, PV_NONE,
2762 {(char_u *)DFLT_VDIR, (char_u *)0L}
2763#else
2764 (char_u *)NULL, PV_NONE,
2765 {(char_u *)0L, (char_u *)0L}
2766#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002767 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002768 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002769#ifdef FEAT_SESSION
2770 (char_u *)&p_vop, PV_NONE,
2771 {(char_u *)"folds,options,cursor", (char_u *)0L}
2772#else
2773 (char_u *)NULL, PV_NONE,
2774 {(char_u *)0L, (char_u *)0L}
2775#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002776 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002777 {"viminfo", "vi", P_STRING|P_ONECOMMA|P_NODUP|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002778#ifdef FEAT_VIMINFO
2779 (char_u *)&p_viminfo, PV_NONE,
2780#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
Bram Moolenaard812df62008-11-09 12:46:09 +00002781 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002782#else
2783# ifdef AMIGA
2784 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002785 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002786# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002787 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002788# endif
2789#endif
2790#else
2791 (char_u *)NULL, PV_NONE,
2792 {(char_u *)0L, (char_u *)0L}
2793#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002794 SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002795 {"virtualedit", "ve", P_STRING|P_ONECOMMA|P_NODUP|P_VI_DEF
2796 |P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002797#ifdef FEAT_VIRTUALEDIT
2798 (char_u *)&p_ve, PV_NONE,
2799 {(char_u *)"", (char_u *)""}
2800#else
2801 (char_u *)NULL, PV_NONE,
2802 {(char_u *)0L, (char_u *)0L}
2803#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002804 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002805 {"visualbell", "vb", P_BOOL|P_VI_DEF,
2806 (char_u *)&p_vb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002807 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002808 {"w300", NULL, P_NUM|P_VI_DEF,
2809 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002810 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002811 {"w1200", NULL, P_NUM|P_VI_DEF,
2812 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002813 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002814 {"w9600", NULL, P_NUM|P_VI_DEF,
2815 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002816 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002817 {"warn", NULL, P_BOOL|P_VI_DEF,
2818 (char_u *)&p_warn, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002819 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002820 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
2821 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002822 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002823 {"whichwrap", "ww", P_STRING|P_VIM|P_ONECOMMA|P_FLAGLIST,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002824 (char_u *)&p_ww, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002825 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002826 {"wildchar", "wc", P_NUM|P_VIM,
2827 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002828 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
2829 SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002830 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002831 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002832 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002833 {"wildignore", "wig", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002834#ifdef FEAT_WILDIGN
2835 (char_u *)&p_wig, PV_NONE,
2836#else
2837 (char_u *)NULL, PV_NONE,
2838#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002839 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002840 {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
2841 (char_u *)&p_wic, PV_NONE,
2842 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002843 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
2844#ifdef FEAT_WILDMENU
2845 (char_u *)&p_wmnu, PV_NONE,
2846#else
2847 (char_u *)NULL, PV_NONE,
2848#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002849 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02002850 {"wildmode", "wim", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002851 (char_u *)&p_wim, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002852 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00002853 {"wildoptions", "wop", P_STRING|P_VI_DEF,
2854#ifdef FEAT_CMDL_COMPL
2855 (char_u *)&p_wop, PV_NONE,
2856 {(char_u *)"", (char_u *)0L}
2857#else
2858 (char_u *)NULL, PV_NONE,
2859 {(char_u *)NULL, (char_u *)0L}
2860#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002861 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002862 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
2863#ifdef FEAT_WAK
2864 (char_u *)&p_wak, PV_NONE,
2865 {(char_u *)"menu", (char_u *)0L}
2866#else
2867 (char_u *)NULL, PV_NONE,
2868 {(char_u *)NULL, (char_u *)0L}
2869#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002870 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002871 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00002872 (char_u *)&p_window, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002873 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002874 {"winheight", "wh", P_NUM|P_VI_DEF,
2875#ifdef FEAT_WINDOWS
2876 (char_u *)&p_wh, PV_NONE,
2877#else
2878 (char_u *)NULL, PV_NONE,
2879#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002880 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002881 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002882#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002883 (char_u *)VAR_WIN, PV_WFH,
2884#else
2885 (char_u *)NULL, PV_NONE,
2886#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002887 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002888 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
2889#ifdef FEAT_VERTSPLIT
2890 (char_u *)VAR_WIN, PV_WFW,
2891#else
2892 (char_u *)NULL, PV_NONE,
2893#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002894 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002895 {"winminheight", "wmh", P_NUM|P_VI_DEF,
2896#ifdef FEAT_WINDOWS
2897 (char_u *)&p_wmh, PV_NONE,
2898#else
2899 (char_u *)NULL, PV_NONE,
2900#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002901 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002902 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
2903#ifdef FEAT_VERTSPLIT
2904 (char_u *)&p_wmw, PV_NONE,
2905#else
2906 (char_u *)NULL, PV_NONE,
2907#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002908 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002909 {"winwidth", "wiw", P_NUM|P_VI_DEF,
2910#ifdef FEAT_VERTSPLIT
2911 (char_u *)&p_wiw, PV_NONE,
2912#else
2913 (char_u *)NULL, PV_NONE,
2914#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002915 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002916 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
2917 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002918 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002919 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
2920 (char_u *)&p_wm, PV_WM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002921 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002922 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
2923 (char_u *)&p_ws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002924 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002925 {"write", NULL, P_BOOL|P_VI_DEF,
2926 (char_u *)&p_write, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002927 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002928 {"writeany", "wa", P_BOOL|P_VI_DEF,
2929 (char_u *)&p_wa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002930 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002931 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
2932 (char_u *)&p_wb, PV_NONE,
2933 {
2934#ifdef FEAT_WRITEBACKUP
2935 (char_u *)TRUE,
2936#else
2937 (char_u *)FALSE,
2938#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002939 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002940 {"writedelay", "wd", P_NUM|P_VI_DEF,
2941 (char_u *)&p_wd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002942 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002943
2944/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002945#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00002946 (char_u *)&vvv, PV_NONE, \
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002947 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002948
2949 p_term("t_AB", T_CAB)
2950 p_term("t_AF", T_CAF)
2951 p_term("t_AL", T_CAL)
2952 p_term("t_al", T_AL)
2953 p_term("t_bc", T_BC)
2954 p_term("t_cd", T_CD)
2955 p_term("t_ce", T_CE)
2956 p_term("t_cl", T_CL)
2957 p_term("t_cm", T_CM)
2958 p_term("t_Co", T_CCO)
2959 p_term("t_CS", T_CCS)
2960 p_term("t_cs", T_CS)
2961#ifdef FEAT_VERTSPLIT
2962 p_term("t_CV", T_CSV)
2963#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002964 p_term("t_da", T_DA)
2965 p_term("t_db", T_DB)
2966 p_term("t_DL", T_CDL)
2967 p_term("t_dl", T_DL)
Bram Moolenaare5401222015-06-25 19:16:56 +02002968 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002969 p_term("t_fs", T_FS)
2970 p_term("t_IE", T_CIE)
2971 p_term("t_IS", T_CIS)
2972 p_term("t_ke", T_KE)
2973 p_term("t_ks", T_KS)
2974 p_term("t_le", T_LE)
2975 p_term("t_mb", T_MB)
2976 p_term("t_md", T_MD)
2977 p_term("t_me", T_ME)
2978 p_term("t_mr", T_MR)
2979 p_term("t_ms", T_MS)
2980 p_term("t_nd", T_ND)
2981 p_term("t_op", T_OP)
Bram Moolenaare5401222015-06-25 19:16:56 +02002982 p_term("t_RB", T_RBG)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002983 p_term("t_RI", T_CRI)
2984 p_term("t_RV", T_CRV)
2985 p_term("t_Sb", T_CSB)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002986 p_term("t_se", T_SE)
Bram Moolenaare5401222015-06-25 19:16:56 +02002987 p_term("t_Sf", T_CSF)
2988 p_term("t_SI", T_CSI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002989 p_term("t_so", T_SO)
Bram Moolenaare5401222015-06-25 19:16:56 +02002990 p_term("t_SR", T_CSR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002991 p_term("t_sr", T_SR)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002992 p_term("t_te", T_TE)
2993 p_term("t_ti", T_TI)
Bram Moolenaare5401222015-06-25 19:16:56 +02002994 p_term("t_ts", T_TS)
2995 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002996 p_term("t_ue", T_UE)
2997 p_term("t_us", T_US)
Bram Moolenaare5401222015-06-25 19:16:56 +02002998 p_term("t_ut", T_UT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002999 p_term("t_vb", T_VB)
3000 p_term("t_ve", T_VE)
3001 p_term("t_vi", T_VI)
3002 p_term("t_vs", T_VS)
3003 p_term("t_WP", T_CWP)
3004 p_term("t_WS", T_CWS)
Bram Moolenaar494838a2015-02-10 19:20:37 +01003005 p_term("t_xn", T_XN)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003006 p_term("t_xs", T_XS)
3007 p_term("t_ZH", T_CZH)
3008 p_term("t_ZR", T_CZR)
3009
3010/* terminal key codes are not in here */
3011
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00003012 /* end marker */
3013 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00003014};
3015
3016#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
3017
3018#ifdef FEAT_MBYTE
3019static char *(p_ambw_values[]) = {"single", "double", NULL};
3020#endif
3021static char *(p_bg_values[]) = {"light", "dark", NULL};
3022static char *(p_nf_values[]) = {"octal", "hex", "alpha", NULL};
3023static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003024#ifdef FEAT_CRYPT
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02003025static char *(p_cm_values[]) = {"zip", "blowfish", "blowfish2", NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02003026#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00003027#ifdef FEAT_CMDL_COMPL
3028static char *(p_wop_values[]) = {"tagfile", NULL};
3029#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003030#ifdef FEAT_WAK
3031static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
3032#endif
3033static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003034static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
3035static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003036static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003037#ifdef FEAT_BROWSE
3038static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
3039#endif
3040#ifdef FEAT_SCROLLBIND
3041static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
3042#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00003043static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00003044#ifdef FEAT_VERTSPLIT
3045static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
3046#endif
3047#if defined(FEAT_QUICKFIX)
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003048# ifdef FEAT_AUTOCMD
3049static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
3050# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003051static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003052# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003053static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
3054#endif
3055static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
3056#ifdef FEAT_FOLDING
3057static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003058# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00003059 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003060# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003061 NULL};
3062static char *(p_fcl_values[]) = {"all", NULL};
3063#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003064#ifdef FEAT_INS_EXPAND
Bram Moolenaarb6be1e22015-07-10 18:18:40 +02003065static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", "noinsert", "noselect", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003066#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003067
3068static void set_option_default __ARGS((int, int opt_flags, int compatible));
3069static void set_options_default __ARGS((int opt_flags));
Bram Moolenaarf740b292006-02-16 22:11:02 +00003070static char_u *term_bg_default __ARGS((void));
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003071static void did_set_option __ARGS((int opt_idx, int opt_flags, int new_value));
Bram Moolenaar071d4272004-06-13 20:20:40 +00003072static char_u *illegal_char __ARGS((char_u *, int));
3073static int string_to_key __ARGS((char_u *arg));
3074#ifdef FEAT_CMDWIN
3075static char_u *check_cedit __ARGS((void));
3076#endif
3077#ifdef FEAT_TITLE
3078static void did_set_title __ARGS((int icon));
3079#endif
3080static char_u *option_expand __ARGS((int opt_idx, char_u *val));
3081static void didset_options __ARGS((void));
3082static void check_string_option __ARGS((char_u **pp));
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003083#if defined(FEAT_EVAL) || defined(PROTO)
3084static long_u *insecure_flag __ARGS((int opt_idx, int opt_flags));
3085#else
3086# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3087#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003088static void set_string_option_global __ARGS((int opt_idx, char_u **varp));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02003089static char_u *set_string_option __ARGS((int opt_idx, char_u *value, int opt_flags));
Bram Moolenaar071d4272004-06-13 20:20:40 +00003090static 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));
3091static char_u *set_chars_option __ARGS((char_u **varp));
Bram Moolenaar1a384422010-07-14 19:53:30 +02003092#ifdef FEAT_SYN_HL
3093static int int_cmp __ARGS((const void *a, const void *b));
3094#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003095#ifdef FEAT_CLIPBOARD
3096static char_u *check_clipboard_option __ARGS((void));
3097#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003098#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02003099static char_u *compile_cap_prog __ARGS((synblock_T *synblock));
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003100#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003101#ifdef FEAT_EVAL
3102static void set_option_scriptID_idx __ARGS((int opt_idx, int opt_flags, int id));
3103#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003104static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value, int opt_flags));
Bram Moolenaar555b2802005-05-19 21:08:39 +00003105static 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 +00003106static void check_redraw __ARGS((long_u flags));
3107static int findoption __ARGS((char_u *));
3108static int find_key_option __ARGS((char_u *));
3109static void showoptions __ARGS((int all, int opt_flags));
3110static int optval_default __ARGS((struct vimoption *, char_u *varp));
3111static void showoneopt __ARGS((struct vimoption *, int opt_flags));
3112static int put_setstring __ARGS((FILE *fd, char *cmd, char *name, char_u **valuep, int expand));
3113static int put_setnum __ARGS((FILE *fd, char *cmd, char *name, long *valuep));
3114static int put_setbool __ARGS((FILE *fd, char *cmd, char *name, int value));
3115static int istermoption __ARGS((struct vimoption *));
3116static char_u *get_varp_scope __ARGS((struct vimoption *p, int opt_flags));
3117static char_u *get_varp __ARGS((struct vimoption *));
3118static void option_value2string __ARGS((struct vimoption *, int opt_flags));
Bram Moolenaar8dc907d2014-06-25 14:44:10 +02003119static void check_winopt __ARGS((winopt_T *wop));
Bram Moolenaar071d4272004-06-13 20:20:40 +00003120static int wc_use_keyname __ARGS((char_u *varp, long *wcp));
3121#ifdef FEAT_LANGMAP
3122static void langmap_init __ARGS((void));
3123static void langmap_set __ARGS((void));
3124#endif
3125static void paste_option_changed __ARGS((void));
3126static void compatible_set __ARGS((void));
3127#ifdef FEAT_LINEBREAK
3128static void fill_breakat_flags __ARGS((void));
3129#endif
3130static int opt_strings_flags __ARGS((char_u *val, char **values, unsigned *flagp, int list));
3131static int check_opt_strings __ARGS((char_u *val, char **values, int));
3132static int check_opt_wim __ARGS((void));
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02003133#ifdef FEAT_LINEBREAK
3134static int briopt_check __ARGS((win_T *wp));
3135#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003136
3137/*
3138 * Initialize the options, first part.
3139 *
3140 * Called only once from main(), just after creating the first buffer.
3141 */
3142 void
3143set_init_1()
3144{
3145 char_u *p;
3146 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003147 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003148
3149#ifdef FEAT_LANGMAP
3150 langmap_init();
3151#endif
3152
3153 /* Be Vi compatible by default */
3154 p_cp = TRUE;
3155
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003156 /* Use POSIX compatibility when $VIM_POSIX is set. */
3157 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003158 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003159 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003160 set_string_default("shm", (char_u *)"A");
3161 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003162
Bram Moolenaar071d4272004-06-13 20:20:40 +00003163 /*
3164 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003165 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003166 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003167 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003168#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
3169# ifdef __EMX__
Bram Moolenaar7c626922005-02-07 22:01:03 +00003170 || ((p = mch_getenv((char_u *)"EMXSHELL")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003171# endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003172 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003173# ifdef WIN3264
Bram Moolenaar7c626922005-02-07 22:01:03 +00003174 || ((p = default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003175# endif
3176#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003177 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003178 set_string_default("sh", p);
3179
3180#ifdef FEAT_WILDIGN
3181 /*
3182 * Set the default for 'backupskip' to include environment variables for
3183 * temp files.
3184 */
3185 {
3186# ifdef UNIX
3187 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3188# else
3189 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3190# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003191 int len;
3192 garray_T ga;
3193 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003194
3195 ga_init2(&ga, 1, 100);
3196 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3197 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003198 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003199# ifdef UNIX
3200 if (*names[n] == NUL)
3201 p = (char_u *)"/tmp";
3202 else
3203# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003204 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003205 if (p != NULL && *p != NUL)
3206 {
3207 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003208 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003209 if (ga_grow(&ga, len) == OK)
3210 {
3211 if (ga.ga_len > 0)
3212 STRCAT(ga.ga_data, ",");
3213 STRCAT(ga.ga_data, p);
3214 add_pathsep(ga.ga_data);
3215 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003216 ga.ga_len += len;
3217 }
3218 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003219 if (mustfree)
3220 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003221 }
3222 if (ga.ga_data != NULL)
3223 {
3224 set_string_default("bsk", ga.ga_data);
3225 vim_free(ga.ga_data);
3226 }
3227 }
3228#endif
3229
3230 /*
3231 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3232 */
3233 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003234 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003235 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003236#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3237 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3238#endif
3239 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003240#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003241 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003242 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003243#else
3244# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003245 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003246 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003247# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003248 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003249# endif
3250#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003251 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003252 opt_idx = findoption((char_u *)"maxmem");
3253 if (opt_idx >= 0)
3254 {
3255#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
Bram Moolenaar427d51c2013-06-16 16:01:25 +02003256 if ((long)options[opt_idx].def_val[VI_DEFAULT] > (long)n
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003257 || (long)options[opt_idx].def_val[VI_DEFAULT] == 0L)
3258#endif
3259 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3260 }
3261 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003262 }
3263
3264#ifdef FEAT_GUI_W32
3265 /* force 'shortname' for Win32s */
3266 if (gui_is_win32s())
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003267 {
3268 opt_idx = findoption((char_u *)"shortname");
3269 if (opt_idx >= 0)
3270 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)TRUE;
3271 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003272#endif
3273
3274#ifdef FEAT_SEARCHPATH
3275 {
3276 char_u *cdpath;
3277 char_u *buf;
3278 int i;
3279 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003280 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003281
3282 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003283 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003284 if (cdpath != NULL)
3285 {
3286 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3287 if (buf != NULL)
3288 {
3289 buf[0] = ','; /* start with ",", current dir first */
3290 j = 1;
3291 for (i = 0; cdpath[i] != NUL; ++i)
3292 {
3293 if (vim_ispathlistsep(cdpath[i]))
3294 buf[j++] = ',';
3295 else
3296 {
3297 if (cdpath[i] == ' ' || cdpath[i] == ',')
3298 buf[j++] = '\\';
3299 buf[j++] = cdpath[i];
3300 }
3301 }
3302 buf[j] = NUL;
3303 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003304 if (opt_idx >= 0)
3305 {
3306 options[opt_idx].def_val[VI_DEFAULT] = buf;
3307 options[opt_idx].flags |= P_DEF_ALLOCED;
3308 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003309 else
3310 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003311 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003312 if (mustfree)
3313 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003314 }
3315 }
3316#endif
3317
3318#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(OS2) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
3319 /* Set print encoding on platforms that don't default to latin1 */
3320 set_string_default("penc",
3321# if defined(MSWIN) || defined(OS2)
3322 (char_u *)"cp1252"
3323# else
3324# ifdef VMS
3325 (char_u *)"dec-mcs"
3326# else
3327# ifdef EBCDIC
3328 (char_u *)"ebcdic-uk"
3329# else
3330# ifdef MAC
3331 (char_u *)"mac-roman"
3332# else /* HPUX */
3333 (char_u *)"hp-roman8"
3334# endif
3335# endif
3336# endif
3337# endif
3338 );
3339#endif
3340
3341#ifdef FEAT_POSTSCRIPT
3342 /* 'printexpr' must be allocated to be able to evaluate it. */
3343 set_string_default("pexpr",
Bram Moolenaared203462004-06-16 11:19:22 +00003344# if defined(MSWIN) || defined(MSDOS) || defined(OS2)
3345 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003346# else
3347# ifdef VMS
3348 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3349
3350# else
3351 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3352# endif
3353# endif
3354 );
3355#endif
3356
3357 /*
3358 * Set all the options (except the terminal options) to their default
3359 * value. Also set the global value for local options.
3360 */
3361 set_options_default(0);
3362
3363#ifdef FEAT_GUI
3364 if (found_reverse_arg)
3365 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3366#endif
3367
3368 curbuf->b_p_initialized = TRUE;
3369 curbuf->b_p_ar = -1; /* no local 'autoread' value */
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01003370 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003371 check_buf_options(curbuf);
3372 check_win_options(curwin);
3373 check_options();
3374
3375 /* Must be before option_expand(), because that one needs vim_isIDc() */
3376 didset_options();
3377
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003378#ifdef FEAT_SPELL
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003379 /* Use the current chartab for the generic chartab. */
3380 init_spell_chartab();
3381#endif
3382
Bram Moolenaar071d4272004-06-13 20:20:40 +00003383#ifdef FEAT_LINEBREAK
3384 /*
3385 * initialize the table for 'breakat'.
3386 */
3387 fill_breakat_flags();
3388#endif
3389
3390 /*
3391 * Expand environment variables and things like "~" for the defaults.
3392 * If option_expand() returns non-NULL the variable is expanded. This can
3393 * only happen for non-indirect options.
3394 * Also set the default to the expanded value, so ":set" does not list
3395 * them.
3396 * Don't set the P_ALLOCED flag, because we don't want to free the
3397 * default.
3398 */
3399 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3400 {
3401 if ((options[opt_idx].flags & P_GETTEXT)
3402 && options[opt_idx].var != NULL)
3403 p = (char_u *)_(*(char **)options[opt_idx].var);
3404 else
3405 p = option_expand(opt_idx, NULL);
3406 if (p != NULL && (p = vim_strsave(p)) != NULL)
3407 {
3408 *(char_u **)options[opt_idx].var = p;
3409 /* VIMEXP
3410 * Defaults for all expanded options are currently the same for Vi
3411 * and Vim. When this changes, add some code here! Also need to
3412 * split P_DEF_ALLOCED in two.
3413 */
3414 if (options[opt_idx].flags & P_DEF_ALLOCED)
3415 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3416 options[opt_idx].def_val[VI_DEFAULT] = p;
3417 options[opt_idx].flags |= P_DEF_ALLOCED;
3418 }
3419 }
3420
3421 /* Initialize the highlight_attr[] table. */
3422 highlight_changed();
3423
3424 save_file_ff(curbuf); /* Buffer is unchanged */
3425
3426 /* Parse default for 'wildmode' */
3427 check_opt_wim();
3428
3429#if defined(FEAT_ARABIC)
3430 /* Detect use of mlterm.
3431 * Mlterm is a terminal emulator akin to xterm that has some special
3432 * abilities (bidi namely).
3433 * NOTE: mlterm's author is being asked to 'set' a variable
3434 * instead of an environment variable due to inheritance.
3435 */
3436 if (mch_getenv((char_u *)"MLTERM") != NULL)
3437 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3438#endif
3439
3440#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
3441 /* Parse default for 'fillchars'. */
3442 (void)set_chars_option(&p_fcs);
3443#endif
3444
3445#ifdef FEAT_CLIPBOARD
3446 /* Parse default for 'clipboard' */
3447 (void)check_clipboard_option();
3448#endif
3449
3450#ifdef FEAT_MBYTE
3451# if defined(WIN3264) && defined(FEAT_GETTEXT)
3452 /*
3453 * If $LANG isn't set, try to get a good value for it. This makes the
3454 * right language be used automatically. Don't do this for English.
3455 */
3456 if (mch_getenv((char_u *)"LANG") == NULL)
3457 {
3458 char buf[20];
3459
3460 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3461 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3462 * only the first two. */
3463 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3464 (LPTSTR)buf, 20);
3465 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3466 {
3467 /* There are a few exceptions (probably more) */
3468 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3469 STRCPY(buf, "zh_TW");
3470 else if (STRNICMP(buf, "chs", 3) == 0
3471 || STRNICMP(buf, "zhc", 3) == 0)
3472 STRCPY(buf, "zh_CN");
3473 else if (STRNICMP(buf, "jp", 2) == 0)
3474 STRCPY(buf, "ja");
3475 else
3476 buf[2] = NUL; /* truncate to two-letter code */
3477 vim_setenv("LANG", buf);
3478 }
3479 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003480# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003481# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003482 /* Moved to os_mac_conv.c to avoid dependency problems. */
3483 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003484# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003485# endif
3486
3487 /* enc_locale() will try to find the encoding of the current locale. */
3488 p = enc_locale();
3489 if (p != NULL)
3490 {
3491 char_u *save_enc;
3492
3493 /* Try setting 'encoding' and check if the value is valid.
3494 * If not, go back to the default "latin1". */
3495 save_enc = p_enc;
3496 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003497 if (STRCMP(p_enc, "gb18030") == 0)
3498 {
3499 /* We don't support "gb18030", but "cp936" is a good substitute
3500 * for practical purposes, thus use that. It's not an alias to
3501 * still support conversion between gb18030 and utf-8. */
3502 p_enc = vim_strsave((char_u *)"cp936");
3503 vim_free(p);
3504 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003505 if (mb_init() == NULL)
3506 {
3507 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003508 if (opt_idx >= 0)
3509 {
3510 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3511 options[opt_idx].flags |= P_DEF_ALLOCED;
3512 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003513
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003514#if defined(MSDOS) || defined(MSWIN) || defined(OS2) || defined(MACOS) \
3515 || defined(VMS)
3516 if (STRCMP(p_enc, "latin1") == 0
3517# ifdef FEAT_MBYTE
3518 || enc_utf8
3519# endif
3520 )
3521 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003522 /* Adjust the default for 'isprint' and 'iskeyword' to match
3523 * latin1. Also set the defaults for when 'nocompatible' is
3524 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003525 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003526 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003527 set_string_option_direct((char_u *)"isk", -1,
3528 ISK_LATIN1, OPT_FREE, SID_NONE);
3529 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003530 if (opt_idx >= 0)
3531 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003532 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003533 if (opt_idx >= 0)
3534 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003535 (void)init_chartab();
3536 }
3537#endif
3538
Bram Moolenaar071d4272004-06-13 20:20:40 +00003539# if defined(WIN3264) && !defined(FEAT_GUI)
3540 /* Win32 console: When GetACP() returns a different value from
3541 * GetConsoleCP() set 'termencoding'. */
3542 if (GetACP() != GetConsoleCP())
3543 {
3544 char buf[50];
3545
3546 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3547 p_tenc = vim_strsave((char_u *)buf);
3548 if (p_tenc != NULL)
3549 {
3550 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003551 if (opt_idx >= 0)
3552 {
3553 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3554 options[opt_idx].flags |= P_DEF_ALLOCED;
3555 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003556 convert_setup(&input_conv, p_tenc, p_enc);
3557 convert_setup(&output_conv, p_enc, p_tenc);
3558 }
3559 else
3560 p_tenc = empty_option;
3561 }
3562# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003563# if defined(WIN3264) && defined(FEAT_MBYTE)
3564 /* $HOME may have characters in active code page. */
3565 init_homedir();
3566# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003567 }
3568 else
3569 {
3570 vim_free(p_enc);
3571 p_enc = save_enc;
3572 }
3573 }
3574#endif
3575
3576#ifdef FEAT_MULTI_LANG
3577 /* Set the default for 'helplang'. */
3578 set_helplang_default(get_mess_lang());
3579#endif
3580}
3581
3582/*
3583 * Set an option to its default value.
3584 * This does not take care of side effects!
3585 */
3586 static void
3587set_option_default(opt_idx, opt_flags, compatible)
3588 int opt_idx;
3589 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3590 int compatible; /* use Vi default value */
3591{
3592 char_u *varp; /* pointer to variable for current option */
3593 int dvi; /* index in def_val[] */
3594 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003595 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003596 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3597
3598 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3599 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003600 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003601 {
3602 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3603 if (flags & P_STRING)
3604 {
3605 /* Use set_string_option_direct() for local options to handle
3606 * freeing and allocating the value. */
3607 if (options[opt_idx].indir != PV_NONE)
3608 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003609 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003610 else
3611 {
3612 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3613 free_string_option(*(char_u **)(varp));
3614 *(char_u **)varp = options[opt_idx].def_val[dvi];
3615 options[opt_idx].flags &= ~P_ALLOCED;
3616 }
3617 }
3618 else if (flags & P_NUM)
3619 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003620 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003621 win_comp_scroll(curwin);
3622 else
3623 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003624 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003625 /* May also set global value for local option. */
3626 if (both)
3627 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3628 *(long *)varp;
3629 }
3630 }
3631 else /* P_BOOL */
3632 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003633 /* the cast to long is required for Manx C, long_i is needed for
3634 * MSVC */
3635 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003636#ifdef UNIX
3637 /* 'modeline' defaults to off for root */
3638 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3639 *(int *)varp = FALSE;
3640#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003641 /* May also set global value for local option. */
3642 if (both)
3643 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3644 *(int *)varp;
3645 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003646
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003647 /* The default value is not insecure. */
3648 flagsp = insecure_flag(opt_idx, opt_flags);
3649 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003650 }
3651
3652#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003653 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003654#endif
3655}
3656
3657/*
3658 * Set all options (except terminal options) to their default value.
3659 */
3660 static void
3661set_options_default(opt_flags)
3662 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3663{
3664 int i;
3665#ifdef FEAT_WINDOWS
3666 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003667 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003668#endif
3669
3670 for (i = 0; !istermoption(&options[i]); i++)
3671 if (!(options[i].flags & P_NODEFAULT))
3672 set_option_default(i, opt_flags, p_cp);
3673
3674#ifdef FEAT_WINDOWS
3675 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003676 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003677 win_comp_scroll(wp);
3678#else
3679 win_comp_scroll(curwin);
3680#endif
Bram Moolenaar5a4eceb2014-09-09 17:33:07 +02003681#ifdef FEAT_CINDENT
3682 parse_cino(curbuf);
3683#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003684}
3685
3686/*
3687 * Set the Vi-default value of a string option.
3688 * Used for 'sh', 'backupskip' and 'term'.
3689 */
3690 void
3691set_string_default(name, val)
3692 char *name;
3693 char_u *val;
3694{
3695 char_u *p;
3696 int opt_idx;
3697
3698 p = vim_strsave(val);
3699 if (p != NULL) /* we don't want a NULL */
3700 {
3701 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003702 if (opt_idx >= 0)
3703 {
3704 if (options[opt_idx].flags & P_DEF_ALLOCED)
3705 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3706 options[opt_idx].def_val[VI_DEFAULT] = p;
3707 options[opt_idx].flags |= P_DEF_ALLOCED;
3708 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003709 }
3710}
3711
3712/*
3713 * Set the Vi-default value of a number option.
3714 * Used for 'lines' and 'columns'.
3715 */
3716 void
3717set_number_default(name, val)
3718 char *name;
3719 long val;
3720{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003721 int opt_idx;
3722
3723 opt_idx = findoption((char_u *)name);
3724 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003725 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003726}
3727
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003728#if defined(EXITFREE) || defined(PROTO)
3729/*
3730 * Free all options.
3731 */
3732 void
3733free_all_options()
3734{
3735 int i;
3736
3737 for (i = 0; !istermoption(&options[i]); i++)
3738 {
3739 if (options[i].indir == PV_NONE)
3740 {
3741 /* global option: free value and default value. */
3742 if (options[i].flags & P_ALLOCED && options[i].var != NULL)
3743 free_string_option(*(char_u **)options[i].var);
3744 if (options[i].flags & P_DEF_ALLOCED)
3745 free_string_option(options[i].def_val[VI_DEFAULT]);
3746 }
3747 else if (options[i].var != VAR_WIN
3748 && (options[i].flags & P_STRING))
3749 /* buffer-local option: free global value */
3750 free_string_option(*(char_u **)options[i].var);
3751 }
3752}
3753#endif
3754
3755
Bram Moolenaar071d4272004-06-13 20:20:40 +00003756/*
3757 * Initialize the options, part two: After getting Rows and Columns and
3758 * setting 'term'.
3759 */
3760 void
3761set_init_2()
3762{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003763 int idx;
3764
Bram Moolenaar071d4272004-06-13 20:20:40 +00003765 /*
3766 * 'scroll' defaults to half the window height. Note that this default is
3767 * wrong when the window height changes.
3768 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003769 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003770 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003771 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003772 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003773 comp_col();
3774
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003775 /*
3776 * 'window' is only for backwards compatibility with Vi.
3777 * Default is Rows - 1.
3778 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003779 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003780 p_window = Rows - 1;
3781 set_number_default("window", Rows - 1);
3782
Bram Moolenaarf740b292006-02-16 22:11:02 +00003783 /* For DOS console the default is always black. */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003784#if !((defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003785 /*
3786 * If 'background' wasn't set by the user, try guessing the value,
3787 * depending on the terminal name. Only need to check for terminals
3788 * with a dark background, that can handle color.
3789 */
3790 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003791 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3792 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003793 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003794 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003795 /* don't mark it as set, when starting the GUI it may be
3796 * changed again */
3797 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003798 }
3799#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003800
3801#ifdef CURSOR_SHAPE
3802 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3803#endif
3804#ifdef FEAT_MOUSESHAPE
3805 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3806#endif
3807#ifdef FEAT_PRINTER
3808 (void)parse_printoptions(); /* parse 'printoptions' default value */
3809#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003810}
3811
3812/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00003813 * Return "dark" or "light" depending on the kind of terminal.
3814 * This is just guessing! Recognized are:
3815 * "linux" Linux console
3816 * "screen.linux" Linux console with screen
3817 * "cygwin" Cygwin shell
3818 * "putty" Putty program
3819 * We also check the COLORFGBG environment variable, which is set by
3820 * rxvt and derivatives. This variable contains either two or three
3821 * values separated by semicolons; we want the last value in either
3822 * case. If this value is 0-6 or 8, our background is dark.
3823 */
3824 static char_u *
3825term_bg_default()
3826{
Bram Moolenaarf740b292006-02-16 22:11:02 +00003827#if defined(MSDOS) || defined(OS2) || defined(WIN3264)
3828 /* DOS console nearly always black */
3829 return (char_u *)"dark";
3830#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00003831 char_u *p;
3832
Bram Moolenaarf740b292006-02-16 22:11:02 +00003833 if (STRCMP(T_NAME, "linux") == 0
3834 || STRCMP(T_NAME, "screen.linux") == 0
3835 || STRCMP(T_NAME, "cygwin") == 0
3836 || STRCMP(T_NAME, "putty") == 0
3837 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
3838 && (p = vim_strrchr(p, ';')) != NULL
3839 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
3840 && p[2] == NUL))
3841 return (char_u *)"dark";
3842 return (char_u *)"light";
3843#endif
3844}
3845
3846/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00003847 * Initialize the options, part three: After reading the .vimrc
3848 */
3849 void
3850set_init_3()
3851{
3852#if defined(UNIX) || defined(OS2) || defined(WIN3264)
3853/*
3854 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
3855 * This is done after other initializations, where 'shell' might have been
3856 * set, but only if they have not been set before.
3857 */
3858 char_u *p;
3859 int idx_srr;
3860 int do_srr;
3861#ifdef FEAT_QUICKFIX
3862 int idx_sp;
3863 int do_sp;
3864#endif
3865
3866 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003867 if (idx_srr < 0)
3868 do_srr = FALSE;
3869 else
3870 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003871#ifdef FEAT_QUICKFIX
3872 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003873 if (idx_sp < 0)
3874 do_sp = FALSE;
3875 else
3876 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003877#endif
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003878 p = get_isolated_shell_name();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003879 if (p != NULL)
3880 {
3881 /*
3882 * Default for p_sp is "| tee", for p_srr is ">".
3883 * For known shells it is changed here to include stderr.
3884 */
3885 if ( fnamecmp(p, "csh") == 0
3886 || fnamecmp(p, "tcsh") == 0
3887# if defined(OS2) || defined(WIN3264) /* also check with .exe extension */
3888 || fnamecmp(p, "csh.exe") == 0
3889 || fnamecmp(p, "tcsh.exe") == 0
3890# endif
3891 )
3892 {
3893#if defined(FEAT_QUICKFIX)
3894 if (do_sp)
3895 {
3896# ifdef WIN3264
3897 p_sp = (char_u *)">&";
3898# else
3899 p_sp = (char_u *)"|& tee";
3900# endif
3901 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3902 }
3903#endif
3904 if (do_srr)
3905 {
3906 p_srr = (char_u *)">&";
3907 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3908 }
3909 }
3910 else
3911# ifndef OS2 /* Always use bourne shell style redirection if we reach this */
3912 if ( fnamecmp(p, "sh") == 0
3913 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003914 || fnamecmp(p, "mksh") == 0
3915 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003916 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003917 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003918 || fnamecmp(p, "bash") == 0
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003919 || fnamecmp(p, "fish") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003920# ifdef WIN3264
3921 || fnamecmp(p, "cmd") == 0
3922 || fnamecmp(p, "sh.exe") == 0
3923 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003924 || fnamecmp(p, "mksh.exe") == 0
3925 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003926 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003927 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003928 || fnamecmp(p, "bash.exe") == 0
3929 || fnamecmp(p, "cmd.exe") == 0
3930# endif
3931 )
3932# endif
3933 {
3934#if defined(FEAT_QUICKFIX)
3935 if (do_sp)
3936 {
3937# ifdef WIN3264
3938 p_sp = (char_u *)">%s 2>&1";
3939# else
3940 p_sp = (char_u *)"2>&1| tee";
3941# endif
3942 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3943 }
3944#endif
3945 if (do_srr)
3946 {
3947 p_srr = (char_u *)">%s 2>&1";
3948 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3949 }
3950 }
3951 vim_free(p);
3952 }
3953#endif
3954
3955#if defined(MSDOS) || defined(WIN3264) || defined(OS2)
3956 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01003957 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
3958 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003959 * This is done after other initializations, where 'shell' might have been
3960 * set, but only if they have not been set before. Default for p_shcf is
3961 * "/c", for p_shq is "". For "sh" like shells it is changed here to
3962 * "-c" and "\"", but not for DJGPP, because it starts the shell without
3963 * command.com. And for Win32 we need to set p_sxq instead.
3964 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00003965 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003966 {
3967 int idx3;
3968
3969 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003970 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003971 {
3972 p_shcf = (char_u *)"-c";
3973 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3974 }
3975
3976# ifndef DJGPP
3977# ifdef WIN3264
3978 /* Somehow Win32 requires the quotes around the redirection too */
3979 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003980 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003981 {
3982 p_sxq = (char_u *)"\"";
3983 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3984 }
3985# else
3986 idx3 = findoption((char_u *)"shq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003987 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003988 {
3989 p_shq = (char_u *)"\"";
3990 options[idx3].def_val[VI_DEFAULT] = p_shq;
3991 }
3992# endif
3993# endif
3994 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01003995 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
3996 {
3997 int idx3;
3998
3999 /*
4000 * cmd.exe on Windows will strip the first and last double quote given
4001 * on the command line, e.g. most of the time things like:
4002 * cmd /c "my path/to/echo" "my args to echo"
4003 * become:
4004 * my path/to/echo" "my args to echo
4005 * when executed.
4006 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01004007 * To avoid this, set shellxquote to surround the command in
4008 * parenthesis. This appears to make most commands work, without
4009 * breaking commands that worked previously, such as
4010 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01004011 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01004012 idx3 = findoption((char_u *)"sxq");
4013 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4014 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004015 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004016 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4017 }
4018
Bram Moolenaara64ba222012-02-12 23:23:31 +01004019 idx3 = findoption((char_u *)"shcf");
4020 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4021 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004022 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004023 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4024 }
4025 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004026#endif
4027
4028#ifdef FEAT_TITLE
4029 set_title_defaults();
4030#endif
4031}
4032
4033#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4034/*
4035 * When 'helplang' is still at its default value, set it to "lang".
4036 * Only the first two characters of "lang" are used.
4037 */
4038 void
4039set_helplang_default(lang)
4040 char_u *lang;
4041{
4042 int idx;
4043
4044 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4045 return;
4046 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004047 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004048 {
4049 if (options[idx].flags & P_ALLOCED)
4050 free_string_option(p_hlg);
4051 p_hlg = vim_strsave(lang);
4052 if (p_hlg == NULL)
4053 p_hlg = empty_option;
4054 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004055 {
4056 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4057 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4058 {
4059 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4060 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4061 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004062 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004063 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004064 options[idx].flags |= P_ALLOCED;
4065 }
4066}
4067#endif
4068
4069#ifdef FEAT_GUI
4070static char_u *gui_bg_default __ARGS((void));
4071
4072 static char_u *
4073gui_bg_default()
4074{
4075 if (gui_get_lightness(gui.back_pixel) < 127)
4076 return (char_u *)"dark";
4077 return (char_u *)"light";
4078}
4079
4080/*
4081 * Option initializations that can only be done after opening the GUI window.
4082 */
4083 void
4084init_gui_options()
4085{
4086 /* Set the 'background' option according to the lightness of the
4087 * background color, unless the user has set it already. */
4088 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4089 {
4090 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4091 highlight_changed();
4092 }
4093}
4094#endif
4095
4096#ifdef FEAT_TITLE
4097/*
4098 * 'title' and 'icon' only default to true if they have not been set or reset
4099 * in .vimrc and we can read the old value.
4100 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4101 * they can be reset. This reduces startup time when using X on a remote
4102 * machine.
4103 */
4104 void
4105set_title_defaults()
4106{
4107 int idx1;
4108 long val;
4109
4110 /*
4111 * If GUI is (going to be) used, we can always set the window title and
4112 * icon name. Saves a bit of time, because the X11 display server does
4113 * not need to be contacted.
4114 */
4115 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004116 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004117 {
4118#ifdef FEAT_GUI
4119 if (gui.starting || gui.in_use)
4120 val = TRUE;
4121 else
4122#endif
4123 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004124 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004125 p_title = val;
4126 }
4127 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004128 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004129 {
4130#ifdef FEAT_GUI
4131 if (gui.starting || gui.in_use)
4132 val = TRUE;
4133 else
4134#endif
4135 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004136 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004137 p_icon = val;
4138 }
4139}
4140#endif
4141
4142/*
4143 * Parse 'arg' for option settings.
4144 *
4145 * 'arg' may be IObuff, but only when no errors can be present and option
4146 * does not need to be expanded with option_expand().
4147 * "opt_flags":
4148 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004149 * OPT_GLOBAL for ":setglobal"
4150 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004151 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004152 * OPT_WINONLY to only set window-local options
4153 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004154 *
4155 * returns FAIL if an error is detected, OK otherwise
4156 */
4157 int
4158do_set(arg, opt_flags)
4159 char_u *arg; /* option string (may be written to!) */
4160 int opt_flags;
4161{
4162 int opt_idx;
4163 char_u *errmsg;
4164 char_u errbuf[80];
4165 char_u *startarg;
4166 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4167 int nextchar; /* next non-white char after option name */
4168 int afterchar; /* character just after option name */
4169 int len;
4170 int i;
4171 long value;
4172 int key;
4173 long_u flags; /* flags for current option */
4174 char_u *varp = NULL; /* pointer to variable for current option */
4175 int did_show = FALSE; /* already showed one value */
4176 int adding; /* "opt+=arg" */
4177 int prepending; /* "opt^=arg" */
4178 int removing; /* "opt-=arg" */
4179 int cp_val = 0;
4180 char_u key_name[2];
4181
4182 if (*arg == NUL)
4183 {
4184 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004185 did_show = TRUE;
4186 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004187 }
4188
4189 while (*arg != NUL) /* loop to process all options */
4190 {
4191 errmsg = NULL;
4192 startarg = arg; /* remember for error message */
4193
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004194 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4195 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004196 {
4197 /*
4198 * ":set all" show all options.
4199 * ":set all&" set all options to their default value.
4200 */
4201 arg += 3;
4202 if (*arg == '&')
4203 {
4204 ++arg;
4205 /* Only for :set command set global value of local options. */
4206 set_options_default(OPT_FREE | opt_flags);
4207 }
4208 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004209 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004210 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004211 did_show = TRUE;
4212 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004213 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004214 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004215 {
4216 showoptions(2, opt_flags);
4217 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004218 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004219 arg += 7;
4220 }
4221 else
4222 {
4223 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004224 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004225 {
4226 prefix = 0;
4227 arg += 2;
4228 }
4229 else if (STRNCMP(arg, "inv", 3) == 0)
4230 {
4231 prefix = 2;
4232 arg += 3;
4233 }
4234
4235 /* find end of name */
4236 key = 0;
4237 if (*arg == '<')
4238 {
4239 nextchar = 0;
4240 opt_idx = -1;
4241 /* look out for <t_>;> */
4242 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4243 len = 5;
4244 else
4245 {
4246 len = 1;
4247 while (arg[len] != NUL && arg[len] != '>')
4248 ++len;
4249 }
4250 if (arg[len] != '>')
4251 {
4252 errmsg = e_invarg;
4253 goto skip;
4254 }
4255 arg[len] = NUL; /* put NUL after name */
4256 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4257 opt_idx = findoption(arg + 1);
4258 arg[len++] = '>'; /* restore '>' */
4259 if (opt_idx == -1)
4260 key = find_key_option(arg + 1);
4261 }
4262 else
4263 {
4264 len = 0;
4265 /*
4266 * The two characters after "t_" may not be alphanumeric.
4267 */
4268 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4269 len = 4;
4270 else
4271 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4272 ++len;
4273 nextchar = arg[len];
4274 arg[len] = NUL; /* put NUL after name */
4275 opt_idx = findoption(arg);
4276 arg[len] = nextchar; /* restore nextchar */
4277 if (opt_idx == -1)
4278 key = find_key_option(arg);
4279 }
4280
4281 /* remember character after option name */
4282 afterchar = arg[len];
4283
4284 /* skip white space, allow ":set ai ?" */
4285 while (vim_iswhite(arg[len]))
4286 ++len;
4287
4288 adding = FALSE;
4289 prepending = FALSE;
4290 removing = FALSE;
4291 if (arg[len] != NUL && arg[len + 1] == '=')
4292 {
4293 if (arg[len] == '+')
4294 {
4295 adding = TRUE; /* "+=" */
4296 ++len;
4297 }
4298 else if (arg[len] == '^')
4299 {
4300 prepending = TRUE; /* "^=" */
4301 ++len;
4302 }
4303 else if (arg[len] == '-')
4304 {
4305 removing = TRUE; /* "-=" */
4306 ++len;
4307 }
4308 }
4309 nextchar = arg[len];
4310
4311 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4312 {
4313 errmsg = (char_u *)N_("E518: Unknown option");
4314 goto skip;
4315 }
4316
4317 if (opt_idx >= 0)
4318 {
4319 if (options[opt_idx].var == NULL) /* hidden option: skip */
4320 {
4321 /* Only give an error message when requesting the value of
4322 * a hidden option, ignore setting it. */
4323 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4324 && (!(options[opt_idx].flags & P_BOOL)
4325 || nextchar == '?'))
4326 errmsg = (char_u *)N_("E519: Option not supported");
4327 goto skip;
4328 }
4329
4330 flags = options[opt_idx].flags;
4331 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4332 }
4333 else
4334 {
4335 flags = P_STRING;
4336 if (key < 0)
4337 {
4338 key_name[0] = KEY2TERMCAP0(key);
4339 key_name[1] = KEY2TERMCAP1(key);
4340 }
4341 else
4342 {
4343 key_name[0] = KS_KEY;
4344 key_name[1] = (key & 0xff);
4345 }
4346 }
4347
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004348 /* Skip all options that are not window-local (used when showing
4349 * an already loaded buffer in a window). */
4350 if ((opt_flags & OPT_WINONLY)
4351 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4352 goto skip;
4353
Bram Moolenaara3227e22006-03-08 21:32:40 +00004354 /* Skip all options that are window-local (used for :vimgrep). */
4355 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4356 && options[opt_idx].var == VAR_WIN)
4357 goto skip;
4358
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004359 /* Disallow changing some options from modelines. */
4360 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004361 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004362 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004363 {
4364 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4365 goto skip;
4366 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004367#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004368 /* In diff mode some options are overruled. This avoids that
4369 * 'foldmethod' becomes "marker" instead of "diff" and that
4370 * "wrap" gets set. */
4371 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004372 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004373 && (options[opt_idx].indir == PV_FDM
4374 || options[opt_idx].indir == PV_WRAP))
4375 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004376#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004377 }
4378
4379#ifdef HAVE_SANDBOX
4380 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004381 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004382 {
4383 errmsg = (char_u *)_(e_sandbox);
4384 goto skip;
4385 }
4386#endif
4387
4388 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4389 {
4390 arg += len;
4391 cp_val = p_cp;
4392 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4393 {
4394 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4395 {
4396 cp_val = FALSE;
4397 arg += 3;
4398 }
4399 else /* "opt&vi": set to Vi default */
4400 {
4401 cp_val = TRUE;
4402 arg += 2;
4403 }
4404 }
4405 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
4406 && arg[1] != NUL && !vim_iswhite(arg[1]))
4407 {
4408 errmsg = e_trailing;
4409 goto skip;
4410 }
4411 }
4412
4413 /*
4414 * allow '=' and ':' as MSDOS command.com allows only one
4415 * '=' character per "set" command line. grrr. (jw)
4416 */
4417 if (nextchar == '?'
4418 || (prefix == 1
4419 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4420 && !(flags & P_BOOL)))
4421 {
4422 /*
4423 * print value
4424 */
4425 if (did_show)
4426 msg_putchar('\n'); /* cursor below last one */
4427 else
4428 {
4429 gotocmdline(TRUE); /* cursor at status line */
4430 did_show = TRUE; /* remember that we did a line */
4431 }
4432 if (opt_idx >= 0)
4433 {
4434 showoneopt(&options[opt_idx], opt_flags);
4435#ifdef FEAT_EVAL
4436 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004437 {
4438 /* Mention where the option was last set. */
4439 if (varp == options[opt_idx].var)
4440 last_set_msg(options[opt_idx].scriptID);
4441 else if ((int)options[opt_idx].indir & PV_WIN)
4442 last_set_msg(curwin->w_p_scriptID[
4443 (int)options[opt_idx].indir & PV_MASK]);
4444 else if ((int)options[opt_idx].indir & PV_BUF)
4445 last_set_msg(curbuf->b_p_scriptID[
4446 (int)options[opt_idx].indir & PV_MASK]);
4447 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004448#endif
4449 }
4450 else
4451 {
4452 char_u *p;
4453
4454 p = find_termcode(key_name);
4455 if (p == NULL)
4456 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004457 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004458 goto skip;
4459 }
4460 else
4461 (void)show_one_termcode(key_name, p, TRUE);
4462 }
4463 if (nextchar != '?'
4464 && nextchar != NUL && !vim_iswhite(afterchar))
4465 errmsg = e_trailing;
4466 }
4467 else
4468 {
4469 if (flags & P_BOOL) /* boolean */
4470 {
4471 if (nextchar == '=' || nextchar == ':')
4472 {
4473 errmsg = e_invarg;
4474 goto skip;
4475 }
4476
4477 /*
4478 * ":set opt!": invert
4479 * ":set opt&": reset to default value
4480 * ":set opt<": reset to global value
4481 */
4482 if (nextchar == '!')
4483 value = *(int *)(varp) ^ 1;
4484 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004485 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004486 ((flags & P_VI_DEF) || cp_val)
4487 ? VI_DEFAULT : VIM_DEFAULT];
4488 else if (nextchar == '<')
4489 {
4490 /* For 'autoread' -1 means to use global value. */
4491 if ((int *)varp == &curbuf->b_p_ar
4492 && opt_flags == OPT_LOCAL)
4493 value = -1;
4494 else
4495 value = *(int *)get_varp_scope(&(options[opt_idx]),
4496 OPT_GLOBAL);
4497 }
4498 else
4499 {
4500 /*
4501 * ":set invopt": invert
4502 * ":set opt" or ":set noopt": set or reset
4503 */
4504 if (nextchar != NUL && !vim_iswhite(afterchar))
4505 {
4506 errmsg = e_trailing;
4507 goto skip;
4508 }
4509 if (prefix == 2) /* inv */
4510 value = *(int *)(varp) ^ 1;
4511 else
4512 value = prefix;
4513 }
4514
4515 errmsg = set_bool_option(opt_idx, varp, (int)value,
4516 opt_flags);
4517 }
4518 else /* numeric or string */
4519 {
4520 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4521 || prefix != 1)
4522 {
4523 errmsg = e_invarg;
4524 goto skip;
4525 }
4526
4527 if (flags & P_NUM) /* numeric */
4528 {
4529 /*
4530 * Different ways to set a number option:
4531 * & set to default value
4532 * < set to global value
4533 * <xx> accept special key codes for 'wildchar'
4534 * c accept any non-digit for 'wildchar'
4535 * [-]0-9 set number
4536 * other error
4537 */
4538 ++arg;
4539 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004540 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004541 ((flags & P_VI_DEF) || cp_val)
4542 ? VI_DEFAULT : VIM_DEFAULT];
4543 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004544 {
4545 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4546 * use the global value. */
4547 if ((long *)varp == &curbuf->b_p_ul
4548 && opt_flags == OPT_LOCAL)
4549 value = NO_LOCAL_UNDOLEVEL;
4550 else
4551 value = *(long *)get_varp_scope(
4552 &(options[opt_idx]), OPT_GLOBAL);
4553 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004554 else if (((long *)varp == &p_wc
4555 || (long *)varp == &p_wcm)
4556 && (*arg == '<'
4557 || *arg == '^'
4558 || ((!arg[1] || vim_iswhite(arg[1]))
4559 && !VIM_ISDIGIT(*arg))))
4560 {
4561 value = string_to_key(arg);
4562 if (value == 0 && (long *)varp != &p_wcm)
4563 {
4564 errmsg = e_invarg;
4565 goto skip;
4566 }
4567 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004568 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4569 {
Bram Moolenaar18400e62015-01-27 15:58:40 +01004570 /* Allow negative (for 'undolevels'), octal and
4571 * hex numbers. */
Bram Moolenaar5d1bc782015-07-17 13:03:48 +02004572 vim_str2nr(arg, NULL, &i, TRUE, TRUE, &value, NULL, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004573 if (arg[i] != NUL && !vim_iswhite(arg[i]))
4574 {
4575 errmsg = e_invarg;
4576 goto skip;
4577 }
4578 }
4579 else
4580 {
4581 errmsg = (char_u *)N_("E521: Number required after =");
4582 goto skip;
4583 }
4584
4585 if (adding)
4586 value = *(long *)varp + value;
4587 if (prepending)
4588 value = *(long *)varp * value;
4589 if (removing)
4590 value = *(long *)varp - value;
4591 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004592 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004593 }
4594 else if (opt_idx >= 0) /* string */
4595 {
4596 char_u *save_arg = NULL;
4597 char_u *s = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004598 char_u *oldval = NULL; /* previous value if *varp */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004599 char_u *newval;
Bram Moolenaar53744302015-07-17 17:38:22 +02004600 char_u *origval = NULL;
4601#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4602 char_u *saved_origval = NULL;
4603#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004604 unsigned newlen;
4605 int comma;
4606 int bs;
4607 int new_value_alloced; /* new string option
4608 was allocated */
4609
4610 /* When using ":set opt=val" for a global option
4611 * with a local value the local value will be
4612 * reset, use the global value here. */
4613 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004614 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004615 varp = options[opt_idx].var;
4616
4617 /* The old value is kept until we are sure that the
4618 * new value is valid. */
4619 oldval = *(char_u **)varp;
4620 if (nextchar == '&') /* set to default val */
4621 {
4622 newval = options[opt_idx].def_val[
4623 ((flags & P_VI_DEF) || cp_val)
4624 ? VI_DEFAULT : VIM_DEFAULT];
4625 if ((char_u **)varp == &p_bg)
4626 {
4627 /* guess the value of 'background' */
4628#ifdef FEAT_GUI
4629 if (gui.in_use)
4630 newval = gui_bg_default();
4631 else
4632#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004633 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004634 }
4635
4636 /* expand environment variables and ~ (since the
4637 * default value was already expanded, only
4638 * required when an environment variable was set
4639 * later */
4640 if (newval == NULL)
4641 newval = empty_option;
4642 else
4643 {
4644 s = option_expand(opt_idx, newval);
4645 if (s == NULL)
4646 s = newval;
4647 newval = vim_strsave(s);
4648 }
4649 new_value_alloced = TRUE;
4650 }
4651 else if (nextchar == '<') /* set to global val */
4652 {
4653 newval = vim_strsave(*(char_u **)get_varp_scope(
4654 &(options[opt_idx]), OPT_GLOBAL));
4655 new_value_alloced = TRUE;
4656 }
4657 else
4658 {
4659 ++arg; /* jump to after the '=' or ':' */
4660
4661 /*
4662 * Set 'keywordprg' to ":help" if an empty
4663 * value was passed to :set by the user.
4664 * Misuse errbuf[] for the resulting string.
4665 */
4666 if (varp == (char_u *)&p_kp
4667 && (*arg == NUL || *arg == ' '))
4668 {
4669 STRCPY(errbuf, ":help");
4670 save_arg = arg;
4671 arg = errbuf;
4672 }
4673 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004674 * Convert 'backspace' number to string, for
4675 * adding, prepending and removing string.
4676 */
4677 else if (varp == (char_u *)&p_bs
4678 && VIM_ISDIGIT(**(char_u **)varp))
4679 {
4680 i = getdigits((char_u **)varp);
4681 switch (i)
4682 {
4683 case 0:
4684 *(char_u **)varp = empty_option;
4685 break;
4686 case 1:
4687 *(char_u **)varp = vim_strsave(
4688 (char_u *)"indent,eol");
4689 break;
4690 case 2:
4691 *(char_u **)varp = vim_strsave(
4692 (char_u *)"indent,eol,start");
4693 break;
4694 }
4695 vim_free(oldval);
4696 oldval = *(char_u **)varp;
4697 }
4698 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004699 * Convert 'whichwrap' number to string, for
4700 * backwards compatibility with Vim 3.0.
4701 * Misuse errbuf[] for the resulting string.
4702 */
4703 else if (varp == (char_u *)&p_ww
4704 && VIM_ISDIGIT(*arg))
4705 {
4706 *errbuf = NUL;
4707 i = getdigits(&arg);
4708 if (i & 1)
4709 STRCAT(errbuf, "b,");
4710 if (i & 2)
4711 STRCAT(errbuf, "s,");
4712 if (i & 4)
4713 STRCAT(errbuf, "h,l,");
4714 if (i & 8)
4715 STRCAT(errbuf, "<,>,");
4716 if (i & 16)
4717 STRCAT(errbuf, "[,],");
4718 if (*errbuf != NUL) /* remove trailing , */
4719 errbuf[STRLEN(errbuf) - 1] = NUL;
4720 save_arg = arg;
4721 arg = errbuf;
4722 }
4723 /*
4724 * Remove '>' before 'dir' and 'bdir', for
4725 * backwards compatibility with version 3.0
4726 */
4727 else if ( *arg == '>'
4728 && (varp == (char_u *)&p_dir
4729 || varp == (char_u *)&p_bdir))
4730 {
4731 ++arg;
4732 }
4733
4734 /* When setting the local value of a global
4735 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004736 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004737 && (opt_flags & OPT_LOCAL))
4738 origval = *(char_u **)get_varp(
4739 &options[opt_idx]);
4740 else
4741 origval = oldval;
4742
4743 /*
4744 * Copy the new string into allocated memory.
4745 * Can't use set_string_option_direct(), because
4746 * we need to remove the backslashes.
4747 */
4748 /* get a bit too much */
4749 newlen = (unsigned)STRLEN(arg) + 1;
4750 if (adding || prepending || removing)
4751 newlen += (unsigned)STRLEN(origval) + 1;
4752 newval = alloc(newlen);
4753 if (newval == NULL) /* out of mem, don't change */
4754 break;
4755 s = newval;
4756
4757 /*
4758 * Copy the string, skip over escaped chars.
4759 * For MS-DOS and WIN32 backslashes before normal
4760 * file name characters are not removed, and keep
4761 * backslash at start, for "\\machine\path", but
4762 * do remove it for "\\\\machine\\path".
4763 * The reverse is found in ExpandOldSetting().
4764 */
4765 while (*arg && !vim_iswhite(*arg))
4766 {
4767 if (*arg == '\\' && arg[1] != NUL
4768#ifdef BACKSLASH_IN_FILENAME
4769 && !((flags & P_EXPAND)
4770 && vim_isfilec(arg[1])
4771 && (arg[1] != '\\'
4772 || (s == newval
4773 && arg[2] != '\\')))
4774#endif
4775 )
4776 ++arg; /* remove backslash */
4777#ifdef FEAT_MBYTE
4778 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00004779 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004780 {
4781 /* copy multibyte char */
4782 mch_memmove(s, arg, (size_t)i);
4783 arg += i;
4784 s += i;
4785 }
4786 else
4787#endif
4788 *s++ = *arg++;
4789 }
4790 *s = NUL;
4791
4792 /*
4793 * Expand environment variables and ~.
4794 * Don't do it when adding without inserting a
4795 * comma.
4796 */
4797 if (!(adding || prepending || removing)
4798 || (flags & P_COMMA))
4799 {
4800 s = option_expand(opt_idx, newval);
4801 if (s != NULL)
4802 {
4803 vim_free(newval);
4804 newlen = (unsigned)STRLEN(s) + 1;
4805 if (adding || prepending || removing)
4806 newlen += (unsigned)STRLEN(origval) + 1;
4807 newval = alloc(newlen);
4808 if (newval == NULL)
4809 break;
4810 STRCPY(newval, s);
4811 }
4812 }
4813
4814 /* locate newval[] in origval[] when removing it
4815 * and when adding to avoid duplicates */
4816 i = 0; /* init for GCC */
4817 if (removing || (flags & P_NODUP))
4818 {
4819 i = (int)STRLEN(newval);
4820 bs = 0;
4821 for (s = origval; *s; ++s)
4822 {
4823 if ((!(flags & P_COMMA)
4824 || s == origval
4825 || (s[-1] == ',' && !(bs & 1)))
4826 && STRNCMP(s, newval, i) == 0
4827 && (!(flags & P_COMMA)
4828 || s[i] == ','
4829 || s[i] == NUL))
4830 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004831 /* Count backslashes. Only a comma with an
4832 * even number of backslashes before it is
Bram Moolenaar071d4272004-06-13 20:20:40 +00004833 * recognized as a separator */
4834 if (s > origval && s[-1] == '\\')
4835 ++bs;
4836 else
4837 bs = 0;
4838 }
4839
4840 /* do not add if already there */
4841 if ((adding || prepending) && *s)
4842 {
4843 prepending = FALSE;
4844 adding = FALSE;
4845 STRCPY(newval, origval);
4846 }
4847 }
4848
4849 /* concatenate the two strings; add a ',' if
4850 * needed */
4851 if (adding || prepending)
4852 {
4853 comma = ((flags & P_COMMA) && *origval != NUL
4854 && *newval != NUL);
4855 if (adding)
4856 {
4857 i = (int)STRLEN(origval);
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004858 /* strip a trailing comma, would get 2 */
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02004859 if (comma && (flags & P_ONECOMMA) && i > 1
4860 && origval[i - 1] == ','
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004861 && origval[i - 2] != '\\')
4862 i--;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004863 mch_memmove(newval + i + comma, newval,
4864 STRLEN(newval) + 1);
4865 mch_memmove(newval, origval, (size_t)i);
4866 }
4867 else
4868 {
4869 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004870 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004871 }
4872 if (comma)
4873 newval[i] = ',';
4874 }
4875
4876 /* Remove newval[] from origval[]. (Note: "i" has
4877 * been set above and is used here). */
4878 if (removing)
4879 {
4880 STRCPY(newval, origval);
4881 if (*s)
4882 {
4883 /* may need to remove a comma */
4884 if (flags & P_COMMA)
4885 {
4886 if (s == origval)
4887 {
4888 /* include comma after string */
4889 if (s[i] == ',')
4890 ++i;
4891 }
4892 else
4893 {
4894 /* include comma before string */
4895 --s;
4896 ++i;
4897 }
4898 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004899 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004900 }
4901 }
4902
4903 if (flags & P_FLAGLIST)
4904 {
4905 /* Remove flags that appear twice. */
4906 for (s = newval; *s; ++s)
4907 if ((!(flags & P_COMMA) || *s != ',')
4908 && vim_strchr(s + 1, *s) != NULL)
4909 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004910 STRMOVE(s, s + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004911 --s;
4912 }
4913 }
4914
4915 if (save_arg != NULL) /* number for 'whichwrap' */
4916 arg = save_arg;
4917 new_value_alloced = TRUE;
4918 }
4919
4920 /* Set the new value. */
4921 *(char_u **)(varp) = newval;
4922
Bram Moolenaar53744302015-07-17 17:38:22 +02004923#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02004924 if (!starting
4925# ifdef FEAT_CRYPT
4926 && options[opt_idx].indir != PV_KEY
4927# endif
Bram Moolenaar53744302015-07-17 17:38:22 +02004928 && origval != NULL)
4929 /* origval may be freed by
4930 * did_set_string_option(), make a copy. */
4931 saved_origval = vim_strsave(origval);
4932#endif
4933
Bram Moolenaar071d4272004-06-13 20:20:40 +00004934 /* Handle side effects, and set the global value for
4935 * ":set" on local options. */
4936 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
4937 new_value_alloced, oldval, errbuf, opt_flags);
4938
4939 /* If error detected, print the error message. */
4940 if (errmsg != NULL)
4941 goto skip;
Bram Moolenaar53744302015-07-17 17:38:22 +02004942#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4943 if (saved_origval != NULL)
4944 {
4945 char_u buf_type[7];
4946
4947 sprintf((char *)buf_type, "%s",
4948 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02004949 set_vim_var_string(VV_OPTION_NEW,
4950 *(char_u **)varp, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02004951 set_vim_var_string(VV_OPTION_OLD, saved_origval, -1);
4952 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
4953 apply_autocmds(EVENT_OPTIONSET,
4954 (char_u *)options[opt_idx].fullname,
4955 NULL, FALSE, NULL);
4956 reset_v_option_vars();
4957 vim_free(saved_origval);
4958 }
4959#endif
4960
Bram Moolenaar071d4272004-06-13 20:20:40 +00004961 }
4962 else /* key code option */
4963 {
4964 char_u *p;
4965
4966 if (nextchar == '&')
4967 {
4968 if (add_termcap_entry(key_name, TRUE) == FAIL)
4969 errmsg = (char_u *)N_("E522: Not found in termcap");
4970 }
4971 else
4972 {
4973 ++arg; /* jump to after the '=' or ':' */
4974 for (p = arg; *p && !vim_iswhite(*p); ++p)
4975 if (*p == '\\' && p[1] != NUL)
4976 ++p;
4977 nextchar = *p;
4978 *p = NUL;
4979 add_termcode(key_name, arg, FALSE);
4980 *p = nextchar;
4981 }
4982 if (full_screen)
4983 ttest(FALSE);
4984 redraw_all_later(CLEAR);
4985 }
4986 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004987
Bram Moolenaar071d4272004-06-13 20:20:40 +00004988 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004989 did_set_option(opt_idx, opt_flags,
4990 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004991 }
4992
4993skip:
4994 /*
4995 * Advance to next argument.
4996 * - skip until a blank found, taking care of backslashes
4997 * - skip blanks
4998 * - skip one "=val" argument (for hidden options ":set gfn =xx")
4999 */
5000 for (i = 0; i < 2 ; ++i)
5001 {
5002 while (*arg != NUL && !vim_iswhite(*arg))
5003 if (*arg++ == '\\' && *arg != NUL)
5004 ++arg;
5005 arg = skipwhite(arg);
5006 if (*arg != '=')
5007 break;
5008 }
5009 }
5010
5011 if (errmsg != NULL)
5012 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005013 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005014 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005015 if (i + (arg - startarg) < IOSIZE)
5016 {
5017 /* append the argument with the error */
5018 STRCAT(IObuff, ": ");
5019 mch_memmove(IObuff + i, startarg, (arg - startarg));
5020 IObuff[i + (arg - startarg)] = NUL;
5021 }
5022 /* make sure all characters are printable */
5023 trans_characters(IObuff, IOSIZE);
5024
5025 ++no_wait_return; /* wait_return done later */
5026 emsg(IObuff); /* show error highlighted */
5027 --no_wait_return;
5028
5029 return FAIL;
5030 }
5031
5032 arg = skipwhite(arg);
5033 }
5034
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005035theend:
5036 if (silent_mode && did_show)
5037 {
5038 /* After displaying option values in silent mode. */
5039 silent_mode = FALSE;
5040 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5041 msg_putchar('\n');
5042 cursor_on(); /* msg_start() switches it off */
5043 out_flush();
5044 silent_mode = TRUE;
5045 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5046 }
5047
Bram Moolenaar071d4272004-06-13 20:20:40 +00005048 return OK;
5049}
5050
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005051/*
5052 * Call this when an option has been given a new value through a user command.
5053 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5054 */
5055 static void
5056did_set_option(opt_idx, opt_flags, new_value)
5057 int opt_idx;
5058 int opt_flags; /* possibly with OPT_MODELINE */
5059 int new_value; /* value was replaced completely */
5060{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005061 long_u *p;
5062
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005063 options[opt_idx].flags |= P_WAS_SET;
5064
5065 /* When an option is set in the sandbox, from a modeline or in secure mode
5066 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005067 * flag. */
5068 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005069 if (secure
5070#ifdef HAVE_SANDBOX
5071 || sandbox != 0
5072#endif
5073 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005074 *p = *p | P_INSECURE;
5075 else if (new_value)
5076 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005077}
5078
Bram Moolenaar071d4272004-06-13 20:20:40 +00005079 static char_u *
5080illegal_char(errbuf, c)
5081 char_u *errbuf;
5082 int c;
5083{
5084 if (errbuf == NULL)
5085 return (char_u *)"";
5086 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005087 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005088 return errbuf;
5089}
5090
5091/*
5092 * Convert a key name or string into a key value.
5093 * Used for 'wildchar' and 'cedit' options.
5094 */
5095 static int
5096string_to_key(arg)
5097 char_u *arg;
5098{
5099 if (*arg == '<')
5100 return find_key_option(arg + 1);
5101 if (*arg == '^')
5102 return Ctrl_chr(arg[1]);
5103 return *arg;
5104}
5105
5106#ifdef FEAT_CMDWIN
5107/*
5108 * Check value of 'cedit' and set cedit_key.
5109 * Returns NULL if value is OK, error message otherwise.
5110 */
5111 static char_u *
5112check_cedit()
5113{
5114 int n;
5115
5116 if (*p_cedit == NUL)
5117 cedit_key = -1;
5118 else
5119 {
5120 n = string_to_key(p_cedit);
5121 if (vim_isprintc(n))
5122 return e_invarg;
5123 cedit_key = n;
5124 }
5125 return NULL;
5126}
5127#endif
5128
5129#ifdef FEAT_TITLE
5130/*
5131 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5132 * maketitle() to create and display it.
5133 * When switching the title or icon off, call mch_restore_title() to get
5134 * the old value back.
5135 */
5136 static void
5137did_set_title(icon)
5138 int icon; /* Did set icon instead of title */
5139{
5140 if (starting != NO_SCREEN
5141#ifdef FEAT_GUI
5142 && !gui.starting
5143#endif
5144 )
5145 {
5146 maketitle();
5147 if (icon)
5148 {
5149 if (!p_icon)
5150 mch_restore_title(2);
5151 }
5152 else
5153 {
5154 if (!p_title)
5155 mch_restore_title(1);
5156 }
5157 }
5158}
5159#endif
5160
5161/*
5162 * set_options_bin - called when 'bin' changes value.
5163 */
5164 void
5165set_options_bin(oldval, newval, opt_flags)
5166 int oldval;
5167 int newval;
5168 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5169{
5170 /*
5171 * The option values that are changed when 'bin' changes are
5172 * copied when 'bin is set and restored when 'bin' is reset.
5173 */
5174 if (newval)
5175 {
5176 if (!oldval) /* switched on */
5177 {
5178 if (!(opt_flags & OPT_GLOBAL))
5179 {
5180 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5181 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5182 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5183 curbuf->b_p_et_nobin = curbuf->b_p_et;
5184 }
5185 if (!(opt_flags & OPT_LOCAL))
5186 {
5187 p_tw_nobin = p_tw;
5188 p_wm_nobin = p_wm;
5189 p_ml_nobin = p_ml;
5190 p_et_nobin = p_et;
5191 }
5192 }
5193
5194 if (!(opt_flags & OPT_GLOBAL))
5195 {
5196 curbuf->b_p_tw = 0; /* no automatic line wrap */
5197 curbuf->b_p_wm = 0; /* no automatic line wrap */
5198 curbuf->b_p_ml = 0; /* no modelines */
5199 curbuf->b_p_et = 0; /* no expandtab */
5200 }
5201 if (!(opt_flags & OPT_LOCAL))
5202 {
5203 p_tw = 0;
5204 p_wm = 0;
5205 p_ml = FALSE;
5206 p_et = FALSE;
5207 p_bin = TRUE; /* needed when called for the "-b" argument */
5208 }
5209 }
5210 else if (oldval) /* switched off */
5211 {
5212 if (!(opt_flags & OPT_GLOBAL))
5213 {
5214 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5215 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5216 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5217 curbuf->b_p_et = curbuf->b_p_et_nobin;
5218 }
5219 if (!(opt_flags & OPT_LOCAL))
5220 {
5221 p_tw = p_tw_nobin;
5222 p_wm = p_wm_nobin;
5223 p_ml = p_ml_nobin;
5224 p_et = p_et_nobin;
5225 }
5226 }
5227}
5228
5229#ifdef FEAT_VIMINFO
5230/*
5231 * Find the parameter represented by the given character (eg ', :, ", or /),
5232 * and return its associated value in the 'viminfo' string.
5233 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005234 * If the parameter is not specified in the string or there is no following
5235 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005236 */
5237 int
5238get_viminfo_parameter(type)
5239 int type;
5240{
5241 char_u *p;
5242
5243 p = find_viminfo_parameter(type);
5244 if (p != NULL && VIM_ISDIGIT(*p))
5245 return atoi((char *)p);
5246 return -1;
5247}
5248
5249/*
5250 * Find the parameter represented by the given character (eg ''', ':', '"', or
5251 * '/') in the 'viminfo' option and return a pointer to the string after it.
5252 * Return NULL if the parameter is not specified in the string.
5253 */
5254 char_u *
5255find_viminfo_parameter(type)
5256 int type;
5257{
5258 char_u *p;
5259
5260 for (p = p_viminfo; *p; ++p)
5261 {
5262 if (*p == type)
5263 return p + 1;
5264 if (*p == 'n') /* 'n' is always the last one */
5265 break;
5266 p = vim_strchr(p, ','); /* skip until next ',' */
5267 if (p == NULL) /* hit the end without finding parameter */
5268 break;
5269 }
5270 return NULL;
5271}
5272#endif
5273
5274/*
5275 * Expand environment variables for some string options.
5276 * These string options cannot be indirect!
5277 * If "val" is NULL expand the current value of the option.
5278 * Return pointer to NameBuff, or NULL when not expanded.
5279 */
5280 static char_u *
5281option_expand(opt_idx, val)
5282 int opt_idx;
5283 char_u *val;
5284{
5285 /* if option doesn't need expansion nothing to do */
5286 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5287 return NULL;
5288
5289 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5290 * expand_env() would truncate the string. */
5291 if (val != NULL && STRLEN(val) > MAXPATHL)
5292 return NULL;
5293
5294 if (val == NULL)
5295 val = *(char_u **)options[opt_idx].var;
5296
5297 /*
5298 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5299 * Escape spaces when expanding 'tags', they are used to separate file
5300 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005301 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005302 */
5303 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005304 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005305#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005306 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5307#endif
5308 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005309 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5310 return NULL;
5311
5312 return NameBuff;
5313}
5314
5315/*
5316 * After setting various option values: recompute variables that depend on
5317 * option values.
5318 */
5319 static void
5320didset_options()
5321{
5322 /* initialize the table for 'iskeyword' et.al. */
5323 (void)init_chartab();
5324
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005325#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005326 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005327#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005328 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
Bram Moolenaar165bc692015-07-21 17:53:25 +02005329 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005330#ifdef FEAT_SESSION
5331 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5332 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5333#endif
5334#ifdef FEAT_FOLDING
5335 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5336#endif
5337 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
5338#ifdef FEAT_VIRTUALEDIT
5339 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5340#endif
5341#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5342 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5343#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005344#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005345 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005346 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005347 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005348#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005349#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5350 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5351#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005352#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005353 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5354#endif
5355#ifdef FEAT_CMDWIN
5356 /* set cedit_key */
5357 (void)check_cedit();
5358#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005359#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005360 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005361#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005362}
5363
5364/*
5365 * Check for string options that are NULL (normally only termcap options).
5366 */
5367 void
5368check_options()
5369{
5370 int opt_idx;
5371
5372 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5373 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5374 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5375}
5376
5377/*
5378 * Check string options in a buffer for NULL value.
5379 */
5380 void
5381check_buf_options(buf)
5382 buf_T *buf;
5383{
5384#if defined(FEAT_QUICKFIX)
5385 check_string_option(&buf->b_p_bh);
5386 check_string_option(&buf->b_p_bt);
5387#endif
5388#ifdef FEAT_MBYTE
5389 check_string_option(&buf->b_p_fenc);
5390#endif
5391 check_string_option(&buf->b_p_ff);
5392#ifdef FEAT_FIND_ID
5393 check_string_option(&buf->b_p_def);
5394 check_string_option(&buf->b_p_inc);
5395# ifdef FEAT_EVAL
5396 check_string_option(&buf->b_p_inex);
5397# endif
5398#endif
5399#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5400 check_string_option(&buf->b_p_inde);
5401 check_string_option(&buf->b_p_indk);
5402#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005403#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5404 check_string_option(&buf->b_p_bexpr);
5405#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005406#if defined(FEAT_CRYPT)
5407 check_string_option(&buf->b_p_cm);
5408#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005409#if defined(FEAT_EVAL)
5410 check_string_option(&buf->b_p_fex);
5411#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005412#ifdef FEAT_CRYPT
5413 check_string_option(&buf->b_p_key);
5414#endif
5415 check_string_option(&buf->b_p_kp);
5416 check_string_option(&buf->b_p_mps);
5417 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005418 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005419 check_string_option(&buf->b_p_isk);
5420#ifdef FEAT_COMMENTS
5421 check_string_option(&buf->b_p_com);
5422#endif
5423#ifdef FEAT_FOLDING
5424 check_string_option(&buf->b_p_cms);
5425#endif
5426 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005427#ifdef FEAT_TEXTOBJ
5428 check_string_option(&buf->b_p_qe);
5429#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005430#ifdef FEAT_SYN_HL
5431 check_string_option(&buf->b_p_syn);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005432#endif
5433#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005434 check_string_option(&buf->b_s.b_p_spc);
5435 check_string_option(&buf->b_s.b_p_spf);
5436 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005437#endif
5438#ifdef FEAT_SEARCHPATH
5439 check_string_option(&buf->b_p_sua);
5440#endif
5441#ifdef FEAT_CINDENT
5442 check_string_option(&buf->b_p_cink);
5443 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005444 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005445#endif
5446#ifdef FEAT_AUTOCMD
5447 check_string_option(&buf->b_p_ft);
5448#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005449#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5450 check_string_option(&buf->b_p_cinw);
5451#endif
5452#ifdef FEAT_INS_EXPAND
5453 check_string_option(&buf->b_p_cpt);
5454#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005455#ifdef FEAT_COMPL_FUNC
5456 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005457 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005458#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005459#ifdef FEAT_KEYMAP
5460 check_string_option(&buf->b_p_keymap);
5461#endif
5462#ifdef FEAT_QUICKFIX
5463 check_string_option(&buf->b_p_gp);
5464 check_string_option(&buf->b_p_mp);
5465 check_string_option(&buf->b_p_efm);
5466#endif
5467 check_string_option(&buf->b_p_ep);
5468 check_string_option(&buf->b_p_path);
5469 check_string_option(&buf->b_p_tags);
5470#ifdef FEAT_INS_EXPAND
5471 check_string_option(&buf->b_p_dict);
5472 check_string_option(&buf->b_p_tsr);
5473#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005474#ifdef FEAT_LISP
5475 check_string_option(&buf->b_p_lw);
5476#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005477 check_string_option(&buf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005478}
5479
5480/*
5481 * Free the string allocated for an option.
5482 * Checks for the string being empty_option. This may happen if we're out of
5483 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5484 * check_options().
5485 * Does NOT check for P_ALLOCED flag!
5486 */
5487 void
5488free_string_option(p)
5489 char_u *p;
5490{
5491 if (p != empty_option)
5492 vim_free(p);
5493}
5494
5495 void
5496clear_string_option(pp)
5497 char_u **pp;
5498{
5499 if (*pp != empty_option)
5500 vim_free(*pp);
5501 *pp = empty_option;
5502}
5503
5504 static void
5505check_string_option(pp)
5506 char_u **pp;
5507{
5508 if (*pp == NULL)
5509 *pp = empty_option;
5510}
5511
5512/*
5513 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5514 */
5515 void
5516set_term_option_alloced(p)
5517 char_u **p;
5518{
5519 int opt_idx;
5520
5521 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5522 if (options[opt_idx].var == (char_u *)p)
5523 {
5524 options[opt_idx].flags |= P_ALLOCED;
5525 return;
5526 }
5527 return; /* cannot happen: didn't find it! */
5528}
5529
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005530#if defined(FEAT_EVAL) || defined(PROTO)
5531/*
5532 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5533 * Return FALSE when it wasn't.
5534 * Return -1 for an unknown option.
5535 */
5536 int
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005537was_set_insecurely(opt, opt_flags)
5538 char_u *opt;
5539 int opt_flags;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005540{
5541 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005542 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005543
5544 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005545 {
5546 flagp = insecure_flag(idx, opt_flags);
5547 return (*flagp & P_INSECURE) != 0;
5548 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005549 EMSG2(_(e_intern2), "was_set_insecurely()");
5550 return -1;
5551}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005552
5553/*
5554 * Get a pointer to the flags used for the P_INSECURE flag of option
5555 * "opt_idx". For some local options a local flags field is used.
5556 */
5557 static long_u *
5558insecure_flag(opt_idx, opt_flags)
5559 int opt_idx;
5560 int opt_flags;
5561{
5562 if (opt_flags & OPT_LOCAL)
5563 switch ((int)options[opt_idx].indir)
5564 {
5565#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005566 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005567#endif
5568#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005569# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005570 case PV_FDE: return &curwin->w_p_fde_flags;
5571 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005572# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005573# ifdef FEAT_BEVAL
5574 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5575# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005576# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005577 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005578# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005579 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005580# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005581 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005582# endif
5583#endif
5584 }
5585
5586 /* Nothing special, return global flags field. */
5587 return &options[opt_idx].flags;
5588}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005589#endif
5590
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005591#ifdef FEAT_TITLE
5592static void redraw_titles __ARGS((void));
5593
5594/*
5595 * Redraw the window title and/or tab page text later.
5596 */
5597static void redraw_titles()
5598{
5599 need_maketitle = TRUE;
5600# ifdef FEAT_WINDOWS
5601 redraw_tabline = TRUE;
5602# endif
5603}
5604#endif
5605
Bram Moolenaar071d4272004-06-13 20:20:40 +00005606/*
5607 * Set a string option to a new value (without checking the effect).
5608 * The string is copied into allocated memory.
5609 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005610 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005611 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005612 */
5613 void
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005614set_string_option_direct(name, opt_idx, val, opt_flags, set_sid)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005615 char_u *name;
5616 int opt_idx;
5617 char_u *val;
5618 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar78a15312009-05-15 19:33:18 +00005619 int set_sid UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005620{
5621 char_u *s;
5622 char_u **varp;
5623 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005624 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005625
Bram Moolenaar89d40322006-08-29 15:30:07 +00005626 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005627 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005628 idx = findoption(name);
5629 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005630 {
5631 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar0b105412014-11-30 13:34:23 +01005632 EMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005633 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005634 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005635 }
5636
Bram Moolenaar89d40322006-08-29 15:30:07 +00005637 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005638 return;
5639
5640 s = vim_strsave(val);
5641 if (s != NULL)
5642 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005643 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005644 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005645 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005646 free_string_option(*varp);
5647 *varp = s;
5648
5649 /* For buffer/window local option may also set the global value. */
5650 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005651 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005652
Bram Moolenaar89d40322006-08-29 15:30:07 +00005653 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005654
5655 /* When setting both values of a global option with a local value,
5656 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005657 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005658 {
5659 free_string_option(*varp);
5660 *varp = empty_option;
5661 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005662# ifdef FEAT_EVAL
5663 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005664 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005665 set_sid == 0 ? current_SID : set_sid);
5666# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005667 }
5668}
5669
5670/*
5671 * Set global value for string option when it's a local option.
5672 */
5673 static void
5674set_string_option_global(opt_idx, varp)
5675 int opt_idx; /* option index */
5676 char_u **varp; /* pointer to option variable */
5677{
5678 char_u **p, *s;
5679
5680 /* the global value is always allocated */
5681 if (options[opt_idx].var == VAR_WIN)
5682 p = (char_u **)GLOBAL_WO(varp);
5683 else
5684 p = (char_u **)options[opt_idx].var;
5685 if (options[opt_idx].indir != PV_NONE
5686 && p != varp
5687 && (s = vim_strsave(*varp)) != NULL)
5688 {
5689 free_string_option(*p);
5690 *p = s;
5691 }
5692}
5693
5694/*
5695 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005696 *
5697 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005698 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005699 static char_u *
Bram Moolenaar071d4272004-06-13 20:20:40 +00005700set_string_option(opt_idx, value, opt_flags)
5701 int opt_idx;
5702 char_u *value;
5703 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5704{
5705 char_u *s;
5706 char_u **varp;
5707 char_u *oldval;
Bram Moolenaar53744302015-07-17 17:38:22 +02005708#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5709 char_u *saved_oldval = NULL;
5710#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005711 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005712
5713 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005714 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005715
5716 s = vim_strsave(value);
5717 if (s != NULL)
5718 {
5719 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5720 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005721 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005722 ? OPT_GLOBAL : OPT_LOCAL)
5723 : opt_flags);
5724 oldval = *varp;
5725 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02005726
5727#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005728 if (!starting
5729# ifdef FEAT_CRYPT
5730 && options[opt_idx].indir != PV_KEY
5731# endif
5732 )
Bram Moolenaar53744302015-07-17 17:38:22 +02005733 saved_oldval = vim_strsave(oldval);
5734#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005735 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5736 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005737 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02005738
5739 /* call autocomamnd after handling side effects */
5740#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5741 if (saved_oldval != NULL)
5742 {
5743 char_u buf_type[7];
5744 sprintf((char *)buf_type, "%s",
5745 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02005746 set_vim_var_string(VV_OPTION_NEW, *varp, -1);
5747 set_vim_var_string(VV_OPTION_OLD, saved_oldval, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02005748 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
5749 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
5750 reset_v_option_vars();
5751 vim_free(saved_oldval);
5752 }
5753#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005754 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005755 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005756}
5757
5758/*
5759 * Handle string options that need some action to perform when changed.
5760 * Returns NULL for success, or an error message for an error.
5761 */
5762 static char_u *
5763did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
5764 opt_flags)
5765 int opt_idx; /* index in options[] table */
5766 char_u **varp; /* pointer to the option variable */
5767 int new_value_alloced; /* new value was allocated */
5768 char_u *oldval; /* previous value of the option */
5769 char_u *errbuf; /* buffer for errors, or NULL */
5770 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5771{
5772 char_u *errmsg = NULL;
5773 char_u *s, *p;
5774 int did_chartab = FALSE;
5775 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005776 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00005777#ifdef FEAT_GUI
5778 /* set when changing an option that only requires a redraw in the GUI */
5779 int redraw_gui_only = FALSE;
5780#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005781
5782 /* Get the global option to compare with, otherwise we would have to check
5783 * two values for all local options. */
5784 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
5785
5786 /* Disallow changing some options from secure mode */
5787 if ((secure
5788#ifdef HAVE_SANDBOX
5789 || sandbox != 0
5790#endif
5791 ) && (options[opt_idx].flags & P_SECURE))
5792 {
5793 errmsg = e_secure;
5794 }
5795
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005796 /* Check for a "normal" file name in some options. Disallow a path
5797 * separator (slash and/or backslash), wildcards and characters that are
5798 * often illegal in a file name. */
5799 else if ((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005800 && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL)
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005801 {
5802 errmsg = e_invarg;
5803 }
5804
Bram Moolenaar071d4272004-06-13 20:20:40 +00005805 /* 'term' */
5806 else if (varp == &T_NAME)
5807 {
5808 if (T_NAME[0] == NUL)
5809 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
5810#ifdef FEAT_GUI
5811 if (gui.in_use)
5812 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
5813 else if (term_is_gui(T_NAME))
5814 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
5815#endif
5816 else if (set_termname(T_NAME) == FAIL)
5817 errmsg = (char_u *)N_("E522: Not found in termcap");
5818 else
5819 /* Screen colors may have changed. */
5820 redraw_later_clear();
5821 }
5822
5823 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005824 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005825 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005826 char_u *bkc = p_bkc;
5827 unsigned int *flags = &bkc_flags;
5828
5829 if (opt_flags & OPT_LOCAL)
5830 {
5831 bkc = curbuf->b_p_bkc;
5832 flags = &curbuf->b_bkc_flags;
5833 }
5834
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005835 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
5836 /* make the local value empty: use the global value */
5837 *flags = 0;
5838 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00005839 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005840 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
5841 errmsg = e_invarg;
5842 if ((((int)*flags & BKC_AUTO) != 0)
5843 + (((int)*flags & BKC_YES) != 0)
5844 + (((int)*flags & BKC_NO) != 0) != 1)
5845 {
5846 /* Must have exactly one of "auto", "yes" and "no". */
5847 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
5848 errmsg = e_invarg;
5849 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005850 }
5851 }
5852
5853 /* 'backupext' and 'patchmode' */
5854 else if (varp == &p_bex || varp == &p_pm)
5855 {
5856 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
5857 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
5858 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
5859 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02005860#ifdef FEAT_LINEBREAK
5861 /* 'breakindentopt' */
5862 else if (varp == &curwin->w_p_briopt)
5863 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005864 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02005865 errmsg = e_invarg;
5866 }
5867#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005868
5869 /*
5870 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[]
5871 * If the new option is invalid, use old value. 'lisp' option: refill
5872 * chartab[] for '-' char
5873 */
5874 else if ( varp == &p_isi
5875 || varp == &(curbuf->b_p_isk)
5876 || varp == &p_isp
5877 || varp == &p_isf)
5878 {
5879 if (init_chartab() == FAIL)
5880 {
5881 did_chartab = TRUE; /* need to restore it below */
5882 errmsg = e_invarg; /* error in value */
5883 }
5884 }
5885
5886 /* 'helpfile' */
5887 else if (varp == &p_hf)
5888 {
5889 /* May compute new values for $VIM and $VIMRUNTIME */
5890 if (didset_vim)
5891 {
5892 vim_setenv((char_u *)"VIM", (char_u *)"");
5893 didset_vim = FALSE;
5894 }
5895 if (didset_vimruntime)
5896 {
5897 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
5898 didset_vimruntime = FALSE;
5899 }
5900 }
5901
Bram Moolenaar1a384422010-07-14 19:53:30 +02005902#ifdef FEAT_SYN_HL
5903 /* 'colorcolumn' */
5904 else if (varp == &curwin->w_p_cc)
5905 errmsg = check_colorcolumn(curwin);
5906#endif
5907
Bram Moolenaar071d4272004-06-13 20:20:40 +00005908#ifdef FEAT_MULTI_LANG
5909 /* 'helplang' */
5910 else if (varp == &p_hlg)
5911 {
5912 /* Check for "", "ab", "ab,cd", etc. */
5913 for (s = p_hlg; *s != NUL; s += 3)
5914 {
5915 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
5916 {
5917 errmsg = e_invarg;
5918 break;
5919 }
5920 if (s[2] == NUL)
5921 break;
5922 }
5923 }
5924#endif
5925
5926 /* 'highlight' */
5927 else if (varp == &p_hl)
5928 {
5929 if (highlight_changed() == FAIL)
5930 errmsg = e_invarg; /* invalid flags */
5931 }
5932
5933 /* 'nrformats' */
5934 else if (gvarp == &p_nf)
5935 {
5936 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
5937 errmsg = e_invarg;
5938 }
5939
5940#ifdef FEAT_SESSION
5941 /* 'sessionoptions' */
5942 else if (varp == &p_ssop)
5943 {
5944 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
5945 errmsg = e_invarg;
5946 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
5947 {
5948 /* Don't allow both "sesdir" and "curdir". */
5949 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
5950 errmsg = e_invarg;
5951 }
5952 }
5953 /* 'viewoptions' */
5954 else if (varp == &p_vop)
5955 {
5956 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
5957 errmsg = e_invarg;
5958 }
5959#endif
5960
5961 /* 'scrollopt' */
5962#ifdef FEAT_SCROLLBIND
5963 else if (varp == &p_sbo)
5964 {
5965 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
5966 errmsg = e_invarg;
5967 }
5968#endif
5969
5970 /* 'ambiwidth' */
5971#ifdef FEAT_MBYTE
5972 else if (varp == &p_ambw)
5973 {
5974 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
5975 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02005976 else if (set_chars_option(&p_lcs) != NULL)
5977 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
5978# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5979 else if (set_chars_option(&p_fcs) != NULL)
5980 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
5981# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005982 }
5983#endif
5984
5985 /* 'background' */
5986 else if (varp == &p_bg)
5987 {
5988 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
5989 {
5990#ifdef FEAT_EVAL
5991 int dark = (*p_bg == 'd');
5992#endif
5993
5994 init_highlight(FALSE, FALSE);
5995
5996#ifdef FEAT_EVAL
5997 if (dark != (*p_bg == 'd')
5998 && get_var_value((char_u *)"g:colors_name") != NULL)
5999 {
6000 /* The color scheme must have set 'background' back to another
6001 * value, that's not what we want here. Disable the color
6002 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00006003 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006004 free_string_option(p_bg);
6005 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
6006 check_string_option(&p_bg);
6007 init_highlight(FALSE, FALSE);
6008 }
6009#endif
6010 }
6011 else
6012 errmsg = e_invarg;
6013 }
6014
6015 /* 'wildmode' */
6016 else if (varp == &p_wim)
6017 {
6018 if (check_opt_wim() == FAIL)
6019 errmsg = e_invarg;
6020 }
6021
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006022#ifdef FEAT_CMDL_COMPL
6023 /* 'wildoptions' */
6024 else if (varp == &p_wop)
6025 {
6026 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6027 errmsg = e_invarg;
6028 }
6029#endif
6030
Bram Moolenaar071d4272004-06-13 20:20:40 +00006031#ifdef FEAT_WAK
6032 /* 'winaltkeys' */
6033 else if (varp == &p_wak)
6034 {
6035 if (*p_wak == NUL
6036 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6037 errmsg = e_invarg;
6038# ifdef FEAT_MENU
6039# ifdef FEAT_GUI_MOTIF
6040 else if (gui.in_use)
6041 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6042# else
6043# ifdef FEAT_GUI_GTK
6044 else if (gui.in_use)
6045 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6046# endif
6047# endif
6048# endif
6049 }
6050#endif
6051
6052#ifdef FEAT_AUTOCMD
6053 /* 'eventignore' */
6054 else if (varp == &p_ei)
6055 {
6056 if (check_ei() == FAIL)
6057 errmsg = e_invarg;
6058 }
6059#endif
6060
6061#ifdef FEAT_MBYTE
6062 /* 'encoding' and 'fileencoding' */
6063 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc)
6064 {
6065 if (gvarp == &p_fenc)
6066 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006067 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006068 errmsg = e_modifiable;
6069 else if (vim_strchr(*varp, ',') != NULL)
6070 /* No comma allowed in 'fileencoding'; catches confusing it
6071 * with 'fileencodings'. */
6072 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006073 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006074 {
6075# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006076 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006077 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006078# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006079 /* Add 'fileencoding' to the swap file. */
6080 ml_setflags(curbuf);
6081 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006082 }
6083 if (errmsg == NULL)
6084 {
6085 /* canonize the value, so that STRCMP() can be used on it */
6086 p = enc_canonize(*varp);
6087 if (p != NULL)
6088 {
6089 vim_free(*varp);
6090 *varp = p;
6091 }
6092 if (varp == &p_enc)
6093 {
6094 errmsg = mb_init();
6095# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006096 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006097# endif
6098 }
6099 }
6100
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006101# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006102 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6103 {
6104 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6105 if (STRCMP(p_tenc, "utf-8") != 0)
6106 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6107 }
6108# endif
6109
6110 if (errmsg == NULL)
6111 {
6112# ifdef FEAT_KEYMAP
6113 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6114 * (with another encoding). */
6115 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6116 (void)keymap_init();
6117# endif
6118
6119 /* When 'termencoding' is not empty and 'encoding' changes or when
6120 * 'termencoding' changes, need to setup for keyboard input and
6121 * display output conversion. */
6122 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6123 {
6124 convert_setup(&input_conv, p_tenc, p_enc);
6125 convert_setup(&output_conv, p_enc, p_tenc);
6126 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006127
6128# if defined(WIN3264) && defined(FEAT_MBYTE)
6129 /* $HOME may have characters in active code page. */
6130 if (varp == &p_enc)
6131 init_homedir();
6132# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006133 }
6134 }
6135#endif
6136
6137#if defined(FEAT_POSTSCRIPT)
6138 else if (varp == &p_penc)
6139 {
6140 /* Canonize printencoding if VIM standard one */
6141 p = enc_canonize(p_penc);
6142 if (p != NULL)
6143 {
6144 vim_free(p_penc);
6145 p_penc = p;
6146 }
6147 else
6148 {
6149 /* Ensure lower case and '-' for '_' */
6150 for (s = p_penc; *s != NUL; s++)
6151 {
6152 if (*s == '_')
6153 *s = '-';
6154 else
6155 *s = TOLOWER_ASC(*s);
6156 }
6157 }
6158 }
6159#endif
6160
Bram Moolenaar9372a112005-12-06 19:59:18 +00006161#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006162 else if (varp == &p_imak)
6163 {
6164 if (gui.in_use && !im_xim_isvalid_imactivate())
6165 errmsg = e_invarg;
6166 }
6167#endif
6168
6169#ifdef FEAT_KEYMAP
6170 else if (varp == &curbuf->b_p_keymap)
6171 {
6172 /* load or unload key mapping tables */
6173 errmsg = keymap_init();
6174
Bram Moolenaarfab06232009-03-04 03:13:35 +00006175 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006176 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006177 if (*curbuf->b_p_keymap != NUL)
6178 {
6179 /* Installed a new keymap, switch on using it. */
6180 curbuf->b_p_iminsert = B_IMODE_LMAP;
6181 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6182 curbuf->b_p_imsearch = B_IMODE_LMAP;
6183 }
6184 else
6185 {
6186 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6187 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6188 curbuf->b_p_iminsert = B_IMODE_NONE;
6189 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6190 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6191 }
6192 if ((opt_flags & OPT_LOCAL) == 0)
6193 {
6194 set_iminsert_global();
6195 set_imsearch_global();
6196 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006197# ifdef FEAT_WINDOWS
6198 status_redraw_curbuf();
6199# endif
6200 }
6201 }
6202#endif
6203
6204 /* 'fileformat' */
6205 else if (gvarp == &p_ff)
6206 {
6207 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6208 errmsg = e_modifiable;
6209 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6210 errmsg = e_invarg;
6211 else
6212 {
6213 /* may also change 'textmode' */
6214 if (get_fileformat(curbuf) == EOL_DOS)
6215 curbuf->b_p_tx = TRUE;
6216 else
6217 curbuf->b_p_tx = FALSE;
6218#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006219 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006220#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006221 /* update flag in swap file */
6222 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006223 /* Redraw needed when switching to/from "mac": a CR in the text
6224 * will be displayed differently. */
6225 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6226 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006227 }
6228 }
6229
6230 /* 'fileformats' */
6231 else if (varp == &p_ffs)
6232 {
6233 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6234 errmsg = e_invarg;
6235 else
6236 {
6237 /* also change 'textauto' */
6238 if (*p_ffs == NUL)
6239 p_ta = FALSE;
6240 else
6241 p_ta = TRUE;
6242 }
6243 }
6244
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006245#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006246 /* 'cryptkey' */
6247 else if (gvarp == &p_key)
6248 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006249# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006250 /* Make sure the ":set" command doesn't show the new value in the
6251 * history. */
6252 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006253# endif
6254 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6255 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006256 ml_set_crypt_key(curbuf, oldval,
6257 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006258 }
6259
6260 else if (gvarp == &p_cm)
6261 {
6262 if (opt_flags & OPT_LOCAL)
6263 p = curbuf->b_p_cm;
6264 else
6265 p = p_cm;
6266 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6267 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006268 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006269 errmsg = e_invarg;
6270 else
6271 {
6272 /* When setting the global value to empty, make it "zip". */
6273 if (*p_cm == NUL)
6274 {
6275 if (new_value_alloced)
6276 free_string_option(p_cm);
6277 p_cm = vim_strsave((char_u *)"zip");
6278 new_value_alloced = TRUE;
6279 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006280 /* When using ":set cm=name" the local value is going to be empty.
6281 * Do that here, otherwise the crypt functions will still use the
6282 * local value. */
6283 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6284 {
6285 free_string_option(curbuf->b_p_cm);
6286 curbuf->b_p_cm = empty_option;
6287 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006288
6289 /* Need to update the swapfile when the effective method changed.
6290 * Set "s" to the effective old value, "p" to the effective new
6291 * method and compare. */
6292 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6293 s = p_cm; /* was previously using the global value */
6294 else
6295 s = oldval;
6296 if (*curbuf->b_p_cm == NUL)
6297 p = p_cm; /* is now using the global value */
6298 else
6299 p = curbuf->b_p_cm;
6300 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006301 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006302
6303 /* If the global value changes need to update the swapfile for all
6304 * buffers using that value. */
6305 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6306 {
6307 buf_T *buf;
6308
6309 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
6310 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006311 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006312 }
6313 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006314 }
6315#endif
6316
6317 /* 'matchpairs' */
6318 else if (gvarp == &p_mps)
6319 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006320#ifdef FEAT_MBYTE
6321 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006322 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006323 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006324 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006325 int x2 = -1;
6326 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006327
6328 if (*p != NUL)
6329 p += mb_ptr2len(p);
6330 if (*p != NUL)
6331 x2 = *p++;
6332 if (*p != NUL)
6333 {
6334 x3 = mb_ptr2char(p);
6335 p += mb_ptr2len(p);
6336 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006337 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006338 {
6339 errmsg = e_invarg;
6340 break;
6341 }
6342 if (*p == NUL)
6343 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006344 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006345 }
6346 else
6347#endif
6348 {
6349 /* Check for "x:y,x:y" */
6350 for (p = *varp; *p != NUL; p += 4)
6351 {
6352 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6353 {
6354 errmsg = e_invarg;
6355 break;
6356 }
6357 if (p[3] == NUL)
6358 break;
6359 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006360 }
6361 }
6362
6363#ifdef FEAT_COMMENTS
6364 /* 'comments' */
6365 else if (gvarp == &p_com)
6366 {
6367 for (s = *varp; *s; )
6368 {
6369 while (*s && *s != ':')
6370 {
6371 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6372 && !VIM_ISDIGIT(*s) && *s != '-')
6373 {
6374 errmsg = illegal_char(errbuf, *s);
6375 break;
6376 }
6377 ++s;
6378 }
6379 if (*s++ == NUL)
6380 errmsg = (char_u *)N_("E524: Missing colon");
6381 else if (*s == ',' || *s == NUL)
6382 errmsg = (char_u *)N_("E525: Zero length string");
6383 if (errmsg != NULL)
6384 break;
6385 while (*s && *s != ',')
6386 {
6387 if (*s == '\\' && s[1] != NUL)
6388 ++s;
6389 ++s;
6390 }
6391 s = skip_to_option_part(s);
6392 }
6393 }
6394#endif
6395
6396 /* 'listchars' */
6397 else if (varp == &p_lcs)
6398 {
6399 errmsg = set_chars_option(varp);
6400 }
6401
6402#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6403 /* 'fillchars' */
6404 else if (varp == &p_fcs)
6405 {
6406 errmsg = set_chars_option(varp);
6407 }
6408#endif
6409
6410#ifdef FEAT_CMDWIN
6411 /* 'cedit' */
6412 else if (varp == &p_cedit)
6413 {
6414 errmsg = check_cedit();
6415 }
6416#endif
6417
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006418 /* 'verbosefile' */
6419 else if (varp == &p_vfile)
6420 {
6421 verbose_stop();
6422 if (*p_vfile != NUL && verbose_open() == FAIL)
6423 errmsg = e_invarg;
6424 }
6425
Bram Moolenaar071d4272004-06-13 20:20:40 +00006426#ifdef FEAT_VIMINFO
6427 /* 'viminfo' */
6428 else if (varp == &p_viminfo)
6429 {
6430 for (s = p_viminfo; *s;)
6431 {
6432 /* Check it's a valid character */
6433 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6434 {
6435 errmsg = illegal_char(errbuf, *s);
6436 break;
6437 }
6438 if (*s == 'n') /* name is always last one */
6439 {
6440 break;
6441 }
6442 else if (*s == 'r') /* skip until next ',' */
6443 {
6444 while (*++s && *s != ',')
6445 ;
6446 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006447 else if (*s == '%')
6448 {
6449 /* optional number */
6450 while (vim_isdigit(*++s))
6451 ;
6452 }
6453 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006454 ++s; /* no extra chars */
6455 else /* must have a number */
6456 {
6457 while (vim_isdigit(*++s))
6458 ;
6459
6460 if (!VIM_ISDIGIT(*(s - 1)))
6461 {
6462 if (errbuf != NULL)
6463 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006464 sprintf((char *)errbuf,
6465 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006466 transchar_byte(*(s - 1)));
6467 errmsg = errbuf;
6468 }
6469 else
6470 errmsg = (char_u *)"";
6471 break;
6472 }
6473 }
6474 if (*s == ',')
6475 ++s;
6476 else if (*s)
6477 {
6478 if (errbuf != NULL)
6479 errmsg = (char_u *)N_("E527: Missing comma");
6480 else
6481 errmsg = (char_u *)"";
6482 break;
6483 }
6484 }
6485 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6486 errmsg = (char_u *)N_("E528: Must specify a ' value");
6487 }
6488#endif /* FEAT_VIMINFO */
6489
6490 /* terminal options */
6491 else if (istermoption(&options[opt_idx]) && full_screen)
6492 {
6493 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6494 if (varp == &T_CCO)
6495 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006496 int colors = atoi((char *)T_CCO);
6497
6498 /* Only reinitialize colors if t_Co value has really changed to
6499 * avoid expensive reload of colorscheme if t_Co is set to the
6500 * same value multiple times. */
6501 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006502 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006503 t_colors = colors;
6504 if (t_colors <= 1)
6505 {
6506 if (new_value_alloced)
6507 vim_free(T_CCO);
6508 T_CCO = empty_option;
6509 }
6510 /* We now have a different color setup, initialize it again. */
6511 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006512 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006513 }
6514 ttest(FALSE);
6515 if (varp == &T_ME)
6516 {
6517 out_str(T_ME);
6518 redraw_later(CLEAR);
6519#if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32))
6520 /* Since t_me has been set, this probably means that the user
6521 * wants to use this as default colors. Need to reset default
6522 * background/foreground colors. */
6523 mch_set_normal_colors();
6524#endif
6525 }
6526 }
6527
6528#ifdef FEAT_LINEBREAK
6529 /* 'showbreak' */
6530 else if (varp == &p_sbr)
6531 {
6532 for (s = p_sbr; *s; )
6533 {
6534 if (ptr2cells(s) != 1)
6535 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006536 mb_ptr_adv(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006537 }
6538 }
6539#endif
6540
6541#ifdef FEAT_GUI
6542 /* 'guifont' */
6543 else if (varp == &p_guifont)
6544 {
6545 if (gui.in_use)
6546 {
6547 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006548# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006549 /*
6550 * Put up a font dialog and let the user select a new value.
6551 * If this is cancelled go back to the old value but don't
6552 * give an error message.
6553 */
6554 if (STRCMP(p, "*") == 0)
6555 {
6556 p = gui_mch_font_dialog(oldval);
6557
6558 if (new_value_alloced)
6559 free_string_option(p_guifont);
6560
6561 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6562 new_value_alloced = TRUE;
6563 }
6564# endif
6565 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6566 {
6567# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6568 if (STRCMP(p_guifont, "*") == 0)
6569 {
6570 /* Dialog was cancelled: Keep the old value without giving
6571 * an error message. */
6572 if (new_value_alloced)
6573 free_string_option(p_guifont);
6574 p_guifont = vim_strsave(oldval);
6575 new_value_alloced = TRUE;
6576 }
6577 else
6578# endif
6579 errmsg = (char_u *)N_("E596: Invalid font(s)");
6580 }
6581 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006582 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006583 }
6584# ifdef FEAT_XFONTSET
6585 else if (varp == &p_guifontset)
6586 {
6587 if (STRCMP(p_guifontset, "*") == 0)
6588 errmsg = (char_u *)N_("E597: can't select fontset");
6589 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6590 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006591 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006592 }
6593# endif
6594# ifdef FEAT_MBYTE
6595 else if (varp == &p_guifontwide)
6596 {
6597 if (STRCMP(p_guifontwide, "*") == 0)
6598 errmsg = (char_u *)N_("E533: can't select wide font");
6599 else if (gui_get_wide_font() == FAIL)
6600 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006601 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006602 }
6603# endif
6604#endif
6605
6606#ifdef CURSOR_SHAPE
6607 /* 'guicursor' */
6608 else if (varp == &p_guicursor)
6609 errmsg = parse_shape_opt(SHAPE_CURSOR);
6610#endif
6611
6612#ifdef FEAT_MOUSESHAPE
6613 /* 'mouseshape' */
6614 else if (varp == &p_mouseshape)
6615 {
6616 errmsg = parse_shape_opt(SHAPE_MOUSE);
6617 update_mouseshape(-1);
6618 }
6619#endif
6620
6621#ifdef FEAT_PRINTER
6622 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006623 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006624# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006625 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006626 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006627# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006628#endif
6629
6630#ifdef FEAT_LANGMAP
6631 /* 'langmap' */
6632 else if (varp == &p_langmap)
6633 langmap_set();
6634#endif
6635
6636#ifdef FEAT_LINEBREAK
6637 /* 'breakat' */
6638 else if (varp == &p_breakat)
6639 fill_breakat_flags();
6640#endif
6641
6642#ifdef FEAT_TITLE
6643 /* 'titlestring' and 'iconstring' */
6644 else if (varp == &p_titlestring || varp == &p_iconstring)
6645 {
6646# ifdef FEAT_STL_OPT
6647 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6648
6649 /* NULL => statusline syntax */
6650 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6651 stl_syntax |= flagval;
6652 else
6653 stl_syntax &= ~flagval;
6654# endif
6655 did_set_title(varp == &p_iconstring);
6656
6657 }
6658#endif
6659
6660#ifdef FEAT_GUI
6661 /* 'guioptions' */
6662 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006663 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006664 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006665 redraw_gui_only = TRUE;
6666 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006667#endif
6668
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006669#if defined(FEAT_GUI_TABLINE)
6670 /* 'guitablabel' */
6671 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006672 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006673 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006674 redraw_gui_only = TRUE;
6675 }
6676 /* 'guitabtooltip' */
6677 else if (varp == &p_gtt)
6678 {
6679 redraw_gui_only = TRUE;
6680 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006681#endif
6682
Bram Moolenaar071d4272004-06-13 20:20:40 +00006683#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6684 /* 'ttymouse' */
6685 else if (varp == &p_ttym)
6686 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006687 /* Switch the mouse off before changing the escape sequences used for
6688 * that. */
6689 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006690 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6691 errmsg = e_invarg;
6692 else
6693 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006694 if (termcap_active)
6695 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006696 }
6697#endif
6698
Bram Moolenaar071d4272004-06-13 20:20:40 +00006699 /* 'selection' */
6700 else if (varp == &p_sel)
6701 {
6702 if (*p_sel == NUL
6703 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6704 errmsg = e_invarg;
6705 }
6706
6707 /* 'selectmode' */
6708 else if (varp == &p_slm)
6709 {
6710 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6711 errmsg = e_invarg;
6712 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006713
6714#ifdef FEAT_BROWSE
6715 /* 'browsedir' */
6716 else if (varp == &p_bsdir)
6717 {
6718 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
6719 && !mch_isdir(p_bsdir))
6720 errmsg = e_invarg;
6721 }
6722#endif
6723
Bram Moolenaar071d4272004-06-13 20:20:40 +00006724 /* 'keymodel' */
6725 else if (varp == &p_km)
6726 {
6727 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
6728 errmsg = e_invarg;
6729 else
6730 {
6731 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
6732 km_startsel = (vim_strchr(p_km, 'a') != NULL);
6733 }
6734 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006735
6736 /* 'mousemodel' */
6737 else if (varp == &p_mousem)
6738 {
6739 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
6740 errmsg = e_invarg;
6741#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
6742 else if (*p_mousem != *oldval)
6743 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
6744 * to create or delete the popup menus. */
6745 gui_motif_update_mousemodel(root_menu);
6746#endif
6747 }
6748
6749 /* 'switchbuf' */
6750 else if (varp == &p_swb)
6751 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00006752 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006753 errmsg = e_invarg;
6754 }
6755
6756 /* 'debug' */
6757 else if (varp == &p_debug)
6758 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00006759 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006760 errmsg = e_invarg;
6761 }
6762
6763 /* 'display' */
6764 else if (varp == &p_dy)
6765 {
6766 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
6767 errmsg = e_invarg;
6768 else
6769 (void)init_chartab();
6770
6771 }
6772
6773#ifdef FEAT_VERTSPLIT
6774 /* 'eadirection' */
6775 else if (varp == &p_ead)
6776 {
6777 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
6778 errmsg = e_invarg;
6779 }
6780#endif
6781
6782#ifdef FEAT_CLIPBOARD
6783 /* 'clipboard' */
6784 else if (varp == &p_cb)
6785 errmsg = check_clipboard_option();
6786#endif
6787
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00006788#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006789 /* When 'spelllang' or 'spellfile' is set and there is a window for this
6790 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006791 else if (varp == &(curwin->w_s->b_p_spl)
6792 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00006793 {
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006794 win_T *wp;
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006795 int l;
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006796
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006797 if (varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006798 {
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006799 l = (int)STRLEN(curwin->w_s->b_p_spf);
6800 if (l > 0 && (l < 4 || STRCMP(curwin->w_s->b_p_spf + l - 4,
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006801 ".add") != 0))
6802 errmsg = e_invarg;
6803 }
6804
6805 if (errmsg == NULL)
6806 {
6807 FOR_ALL_WINDOWS(wp)
6808 if (wp->w_buffer == curbuf && wp->w_p_spell)
6809 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006810 errmsg = did_set_spelllang(wp);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006811# ifdef FEAT_WINDOWS
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006812 break;
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006813# endif
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006814 }
6815 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006816 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006817 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006818 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006819 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006820 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006821 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006822 /* 'spellsuggest' */
6823 else if (varp == &p_sps)
6824 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00006825 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006826 errmsg = e_invarg;
6827 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00006828 /* 'mkspellmem' */
6829 else if (varp == &p_msm)
6830 {
6831 if (spell_check_msm() != OK)
6832 errmsg = e_invarg;
6833 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006834#endif
6835
Bram Moolenaar071d4272004-06-13 20:20:40 +00006836#ifdef FEAT_QUICKFIX
6837 /* When 'bufhidden' is set, check for valid value. */
6838 else if (gvarp == &p_bh)
6839 {
6840 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
6841 errmsg = e_invarg;
6842 }
6843
6844 /* When 'buftype' is set, check for valid value. */
6845 else if (gvarp == &p_bt)
6846 {
6847 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
6848 errmsg = e_invarg;
6849 else
6850 {
6851# ifdef FEAT_WINDOWS
6852 if (curwin->w_status_height)
6853 {
6854 curwin->w_redr_status = TRUE;
6855 redraw_later(VALID);
6856 }
6857# endif
6858 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar5075aad2010-01-27 15:58:13 +01006859# ifdef FEAT_TITLE
6860 redraw_titles();
6861# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006862 }
6863 }
6864#endif
6865
6866#ifdef FEAT_STL_OPT
6867 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006868 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006869 {
6870 int wid;
6871
6872 if (varp == &p_ruf) /* reset ru_wid first */
6873 ru_wid = 0;
6874 s = *varp;
6875 if (varp == &p_ruf && *s == '%')
6876 {
6877 /* set ru_wid if 'ruf' starts with "%99(" */
6878 if (*++s == '-') /* ignore a '-' */
6879 s++;
6880 wid = getdigits(&s);
6881 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
6882 ru_wid = wid;
6883 else
6884 errmsg = check_stl_option(p_ruf);
6885 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00006886 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00006887 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006888 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006889 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006890 comp_col();
6891 }
6892#endif
6893
6894#ifdef FEAT_INS_EXPAND
6895 /* check if it is a valid value for 'complete' -- Acevedo */
6896 else if (gvarp == &p_cpt)
6897 {
6898 for (s = *varp; *s;)
6899 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02006900 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006901 s++;
6902 if (!*s)
6903 break;
6904 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
6905 {
6906 errmsg = illegal_char(errbuf, *s);
6907 break;
6908 }
6909 if (*++s != NUL && *s != ',' && *s != ' ')
6910 {
6911 if (s[-1] == 'k' || s[-1] == 's')
6912 {
6913 /* skip optional filename after 'k' and 's' */
6914 while (*s && *s != ',' && *s != ' ')
6915 {
6916 if (*s == '\\')
6917 ++s;
6918 ++s;
6919 }
6920 }
6921 else
6922 {
6923 if (errbuf != NULL)
6924 {
6925 sprintf((char *)errbuf,
6926 _("E535: Illegal character after <%c>"),
6927 *--s);
6928 errmsg = errbuf;
6929 }
6930 else
6931 errmsg = (char_u *)"";
6932 break;
6933 }
6934 }
6935 }
6936 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00006937
6938 /* 'completeopt' */
6939 else if (varp == &p_cot)
6940 {
6941 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
6942 errmsg = e_invarg;
6943 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006944#endif /* FEAT_INS_EXPAND */
6945
6946
6947#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
6948 else if (varp == &p_toolbar)
6949 {
6950 if (opt_strings_flags(p_toolbar, p_toolbar_values,
6951 &toolbar_flags, TRUE) != OK)
6952 errmsg = e_invarg;
6953 else
6954 {
6955 out_flush();
6956 gui_mch_show_toolbar((toolbar_flags &
6957 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6958 }
6959 }
6960#endif
6961
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006962#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006963 /* 'toolbariconsize': GTK+ 2 only */
6964 else if (varp == &p_tbis)
6965 {
6966 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
6967 errmsg = e_invarg;
6968 else
6969 {
6970 out_flush();
6971 gui_mch_show_toolbar((toolbar_flags &
6972 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6973 }
6974 }
6975#endif
6976
6977 /* 'pastetoggle': translate key codes like in a mapping */
6978 else if (varp == &p_pt)
6979 {
6980 if (*p_pt)
6981 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00006982 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006983 if (p != NULL)
6984 {
6985 if (new_value_alloced)
6986 free_string_option(p_pt);
6987 p_pt = p;
6988 new_value_alloced = TRUE;
6989 }
6990 }
6991 }
6992
6993 /* 'backspace' */
6994 else if (varp == &p_bs)
6995 {
6996 if (VIM_ISDIGIT(*p_bs))
6997 {
6998 if (*p_bs >'2' || p_bs[1] != NUL)
6999 errmsg = e_invarg;
7000 }
7001 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
7002 errmsg = e_invarg;
7003 }
Bram Moolenaar165bc692015-07-21 17:53:25 +02007004 else if (varp == &p_bo)
7005 {
7006 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK)
7007 errmsg = e_invarg;
7008 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007009
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007010#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007011 /* 'casemap' */
7012 else if (varp == &p_cmp)
7013 {
7014 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
7015 errmsg = e_invarg;
7016 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007017#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007018
7019#ifdef FEAT_DIFF
7020 /* 'diffopt' */
7021 else if (varp == &p_dip)
7022 {
7023 if (diffopt_changed() == FAIL)
7024 errmsg = e_invarg;
7025 }
7026#endif
7027
7028#ifdef FEAT_FOLDING
7029 /* 'foldmethod' */
7030 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7031 {
7032 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7033 || *curwin->w_p_fdm == NUL)
7034 errmsg = e_invarg;
7035 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007036 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007037 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007038 if (foldmethodIsDiff(curwin))
7039 newFoldLevel();
7040 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007041 }
7042# ifdef FEAT_EVAL
7043 /* 'foldexpr' */
7044 else if (varp == &curwin->w_p_fde)
7045 {
7046 if (foldmethodIsExpr(curwin))
7047 foldUpdateAll(curwin);
7048 }
7049# endif
7050 /* 'foldmarker' */
7051 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7052 {
7053 p = vim_strchr(*varp, ',');
7054 if (p == NULL)
7055 errmsg = (char_u *)N_("E536: comma required");
7056 else if (p == *varp || p[1] == NUL)
7057 errmsg = e_invarg;
7058 else if (foldmethodIsMarker(curwin))
7059 foldUpdateAll(curwin);
7060 }
7061 /* 'commentstring' */
7062 else if (gvarp == &p_cms)
7063 {
7064 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7065 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7066 }
7067 /* 'foldopen' */
7068 else if (varp == &p_fdo)
7069 {
7070 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7071 errmsg = e_invarg;
7072 }
7073 /* 'foldclose' */
7074 else if (varp == &p_fcl)
7075 {
7076 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7077 errmsg = e_invarg;
7078 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007079 /* 'foldignore' */
7080 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7081 {
7082 if (foldmethodIsIndent(curwin))
7083 foldUpdateAll(curwin);
7084 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007085#endif
7086
7087#ifdef FEAT_VIRTUALEDIT
7088 /* 'virtualedit' */
7089 else if (varp == &p_ve)
7090 {
7091 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7092 errmsg = e_invarg;
7093 else if (STRCMP(p_ve, oldval) != 0)
7094 {
7095 /* Recompute cursor position in case the new 've' setting
7096 * changes something. */
7097 validate_virtcol();
7098 coladvance(curwin->w_virtcol);
7099 }
7100 }
7101#endif
7102
7103#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7104 else if (varp == &p_csqf)
7105 {
7106 if (p_csqf != NULL)
7107 {
7108 p = p_csqf;
7109 while (*p != NUL)
7110 {
7111 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7112 || p[1] == NUL
7113 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7114 || (p[2] != NUL && p[2] != ','))
7115 {
7116 errmsg = e_invarg;
7117 break;
7118 }
7119 else if (p[2] == NUL)
7120 break;
7121 else
7122 p += 3;
7123 }
7124 }
7125 }
7126#endif
7127
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007128#ifdef FEAT_CINDENT
7129 /* 'cinoptions' */
7130 else if (gvarp == &p_cino)
7131 {
7132 /* TODO: recognize errors */
7133 parse_cino(curbuf);
7134 }
7135#endif
7136
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007137#if defined(FEAT_RENDER_OPTIONS)
7138 else if (varp == &p_rop && gui.in_use)
7139 {
7140 if (!gui_mch_set_rendering_options(p_rop))
7141 errmsg = e_invarg;
7142 }
7143#endif
7144
Bram Moolenaar071d4272004-06-13 20:20:40 +00007145 /* Options that are a list of flags. */
7146 else
7147 {
7148 p = NULL;
7149 if (varp == &p_ww)
7150 p = (char_u *)WW_ALL;
7151 if (varp == &p_shm)
7152 p = (char_u *)SHM_ALL;
7153 else if (varp == &(p_cpo))
7154 p = (char_u *)CPO_ALL;
7155 else if (varp == &(curbuf->b_p_fo))
7156 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007157#ifdef FEAT_CONCEAL
7158 else if (varp == &curwin->w_p_cocu)
7159 p = (char_u *)COCU_ALL;
7160#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007161 else if (varp == &p_mouse)
7162 {
7163#ifdef FEAT_MOUSE
7164 p = (char_u *)MOUSE_ALL;
7165#else
7166 if (*p_mouse != NUL)
7167 errmsg = (char_u *)N_("E538: No mouse support");
7168#endif
7169 }
7170#if defined(FEAT_GUI)
7171 else if (varp == &p_go)
7172 p = (char_u *)GO_ALL;
7173#endif
7174 if (p != NULL)
7175 {
7176 for (s = *varp; *s; ++s)
7177 if (vim_strchr(p, *s) == NULL)
7178 {
7179 errmsg = illegal_char(errbuf, *s);
7180 break;
7181 }
7182 }
7183 }
7184
7185 /*
7186 * If error detected, restore the previous value.
7187 */
7188 if (errmsg != NULL)
7189 {
7190 if (new_value_alloced)
7191 free_string_option(*varp);
7192 *varp = oldval;
7193 /*
7194 * When resetting some values, need to act on it.
7195 */
7196 if (did_chartab)
7197 (void)init_chartab();
7198 if (varp == &p_hl)
7199 (void)highlight_changed();
7200 }
7201 else
7202 {
7203#ifdef FEAT_EVAL
7204 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007205 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007206#endif
7207 /*
7208 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007209 * Use "free_oldval", because recursiveness may change the flags under
7210 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007211 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007212 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007213 free_string_option(oldval);
7214 if (new_value_alloced)
7215 options[opt_idx].flags |= P_ALLOCED;
7216 else
7217 options[opt_idx].flags &= ~P_ALLOCED;
7218
7219 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007220 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007221 {
7222 /* global option with local value set to use global value; free
7223 * the local value and make it empty */
7224 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7225 free_string_option(*(char_u **)p);
7226 *(char_u **)p = empty_option;
7227 }
7228
7229 /* May set global value for local option. */
7230 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7231 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007232
7233#ifdef FEAT_AUTOCMD
7234 /*
7235 * Trigger the autocommand only after setting the flags.
7236 */
7237# ifdef FEAT_SYN_HL
7238 /* When 'syntax' is set, load the syntax of that name */
7239 if (varp == &(curbuf->b_p_syn))
7240 {
7241 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7242 curbuf->b_fname, TRUE, curbuf);
7243 }
7244# endif
7245 else if (varp == &(curbuf->b_p_ft))
7246 {
7247 /* 'filetype' is set, trigger the FileType autocommand */
7248 did_filetype = TRUE;
7249 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
7250 curbuf->b_fname, TRUE, curbuf);
7251 }
7252#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007253#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007254 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007255 {
7256 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007257 char_u *q = curwin->w_s->b_p_spl;
7258
7259 /* Skip the first name if it is "cjk". */
7260 if (STRNCMP(q, "cjk,", 4) == 0)
7261 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007262
7263 /*
7264 * Source the spell/LANG.vim in 'runtimepath'.
7265 * They could set 'spellcapcheck' depending on the language.
7266 * Use the first name in 'spelllang' up to '_region' or
7267 * '.encoding'.
7268 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007269 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007270 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7271 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007272 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007273 source_runtime(fname, TRUE);
7274 }
7275#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007276 }
7277
7278#ifdef FEAT_MOUSE
7279 if (varp == &p_mouse)
7280 {
7281# ifdef FEAT_MOUSE_TTY
7282 if (*p_mouse == NUL)
7283 mch_setmouse(FALSE); /* switch mouse off */
7284 else
7285# endif
7286 setmouse(); /* in case 'mouse' changed */
7287 }
7288#endif
7289
Bram Moolenaar913077c2012-03-28 19:59:04 +02007290 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007291 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007292 curwin->w_set_curswant = TRUE;
7293
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007294#ifdef FEAT_GUI
7295 /* check redraw when it's not a GUI option or the GUI is active. */
7296 if (!redraw_gui_only || gui.in_use)
7297#endif
7298 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007299
7300 return errmsg;
7301}
7302
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007303#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007304/*
7305 * Simple int comparison function for use with qsort()
7306 */
7307 static int
7308int_cmp(a, b)
7309 const void *a;
7310 const void *b;
7311{
7312 return *(const int *)a - *(const int *)b;
7313}
7314
7315/*
7316 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7317 * Returns error message, NULL if it's OK.
7318 */
7319 char_u *
7320check_colorcolumn(wp)
7321 win_T *wp;
7322{
7323 char_u *s;
7324 int col;
7325 int count = 0;
7326 int color_cols[256];
7327 int i;
7328 int j = 0;
7329
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007330 if (wp->w_buffer == NULL)
7331 return NULL; /* buffer was closed */
7332
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007333 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007334 {
7335 if (*s == '-' || *s == '+')
7336 {
7337 /* -N and +N: add to 'textwidth' */
7338 col = (*s == '-') ? -1 : 1;
7339 ++s;
7340 if (!VIM_ISDIGIT(*s))
7341 return e_invarg;
7342 col = col * getdigits(&s);
7343 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007344 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007345 col += wp->w_buffer->b_p_tw;
7346 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007347 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007348 }
7349 else if (VIM_ISDIGIT(*s))
7350 col = getdigits(&s);
7351 else
7352 return e_invarg;
7353 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007354skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007355 if (*s == NUL)
7356 break;
7357 if (*s != ',')
7358 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007359 if (*++s == NUL)
7360 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007361 }
7362
7363 vim_free(wp->w_p_cc_cols);
7364 if (count == 0)
7365 wp->w_p_cc_cols = NULL;
7366 else
7367 {
7368 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7369 if (wp->w_p_cc_cols != NULL)
7370 {
7371 /* sort the columns for faster usage on screen redraw inside
7372 * win_line() */
7373 qsort(color_cols, count, sizeof(int), int_cmp);
7374
7375 for (i = 0; i < count; ++i)
7376 /* skip duplicates */
7377 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7378 wp->w_p_cc_cols[j++] = color_cols[i];
7379 wp->w_p_cc_cols[j] = -1; /* end marker */
7380 }
7381 }
7382
7383 return NULL; /* no error */
7384}
7385#endif
7386
Bram Moolenaar071d4272004-06-13 20:20:40 +00007387/*
7388 * Handle setting 'listchars' or 'fillchars'.
7389 * Returns error message, NULL if it's OK.
7390 */
7391 static char_u *
7392set_chars_option(varp)
7393 char_u **varp;
7394{
7395 int round, i, len, entries;
7396 char_u *p, *s;
7397 int c1, c2 = 0;
7398 struct charstab
7399 {
7400 int *cp;
7401 char *name;
7402 };
7403#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7404 static struct charstab filltab[] =
7405 {
7406 {&fill_stl, "stl"},
7407 {&fill_stlnc, "stlnc"},
7408 {&fill_vert, "vert"},
7409 {&fill_fold, "fold"},
7410 {&fill_diff, "diff"},
7411 };
7412#endif
7413 static struct charstab lcstab[] =
7414 {
7415 {&lcs_eol, "eol"},
7416 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007417 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007418 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007419 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007420 {&lcs_tab2, "tab"},
7421 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007422#ifdef FEAT_CONCEAL
7423 {&lcs_conceal, "conceal"},
7424#else
7425 {NULL, "conceal"},
7426#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007427 };
7428 struct charstab *tab;
7429
7430#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7431 if (varp == &p_lcs)
7432#endif
7433 {
7434 tab = lcstab;
7435 entries = sizeof(lcstab) / sizeof(struct charstab);
7436 }
7437#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7438 else
7439 {
7440 tab = filltab;
7441 entries = sizeof(filltab) / sizeof(struct charstab);
7442 }
7443#endif
7444
7445 /* first round: check for valid value, second round: assign values */
7446 for (round = 0; round <= 1; ++round)
7447 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007448 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007449 {
7450 /* After checking that the value is valid: set defaults: space for
7451 * 'fillchars', NUL for 'listchars' */
7452 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007453 if (tab[i].cp != NULL)
7454 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007455 if (varp == &p_lcs)
7456 lcs_tab1 = NUL;
7457#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7458 else
7459 fill_diff = '-';
7460#endif
7461 }
7462 p = *varp;
7463 while (*p)
7464 {
7465 for (i = 0; i < entries; ++i)
7466 {
7467 len = (int)STRLEN(tab[i].name);
7468 if (STRNCMP(p, tab[i].name, len) == 0
7469 && p[len] == ':'
7470 && p[len + 1] != NUL)
7471 {
7472 s = p + len + 1;
7473#ifdef FEAT_MBYTE
7474 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007475 if (mb_char2cells(c1) > 1)
7476 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007477#else
7478 c1 = *s++;
7479#endif
7480 if (tab[i].cp == &lcs_tab2)
7481 {
7482 if (*s == NUL)
7483 continue;
7484#ifdef FEAT_MBYTE
7485 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007486 if (mb_char2cells(c2) > 1)
7487 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007488#else
7489 c2 = *s++;
7490#endif
7491 }
7492 if (*s == ',' || *s == NUL)
7493 {
7494 if (round)
7495 {
7496 if (tab[i].cp == &lcs_tab2)
7497 {
7498 lcs_tab1 = c1;
7499 lcs_tab2 = c2;
7500 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007501 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007502 *(tab[i].cp) = c1;
7503
7504 }
7505 p = s;
7506 break;
7507 }
7508 }
7509 }
7510
7511 if (i == entries)
7512 return e_invarg;
7513 if (*p == ',')
7514 ++p;
7515 }
7516 }
7517
7518 return NULL; /* no error */
7519}
7520
7521#ifdef FEAT_STL_OPT
7522/*
7523 * Check validity of options with the 'statusline' format.
7524 * Return error message or NULL.
7525 */
7526 char_u *
7527check_stl_option(s)
7528 char_u *s;
7529{
7530 int itemcnt = 0;
7531 int groupdepth = 0;
7532 static char_u errbuf[80];
7533
7534 while (*s && itemcnt < STL_MAX_ITEM)
7535 {
7536 /* Check for valid keys after % sequences */
7537 while (*s && *s != '%')
7538 s++;
7539 if (!*s)
7540 break;
7541 s++;
7542 if (*s != '%' && *s != ')')
7543 ++itemcnt;
7544 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7545 {
7546 s++;
7547 continue;
7548 }
7549 if (*s == ')')
7550 {
7551 s++;
7552 if (--groupdepth < 0)
7553 break;
7554 continue;
7555 }
7556 if (*s == '-')
7557 s++;
7558 while (VIM_ISDIGIT(*s))
7559 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007560 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007561 continue;
7562 if (*s == '.')
7563 {
7564 s++;
7565 while (*s && VIM_ISDIGIT(*s))
7566 s++;
7567 }
7568 if (*s == '(')
7569 {
7570 groupdepth++;
7571 continue;
7572 }
7573 if (vim_strchr(STL_ALL, *s) == NULL)
7574 {
7575 return illegal_char(errbuf, *s);
7576 }
7577 if (*s == '{')
7578 {
7579 s++;
7580 while (*s != '}' && *s)
7581 s++;
7582 if (*s != '}')
7583 return (char_u *)N_("E540: Unclosed expression sequence");
7584 }
7585 }
7586 if (itemcnt >= STL_MAX_ITEM)
7587 return (char_u *)N_("E541: too many items");
7588 if (groupdepth != 0)
7589 return (char_u *)N_("E542: unbalanced groups");
7590 return NULL;
7591}
7592#endif
7593
7594#ifdef FEAT_CLIPBOARD
7595/*
7596 * Extract the items in the 'clipboard' option and set global values.
7597 */
7598 static char_u *
7599check_clipboard_option()
7600{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007601 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007602 int new_autoselect_star = FALSE;
7603 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007604 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007605 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007606 regprog_T *new_exclude_prog = NULL;
7607 char_u *errmsg = NULL;
7608 char_u *p;
7609
7610 for (p = p_cb; *p != NUL; )
7611 {
7612 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7613 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007614 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007615 p += 7;
7616 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007617 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007618 && (p[11] == ',' || p[11] == NUL))
7619 {
7620 new_unnamed |= CLIP_UNNAMED_PLUS;
7621 p += 11;
7622 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007623 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007624 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007625 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007626 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007627 p += 10;
7628 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007629 else if (STRNCMP(p, "autoselectplus", 14) == 0
7630 && (p[14] == ',' || p[14] == NUL))
7631 {
7632 new_autoselect_plus = TRUE;
7633 p += 14;
7634 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007635 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007636 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007637 {
7638 new_autoselectml = TRUE;
7639 p += 12;
7640 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007641 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7642 {
7643 new_html = TRUE;
7644 p += 4;
7645 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007646 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7647 {
7648 p += 8;
7649 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7650 if (new_exclude_prog == NULL)
7651 errmsg = e_invarg;
7652 break;
7653 }
7654 else
7655 {
7656 errmsg = e_invarg;
7657 break;
7658 }
7659 if (*p == ',')
7660 ++p;
7661 }
7662 if (errmsg == NULL)
7663 {
7664 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007665 clip_autoselect_star = new_autoselect_star;
7666 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007667 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007668 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02007669 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007670 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02007671#ifdef FEAT_GUI_GTK
7672 if (gui.in_use)
7673 {
7674 gui_gtk_set_selection_targets();
7675 gui_gtk_set_dnd_targets();
7676 }
7677#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007678 }
7679 else
Bram Moolenaar473de612013-06-08 18:19:48 +02007680 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007681
7682 return errmsg;
7683}
7684#endif
7685
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007686#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007687/*
7688 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
7689 * Return error message when failed, NULL when OK.
7690 */
7691 static char_u *
Bram Moolenaar860cae12010-06-05 23:22:07 +02007692compile_cap_prog(synblock)
7693 synblock_T *synblock;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007694{
Bram Moolenaar860cae12010-06-05 23:22:07 +02007695 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007696 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007697
Bram Moolenaar860cae12010-06-05 23:22:07 +02007698 if (*synblock->b_p_spc == NUL)
7699 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007700 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007701 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007702 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007703 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007704 if (re != NULL)
7705 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007706 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02007707 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02007708 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007709 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007710 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007711 return e_invarg;
7712 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007713 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007714 }
7715
Bram Moolenaar473de612013-06-08 18:19:48 +02007716 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007717 return NULL;
7718}
7719#endif
7720
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007721#if defined(FEAT_EVAL) || defined(PROTO)
7722/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007723 * Set the scriptID for an option, taking care of setting the buffer- or
7724 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007725 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007726 static void
7727set_option_scriptID_idx(opt_idx, opt_flags, id)
7728 int opt_idx;
7729 int opt_flags;
7730 int id;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007731{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007732 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
7733 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007734
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007735 /* Remember where the option was set. For local options need to do that
7736 * in the buffer or window structure. */
7737 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007738 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007739 if (both || (opt_flags & OPT_LOCAL))
7740 {
7741 if (indir & PV_BUF)
7742 curbuf->b_p_scriptID[indir & PV_MASK] = id;
7743 else if (indir & PV_WIN)
7744 curwin->w_p_scriptID[indir & PV_MASK] = id;
7745 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007746}
7747#endif
7748
Bram Moolenaar071d4272004-06-13 20:20:40 +00007749/*
7750 * Set the value of a boolean option, and take care of side effects.
7751 * Returns NULL for success, or an error message for an error.
7752 */
7753 static char_u *
7754set_bool_option(opt_idx, varp, value, opt_flags)
7755 int opt_idx; /* index in options[] table */
7756 char_u *varp; /* pointer to the option variable */
7757 int value; /* new value */
7758 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
7759{
7760 int old_value = *(int *)varp;
7761
Bram Moolenaar071d4272004-06-13 20:20:40 +00007762 /* Disallow changing some options from secure mode */
7763 if ((secure
7764#ifdef HAVE_SANDBOX
7765 || sandbox != 0
7766#endif
7767 ) && (options[opt_idx].flags & P_SECURE))
7768 return e_secure;
7769
7770 *(int *)varp = value; /* set the new value */
7771#ifdef FEAT_EVAL
7772 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007773 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007774#endif
7775
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00007776#ifdef FEAT_GUI
7777 need_mouse_correct = TRUE;
7778#endif
7779
Bram Moolenaar071d4272004-06-13 20:20:40 +00007780 /* May set global value for local option. */
7781 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
7782 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
7783
7784 /*
7785 * Handle side effects of changing a bool option.
7786 */
7787
7788 /* 'compatible' */
7789 if ((int *)varp == &p_cp)
7790 {
7791 compatible_set();
7792 }
7793
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007794#ifdef FEAT_PERSISTENT_UNDO
7795 /* 'undofile' */
7796 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
7797 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007798 /* Only take action when the option was set. When reset we do not
7799 * delete the undo file, the option may be set again without making
7800 * any changes in between. */
7801 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007802 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007803 char_u hash[UNDO_HASH_SIZE];
7804 buf_T *save_curbuf = curbuf;
7805
7806 for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007807 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007808 /* When 'undofile' is set globally: for every buffer, otherwise
7809 * only for the current buffer: Try to read in the undofile,
7810 * if one exists, the buffer wasn't changed and the buffer was
7811 * loaded */
7812 if ((curbuf == save_curbuf
7813 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
7814 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
7815 {
7816 u_compute_hash(hash);
7817 u_read_undo(NULL, hash, curbuf->b_fname);
7818 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007819 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007820 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007821 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007822 }
7823#endif
7824
Bram Moolenaar071d4272004-06-13 20:20:40 +00007825 else if ((int *)varp == &curbuf->b_p_ro)
7826 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007827 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007828 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
7829 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007830
7831 /* when 'readonly' is set may give W10 again */
7832 if (curbuf->b_p_ro)
7833 curbuf->b_did_warn = FALSE;
7834
Bram Moolenaar071d4272004-06-13 20:20:40 +00007835#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007836 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007837#endif
7838 }
7839
Bram Moolenaar9c449722010-07-20 18:44:27 +02007840#ifdef FEAT_GUI
7841 else if ((int *)varp == &p_mh)
7842 {
7843 if (!p_mh)
7844 gui_mch_mousehide(FALSE);
7845 }
7846#endif
7847
Bram Moolenaara539df02010-08-01 14:35:05 +02007848#ifdef FEAT_TITLE
7849 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007850 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007851 {
7852 redraw_titles();
7853 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007854 /* when 'endofline' is changed, redraw the window title */
7855 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007856 {
7857 redraw_titles();
7858 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02007859 /* when 'fixeol' is changed, redraw the window title */
7860 else if ((int *)varp == &curbuf->b_p_fixeol)
7861 {
7862 redraw_titles();
7863 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007864# ifdef FEAT_MBYTE
7865 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00007866 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007867 {
7868 redraw_titles();
7869 }
7870# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007871#endif
7872
7873 /* when 'bin' is set also set some other options */
7874 else if ((int *)varp == &curbuf->b_p_bin)
7875 {
7876 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
7877#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007878 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007879#endif
7880 }
7881
7882#ifdef FEAT_AUTOCMD
7883 /* when 'buflisted' changes, trigger autocommands */
7884 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
7885 {
7886 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
7887 NULL, NULL, TRUE, curbuf);
7888 }
7889#endif
7890
7891 /* when 'swf' is set, create swapfile, when reset remove swapfile */
7892 else if ((int *)varp == &curbuf->b_p_swf)
7893 {
7894 if (curbuf->b_p_swf && p_uc)
7895 ml_open_file(curbuf); /* create the swap file */
7896 else
Bram Moolenaard55de222007-05-06 13:38:48 +00007897 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
7898 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007899 mf_close_file(curbuf, TRUE); /* remove the swap file */
7900 }
7901
7902 /* when 'terse' is set change 'shortmess' */
7903 else if ((int *)varp == &p_terse)
7904 {
7905 char_u *p;
7906
7907 p = vim_strchr(p_shm, SHM_SEARCH);
7908
7909 /* insert 's' in p_shm */
7910 if (p_terse && p == NULL)
7911 {
7912 STRCPY(IObuff, p_shm);
7913 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007914 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007915 }
7916 /* remove 's' from p_shm */
7917 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007918 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007919 }
7920
7921 /* when 'paste' is set or reset also change other options */
7922 else if ((int *)varp == &p_paste)
7923 {
7924 paste_option_changed();
7925 }
7926
7927 /* when 'insertmode' is set from an autocommand need to do work here */
7928 else if ((int *)varp == &p_im)
7929 {
7930 if (p_im)
7931 {
7932 if ((State & INSERT) == 0)
7933 need_start_insertmode = TRUE;
7934 stop_insert_mode = FALSE;
7935 }
7936 else
7937 {
7938 need_start_insertmode = FALSE;
7939 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00007940 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007941 clear_cmdline = TRUE; /* remove "(insert)" */
7942 restart_edit = 0;
7943 }
7944 }
7945
7946 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
7947 else if ((int *)varp == &p_ic && p_hls)
7948 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007949 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007950 }
7951
7952#ifdef FEAT_SEARCH_EXTRA
7953 /* when 'hlsearch' is set or reset: reset no_hlsearch */
7954 else if ((int *)varp == &p_hls)
7955 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01007956 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007957 }
7958#endif
7959
7960#ifdef FEAT_SCROLLBIND
7961 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
7962 * at the end of normal_cmd() */
7963 else if ((int *)varp == &curwin->w_p_scb)
7964 {
7965 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02007966 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007967 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02007968 curwin->w_scbind_pos = curwin->w_topline;
7969 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007970 }
7971#endif
7972
7973#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
7974 /* There can be only one window with 'previewwindow' set. */
7975 else if ((int *)varp == &curwin->w_p_pvw)
7976 {
7977 if (curwin->w_p_pvw)
7978 {
7979 win_T *win;
7980
7981 for (win = firstwin; win != NULL; win = win->w_next)
7982 if (win->w_p_pvw && win != curwin)
7983 {
7984 curwin->w_p_pvw = FALSE;
7985 return (char_u *)N_("E590: A preview window already exists");
7986 }
7987 }
7988 }
7989#endif
7990
7991 /* when 'textmode' is set or reset also change 'fileformat' */
7992 else if ((int *)varp == &curbuf->b_p_tx)
7993 {
7994 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
7995 }
7996
7997 /* when 'textauto' is set or reset also change 'fileformats' */
7998 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007999 set_string_option_direct((char_u *)"ffs", -1,
8000 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008001 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008002
8003 /*
8004 * When 'lisp' option changes include/exclude '-' in
8005 * keyword characters.
8006 */
8007#ifdef FEAT_LISP
8008 else if (varp == (char_u *)&(curbuf->b_p_lisp))
8009 {
8010 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
8011 }
8012#endif
8013
8014#ifdef FEAT_TITLE
8015 /* when 'title' changed, may need to change the title; same for 'icon' */
8016 else if ((int *)varp == &p_title)
8017 {
8018 did_set_title(FALSE);
8019 }
8020
8021 else if ((int *)varp == &p_icon)
8022 {
8023 did_set_title(TRUE);
8024 }
8025#endif
8026
8027 else if ((int *)varp == &curbuf->b_changed)
8028 {
8029 if (!value)
8030 save_file_ff(curbuf); /* Buffer is unchanged */
8031#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008032 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008033#endif
8034#ifdef FEAT_AUTOCMD
8035 modified_was_set = value;
8036#endif
8037 }
8038
8039#ifdef BACKSLASH_IN_FILENAME
8040 else if ((int *)varp == &p_ssl)
8041 {
8042 if (p_ssl)
8043 {
8044 psepc = '/';
8045 psepcN = '\\';
8046 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008047 }
8048 else
8049 {
8050 psepc = '\\';
8051 psepcN = '/';
8052 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008053 }
8054
8055 /* need to adjust the file name arguments and buffer names. */
8056 buflist_slash_adjust();
8057 alist_slash_adjust();
8058# ifdef FEAT_EVAL
8059 scriptnames_slash_adjust();
8060# endif
8061 }
8062#endif
8063
8064 /* If 'wrap' is set, set w_leftcol to zero. */
8065 else if ((int *)varp == &curwin->w_p_wrap)
8066 {
8067 if (curwin->w_p_wrap)
8068 curwin->w_leftcol = 0;
8069 }
8070
8071#ifdef FEAT_WINDOWS
8072 else if ((int *)varp == &p_ea)
8073 {
8074 if (p_ea && !old_value)
8075 win_equal(curwin, FALSE, 0);
8076 }
8077#endif
8078
8079 else if ((int *)varp == &p_wiv)
8080 {
8081 /*
8082 * When 'weirdinvert' changed, set/reset 't_xs'.
8083 * Then set 'weirdinvert' according to value of 't_xs'.
8084 */
8085 if (p_wiv && !old_value)
8086 T_XS = (char_u *)"y";
8087 else if (!p_wiv && old_value)
8088 T_XS = empty_option;
8089 p_wiv = (*T_XS != NUL);
8090 }
8091
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00008092#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00008093 else if ((int *)varp == &p_beval)
8094 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008095 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008096 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008097 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008098 gui_mch_disable_beval_area(balloonEval);
8099 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008100#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008101
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008102#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008103 else if ((int *)varp == &p_acd)
8104 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008105 /* Change directories when the 'acd' option is set now. */
8106 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008107 }
8108#endif
8109
8110#ifdef FEAT_DIFF
8111 /* 'diff' */
8112 else if ((int *)varp == &curwin->w_p_diff)
8113 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008114 /* May add or remove the buffer from the list of diff buffers. */
8115 diff_buf_adjust(curwin);
8116# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008117 if (foldmethodIsDiff(curwin))
8118 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008119# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008120 }
8121#endif
8122
8123#ifdef USE_IM_CONTROL
8124 /* 'imdisable' */
8125 else if ((int *)varp == &p_imdisable)
8126 {
8127 /* Only de-activate it here, it will be enabled when changing mode. */
8128 if (p_imdisable)
8129 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008130 else if (State & INSERT)
8131 /* When the option is set from an autocommand, it may need to take
8132 * effect right away. */
8133 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008134 }
8135#endif
8136
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008137#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008138 /* 'spell' */
8139 else if ((int *)varp == &curwin->w_p_spell)
8140 {
8141 if (curwin->w_p_spell)
8142 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008143 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008144 if (errmsg != NULL)
8145 EMSG(_(errmsg));
8146 }
8147 }
8148#endif
8149
Bram Moolenaar071d4272004-06-13 20:20:40 +00008150#ifdef FEAT_FKMAP
8151 else if ((int *)varp == &p_altkeymap)
8152 {
8153 if (old_value != p_altkeymap)
8154 {
8155 if (!p_altkeymap)
8156 {
8157 p_hkmap = p_fkmap;
8158 p_fkmap = 0;
8159 }
8160 else
8161 {
8162 p_fkmap = p_hkmap;
8163 p_hkmap = 0;
8164 }
8165 (void)init_chartab();
8166 }
8167 }
8168
8169 /*
8170 * In case some second language keymapping options have changed, check
8171 * and correct the setting in a consistent way.
8172 */
8173
8174 /*
8175 * If hkmap or fkmap are set, reset Arabic keymapping.
8176 */
8177 if ((p_hkmap || p_fkmap) && p_altkeymap)
8178 {
8179 p_altkeymap = p_fkmap;
8180# ifdef FEAT_ARABIC
8181 curwin->w_p_arab = FALSE;
8182# endif
8183 (void)init_chartab();
8184 }
8185
8186 /*
8187 * If hkmap set, reset Farsi keymapping.
8188 */
8189 if (p_hkmap && p_altkeymap)
8190 {
8191 p_altkeymap = 0;
8192 p_fkmap = 0;
8193# ifdef FEAT_ARABIC
8194 curwin->w_p_arab = FALSE;
8195# endif
8196 (void)init_chartab();
8197 }
8198
8199 /*
8200 * If fkmap set, reset Hebrew keymapping.
8201 */
8202 if (p_fkmap && !p_altkeymap)
8203 {
8204 p_altkeymap = 1;
8205 p_hkmap = 0;
8206# ifdef FEAT_ARABIC
8207 curwin->w_p_arab = FALSE;
8208# endif
8209 (void)init_chartab();
8210 }
8211#endif
8212
8213#ifdef FEAT_ARABIC
8214 if ((int *)varp == &curwin->w_p_arab)
8215 {
8216 if (curwin->w_p_arab)
8217 {
8218 /*
8219 * 'arabic' is set, handle various sub-settings.
8220 */
8221 if (!p_tbidi)
8222 {
8223 /* set rightleft mode */
8224 if (!curwin->w_p_rl)
8225 {
8226 curwin->w_p_rl = TRUE;
8227 changed_window_setting();
8228 }
8229
8230 /* Enable Arabic shaping (major part of what Arabic requires) */
8231 if (!p_arshape)
8232 {
8233 p_arshape = TRUE;
8234 redraw_later_clear();
8235 }
8236 }
8237
8238 /* Arabic requires a utf-8 encoding, inform the user if its not
8239 * set. */
8240 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008241 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008242 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8243
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008244 msg_source(hl_attr(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008245 MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
8246#ifdef FEAT_EVAL
8247 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8248#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008249 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008250
8251# ifdef FEAT_MBYTE
8252 /* set 'delcombine' */
8253 p_deco = TRUE;
8254# endif
8255
8256# ifdef FEAT_KEYMAP
8257 /* Force-set the necessary keymap for arabic */
8258 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8259 OPT_LOCAL);
8260# endif
8261# ifdef FEAT_FKMAP
8262 p_altkeymap = 0;
8263 p_hkmap = 0;
8264 p_fkmap = 0;
8265 (void)init_chartab();
8266# endif
8267 }
8268 else
8269 {
8270 /*
8271 * 'arabic' is reset, handle various sub-settings.
8272 */
8273 if (!p_tbidi)
8274 {
8275 /* reset rightleft mode */
8276 if (curwin->w_p_rl)
8277 {
8278 curwin->w_p_rl = FALSE;
8279 changed_window_setting();
8280 }
8281
8282 /* 'arabicshape' isn't reset, it is a global option and
8283 * another window may still need it "on". */
8284 }
8285
8286 /* 'delcombine' isn't reset, it is a global option and another
8287 * window may still want it "on". */
8288
8289# ifdef FEAT_KEYMAP
8290 /* Revert to the default keymap */
8291 curbuf->b_p_iminsert = B_IMODE_NONE;
8292 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8293# endif
8294 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008295 }
8296
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008297#endif
8298
Bram Moolenaar071d4272004-06-13 20:20:40 +00008299 /*
8300 * End of handling side effects for bool options.
8301 */
8302
Bram Moolenaar53744302015-07-17 17:38:22 +02008303 /* after handling side effects, call autocommand */
8304
Bram Moolenaar071d4272004-06-13 20:20:40 +00008305 options[opt_idx].flags |= P_WAS_SET;
8306
Bram Moolenaar53744302015-07-17 17:38:22 +02008307#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8308 if (!starting)
8309 {
8310 char_u buf_old[2], buf_new[2], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008311 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8312 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8313 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008314 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8315 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8316 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8317 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8318 reset_v_option_vars();
8319 }
8320#endif
8321
Bram Moolenaar071d4272004-06-13 20:20:40 +00008322 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008323 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008324 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008325 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008326 check_redraw(options[opt_idx].flags);
8327
8328 return NULL;
8329}
8330
8331/*
8332 * Set the value of a number option, and take care of side effects.
8333 * Returns NULL for success, or an error message for an error.
8334 */
8335 static char_u *
Bram Moolenaar555b2802005-05-19 21:08:39 +00008336set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008337 int opt_idx; /* index in options[] table */
8338 char_u *varp; /* pointer to the option variable */
8339 long value; /* new value */
8340 char_u *errbuf; /* buffer for error messages */
Bram Moolenaar555b2802005-05-19 21:08:39 +00008341 size_t errbuflen; /* length of "errbuf" */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008342 int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and
8343 OPT_MODELINE */
8344{
8345 char_u *errmsg = NULL;
8346 long old_value = *(long *)varp;
8347 long old_Rows = Rows; /* remember old Rows */
8348 long old_Columns = Columns; /* remember old Columns */
8349 long *pp = (long *)varp;
8350
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008351 /* Disallow changing some options from secure mode. */
8352 if ((secure
8353#ifdef HAVE_SANDBOX
8354 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008355#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008356 ) && (options[opt_idx].flags & P_SECURE))
8357 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008358
8359 *pp = value;
8360#ifdef FEAT_EVAL
8361 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008362 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008363#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008364#ifdef FEAT_GUI
8365 need_mouse_correct = TRUE;
8366#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008367
Bram Moolenaar14f24742012-08-08 18:01:05 +02008368 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008369 {
8370 errmsg = e_positive;
8371 curbuf->b_p_sw = curbuf->b_p_ts;
8372 }
8373
8374 /*
8375 * Number options that need some action when changed
8376 */
8377#ifdef FEAT_WINDOWS
8378 if (pp == &p_wh || pp == &p_hh)
8379 {
8380 if (p_wh < 1)
8381 {
8382 errmsg = e_positive;
8383 p_wh = 1;
8384 }
8385 if (p_wmh > p_wh)
8386 {
8387 errmsg = e_winheight;
8388 p_wh = p_wmh;
8389 }
8390 if (p_hh < 0)
8391 {
8392 errmsg = e_positive;
8393 p_hh = 0;
8394 }
8395
8396 /* Change window height NOW */
8397 if (lastwin != firstwin)
8398 {
8399 if (pp == &p_wh && curwin->w_height < p_wh)
8400 win_setheight((int)p_wh);
8401 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8402 win_setheight((int)p_hh);
8403 }
8404 }
8405
8406 /* 'winminheight' */
8407 else if (pp == &p_wmh)
8408 {
8409 if (p_wmh < 0)
8410 {
8411 errmsg = e_positive;
8412 p_wmh = 0;
8413 }
8414 if (p_wmh > p_wh)
8415 {
8416 errmsg = e_winheight;
8417 p_wmh = p_wh;
8418 }
8419 win_setminheight();
8420 }
8421
8422# ifdef FEAT_VERTSPLIT
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008423 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008424 {
8425 if (p_wiw < 1)
8426 {
8427 errmsg = e_positive;
8428 p_wiw = 1;
8429 }
8430 if (p_wmw > p_wiw)
8431 {
8432 errmsg = e_winwidth;
8433 p_wiw = p_wmw;
8434 }
8435
8436 /* Change window width NOW */
8437 if (lastwin != firstwin && curwin->w_width < p_wiw)
8438 win_setwidth((int)p_wiw);
8439 }
8440
8441 /* 'winminwidth' */
8442 else if (pp == &p_wmw)
8443 {
8444 if (p_wmw < 0)
8445 {
8446 errmsg = e_positive;
8447 p_wmw = 0;
8448 }
8449 if (p_wmw > p_wiw)
8450 {
8451 errmsg = e_winwidth;
8452 p_wmw = p_wiw;
8453 }
8454 win_setminheight();
8455 }
8456# endif
8457
8458#endif
8459
8460#ifdef FEAT_WINDOWS
8461 /* (re)set last window status line */
8462 else if (pp == &p_ls)
8463 {
8464 last_status(FALSE);
8465 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008466
8467 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008468 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008469 {
8470 shell_new_rows(); /* recompute window positions and heights */
8471 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008472#endif
8473
8474#ifdef FEAT_GUI
8475 else if (pp == &p_linespace)
8476 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008477 /* Recompute gui.char_height and resize the Vim window to keep the
8478 * same number of lines. */
8479 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008480 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008481 }
8482#endif
8483
8484#ifdef FEAT_FOLDING
8485 /* 'foldlevel' */
8486 else if (pp == &curwin->w_p_fdl)
8487 {
8488 if (curwin->w_p_fdl < 0)
8489 curwin->w_p_fdl = 0;
8490 newFoldLevel();
8491 }
8492
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008493 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008494 else if (pp == &curwin->w_p_fml)
8495 {
8496 foldUpdateAll(curwin);
8497 }
8498
8499 /* 'foldnestmax' */
8500 else if (pp == &curwin->w_p_fdn)
8501 {
8502 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8503 foldUpdateAll(curwin);
8504 }
8505
8506 /* 'foldcolumn' */
8507 else if (pp == &curwin->w_p_fdc)
8508 {
8509 if (curwin->w_p_fdc < 0)
8510 {
8511 errmsg = e_positive;
8512 curwin->w_p_fdc = 0;
8513 }
8514 else if (curwin->w_p_fdc > 12)
8515 {
8516 errmsg = e_invarg;
8517 curwin->w_p_fdc = 12;
8518 }
8519 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008520#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008521
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008522#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008523 /* 'shiftwidth' or 'tabstop' */
8524 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8525 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008526# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008527 if (foldmethodIsIndent(curwin))
8528 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008529# endif
8530# ifdef FEAT_CINDENT
8531 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8532 * parse 'cinoptions'. */
8533 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8534 parse_cino(curbuf);
8535# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008536 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008537#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008538
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008539#ifdef FEAT_MBYTE
8540 /* 'maxcombine' */
8541 else if (pp == &p_mco)
8542 {
8543 if (p_mco > MAX_MCO)
8544 p_mco = MAX_MCO;
8545 else if (p_mco < 0)
8546 p_mco = 0;
8547 screenclear(); /* will re-allocate the screen */
8548 }
8549#endif
8550
Bram Moolenaar071d4272004-06-13 20:20:40 +00008551 else if (pp == &curbuf->b_p_iminsert)
8552 {
8553 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8554 {
8555 errmsg = e_invarg;
8556 curbuf->b_p_iminsert = B_IMODE_NONE;
8557 }
8558 p_iminsert = curbuf->b_p_iminsert;
8559 if (termcap_active) /* don't do this in the alternate screen */
8560 showmode();
8561#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8562 /* Show/unshow value of 'keymap' in status lines. */
8563 status_redraw_curbuf();
8564#endif
8565 }
8566
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008567 else if (pp == &p_window)
8568 {
8569 if (p_window < 1)
8570 p_window = 1;
8571 else if (p_window >= Rows)
8572 p_window = Rows - 1;
8573 }
8574
Bram Moolenaar071d4272004-06-13 20:20:40 +00008575 else if (pp == &curbuf->b_p_imsearch)
8576 {
8577 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8578 {
8579 errmsg = e_invarg;
8580 curbuf->b_p_imsearch = B_IMODE_NONE;
8581 }
8582 p_imsearch = curbuf->b_p_imsearch;
8583 }
8584
8585#ifdef FEAT_TITLE
8586 /* if 'titlelen' has changed, redraw the title */
8587 else if (pp == &p_titlelen)
8588 {
8589 if (p_titlelen < 0)
8590 {
8591 errmsg = e_positive;
8592 p_titlelen = 85;
8593 }
8594 if (starting != NO_SCREEN && old_value != p_titlelen)
8595 need_maketitle = TRUE;
8596 }
8597#endif
8598
8599 /* if p_ch changed value, change the command line height */
8600 else if (pp == &p_ch)
8601 {
8602 if (p_ch < 1)
8603 {
8604 errmsg = e_positive;
8605 p_ch = 1;
8606 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008607 if (p_ch > Rows - min_rows() + 1)
8608 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008609
8610 /* Only compute the new window layout when startup has been
8611 * completed. Otherwise the frame sizes may be wrong. */
8612 if (p_ch != old_value && full_screen
8613#ifdef FEAT_GUI
8614 && !gui.starting
8615#endif
8616 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008617 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008618 }
8619
8620 /* when 'updatecount' changes from zero to non-zero, open swap files */
8621 else if (pp == &p_uc)
8622 {
8623 if (p_uc < 0)
8624 {
8625 errmsg = e_positive;
8626 p_uc = 100;
8627 }
8628 if (p_uc && !old_value)
8629 ml_open_files();
8630 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008631#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008632 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008633 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008634 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008635 {
8636 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008637 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008638 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008639 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008640 {
8641 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008642 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008643 }
8644 }
8645#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008646#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008647 else if (pp == &p_mzq)
8648 mzvim_reset_timer();
8649#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008650
8651 /* sync undo before 'undolevels' changes */
8652 else if (pp == &p_ul)
8653 {
8654 /* use the old value, otherwise u_sync() may not work properly */
8655 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00008656 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008657 p_ul = value;
8658 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01008659 else if (pp == &curbuf->b_p_ul)
8660 {
8661 /* use the old value, otherwise u_sync() may not work properly */
8662 curbuf->b_p_ul = old_value;
8663 u_sync(TRUE);
8664 curbuf->b_p_ul = value;
8665 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008666
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008667#ifdef FEAT_LINEBREAK
8668 /* 'numberwidth' must be positive */
8669 else if (pp == &curwin->w_p_nuw)
8670 {
8671 if (curwin->w_p_nuw < 1)
8672 {
8673 errmsg = e_positive;
8674 curwin->w_p_nuw = 1;
8675 }
8676 if (curwin->w_p_nuw > 10)
8677 {
8678 errmsg = e_invarg;
8679 curwin->w_p_nuw = 10;
8680 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02008681 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008682 }
8683#endif
8684
Bram Moolenaar1a384422010-07-14 19:53:30 +02008685 else if (pp == &curbuf->b_p_tw)
8686 {
8687 if (curbuf->b_p_tw < 0)
8688 {
8689 errmsg = e_positive;
8690 curbuf->b_p_tw = 0;
8691 }
8692#ifdef FEAT_SYN_HL
8693# ifdef FEAT_WINDOWS
8694 {
8695 win_T *wp;
8696 tabpage_T *tp;
8697
8698 FOR_ALL_TAB_WINDOWS(tp, wp)
8699 check_colorcolumn(wp);
8700 }
8701# else
8702 check_colorcolumn(curwin);
8703# endif
8704#endif
8705 }
8706
Bram Moolenaar071d4272004-06-13 20:20:40 +00008707 /*
8708 * Check the bounds for numeric options here
8709 */
8710 if (Rows < min_rows() && full_screen)
8711 {
8712 if (errbuf != NULL)
8713 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008714 vim_snprintf((char *)errbuf, errbuflen,
8715 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00008716 errmsg = errbuf;
8717 }
8718 Rows = min_rows();
8719 }
8720 if (Columns < MIN_COLUMNS && full_screen)
8721 {
8722 if (errbuf != NULL)
8723 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008724 vim_snprintf((char *)errbuf, errbuflen,
8725 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008726 errmsg = errbuf;
8727 }
8728 Columns = MIN_COLUMNS;
8729 }
Bram Moolenaare057d402013-06-30 17:51:51 +02008730 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008731
8732#ifdef DJGPP
8733 /* avoid a crash by checking for a too large value of 'columns' */
8734 if (old_Columns != Columns && full_screen && term_console)
8735 mch_check_columns();
8736#endif
8737
8738 /*
8739 * If the screen (shell) height has been changed, assume it is the
8740 * physical screenheight.
8741 */
8742 if (old_Rows != Rows || old_Columns != Columns)
8743 {
8744 /* Changing the screen size is not allowed while updating the screen. */
8745 if (updating_screen)
8746 *pp = old_value;
8747 else if (full_screen
8748#ifdef FEAT_GUI
8749 && !gui.starting
8750#endif
8751 )
8752 set_shellsize((int)Columns, (int)Rows, TRUE);
8753 else
8754 {
8755 /* Postpone the resizing; check the size and cmdline position for
8756 * messages. */
8757 check_shellsize();
8758 if (cmdline_row > Rows - p_ch && Rows > p_ch)
8759 cmdline_row = Rows - p_ch;
8760 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00008761 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008762 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008763 }
8764
Bram Moolenaar071d4272004-06-13 20:20:40 +00008765 if (curbuf->b_p_ts <= 0)
8766 {
8767 errmsg = e_positive;
8768 curbuf->b_p_ts = 8;
8769 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008770 if (p_tm < 0)
8771 {
8772 errmsg = e_positive;
8773 p_tm = 0;
8774 }
8775 if ((curwin->w_p_scr <= 0
8776 || (curwin->w_p_scr > curwin->w_height
8777 && curwin->w_height > 0))
8778 && full_screen)
8779 {
8780 if (pp == &(curwin->w_p_scr))
8781 {
8782 if (curwin->w_p_scr != 0)
8783 errmsg = e_scroll;
8784 win_comp_scroll(curwin);
8785 }
8786 /* If 'scroll' became invalid because of a side effect silently adjust
8787 * it. */
8788 else if (curwin->w_p_scr <= 0)
8789 curwin->w_p_scr = 1;
8790 else /* curwin->w_p_scr > curwin->w_height */
8791 curwin->w_p_scr = curwin->w_height;
8792 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00008793 if (p_hi < 0)
8794 {
8795 errmsg = e_positive;
8796 p_hi = 0;
8797 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02008798 else if (p_hi > 10000)
8799 {
8800 errmsg = e_invarg;
8801 p_hi = 10000;
8802 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02008803 if (p_re < 0 || p_re > 2)
8804 {
8805 errmsg = e_invarg;
8806 p_re = 0;
8807 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008808 if (p_report < 0)
8809 {
8810 errmsg = e_positive;
8811 p_report = 1;
8812 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00008813 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008814 {
8815 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
8816 p_sj = Rows / 2;
8817 else
8818 {
8819 errmsg = e_scroll;
8820 p_sj = 1;
8821 }
8822 }
8823 if (p_so < 0 && full_screen)
8824 {
8825 errmsg = e_scroll;
8826 p_so = 0;
8827 }
8828 if (p_siso < 0 && full_screen)
8829 {
8830 errmsg = e_positive;
8831 p_siso = 0;
8832 }
8833#ifdef FEAT_CMDWIN
8834 if (p_cwh < 1)
8835 {
8836 errmsg = e_positive;
8837 p_cwh = 1;
8838 }
8839#endif
8840 if (p_ut < 0)
8841 {
8842 errmsg = e_positive;
8843 p_ut = 2000;
8844 }
8845 if (p_ss < 0)
8846 {
8847 errmsg = e_positive;
8848 p_ss = 0;
8849 }
8850
8851 /* May set global value for local option. */
8852 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8853 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
8854
8855 options[opt_idx].flags |= P_WAS_SET;
8856
Bram Moolenaar53744302015-07-17 17:38:22 +02008857#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8858 if (!starting && errmsg == NULL)
8859 {
8860 char_u buf_old[11], buf_new[11], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008861 vim_snprintf((char *)buf_old, 10, "%ld", old_value);
8862 vim_snprintf((char *)buf_new, 10, "%ld", value);
8863 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008864 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8865 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8866 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8867 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8868 reset_v_option_vars();
8869 }
8870#endif
8871
Bram Moolenaar071d4272004-06-13 20:20:40 +00008872 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008873 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008874 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008875 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008876 check_redraw(options[opt_idx].flags);
8877
8878 return errmsg;
8879}
8880
8881/*
8882 * Called after an option changed: check if something needs to be redrawn.
8883 */
8884 static void
8885check_redraw(flags)
8886 long_u flags;
8887{
8888 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008889 int doclear = (flags & P_RCLR) == P_RCLR;
8890 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008891
8892#ifdef FEAT_WINDOWS
8893 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
8894 status_redraw_all();
8895#endif
8896
8897 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
8898 changed_window_setting();
8899 if (flags & P_RBUF)
8900 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008901 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008902 redraw_all_later(CLEAR);
8903 else if (all)
8904 redraw_all_later(NOT_VALID);
8905}
8906
8907/*
8908 * Find index for option 'arg'.
8909 * Return -1 if not found.
8910 */
8911 static int
8912findoption(arg)
8913 char_u *arg;
8914{
8915 int opt_idx;
8916 char *s, *p;
8917 static short quick_tab[27] = {0, 0}; /* quick access table */
8918 int is_term_opt;
8919
8920 /*
8921 * For first call: Initialize the quick-access table.
8922 * It contains the index for the first option that starts with a certain
8923 * letter. There are 26 letters, plus the first "t_" option.
8924 */
8925 if (quick_tab[1] == 0)
8926 {
8927 p = options[0].fullname;
8928 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8929 {
8930 if (s[0] != p[0])
8931 {
8932 if (s[0] == 't' && s[1] == '_')
8933 quick_tab[26] = opt_idx;
8934 else
8935 quick_tab[CharOrdLow(s[0])] = opt_idx;
8936 }
8937 p = s;
8938 }
8939 }
8940
8941 /*
8942 * Check for name starting with an illegal character.
8943 */
8944#ifdef EBCDIC
8945 if (!islower(arg[0]))
8946#else
8947 if (arg[0] < 'a' || arg[0] > 'z')
8948#endif
8949 return -1;
8950
8951 is_term_opt = (arg[0] == 't' && arg[1] == '_');
8952 if (is_term_opt)
8953 opt_idx = quick_tab[26];
8954 else
8955 opt_idx = quick_tab[CharOrdLow(arg[0])];
8956 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8957 {
8958 if (STRCMP(arg, s) == 0) /* match full name */
8959 break;
8960 }
8961 if (s == NULL && !is_term_opt)
8962 {
8963 opt_idx = quick_tab[CharOrdLow(arg[0])];
8964 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
8965 {
8966 s = options[opt_idx].shortname;
8967 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
8968 break;
8969 s = NULL;
8970 }
8971 }
8972 if (s == NULL)
8973 opt_idx = -1;
8974 return opt_idx;
8975}
8976
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008977#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008978/*
8979 * Get the value for an option.
8980 *
8981 * Returns:
8982 * Number or Toggle option: 1, *numval gets value.
8983 * String option: 0, *stringval gets allocated string.
8984 * Hidden Number or Toggle option: -1.
8985 * hidden String option: -2.
8986 * unknown option: -3.
8987 */
8988 int
8989get_option_value(name, numval, stringval, opt_flags)
8990 char_u *name;
8991 long *numval;
Bram Moolenaar370df582010-06-22 05:16:38 +02008992 char_u **stringval; /* NULL when only checking existence */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008993 int opt_flags;
8994{
8995 int opt_idx;
8996 char_u *varp;
8997
8998 opt_idx = findoption(name);
8999 if (opt_idx < 0) /* unknown option */
9000 return -3;
9001
9002 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
9003
9004 if (options[opt_idx].flags & P_STRING)
9005 {
9006 if (varp == NULL) /* hidden option */
9007 return -2;
9008 if (stringval != NULL)
9009 {
9010#ifdef FEAT_CRYPT
9011 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00009012 if ((char_u **)varp == &curbuf->b_p_key
9013 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009014 *stringval = vim_strsave((char_u *)"*****");
9015 else
9016#endif
9017 *stringval = vim_strsave(*(char_u **)(varp));
9018 }
9019 return 0;
9020 }
9021
9022 if (varp == NULL) /* hidden option */
9023 return -1;
9024 if (options[opt_idx].flags & P_NUM)
9025 *numval = *(long *)varp;
9026 else
9027 {
9028 /* Special case: 'modified' is b_changed, but we also want to consider
9029 * it set when 'ff' or 'fenc' changed. */
9030 if ((int *)varp == &curbuf->b_changed)
9031 *numval = curbufIsChanged();
9032 else
9033 *numval = *(int *)varp;
9034 }
9035 return 1;
9036}
9037#endif
9038
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009039#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009040/*
9041 * Returns the option attributes and its value. Unlike the above function it
9042 * will return either global value or local value of the option depending on
9043 * what was requested, but it will never return global value if it was
9044 * requested to return local one and vice versa. Neither it will return
9045 * buffer-local value if it was requested to return window-local one.
9046 *
9047 * Pretends that option is absent if it is not present in the requested scope
9048 * (i.e. has no global, window-local or buffer-local value depending on
9049 * opt_type). Uses
9050 *
9051 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009052 * 0 hidden or unknown option, also option that does not have requested
9053 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009054 * see SOPT_* in vim.h for other flags
9055 *
9056 * Possible opt_type values: see SREQ_* in vim.h
9057 */
9058 int
9059get_option_value_strict(name, numval, stringval, opt_type, from)
9060 char_u *name;
9061 long *numval;
9062 char_u **stringval; /* NULL when only obtaining attributes */
9063 int opt_type;
9064 void *from;
9065{
9066 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009067 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009068 struct vimoption *p;
9069 int r = 0;
9070
9071 opt_idx = findoption(name);
9072 if (opt_idx < 0)
9073 return 0;
9074
9075 p = &(options[opt_idx]);
9076
9077 /* Hidden option */
9078 if (p->var == NULL)
9079 return 0;
9080
9081 if (p->flags & P_BOOL)
9082 r |= SOPT_BOOL;
9083 else if (p->flags & P_NUM)
9084 r |= SOPT_NUM;
9085 else if (p->flags & P_STRING)
9086 r |= SOPT_STRING;
9087
9088 if (p->indir == PV_NONE)
9089 {
9090 if (opt_type == SREQ_GLOBAL)
9091 r |= SOPT_GLOBAL;
9092 else
9093 return 0; /* Did not request global-only option */
9094 }
9095 else
9096 {
9097 if (p->indir & PV_BOTH)
9098 r |= SOPT_GLOBAL;
9099 else if (opt_type == SREQ_GLOBAL)
9100 return 0; /* Requested global option */
9101
9102 if (p->indir & PV_WIN)
9103 {
9104 if (opt_type == SREQ_BUF)
9105 return 0; /* Did not request window-local option */
9106 else
9107 r |= SOPT_WIN;
9108 }
9109 else if (p->indir & PV_BUF)
9110 {
9111 if (opt_type == SREQ_WIN)
9112 return 0; /* Did not request buffer-local option */
9113 else
9114 r |= SOPT_BUF;
9115 }
9116 }
9117
9118 if (stringval == NULL)
9119 return r;
9120
9121 if (opt_type == SREQ_GLOBAL)
9122 varp = p->var;
9123 else
9124 {
9125 if (opt_type == SREQ_BUF)
9126 {
9127 /* Special case: 'modified' is b_changed, but we also want to
9128 * consider it set when 'ff' or 'fenc' changed. */
9129 if (p->indir == PV_MOD)
9130 {
9131 *numval = bufIsChanged((buf_T *) from);
9132 varp = NULL;
9133 }
9134#ifdef FEAT_CRYPT
9135 else if (p->indir == PV_KEY)
9136 {
9137 /* never return the value of the crypt key */
9138 *stringval = NULL;
9139 varp = NULL;
9140 }
9141#endif
9142 else
9143 {
9144 aco_save_T aco;
9145 aucmd_prepbuf(&aco, (buf_T *) from);
9146 varp = get_varp(p);
9147 aucmd_restbuf(&aco);
9148 }
9149 }
9150 else if (opt_type == SREQ_WIN)
9151 {
9152 win_T *save_curwin;
9153 save_curwin = curwin;
9154 curwin = (win_T *) from;
9155 curbuf = curwin->w_buffer;
9156 varp = get_varp(p);
9157 curwin = save_curwin;
9158 curbuf = curwin->w_buffer;
9159 }
9160 if (varp == p->var)
9161 return (r | SOPT_UNSET);
9162 }
9163
9164 if (varp != NULL)
9165 {
9166 if (p->flags & P_STRING)
9167 *stringval = vim_strsave(*(char_u **)(varp));
9168 else if (p->flags & P_NUM)
9169 *numval = *(long *) varp;
9170 else
9171 *numval = *(int *)varp;
9172 }
9173
9174 return r;
9175}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009176
9177/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009178 * Iterate over options. First argument is a pointer to a pointer to a
9179 * structure inside options[] array, second is option type like in the above
9180 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009181 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009182 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009183 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009184 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009185 * first argument to NULL.
9186 *
9187 * Returns full option name for current option on each call.
9188 */
9189 char_u *
9190option_iter_next(option, opt_type)
9191 void **option;
9192 int opt_type;
9193{
9194 struct vimoption *ret = NULL;
9195 do
9196 {
9197 if (*option == NULL)
9198 *option = (void *) options;
9199 else if (((struct vimoption *) (*option))->fullname == NULL)
9200 {
9201 *option = NULL;
9202 return NULL;
9203 }
9204 else
9205 *option = (void *) (((struct vimoption *) (*option)) + 1);
9206
9207 ret = ((struct vimoption *) (*option));
9208
9209 /* Hidden option */
9210 if (ret->var == NULL)
9211 {
9212 ret = NULL;
9213 continue;
9214 }
9215
9216 switch (opt_type)
9217 {
9218 case SREQ_GLOBAL:
9219 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9220 ret = NULL;
9221 break;
9222 case SREQ_BUF:
9223 if (!(ret->indir & PV_BUF))
9224 ret = NULL;
9225 break;
9226 case SREQ_WIN:
9227 if (!(ret->indir & PV_WIN))
9228 ret = NULL;
9229 break;
9230 default:
9231 EMSG2(_(e_intern2), "option_iter_next()");
9232 return NULL;
9233 }
9234 }
9235 while (ret == NULL);
9236
9237 return (char_u *)ret->fullname;
9238}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009239#endif
9240
Bram Moolenaar071d4272004-06-13 20:20:40 +00009241/*
9242 * Set the value of option "name".
9243 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009244 *
9245 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009246 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009247 char_u *
Bram Moolenaar071d4272004-06-13 20:20:40 +00009248set_option_value(name, number, string, opt_flags)
9249 char_u *name;
9250 long number;
9251 char_u *string;
9252 int opt_flags; /* OPT_LOCAL or 0 (both) */
9253{
9254 int opt_idx;
9255 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009256 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009257
9258 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009259 if (opt_idx < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009260 EMSG2(_("E355: Unknown option: %s"), name);
9261 else
9262 {
9263 flags = options[opt_idx].flags;
9264#ifdef HAVE_SANDBOX
9265 /* Disallow changing some options in the sandbox */
9266 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009267 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009268 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009269 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009270 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009271#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009272 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009273 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009274 else
9275 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009276 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009277 if (varp != NULL) /* hidden option is not changed */
9278 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009279 if (number == 0 && string != NULL)
9280 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009281 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009282
9283 /* Either we are given a string or we are setting option
9284 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009285 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009286 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009287 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009288 {
9289 /* There's another character after zeros or the string
9290 * is empty. In both cases, we are trying to set a
9291 * num option using a string. */
9292 EMSG3(_("E521: Number required: &%s = '%s'"),
9293 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009294 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009295
9296 }
9297 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009298 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009299 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009300 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009301 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009302 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009303 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009304 }
9305 }
9306 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009307 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009308}
9309
9310/*
9311 * Get the terminal code for a terminal option.
9312 * Returns NULL when not found.
9313 */
9314 char_u *
9315get_term_code(tname)
9316 char_u *tname;
9317{
9318 int opt_idx;
9319 char_u *varp;
9320
9321 if (tname[0] != 't' || tname[1] != '_' ||
9322 tname[2] == NUL || tname[3] == NUL)
9323 return NULL;
9324 if ((opt_idx = findoption(tname)) >= 0)
9325 {
9326 varp = get_varp(&(options[opt_idx]));
9327 if (varp != NULL)
9328 varp = *(char_u **)(varp);
9329 return varp;
9330 }
9331 return find_termcode(tname + 2);
9332}
9333
9334 char_u *
9335get_highlight_default()
9336{
9337 int i;
9338
9339 i = findoption((char_u *)"hl");
9340 if (i >= 0)
9341 return options[i].def_val[VI_DEFAULT];
9342 return (char_u *)NULL;
9343}
9344
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009345#if defined(FEAT_MBYTE) || defined(PROTO)
9346 char_u *
9347get_encoding_default()
9348{
9349 int i;
9350
9351 i = findoption((char_u *)"enc");
9352 if (i >= 0)
9353 return options[i].def_val[VI_DEFAULT];
9354 return (char_u *)NULL;
9355}
9356#endif
9357
Bram Moolenaar071d4272004-06-13 20:20:40 +00009358/*
9359 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9360 */
9361 static int
9362find_key_option(arg)
9363 char_u *arg;
9364{
9365 int key;
9366 int modifiers;
9367
9368 /*
9369 * Don't use get_special_key_code() for t_xx, we don't want it to call
9370 * add_termcap_entry().
9371 */
9372 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9373 key = TERMCAP2KEY(arg[2], arg[3]);
9374 else
9375 {
9376 --arg; /* put arg at the '<' */
9377 modifiers = 0;
Bram Moolenaar2a8ced02008-12-24 11:54:31 +00009378 key = find_special_key(&arg, &modifiers, TRUE, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009379 if (modifiers) /* can't handle modifiers here */
9380 key = 0;
9381 }
9382 return key;
9383}
9384
9385/*
9386 * if 'all' == 0: show changed options
9387 * if 'all' == 1: show all normal options
9388 * if 'all' == 2: show all terminal options
9389 */
9390 static void
9391showoptions(all, opt_flags)
9392 int all;
9393 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
9394{
9395 struct vimoption *p;
9396 int col;
9397 int isterm;
9398 char_u *varp;
9399 struct vimoption **items;
9400 int item_count;
9401 int run;
9402 int row, rows;
9403 int cols;
9404 int i;
9405 int len;
9406
9407#define INC 20
9408#define GAP 3
9409
9410 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9411 PARAM_COUNT));
9412 if (items == NULL)
9413 return;
9414
9415 /* Highlight title */
9416 if (all == 2)
9417 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9418 else if (opt_flags & OPT_GLOBAL)
9419 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9420 else if (opt_flags & OPT_LOCAL)
9421 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9422 else
9423 MSG_PUTS_TITLE(_("\n--- Options ---"));
9424
9425 /*
9426 * do the loop two times:
9427 * 1. display the short items
9428 * 2. display the long items (only strings and numbers)
9429 */
9430 for (run = 1; run <= 2 && !got_int; ++run)
9431 {
9432 /*
9433 * collect the items in items[]
9434 */
9435 item_count = 0;
9436 for (p = &options[0]; p->fullname != NULL; p++)
9437 {
9438 varp = NULL;
9439 isterm = istermoption(p);
9440 if (opt_flags != 0)
9441 {
9442 if (p->indir != PV_NONE && !isterm)
9443 varp = get_varp_scope(p, opt_flags);
9444 }
9445 else
9446 varp = get_varp(p);
9447 if (varp != NULL
9448 && ((all == 2 && isterm)
9449 || (all == 1 && !isterm)
9450 || (all == 0 && !optval_default(p, varp))))
9451 {
9452 if (p->flags & P_BOOL)
9453 len = 1; /* a toggle option fits always */
9454 else
9455 {
9456 option_value2string(p, opt_flags);
9457 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9458 }
9459 if ((len <= INC - GAP && run == 1) ||
9460 (len > INC - GAP && run == 2))
9461 items[item_count++] = p;
9462 }
9463 }
9464
9465 /*
9466 * display the items
9467 */
9468 if (run == 1)
9469 {
9470 cols = (Columns + GAP - 3) / INC;
9471 if (cols == 0)
9472 cols = 1;
9473 rows = (item_count + cols - 1) / cols;
9474 }
9475 else /* run == 2 */
9476 rows = item_count;
9477 for (row = 0; row < rows && !got_int; ++row)
9478 {
9479 msg_putchar('\n'); /* go to next line */
9480 if (got_int) /* 'q' typed in more */
9481 break;
9482 col = 0;
9483 for (i = row; i < item_count; i += rows)
9484 {
9485 msg_col = col; /* make columns */
9486 showoneopt(items[i], opt_flags);
9487 col += INC;
9488 }
9489 out_flush();
9490 ui_breakcheck();
9491 }
9492 }
9493 vim_free(items);
9494}
9495
9496/*
9497 * Return TRUE if option "p" has its default value.
9498 */
9499 static int
9500optval_default(p, varp)
9501 struct vimoption *p;
9502 char_u *varp;
9503{
9504 int dvi;
9505
9506 if (varp == NULL)
9507 return TRUE; /* hidden option is always at default */
9508 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9509 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009510 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009511 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009512 /* the cast to long is required for Manx C, long_i is
9513 * needed for MSVC */
9514 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009515 /* P_STRING */
9516 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9517}
9518
9519/*
9520 * showoneopt: show the value of one option
9521 * must not be called with a hidden option!
9522 */
9523 static void
9524showoneopt(p, opt_flags)
9525 struct vimoption *p;
9526 int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */
9527{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009528 char_u *varp;
9529 int save_silent = silent_mode;
9530
9531 silent_mode = FALSE;
9532 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009533
9534 varp = get_varp_scope(p, opt_flags);
9535
9536 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9537 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9538 ? !curbufIsChanged() : !*(int *)varp))
9539 MSG_PUTS("no");
9540 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9541 MSG_PUTS("--");
9542 else
9543 MSG_PUTS(" ");
9544 MSG_PUTS(p->fullname);
9545 if (!(p->flags & P_BOOL))
9546 {
9547 msg_putchar('=');
9548 /* put value string in NameBuff */
9549 option_value2string(p, opt_flags);
9550 msg_outtrans(NameBuff);
9551 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009552
9553 silent_mode = save_silent;
9554 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009555}
9556
9557/*
9558 * Write modified options as ":set" commands to a file.
9559 *
9560 * There are three values for "opt_flags":
9561 * OPT_GLOBAL: Write global option values and fresh values of
9562 * buffer-local options (used for start of a session
9563 * file).
9564 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
9565 * curwin (used for a vimrc file).
9566 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
9567 * and local values for window-local options of
9568 * curwin. Local values are also written when at the
9569 * default value, because a modeline or autocommand
9570 * may have set them when doing ":edit file" and the
9571 * user has set them back at the default or fresh
9572 * value.
9573 * When "local_only" is TRUE, don't write fresh
9574 * values, only local values (for ":mkview").
9575 * (fresh value = value used for a new buffer or window for a local option).
9576 *
9577 * Return FAIL on error, OK otherwise.
9578 */
9579 int
9580makeset(fd, opt_flags, local_only)
9581 FILE *fd;
9582 int opt_flags;
9583 int local_only;
9584{
9585 struct vimoption *p;
9586 char_u *varp; /* currently used value */
9587 char_u *varp_fresh; /* local value */
9588 char_u *varp_local = NULL; /* fresh value */
9589 char *cmd;
9590 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009591 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009592
9593 /*
9594 * The options that don't have a default (terminal name, columns, lines)
9595 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009596 * Do the loop over "options[]" twice: once for options with the
9597 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009598 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009599 for (pri = 1; pri >= 0; --pri)
9600 {
9601 for (p = &options[0]; !istermoption(p); p++)
9602 if (!(p->flags & P_NO_MKRC)
9603 && !istermoption(p)
9604 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009605 {
9606 /* skip global option when only doing locals */
9607 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
9608 continue;
9609
9610 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
9611 * file, they are always buffer-specific. */
9612 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
9613 continue;
9614
9615 /* Global values are only written when not at the default value. */
9616 varp = get_varp_scope(p, opt_flags);
9617 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
9618 continue;
9619
9620 round = 2;
9621 if (p->indir != PV_NONE)
9622 {
9623 if (p->var == VAR_WIN)
9624 {
9625 /* skip window-local option when only doing globals */
9626 if (!(opt_flags & OPT_LOCAL))
9627 continue;
9628 /* When fresh value of window-local option is not at the
9629 * default, need to write it too. */
9630 if (!(opt_flags & OPT_GLOBAL) && !local_only)
9631 {
9632 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
9633 if (!optval_default(p, varp_fresh))
9634 {
9635 round = 1;
9636 varp_local = varp;
9637 varp = varp_fresh;
9638 }
9639 }
9640 }
9641 }
9642
9643 /* Round 1: fresh value for window-local options.
9644 * Round 2: other values */
9645 for ( ; round <= 2; varp = varp_local, ++round)
9646 {
9647 if (round == 1 || (opt_flags & OPT_GLOBAL))
9648 cmd = "set";
9649 else
9650 cmd = "setlocal";
9651
9652 if (p->flags & P_BOOL)
9653 {
9654 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
9655 return FAIL;
9656 }
9657 else if (p->flags & P_NUM)
9658 {
9659 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
9660 return FAIL;
9661 }
9662 else /* P_STRING */
9663 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009664#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9665 int do_endif = FALSE;
9666
Bram Moolenaar071d4272004-06-13 20:20:40 +00009667 /* Don't set 'syntax' and 'filetype' again if the value is
9668 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009669 if (
9670# if defined(FEAT_SYN_HL)
9671 p->indir == PV_SYN
9672# if defined(FEAT_AUTOCMD)
9673 ||
9674# endif
9675# endif
9676# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009677 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009678# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009679 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00009680 {
9681 if (fprintf(fd, "if &%s != '%s'", p->fullname,
9682 *(char_u **)(varp)) < 0
9683 || put_eol(fd) < 0)
9684 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009685 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009686 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009687#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009688 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
9689 (p->flags & P_EXPAND) != 0) == FAIL)
9690 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009691#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9692 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009693 {
9694 if (put_line(fd, "endif") == FAIL)
9695 return FAIL;
9696 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009697#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009698 }
9699 }
9700 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009701 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009702 return OK;
9703}
9704
9705#if defined(FEAT_FOLDING) || defined(PROTO)
9706/*
9707 * Generate set commands for the local fold options only. Used when
9708 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
9709 */
9710 int
9711makefoldset(fd)
9712 FILE *fd;
9713{
9714 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
9715# ifdef FEAT_EVAL
9716 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
9717 == FAIL
9718# endif
9719 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
9720 == FAIL
9721 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
9722 == FAIL
9723 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
9724 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
9725 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
9726 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
9727 )
9728 return FAIL;
9729
9730 return OK;
9731}
9732#endif
9733
9734 static int
9735put_setstring(fd, cmd, name, valuep, expand)
9736 FILE *fd;
9737 char *cmd;
9738 char *name;
9739 char_u **valuep;
9740 int expand;
9741{
9742 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009743 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009744
9745 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9746 return FAIL;
9747 if (*valuep != NULL)
9748 {
9749 /* Output 'pastetoggle' as key names. For other
9750 * options some characters have to be escaped with
9751 * CTRL-V or backslash */
9752 if (valuep == &p_pt)
9753 {
9754 s = *valuep;
9755 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +00009756 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009757 return FAIL;
9758 }
9759 else if (expand)
9760 {
Bram Moolenaarf8441472011-04-28 17:24:58 +02009761 buf = alloc(MAXPATHL);
9762 if (buf == NULL)
9763 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009764 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
9765 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +02009766 {
9767 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009768 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009769 }
9770 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009771 }
9772 else if (put_escstr(fd, *valuep, 2) == FAIL)
9773 return FAIL;
9774 }
9775 if (put_eol(fd) < 0)
9776 return FAIL;
9777 return OK;
9778}
9779
9780 static int
9781put_setnum(fd, cmd, name, valuep)
9782 FILE *fd;
9783 char *cmd;
9784 char *name;
9785 long *valuep;
9786{
9787 long wc;
9788
9789 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9790 return FAIL;
9791 if (wc_use_keyname((char_u *)valuep, &wc))
9792 {
9793 /* print 'wildchar' and 'wildcharm' as a key name */
9794 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
9795 return FAIL;
9796 }
9797 else if (fprintf(fd, "%ld", *valuep) < 0)
9798 return FAIL;
9799 if (put_eol(fd) < 0)
9800 return FAIL;
9801 return OK;
9802}
9803
9804 static int
9805put_setbool(fd, cmd, name, value)
9806 FILE *fd;
9807 char *cmd;
9808 char *name;
9809 int value;
9810{
Bram Moolenaar893de922007-10-02 18:40:57 +00009811 if (value < 0) /* global/local option using global value */
9812 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009813 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
9814 || put_eol(fd) < 0)
9815 return FAIL;
9816 return OK;
9817}
9818
9819/*
9820 * Clear all the terminal options.
9821 * If the option has been allocated, free the memory.
9822 * Terminal options are never hidden or indirect.
9823 */
9824 void
9825clear_termoptions()
9826{
Bram Moolenaar071d4272004-06-13 20:20:40 +00009827 /*
9828 * Reset a few things before clearing the old options. This may cause
9829 * outputting a few things that the terminal doesn't understand, but the
9830 * screen will be cleared later, so this is OK.
9831 */
9832#ifdef FEAT_MOUSE_TTY
9833 mch_setmouse(FALSE); /* switch mouse off */
9834#endif
9835#ifdef FEAT_TITLE
9836 mch_restore_title(3); /* restore window titles */
9837#endif
9838#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
9839 /* When starting the GUI close the display opened for the clipboard.
9840 * After restoring the title, because that will need the display. */
9841 if (gui.starting)
9842 clear_xterm_clip();
9843#endif
9844#ifdef WIN3264
9845 /*
9846 * Check if this is allowed now.
9847 */
9848 if (can_end_termcap_mode(FALSE) == TRUE)
9849#endif
9850 stoptermcap(); /* stop termcap mode */
9851
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00009852 free_termoptions();
9853}
9854
9855 void
9856free_termoptions()
9857{
9858 struct vimoption *p;
9859
Bram Moolenaar071d4272004-06-13 20:20:40 +00009860 for (p = &options[0]; p->fullname != NULL; p++)
9861 if (istermoption(p))
9862 {
9863 if (p->flags & P_ALLOCED)
9864 free_string_option(*(char_u **)(p->var));
9865 if (p->flags & P_DEF_ALLOCED)
9866 free_string_option(p->def_val[VI_DEFAULT]);
9867 *(char_u **)(p->var) = empty_option;
9868 p->def_val[VI_DEFAULT] = empty_option;
9869 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
9870 }
9871 clear_termcodes();
9872}
9873
9874/*
Bram Moolenaar363cb672009-07-22 12:28:17 +00009875 * Free the string for one term option, if it was allocated.
9876 * Set the string to empty_option and clear allocated flag.
9877 * "var" points to the option value.
9878 */
9879 void
9880free_one_termoption(var)
9881 char_u *var;
9882{
9883 struct vimoption *p;
9884
9885 for (p = &options[0]; p->fullname != NULL; p++)
9886 if (p->var == var)
9887 {
9888 if (p->flags & P_ALLOCED)
9889 free_string_option(*(char_u **)(p->var));
9890 *(char_u **)(p->var) = empty_option;
9891 p->flags &= ~P_ALLOCED;
9892 break;
9893 }
9894}
9895
9896/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00009897 * Set the terminal option defaults to the current value.
9898 * Used after setting the terminal name.
9899 */
9900 void
9901set_term_defaults()
9902{
9903 struct vimoption *p;
9904
9905 for (p = &options[0]; p->fullname != NULL; p++)
9906 {
9907 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
9908 {
9909 if (p->flags & P_DEF_ALLOCED)
9910 {
9911 free_string_option(p->def_val[VI_DEFAULT]);
9912 p->flags &= ~P_DEF_ALLOCED;
9913 }
9914 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
9915 if (p->flags & P_ALLOCED)
9916 {
9917 p->flags |= P_DEF_ALLOCED;
9918 p->flags &= ~P_ALLOCED; /* don't free the value now */
9919 }
9920 }
9921 }
9922}
9923
9924/*
9925 * return TRUE if 'p' starts with 't_'
9926 */
9927 static int
9928istermoption(p)
9929 struct vimoption *p;
9930{
9931 return (p->fullname[0] == 't' && p->fullname[1] == '_');
9932}
9933
9934/*
9935 * Compute columns for ruler and shown command. 'sc_col' is also used to
9936 * decide what the maximum length of a message on the status line can be.
9937 * If there is a status line for the last window, 'sc_col' is independent
9938 * of 'ru_col'.
9939 */
9940
9941#define COL_RULER 17 /* columns needed by standard ruler */
9942
9943 void
9944comp_col()
9945{
9946#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
9947 int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin));
9948
9949 sc_col = 0;
9950 ru_col = 0;
9951 if (p_ru)
9952 {
9953#ifdef FEAT_STL_OPT
9954 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
9955#else
9956 ru_col = COL_RULER + 1;
9957#endif
9958 /* no last status line, adjust sc_col */
9959 if (!last_has_status)
9960 sc_col = ru_col;
9961 }
9962 if (p_sc)
9963 {
9964 sc_col += SHOWCMD_COLS;
9965 if (!p_ru || last_has_status) /* no need for separating space */
9966 ++sc_col;
9967 }
9968 sc_col = Columns - sc_col;
9969 ru_col = Columns - ru_col;
9970 if (sc_col <= 0) /* screen too narrow, will become a mess */
9971 sc_col = 1;
9972 if (ru_col <= 0)
9973 ru_col = 1;
9974#else
9975 sc_col = Columns;
9976 ru_col = Columns;
9977#endif
9978}
9979
9980/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009981 * Unset local option value, similar to ":set opt<".
9982 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009983 void
9984unset_global_local_option(name, from)
9985 char_u *name;
9986 void *from;
9987{
9988 struct vimoption *p;
9989 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009990 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009991
9992 opt_idx = findoption(name);
9993 p = &(options[opt_idx]);
9994
9995 switch ((int)p->indir)
9996 {
9997 /* global option with local value: use local value if it's been set */
9998 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009999 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010000 break;
10001 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010002 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010003 break;
10004 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010005 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010006 break;
10007 case PV_AR:
10008 buf->b_p_ar = -1;
10009 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010010 case PV_BKC:
10011 clear_string_option(&buf->b_p_bkc);
10012 buf->b_bkc_flags = 0;
10013 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010014 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010015 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010016 break;
10017#ifdef FEAT_FIND_ID
10018 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010019 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010020 break;
10021 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010022 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010023 break;
10024#endif
10025#ifdef FEAT_INS_EXPAND
10026 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010027 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010028 break;
10029 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010030 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010031 break;
10032#endif
10033#ifdef FEAT_QUICKFIX
10034 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010035 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010036 break;
10037 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010038 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010039 break;
10040 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010041 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010042 break;
10043#endif
10044#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10045 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010046 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010047 break;
10048#endif
10049#if defined(FEAT_CRYPT)
10050 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010051 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010052 break;
10053#endif
10054#ifdef FEAT_STL_OPT
10055 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010056 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010057 break;
10058#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010059 case PV_UL:
10060 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10061 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010062#ifdef FEAT_LISP
10063 case PV_LW:
10064 clear_string_option(&buf->b_p_lw);
10065 break;
10066#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010067 }
10068}
10069
10070/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010071 * Get pointer to option variable, depending on local or global scope.
10072 */
10073 static char_u *
10074get_varp_scope(p, opt_flags)
10075 struct vimoption *p;
10076 int opt_flags;
10077{
10078 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10079 {
10080 if (p->var == VAR_WIN)
10081 return (char_u *)GLOBAL_WO(get_varp(p));
10082 return p->var;
10083 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010084 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010085 {
10086 switch ((int)p->indir)
10087 {
10088#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010089 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10090 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10091 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010092#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010093 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10094 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10095 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010096 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010097 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010098#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010099 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10100 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010101#endif
10102#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010103 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10104 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010105#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010106#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10107 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10108#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010109#if defined(FEAT_CRYPT)
10110 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10111#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010112#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010113 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010114#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010115 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010116#ifdef FEAT_LISP
10117 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10118#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010119 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010120 }
10121 return NULL; /* "cannot happen" */
10122 }
10123 return get_varp(p);
10124}
10125
10126/*
10127 * Get pointer to option variable.
10128 */
10129 static char_u *
10130get_varp(p)
10131 struct vimoption *p;
10132{
10133 /* hidden option, always return NULL */
10134 if (p->var == NULL)
10135 return NULL;
10136
10137 switch ((int)p->indir)
10138 {
10139 case PV_NONE: return p->var;
10140
10141 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010142 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010143 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010144 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010145 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010146 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010147 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010148 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010149 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010150 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010151 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010152 case PV_BKC: return *curbuf->b_p_bkc != NUL
10153 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010154#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010155 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010156 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010157 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010158 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10159#endif
10160#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010161 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010162 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010163 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010164 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10165#endif
10166#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010167 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010168 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010169 case PV_GP: return *curbuf->b_p_gp != NUL
10170 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10171 case PV_MP: return *curbuf->b_p_mp != NUL
10172 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010173#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010174#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10175 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10176 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10177#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010178#if defined(FEAT_CRYPT)
10179 case PV_CM: return *curbuf->b_p_cm != NUL
10180 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10181#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010182#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010183 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010184 ? (char_u *)&(curwin->w_p_stl) : p->var;
10185#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010186 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10187 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010188#ifdef FEAT_LISP
10189 case PV_LW: return *curbuf->b_p_lw != NUL
10190 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10191#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010192
10193#ifdef FEAT_ARABIC
10194 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10195#endif
10196 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010197#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010198 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10199#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010200#ifdef FEAT_SYN_HL
10201 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10202 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010203 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010204#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010205#ifdef FEAT_DIFF
10206 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10207#endif
10208#ifdef FEAT_FOLDING
10209 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10210 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10211 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10212 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10213 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10214 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10215 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10216# ifdef FEAT_EVAL
10217 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10218 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10219# endif
10220 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10221#endif
10222 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010223 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010224#ifdef FEAT_LINEBREAK
10225 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10226#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010227#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010228 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
10229#endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010230#ifdef FEAT_VERTSPLIT
10231 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10232#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010233#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10234 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10235#endif
10236#ifdef FEAT_RIGHTLEFT
10237 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10238 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10239#endif
10240 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10241 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10242#ifdef FEAT_LINEBREAK
10243 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010244 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10245 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010246#endif
10247#ifdef FEAT_SCROLLBIND
10248 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10249#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010250#ifdef FEAT_CURSORBIND
10251 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10252#endif
10253#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010254 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10255 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010256#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010257
10258 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10259 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10260#ifdef FEAT_MBYTE
10261 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10262#endif
10263#if defined(FEAT_QUICKFIX)
10264 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10265 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
10266#endif
10267 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10268 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10269#ifdef FEAT_CINDENT
10270 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10271 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10272 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10273#endif
10274#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10275 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10276#endif
10277#ifdef FEAT_COMMENTS
10278 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10279#endif
10280#ifdef FEAT_FOLDING
10281 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10282#endif
10283#ifdef FEAT_INS_EXPAND
10284 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10285#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010286#ifdef FEAT_COMPL_FUNC
10287 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010288 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010289#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010290 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010291 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010292 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10293#ifdef FEAT_MBYTE
10294 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10295#endif
10296 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10297#ifdef FEAT_AUTOCMD
10298 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10299#endif
10300 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010301 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010302 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10303 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10304 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10305 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10306#ifdef FEAT_FIND_ID
10307# ifdef FEAT_EVAL
10308 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10309# endif
10310#endif
10311#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10312 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10313 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10314#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010315#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010316 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10317#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010318#ifdef FEAT_CRYPT
10319 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10320#endif
10321#ifdef FEAT_LISP
10322 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10323#endif
10324 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10325 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10326 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10327 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10328 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010329 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010330#ifdef FEAT_TEXTOBJ
10331 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10332#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010333 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10334#ifdef FEAT_SMARTINDENT
10335 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10336#endif
10337#ifndef SHORT_FNAME
10338 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
10339#endif
10340 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10341#ifdef FEAT_SEARCHPATH
10342 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10343#endif
10344 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10345#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010346 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010347 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10348#endif
10349#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010350 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10351 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10352 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010353#endif
10354 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10355 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10356 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10357 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010358#ifdef FEAT_PERSISTENT_UNDO
10359 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10360#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010361 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10362#ifdef FEAT_KEYMAP
10363 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10364#endif
10365 default: EMSG(_("E356: get_varp ERROR"));
10366 }
10367 /* always return a valid pointer to avoid a crash! */
10368 return (char_u *)&(curbuf->b_p_wm);
10369}
10370
10371/*
10372 * Get the value of 'equalprg', either the buffer-local one or the global one.
10373 */
10374 char_u *
10375get_equalprg()
10376{
10377 if (*curbuf->b_p_ep == NUL)
10378 return p_ep;
10379 return curbuf->b_p_ep;
10380}
10381
10382#if defined(FEAT_WINDOWS) || defined(PROTO)
10383/*
10384 * Copy options from one window to another.
10385 * Used when splitting a window.
10386 */
10387 void
10388win_copy_options(wp_from, wp_to)
10389 win_T *wp_from;
10390 win_T *wp_to;
10391{
10392 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10393 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10394# ifdef FEAT_RIGHTLEFT
10395# ifdef FEAT_FKMAP
10396 /* Is this right? */
10397 wp_to->w_farsi = wp_from->w_farsi;
10398# endif
10399# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020010400#if defined(FEAT_LINEBREAK)
10401 briopt_check(wp_to);
10402#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010403}
10404#endif
10405
10406/*
10407 * Copy the options from one winopt_T to another.
10408 * Doesn't free the old option values in "to", use clear_winopt() for that.
10409 * The 'scroll' option is not copied, because it depends on the window height.
10410 * The 'previewwindow' option is reset, there can be only one preview window.
10411 */
10412 void
10413copy_winopt(from, to)
10414 winopt_T *from;
10415 winopt_T *to;
10416{
10417#ifdef FEAT_ARABIC
10418 to->wo_arab = from->wo_arab;
10419#endif
10420 to->wo_list = from->wo_list;
10421 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010422 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010423#ifdef FEAT_LINEBREAK
10424 to->wo_nuw = from->wo_nuw;
10425#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010426#ifdef FEAT_RIGHTLEFT
10427 to->wo_rl = from->wo_rl;
10428 to->wo_rlc = vim_strsave(from->wo_rlc);
10429#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010430#ifdef FEAT_STL_OPT
10431 to->wo_stl = vim_strsave(from->wo_stl);
10432#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010433 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010434#ifdef FEAT_DIFF
10435 to->wo_wrap_save = from->wo_wrap_save;
10436#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010437#ifdef FEAT_LINEBREAK
10438 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020010439 to->wo_bri = from->wo_bri;
10440 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010441#endif
10442#ifdef FEAT_SCROLLBIND
10443 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010444 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010445#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010446#ifdef FEAT_CURSORBIND
10447 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010448 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010449#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010450#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010451 to->wo_spell = from->wo_spell;
10452#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010453#ifdef FEAT_SYN_HL
10454 to->wo_cuc = from->wo_cuc;
10455 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010456 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010457#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010458#ifdef FEAT_DIFF
10459 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010460 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010461#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010462#ifdef FEAT_CONCEAL
10463 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010464 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010465#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010466#ifdef FEAT_FOLDING
10467 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010468 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010469 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010470 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010471 to->wo_fdi = vim_strsave(from->wo_fdi);
10472 to->wo_fml = from->wo_fml;
10473 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010474 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010475 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010476 to->wo_fdm_save = from->wo_diff_saved
10477 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010478 to->wo_fdn = from->wo_fdn;
10479# ifdef FEAT_EVAL
10480 to->wo_fde = vim_strsave(from->wo_fde);
10481 to->wo_fdt = vim_strsave(from->wo_fdt);
10482# endif
10483 to->wo_fmr = vim_strsave(from->wo_fmr);
10484#endif
10485 check_winopt(to); /* don't want NULL pointers */
10486}
10487
10488/*
10489 * Check string options in a window for a NULL value.
10490 */
10491 void
10492check_win_options(win)
10493 win_T *win;
10494{
10495 check_winopt(&win->w_onebuf_opt);
10496 check_winopt(&win->w_allbuf_opt);
10497}
10498
10499/*
10500 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10501 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020010502 static void
Bram Moolenaar071d4272004-06-13 20:20:40 +000010503check_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010504 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010505{
10506#ifdef FEAT_FOLDING
10507 check_string_option(&wop->wo_fdi);
10508 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010509 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010510# ifdef FEAT_EVAL
10511 check_string_option(&wop->wo_fde);
10512 check_string_option(&wop->wo_fdt);
10513# endif
10514 check_string_option(&wop->wo_fmr);
10515#endif
10516#ifdef FEAT_RIGHTLEFT
10517 check_string_option(&wop->wo_rlc);
10518#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010519#ifdef FEAT_STL_OPT
10520 check_string_option(&wop->wo_stl);
10521#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010522#ifdef FEAT_SYN_HL
10523 check_string_option(&wop->wo_cc);
10524#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010525#ifdef FEAT_CONCEAL
10526 check_string_option(&wop->wo_cocu);
10527#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010528#ifdef FEAT_LINEBREAK
10529 check_string_option(&wop->wo_briopt);
10530#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010531}
10532
10533/*
10534 * Free the allocated memory inside a winopt_T.
10535 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010536 void
10537clear_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010538 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010539{
10540#ifdef FEAT_FOLDING
10541 clear_string_option(&wop->wo_fdi);
10542 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010543 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010544# ifdef FEAT_EVAL
10545 clear_string_option(&wop->wo_fde);
10546 clear_string_option(&wop->wo_fdt);
10547# endif
10548 clear_string_option(&wop->wo_fmr);
10549#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010550#ifdef FEAT_LINEBREAK
10551 clear_string_option(&wop->wo_briopt);
10552#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010553#ifdef FEAT_RIGHTLEFT
10554 clear_string_option(&wop->wo_rlc);
10555#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010556#ifdef FEAT_STL_OPT
10557 clear_string_option(&wop->wo_stl);
10558#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010559#ifdef FEAT_SYN_HL
10560 clear_string_option(&wop->wo_cc);
10561#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010562#ifdef FEAT_CONCEAL
10563 clear_string_option(&wop->wo_cocu);
10564#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010565}
10566
10567/*
10568 * Copy global option values to local options for one buffer.
10569 * Used when creating a new buffer and sometimes when entering a buffer.
10570 * flags:
10571 * BCO_ENTER We will enter the buf buffer.
10572 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
10573 * appropriate.
10574 * BCO_NOHELP Don't copy the values to a help buffer.
10575 */
10576 void
10577buf_copy_options(buf, flags)
10578 buf_T *buf;
10579 int flags;
10580{
10581 int should_copy = TRUE;
10582 char_u *save_p_isk = NULL; /* init for GCC */
10583 int dont_do_help;
10584 int did_isk = FALSE;
10585
10586 /*
Bram Moolenaar1a384422010-07-14 19:53:30 +020010587 * Don't do anything if the buffer is invalid.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010588 */
10589 if (buf == NULL || !buf_valid(buf))
10590 return;
10591
10592 /*
10593 * Skip this when the option defaults have not been set yet. Happens when
10594 * main() allocates the first buffer.
10595 */
10596 if (p_cpo != NULL)
10597 {
10598 /*
10599 * Always copy when entering and 'cpo' contains 'S'.
10600 * Don't copy when already initialized.
10601 * Don't copy when 'cpo' contains 's' and not entering.
10602 * 'S' BCO_ENTER initialized 's' should_copy
10603 * yes yes X X TRUE
10604 * yes no yes X FALSE
10605 * no X yes X FALSE
10606 * X no no yes FALSE
10607 * X no no no TRUE
10608 * no yes no X TRUE
10609 */
10610 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
10611 && (buf->b_p_initialized
10612 || (!(flags & BCO_ENTER)
10613 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
10614 should_copy = FALSE;
10615
10616 if (should_copy || (flags & BCO_ALWAYS))
10617 {
10618 /* Don't copy the options specific to a help buffer when
10619 * BCO_NOHELP is given or the options were initialized already
10620 * (jumping back to a help file with CTRL-T or CTRL-O) */
10621 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
10622 || buf->b_p_initialized;
10623 if (dont_do_help) /* don't free b_p_isk */
10624 {
10625 save_p_isk = buf->b_p_isk;
10626 buf->b_p_isk = NULL;
10627 }
10628 /*
10629 * Always free the allocated strings.
10630 * If not already initialized, set 'readonly' and copy 'fileformat'.
10631 */
10632 if (!buf->b_p_initialized)
10633 {
10634 free_buf_options(buf, TRUE);
10635 buf->b_p_ro = FALSE; /* don't copy readonly */
10636 buf->b_p_tx = p_tx;
10637#ifdef FEAT_MBYTE
10638 buf->b_p_fenc = vim_strsave(p_fenc);
10639#endif
10640 buf->b_p_ff = vim_strsave(p_ff);
10641#if defined(FEAT_QUICKFIX)
10642 buf->b_p_bh = empty_option;
10643 buf->b_p_bt = empty_option;
10644#endif
10645 }
10646 else
10647 free_buf_options(buf, FALSE);
10648
10649 buf->b_p_ai = p_ai;
10650 buf->b_p_ai_nopaste = p_ai_nopaste;
10651 buf->b_p_sw = p_sw;
10652 buf->b_p_tw = p_tw;
10653 buf->b_p_tw_nopaste = p_tw_nopaste;
10654 buf->b_p_tw_nobin = p_tw_nobin;
10655 buf->b_p_wm = p_wm;
10656 buf->b_p_wm_nopaste = p_wm_nopaste;
10657 buf->b_p_wm_nobin = p_wm_nobin;
10658 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000010659#ifdef FEAT_MBYTE
10660 buf->b_p_bomb = p_bomb;
10661#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010662 buf->b_p_et = p_et;
10663 buf->b_p_et_nobin = p_et_nobin;
10664 buf->b_p_ml = p_ml;
10665 buf->b_p_ml_nobin = p_ml_nobin;
10666 buf->b_p_inf = p_inf;
10667 buf->b_p_swf = p_swf;
10668#ifdef FEAT_INS_EXPAND
10669 buf->b_p_cpt = vim_strsave(p_cpt);
10670#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010671#ifdef FEAT_COMPL_FUNC
10672 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010673 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010674#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010675 buf->b_p_sts = p_sts;
10676 buf->b_p_sts_nopaste = p_sts_nopaste;
10677#ifndef SHORT_FNAME
10678 buf->b_p_sn = p_sn;
10679#endif
10680#ifdef FEAT_COMMENTS
10681 buf->b_p_com = vim_strsave(p_com);
10682#endif
10683#ifdef FEAT_FOLDING
10684 buf->b_p_cms = vim_strsave(p_cms);
10685#endif
10686 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010687 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010688 buf->b_p_nf = vim_strsave(p_nf);
10689 buf->b_p_mps = vim_strsave(p_mps);
10690#ifdef FEAT_SMARTINDENT
10691 buf->b_p_si = p_si;
10692#endif
10693 buf->b_p_ci = p_ci;
10694#ifdef FEAT_CINDENT
10695 buf->b_p_cin = p_cin;
10696 buf->b_p_cink = vim_strsave(p_cink);
10697 buf->b_p_cino = vim_strsave(p_cino);
10698#endif
10699#ifdef FEAT_AUTOCMD
10700 /* Don't copy 'filetype', it must be detected */
10701 buf->b_p_ft = empty_option;
10702#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010703 buf->b_p_pi = p_pi;
10704#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10705 buf->b_p_cinw = vim_strsave(p_cinw);
10706#endif
10707#ifdef FEAT_LISP
10708 buf->b_p_lisp = p_lisp;
10709#endif
10710#ifdef FEAT_SYN_HL
10711 /* Don't copy 'syntax', it must be set */
10712 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010713 buf->b_p_smc = p_smc;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010714#endif
10715#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020010716 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010717 (void)compile_cap_prog(&buf->b_s);
10718 buf->b_s.b_p_spf = vim_strsave(p_spf);
10719 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010720#endif
10721#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10722 buf->b_p_inde = vim_strsave(p_inde);
10723 buf->b_p_indk = vim_strsave(p_indk);
10724#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010725#if defined(FEAT_EVAL)
10726 buf->b_p_fex = vim_strsave(p_fex);
10727#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010728#ifdef FEAT_CRYPT
10729 buf->b_p_key = vim_strsave(p_key);
10730#endif
10731#ifdef FEAT_SEARCHPATH
10732 buf->b_p_sua = vim_strsave(p_sua);
10733#endif
10734#ifdef FEAT_KEYMAP
10735 buf->b_p_keymap = vim_strsave(p_keymap);
10736 buf->b_kmap_state |= KEYMAP_INIT;
10737#endif
10738 /* This isn't really an option, but copying the langmap and IME
10739 * state from the current buffer is better than resetting it. */
10740 buf->b_p_iminsert = p_iminsert;
10741 buf->b_p_imsearch = p_imsearch;
10742
10743 /* options that are normally global but also have a local value
10744 * are not copied, start using the global value */
10745 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010746 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010747 buf->b_p_bkc = empty_option;
10748 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010749#ifdef FEAT_QUICKFIX
10750 buf->b_p_gp = empty_option;
10751 buf->b_p_mp = empty_option;
10752 buf->b_p_efm = empty_option;
10753#endif
10754 buf->b_p_ep = empty_option;
10755 buf->b_p_kp = empty_option;
10756 buf->b_p_path = empty_option;
10757 buf->b_p_tags = empty_option;
10758#ifdef FEAT_FIND_ID
10759 buf->b_p_def = empty_option;
10760 buf->b_p_inc = empty_option;
10761# ifdef FEAT_EVAL
10762 buf->b_p_inex = vim_strsave(p_inex);
10763# endif
10764#endif
10765#ifdef FEAT_INS_EXPAND
10766 buf->b_p_dict = empty_option;
10767 buf->b_p_tsr = empty_option;
10768#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010769#ifdef FEAT_TEXTOBJ
10770 buf->b_p_qe = vim_strsave(p_qe);
10771#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010772#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10773 buf->b_p_bexpr = empty_option;
10774#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010775#if defined(FEAT_CRYPT)
10776 buf->b_p_cm = empty_option;
10777#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010778#ifdef FEAT_PERSISTENT_UNDO
10779 buf->b_p_udf = p_udf;
10780#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010781#ifdef FEAT_LISP
10782 buf->b_p_lw = empty_option;
10783#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010784
10785 /*
10786 * Don't copy the options set by ex_help(), use the saved values,
10787 * when going from a help buffer to a non-help buffer.
10788 * Don't touch these at all when BCO_NOHELP is used and going from
10789 * or to a help buffer.
10790 */
10791 if (dont_do_help)
10792 buf->b_p_isk = save_p_isk;
10793 else
10794 {
10795 buf->b_p_isk = vim_strsave(p_isk);
10796 did_isk = TRUE;
10797 buf->b_p_ts = p_ts;
10798 buf->b_help = FALSE;
10799#ifdef FEAT_QUICKFIX
10800 if (buf->b_p_bt[0] == 'h')
10801 clear_string_option(&buf->b_p_bt);
10802#endif
10803 buf->b_p_ma = p_ma;
10804 }
10805 }
10806
10807 /*
10808 * When the options should be copied (ignoring BCO_ALWAYS), set the
10809 * flag that indicates that the options have been initialized.
10810 */
10811 if (should_copy)
10812 buf->b_p_initialized = TRUE;
10813 }
10814
10815 check_buf_options(buf); /* make sure we don't have NULLs */
10816 if (did_isk)
10817 (void)buf_init_chartab(buf, FALSE);
10818}
10819
10820/*
10821 * Reset the 'modifiable' option and its default value.
10822 */
10823 void
10824reset_modifiable()
10825{
10826 int opt_idx;
10827
10828 curbuf->b_p_ma = FALSE;
10829 p_ma = FALSE;
10830 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000010831 if (opt_idx >= 0)
10832 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010833}
10834
10835/*
10836 * Set the global value for 'iminsert' to the local value.
10837 */
10838 void
10839set_iminsert_global()
10840{
10841 p_iminsert = curbuf->b_p_iminsert;
10842}
10843
10844/*
10845 * Set the global value for 'imsearch' to the local value.
10846 */
10847 void
10848set_imsearch_global()
10849{
10850 p_imsearch = curbuf->b_p_imsearch;
10851}
10852
10853#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
10854static int expand_option_idx = -1;
10855static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
10856static int expand_option_flags = 0;
10857
10858 void
10859set_context_in_set_cmd(xp, arg, opt_flags)
10860 expand_T *xp;
10861 char_u *arg;
10862 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
10863{
10864 int nextchar;
10865 long_u flags = 0; /* init for GCC */
10866 int opt_idx = 0; /* init for GCC */
10867 char_u *p;
10868 char_u *s;
10869 int is_term_option = FALSE;
10870 int key;
10871
10872 expand_option_flags = opt_flags;
10873
10874 xp->xp_context = EXPAND_SETTINGS;
10875 if (*arg == NUL)
10876 {
10877 xp->xp_pattern = arg;
10878 return;
10879 }
10880 p = arg + STRLEN(arg) - 1;
10881 if (*p == ' ' && *(p - 1) != '\\')
10882 {
10883 xp->xp_pattern = p + 1;
10884 return;
10885 }
10886 while (p > arg)
10887 {
10888 s = p;
10889 /* count number of backslashes before ' ' or ',' */
10890 if (*p == ' ' || *p == ',')
10891 {
10892 while (s > arg && *(s - 1) == '\\')
10893 --s;
10894 }
10895 /* break at a space with an even number of backslashes */
10896 if (*p == ' ' && ((p - s) & 1) == 0)
10897 {
10898 ++p;
10899 break;
10900 }
10901 --p;
10902 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000010903 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010904 {
10905 xp->xp_context = EXPAND_BOOL_SETTINGS;
10906 p += 2;
10907 }
10908 if (STRNCMP(p, "inv", 3) == 0)
10909 {
10910 xp->xp_context = EXPAND_BOOL_SETTINGS;
10911 p += 3;
10912 }
10913 xp->xp_pattern = arg = p;
10914 if (*arg == '<')
10915 {
10916 while (*p != '>')
10917 if (*p++ == NUL) /* expand terminal option name */
10918 return;
10919 key = get_special_key_code(arg + 1);
10920 if (key == 0) /* unknown name */
10921 {
10922 xp->xp_context = EXPAND_NOTHING;
10923 return;
10924 }
10925 nextchar = *++p;
10926 is_term_option = TRUE;
10927 expand_option_name[2] = KEY2TERMCAP0(key);
10928 expand_option_name[3] = KEY2TERMCAP1(key);
10929 }
10930 else
10931 {
10932 if (p[0] == 't' && p[1] == '_')
10933 {
10934 p += 2;
10935 if (*p != NUL)
10936 ++p;
10937 if (*p == NUL)
10938 return; /* expand option name */
10939 nextchar = *++p;
10940 is_term_option = TRUE;
10941 expand_option_name[2] = p[-2];
10942 expand_option_name[3] = p[-1];
10943 }
10944 else
10945 {
10946 /* Allow * wildcard */
10947 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
10948 p++;
10949 if (*p == NUL)
10950 return;
10951 nextchar = *p;
10952 *p = NUL;
10953 opt_idx = findoption(arg);
10954 *p = nextchar;
10955 if (opt_idx == -1 || options[opt_idx].var == NULL)
10956 {
10957 xp->xp_context = EXPAND_NOTHING;
10958 return;
10959 }
10960 flags = options[opt_idx].flags;
10961 if (flags & P_BOOL)
10962 {
10963 xp->xp_context = EXPAND_NOTHING;
10964 return;
10965 }
10966 }
10967 }
10968 /* handle "-=" and "+=" */
10969 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
10970 {
10971 ++p;
10972 nextchar = '=';
10973 }
10974 if ((nextchar != '=' && nextchar != ':')
10975 || xp->xp_context == EXPAND_BOOL_SETTINGS)
10976 {
10977 xp->xp_context = EXPAND_UNSUCCESSFUL;
10978 return;
10979 }
10980 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
10981 {
10982 xp->xp_context = EXPAND_OLD_SETTING;
10983 if (is_term_option)
10984 expand_option_idx = -1;
10985 else
10986 expand_option_idx = opt_idx;
10987 xp->xp_pattern = p + 1;
10988 return;
10989 }
10990 xp->xp_context = EXPAND_NOTHING;
10991 if (is_term_option || (flags & P_NUM))
10992 return;
10993
10994 xp->xp_pattern = p + 1;
10995
10996 if (flags & P_EXPAND)
10997 {
10998 p = options[opt_idx].var;
10999 if (p == (char_u *)&p_bdir
11000 || p == (char_u *)&p_dir
11001 || p == (char_u *)&p_path
11002 || p == (char_u *)&p_rtp
11003#ifdef FEAT_SEARCHPATH
11004 || p == (char_u *)&p_cdpath
11005#endif
11006#ifdef FEAT_SESSION
11007 || p == (char_u *)&p_vdir
11008#endif
11009 )
11010 {
11011 xp->xp_context = EXPAND_DIRECTORIES;
11012 if (p == (char_u *)&p_path
11013#ifdef FEAT_SEARCHPATH
11014 || p == (char_u *)&p_cdpath
11015#endif
11016 )
11017 xp->xp_backslash = XP_BS_THREE;
11018 else
11019 xp->xp_backslash = XP_BS_ONE;
11020 }
11021 else
11022 {
11023 xp->xp_context = EXPAND_FILES;
11024 /* for 'tags' need three backslashes for a space */
11025 if (p == (char_u *)&p_tags)
11026 xp->xp_backslash = XP_BS_THREE;
11027 else
11028 xp->xp_backslash = XP_BS_ONE;
11029 }
11030 }
11031
11032 /* For an option that is a list of file names, find the start of the
11033 * last file name. */
11034 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11035 {
11036 /* count number of backslashes before ' ' or ',' */
11037 if (*p == ' ' || *p == ',')
11038 {
11039 s = p;
11040 while (s > xp->xp_pattern && *(s - 1) == '\\')
11041 --s;
11042 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11043 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11044 {
11045 xp->xp_pattern = p + 1;
11046 break;
11047 }
11048 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011049
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011050#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011051 /* for 'spellsuggest' start at "file:" */
11052 if (options[opt_idx].var == (char_u *)&p_sps
11053 && STRNCMP(p, "file:", 5) == 0)
11054 {
11055 xp->xp_pattern = p + 5;
11056 break;
11057 }
11058#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011059 }
11060
11061 return;
11062}
11063
11064 int
11065ExpandSettings(xp, regmatch, num_file, file)
11066 expand_T *xp;
11067 regmatch_T *regmatch;
11068 int *num_file;
11069 char_u ***file;
11070{
11071 int num_normal = 0; /* Nr of matching non-term-code settings */
11072 int num_term = 0; /* Nr of matching terminal code settings */
11073 int opt_idx;
11074 int match;
11075 int count = 0;
11076 char_u *str;
11077 int loop;
11078 int is_term_opt;
11079 char_u name_buf[MAX_KEY_NAME_LEN];
11080 static char *(names[]) = {"all", "termcap"};
11081 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11082
11083 /* do this loop twice:
11084 * loop == 0: count the number of matching options
11085 * loop == 1: copy the matching options into allocated memory
11086 */
11087 for (loop = 0; loop <= 1; ++loop)
11088 {
11089 regmatch->rm_ic = ic;
11090 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11091 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011092 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11093 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011094 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11095 {
11096 if (loop == 0)
11097 num_normal++;
11098 else
11099 (*file)[count++] = vim_strsave((char_u *)names[match]);
11100 }
11101 }
11102 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11103 opt_idx++)
11104 {
11105 if (options[opt_idx].var == NULL)
11106 continue;
11107 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11108 && !(options[opt_idx].flags & P_BOOL))
11109 continue;
11110 is_term_opt = istermoption(&options[opt_idx]);
11111 if (is_term_opt && num_normal > 0)
11112 continue;
11113 match = FALSE;
11114 if (vim_regexec(regmatch, str, (colnr_T)0)
11115 || (options[opt_idx].shortname != NULL
11116 && vim_regexec(regmatch,
11117 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11118 match = TRUE;
11119 else if (is_term_opt)
11120 {
11121 name_buf[0] = '<';
11122 name_buf[1] = 't';
11123 name_buf[2] = '_';
11124 name_buf[3] = str[2];
11125 name_buf[4] = str[3];
11126 name_buf[5] = '>';
11127 name_buf[6] = NUL;
11128 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11129 {
11130 match = TRUE;
11131 str = name_buf;
11132 }
11133 }
11134 if (match)
11135 {
11136 if (loop == 0)
11137 {
11138 if (is_term_opt)
11139 num_term++;
11140 else
11141 num_normal++;
11142 }
11143 else
11144 (*file)[count++] = vim_strsave(str);
11145 }
11146 }
11147 /*
11148 * Check terminal key codes, these are not in the option table
11149 */
11150 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11151 {
11152 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11153 {
11154 if (!isprint(str[0]) || !isprint(str[1]))
11155 continue;
11156
11157 name_buf[0] = 't';
11158 name_buf[1] = '_';
11159 name_buf[2] = str[0];
11160 name_buf[3] = str[1];
11161 name_buf[4] = NUL;
11162
11163 match = FALSE;
11164 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11165 match = TRUE;
11166 else
11167 {
11168 name_buf[0] = '<';
11169 name_buf[1] = 't';
11170 name_buf[2] = '_';
11171 name_buf[3] = str[0];
11172 name_buf[4] = str[1];
11173 name_buf[5] = '>';
11174 name_buf[6] = NUL;
11175
11176 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11177 match = TRUE;
11178 }
11179 if (match)
11180 {
11181 if (loop == 0)
11182 num_term++;
11183 else
11184 (*file)[count++] = vim_strsave(name_buf);
11185 }
11186 }
11187
11188 /*
11189 * Check special key names.
11190 */
11191 regmatch->rm_ic = TRUE; /* ignore case here */
11192 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11193 {
11194 name_buf[0] = '<';
11195 STRCPY(name_buf + 1, str);
11196 STRCAT(name_buf, ">");
11197
11198 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11199 {
11200 if (loop == 0)
11201 num_term++;
11202 else
11203 (*file)[count++] = vim_strsave(name_buf);
11204 }
11205 }
11206 }
11207 if (loop == 0)
11208 {
11209 if (num_normal > 0)
11210 *num_file = num_normal;
11211 else if (num_term > 0)
11212 *num_file = num_term;
11213 else
11214 return OK;
11215 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11216 if (*file == NULL)
11217 {
11218 *file = (char_u **)"";
11219 return FAIL;
11220 }
11221 }
11222 }
11223 return OK;
11224}
11225
11226 int
11227ExpandOldSetting(num_file, file)
11228 int *num_file;
11229 char_u ***file;
11230{
11231 char_u *var = NULL; /* init for GCC */
11232 char_u *buf;
11233
11234 *num_file = 0;
11235 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11236 if (*file == NULL)
11237 return FAIL;
11238
11239 /*
11240 * For a terminal key code expand_option_idx is < 0.
11241 */
11242 if (expand_option_idx < 0)
11243 {
11244 var = find_termcode(expand_option_name + 2);
11245 if (var == NULL)
11246 expand_option_idx = findoption(expand_option_name);
11247 }
11248
11249 if (expand_option_idx >= 0)
11250 {
11251 /* put string of option value in NameBuff */
11252 option_value2string(&options[expand_option_idx], expand_option_flags);
11253 var = NameBuff;
11254 }
11255 else if (var == NULL)
11256 var = (char_u *)"";
11257
11258 /* A backslash is required before some characters. This is the reverse of
11259 * what happens in do_set(). */
11260 buf = vim_strsave_escaped(var, escape_chars);
11261
11262 if (buf == NULL)
11263 {
11264 vim_free(*file);
11265 *file = NULL;
11266 return FAIL;
11267 }
11268
11269#ifdef BACKSLASH_IN_FILENAME
11270 /* For MS-Windows et al. we don't double backslashes at the start and
11271 * before a file name character. */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011272 for (var = buf; *var != NUL; mb_ptr_adv(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011273 if (var[0] == '\\' && var[1] == '\\'
11274 && expand_option_idx >= 0
11275 && (options[expand_option_idx].flags & P_EXPAND)
11276 && vim_isfilec(var[2])
11277 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011278 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011279#endif
11280
11281 *file[0] = buf;
11282 *num_file = 1;
11283 return OK;
11284}
11285#endif
11286
11287/*
11288 * Get the value for the numeric or string option *opp in a nice format into
11289 * NameBuff[]. Must not be called with a hidden option!
11290 */
11291 static void
11292option_value2string(opp, opt_flags)
11293 struct vimoption *opp;
11294 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
11295{
11296 char_u *varp;
11297
11298 varp = get_varp_scope(opp, opt_flags);
11299
11300 if (opp->flags & P_NUM)
11301 {
11302 long wc = 0;
11303
11304 if (wc_use_keyname(varp, &wc))
11305 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11306 else if (wc != 0)
11307 STRCPY(NameBuff, transchar((int)wc));
11308 else
11309 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11310 }
11311 else /* P_STRING */
11312 {
11313 varp = *(char_u **)(varp);
11314 if (varp == NULL) /* just in case */
11315 NameBuff[0] = NUL;
11316#ifdef FEAT_CRYPT
11317 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011318 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011319 STRCPY(NameBuff, "*****");
11320#endif
11321 else if (opp->flags & P_EXPAND)
11322 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11323 /* Translate 'pastetoggle' into special key names */
11324 else if ((char_u **)opp->var == &p_pt)
11325 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11326 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011327 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011328 }
11329}
11330
11331/*
11332 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11333 * printed as a keyname.
11334 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11335 */
11336 static int
11337wc_use_keyname(varp, wcp)
11338 char_u *varp;
11339 long *wcp;
11340{
11341 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11342 {
11343 *wcp = *(long *)varp;
11344 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11345 return TRUE;
11346 }
11347 return FALSE;
11348}
11349
Bram Moolenaar01615492015-02-03 13:00:38 +010011350#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011351/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011352 * Any character has an equivalent 'langmap' character. This is used for
11353 * keyboards that have a special language mode that sends characters above
11354 * 128 (although other characters can be translated too). The "to" field is a
11355 * Vim command character. This avoids having to switch the keyboard back to
11356 * ASCII mode when leaving Insert mode.
11357 *
11358 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11359 * commands.
11360 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11361 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11362 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011363 */
Bram Moolenaar01615492015-02-03 13:00:38 +010011364# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011365/*
11366 * With multi-byte support use growarray for 'langmap' chars >= 256
11367 */
11368typedef struct
11369{
11370 int from;
11371 int to;
11372} langmap_entry_T;
11373
11374static garray_T langmap_mapga;
11375static void langmap_set_entry __ARGS((int from, int to));
Bram Moolenaar071d4272004-06-13 20:20:40 +000011376
11377/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011378 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11379 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011380 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011381 static void
11382langmap_set_entry(from, to)
11383 int from;
11384 int to;
11385{
11386 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011387 int a = 0;
11388 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011389
11390 /* Do a binary search for an existing entry. */
11391 while (a != b)
11392 {
11393 int i = (a + b) / 2;
11394 int d = entries[i].from - from;
11395
11396 if (d == 0)
11397 {
11398 entries[i].to = to;
11399 return;
11400 }
11401 if (d < 0)
11402 a = i + 1;
11403 else
11404 b = i;
11405 }
11406
11407 if (ga_grow(&langmap_mapga, 1) != OK)
11408 return; /* out of memory */
11409
11410 /* insert new entry at position "a" */
11411 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11412 mch_memmove(entries + 1, entries,
11413 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11414 ++langmap_mapga.ga_len;
11415 entries[0].from = from;
11416 entries[0].to = to;
11417}
11418
11419/*
11420 * Apply 'langmap' to multi-byte character "c" and return the result.
11421 */
11422 int
11423langmap_adjust_mb(c)
11424 int c;
11425{
11426 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11427 int a = 0;
11428 int b = langmap_mapga.ga_len;
11429
11430 while (a != b)
11431 {
11432 int i = (a + b) / 2;
11433 int d = entries[i].from - c;
11434
11435 if (d == 0)
11436 return entries[i].to; /* found matching entry */
11437 if (d < 0)
11438 a = i + 1;
11439 else
11440 b = i;
11441 }
11442 return c; /* no entry found, return "c" unmodified */
11443}
11444# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011445
11446 static void
11447langmap_init()
11448{
11449 int i;
11450
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011451 for (i = 0; i < 256; i++)
11452 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11453# ifdef FEAT_MBYTE
11454 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11455# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011456}
11457
11458/*
11459 * Called when langmap option is set; the language map can be
11460 * changed at any time!
11461 */
11462 static void
11463langmap_set()
11464{
11465 char_u *p;
11466 char_u *p2;
11467 int from, to;
11468
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011469#ifdef FEAT_MBYTE
11470 ga_clear(&langmap_mapga); /* clear the previous map first */
11471#endif
11472 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011473
11474 for (p = p_langmap; p[0] != NUL; )
11475 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011476 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
11477 mb_ptr_adv(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011478 {
11479 if (p2[0] == '\\' && p2[1] != NUL)
11480 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011481 }
11482 if (p2[0] == ';')
11483 ++p2; /* abcd;ABCD form, p2 points to A */
11484 else
11485 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11486 while (p[0])
11487 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011488 if (p[0] == ',')
11489 {
11490 ++p;
11491 break;
11492 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011493 if (p[0] == '\\' && p[1] != NUL)
11494 ++p;
11495#ifdef FEAT_MBYTE
11496 from = (*mb_ptr2char)(p);
11497#else
11498 from = p[0];
11499#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011500 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011501 if (p2 == NULL)
11502 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011503 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011504 if (p[0] != ',')
11505 {
11506 if (p[0] == '\\')
11507 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011508#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011509 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011510#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011511 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011512#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011513 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011514 }
11515 else
11516 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011517 if (p2[0] != ',')
11518 {
11519 if (p2[0] == '\\')
11520 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011521#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011522 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011523#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011524 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011525#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011526 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011527 }
11528 if (to == NUL)
11529 {
11530 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
11531 transchar(from));
11532 return;
11533 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011534
11535#ifdef FEAT_MBYTE
11536 if (from >= 256)
11537 langmap_set_entry(from, to);
11538 else
11539#endif
11540 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011541
11542 /* Advance to next pair */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011543 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011544 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011545 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011546 mb_ptr_adv(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011547 if (*p == ';')
11548 {
11549 p = p2;
11550 if (p[0] != NUL)
11551 {
11552 if (p[0] != ',')
11553 {
11554 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
11555 return;
11556 }
11557 ++p;
11558 }
11559 break;
11560 }
11561 }
11562 }
11563 }
11564}
11565#endif
11566
11567/*
11568 * Return TRUE if format option 'x' is in effect.
11569 * Take care of no formatting when 'paste' is set.
11570 */
11571 int
11572has_format_option(x)
11573 int x;
11574{
11575 if (p_paste)
11576 return FALSE;
11577 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
11578}
11579
11580/*
11581 * Return TRUE if "x" is present in 'shortmess' option, or
11582 * 'shortmess' contains 'a' and "x" is present in SHM_A.
11583 */
11584 int
11585shortmess(x)
11586 int x;
11587{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010011588 return p_shm != NULL &&
11589 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000011590 || (vim_strchr(p_shm, 'a') != NULL
11591 && vim_strchr((char_u *)SHM_A, x) != NULL));
11592}
11593
11594/*
11595 * paste_option_changed() - Called after p_paste was set or reset.
11596 */
11597 static void
11598paste_option_changed()
11599{
11600 static int old_p_paste = FALSE;
11601 static int save_sm = 0;
11602#ifdef FEAT_CMDL_INFO
11603 static int save_ru = 0;
11604#endif
11605#ifdef FEAT_RIGHTLEFT
11606 static int save_ri = 0;
11607 static int save_hkmap = 0;
11608#endif
11609 buf_T *buf;
11610
11611 if (p_paste)
11612 {
11613 /*
11614 * Paste switched from off to on.
11615 * Save the current values, so they can be restored later.
11616 */
11617 if (!old_p_paste)
11618 {
11619 /* save options for each buffer */
11620 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11621 {
11622 buf->b_p_tw_nopaste = buf->b_p_tw;
11623 buf->b_p_wm_nopaste = buf->b_p_wm;
11624 buf->b_p_sts_nopaste = buf->b_p_sts;
11625 buf->b_p_ai_nopaste = buf->b_p_ai;
11626 }
11627
11628 /* save global options */
11629 save_sm = p_sm;
11630#ifdef FEAT_CMDL_INFO
11631 save_ru = p_ru;
11632#endif
11633#ifdef FEAT_RIGHTLEFT
11634 save_ri = p_ri;
11635 save_hkmap = p_hkmap;
11636#endif
11637 /* save global values for local buffer options */
11638 p_tw_nopaste = p_tw;
11639 p_wm_nopaste = p_wm;
11640 p_sts_nopaste = p_sts;
11641 p_ai_nopaste = p_ai;
11642 }
11643
11644 /*
11645 * Always set the option values, also when 'paste' is set when it is
11646 * already on.
11647 */
11648 /* set options for each buffer */
11649 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11650 {
11651 buf->b_p_tw = 0; /* textwidth is 0 */
11652 buf->b_p_wm = 0; /* wrapmargin is 0 */
11653 buf->b_p_sts = 0; /* softtabstop is 0 */
11654 buf->b_p_ai = 0; /* no auto-indent */
11655 }
11656
11657 /* set global options */
11658 p_sm = 0; /* no showmatch */
11659#ifdef FEAT_CMDL_INFO
11660# ifdef FEAT_WINDOWS
11661 if (p_ru)
11662 status_redraw_all(); /* redraw to remove the ruler */
11663# endif
11664 p_ru = 0; /* no ruler */
11665#endif
11666#ifdef FEAT_RIGHTLEFT
11667 p_ri = 0; /* no reverse insert */
11668 p_hkmap = 0; /* no Hebrew keyboard */
11669#endif
11670 /* set global values for local buffer options */
11671 p_tw = 0;
11672 p_wm = 0;
11673 p_sts = 0;
11674 p_ai = 0;
11675 }
11676
11677 /*
11678 * Paste switched from on to off: Restore saved values.
11679 */
11680 else if (old_p_paste)
11681 {
11682 /* restore options for each buffer */
11683 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11684 {
11685 buf->b_p_tw = buf->b_p_tw_nopaste;
11686 buf->b_p_wm = buf->b_p_wm_nopaste;
11687 buf->b_p_sts = buf->b_p_sts_nopaste;
11688 buf->b_p_ai = buf->b_p_ai_nopaste;
11689 }
11690
11691 /* restore global options */
11692 p_sm = save_sm;
11693#ifdef FEAT_CMDL_INFO
11694# ifdef FEAT_WINDOWS
11695 if (p_ru != save_ru)
11696 status_redraw_all(); /* redraw to draw the ruler */
11697# endif
11698 p_ru = save_ru;
11699#endif
11700#ifdef FEAT_RIGHTLEFT
11701 p_ri = save_ri;
11702 p_hkmap = save_hkmap;
11703#endif
11704 /* set global values for local buffer options */
11705 p_tw = p_tw_nopaste;
11706 p_wm = p_wm_nopaste;
11707 p_sts = p_sts_nopaste;
11708 p_ai = p_ai_nopaste;
11709 }
11710
11711 old_p_paste = p_paste;
11712}
11713
11714/*
11715 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
11716 *
11717 * Reset 'compatible' and set the values for options that didn't get set yet
11718 * to the Vim defaults.
11719 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011720 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011721 */
11722 void
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011723vimrc_found(fname, envname)
11724 char_u *fname;
11725 char_u *envname;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011726{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011727 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000011728 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011729 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011730
11731 if (!option_was_set((char_u *)"cp"))
11732 {
11733 p_cp = FALSE;
11734 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11735 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
11736 set_option_default(opt_idx, OPT_FREE, FALSE);
11737 didset_options();
11738 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011739
11740 if (fname != NULL)
11741 {
11742 p = vim_getenv(envname, &dofree);
11743 if (p == NULL)
11744 {
11745 /* Set $MYVIMRC to the first vimrc file found. */
11746 p = FullName_save(fname, FALSE);
11747 if (p != NULL)
11748 {
11749 vim_setenv(envname, p);
11750 vim_free(p);
11751 }
11752 }
11753 else if (dofree)
11754 vim_free(p);
11755 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011756}
11757
11758/*
11759 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
11760 */
11761 void
11762change_compatible(on)
11763 int on;
11764{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011765 int opt_idx;
11766
Bram Moolenaar071d4272004-06-13 20:20:40 +000011767 if (p_cp != on)
11768 {
11769 p_cp = on;
11770 compatible_set();
11771 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011772 opt_idx = findoption((char_u *)"cp");
11773 if (opt_idx >= 0)
11774 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011775}
11776
11777/*
11778 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020011779 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011780 */
11781 int
11782option_was_set(name)
11783 char_u *name;
11784{
11785 int idx;
11786
11787 idx = findoption(name);
11788 if (idx < 0) /* unknown option */
11789 return FALSE;
11790 if (options[idx].flags & P_WAS_SET)
11791 return TRUE;
11792 return FALSE;
11793}
11794
11795/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010011796 * Reset the flag indicating option "name" was set.
11797 */
11798 void
11799reset_option_was_set(name)
11800 char_u *name;
11801{
11802 int idx = findoption(name);
11803
11804 if (idx >= 0)
11805 options[idx].flags &= ~P_WAS_SET;
11806}
11807
11808/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011809 * compatible_set() - Called when 'compatible' has been set or unset.
11810 *
11811 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
11812 * flag) to a Vi compatible value.
11813 * When 'compatible' is unset: Set all options that have a different default
11814 * for Vim (without the P_VI_DEF flag) to that default.
11815 */
11816 static void
11817compatible_set()
11818{
11819 int opt_idx;
11820
11821 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11822 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
11823 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
11824 set_option_default(opt_idx, OPT_FREE, p_cp);
11825 didset_options();
11826}
11827
11828#ifdef FEAT_LINEBREAK
11829
11830# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
11831 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011832 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011833# endif
11834
11835/*
11836 * fill_breakat_flags() -- called when 'breakat' changes value.
11837 */
11838 static void
11839fill_breakat_flags()
11840{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011841 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011842 int i;
11843
11844 for (i = 0; i < 256; i++)
11845 breakat_flags[i] = FALSE;
11846
11847 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011848 for (p = p_breakat; *p; p++)
11849 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011850}
11851
11852# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011853 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011854# endif
11855
11856#endif
11857
11858/*
11859 * Check an option that can be a range of string values.
11860 *
11861 * Return OK for correct value, FAIL otherwise.
11862 * Empty is always OK.
11863 */
11864 static int
11865check_opt_strings(val, values, list)
11866 char_u *val;
11867 char **values;
11868 int list; /* when TRUE: accept a list of values */
11869{
11870 return opt_strings_flags(val, values, NULL, list);
11871}
11872
11873/*
11874 * Handle an option that can be a range of string values.
11875 * Set a flag in "*flagp" for each string present.
11876 *
11877 * Return OK for correct value, FAIL otherwise.
11878 * Empty is always OK.
11879 */
11880 static int
11881opt_strings_flags(val, values, flagp, list)
11882 char_u *val; /* new value */
11883 char **values; /* array of valid string values */
11884 unsigned *flagp;
11885 int list; /* when TRUE: accept a list of values */
11886{
11887 int i;
11888 int len;
11889 unsigned new_flags = 0;
11890
11891 while (*val)
11892 {
11893 for (i = 0; ; ++i)
11894 {
11895 if (values[i] == NULL) /* val not found in values[] */
11896 return FAIL;
11897
11898 len = (int)STRLEN(values[i]);
11899 if (STRNCMP(values[i], val, len) == 0
11900 && ((list && val[len] == ',') || val[len] == NUL))
11901 {
11902 val += len + (val[len] == ',');
11903 new_flags |= (1 << i);
11904 break; /* check next item in val list */
11905 }
11906 }
11907 }
11908 if (flagp != NULL)
11909 *flagp = new_flags;
11910
11911 return OK;
11912}
11913
11914/*
11915 * Read the 'wildmode' option, fill wim_flags[].
11916 */
11917 static int
11918check_opt_wim()
11919{
11920 char_u new_wim_flags[4];
11921 char_u *p;
11922 int i;
11923 int idx = 0;
11924
11925 for (i = 0; i < 4; ++i)
11926 new_wim_flags[i] = 0;
11927
11928 for (p = p_wim; *p; ++p)
11929 {
11930 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
11931 ;
11932 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
11933 return FAIL;
11934 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
11935 new_wim_flags[idx] |= WIM_LONGEST;
11936 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
11937 new_wim_flags[idx] |= WIM_FULL;
11938 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
11939 new_wim_flags[idx] |= WIM_LIST;
11940 else
11941 return FAIL;
11942 p += i;
11943 if (*p == NUL)
11944 break;
11945 if (*p == ',')
11946 {
11947 if (idx == 3)
11948 return FAIL;
11949 ++idx;
11950 }
11951 }
11952
11953 /* fill remaining entries with last flag */
11954 while (idx < 3)
11955 {
11956 new_wim_flags[idx + 1] = new_wim_flags[idx];
11957 ++idx;
11958 }
11959
11960 /* only when there are no errors, wim_flags[] is changed */
11961 for (i = 0; i < 4; ++i)
11962 wim_flags[i] = new_wim_flags[i];
11963 return OK;
11964}
11965
11966/*
11967 * Check if backspacing over something is allowed.
11968 */
11969 int
11970can_bs(what)
11971 int what; /* BS_INDENT, BS_EOL or BS_START */
11972{
11973 switch (*p_bs)
11974 {
11975 case '2': return TRUE;
11976 case '1': return (what != BS_START);
11977 case '0': return FALSE;
11978 }
11979 return vim_strchr(p_bs, what) != NULL;
11980}
11981
11982/*
11983 * Save the current values of 'fileformat' and 'fileencoding', so that we know
11984 * the file must be considered changed when the value is different.
11985 */
11986 void
11987save_file_ff(buf)
11988 buf_T *buf;
11989{
11990 buf->b_start_ffc = *buf->b_p_ff;
11991 buf->b_start_eol = buf->b_p_eol;
11992#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011993 buf->b_start_bomb = buf->b_p_bomb;
11994
Bram Moolenaar071d4272004-06-13 20:20:40 +000011995 /* Only use free/alloc when necessary, they take time. */
11996 if (buf->b_start_fenc == NULL
11997 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
11998 {
11999 vim_free(buf->b_start_fenc);
12000 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
12001 }
12002#endif
12003}
12004
12005/*
12006 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
12007 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012008 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
12009 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012010 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012011 * When "ignore_empty" is true don't consider a new, empty buffer to be
12012 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012013 */
12014 int
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012015file_ff_differs(buf, ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012016 buf_T *buf;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012017 int ignore_empty;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012018{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012019 /* In a buffer that was never loaded the options are not valid. */
12020 if (buf->b_flags & BF_NEVERLOADED)
12021 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012022 if (ignore_empty
12023 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012024 && buf->b_ml.ml_line_count == 1
12025 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12026 return FALSE;
12027 if (buf->b_start_ffc != *buf->b_p_ff)
12028 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012029 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012030 return TRUE;
12031#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012032 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12033 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012034 if (buf->b_start_fenc == NULL)
12035 return (*buf->b_p_fenc != NUL);
12036 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12037#else
12038 return FALSE;
12039#endif
12040}
12041
12042/*
12043 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12044 */
12045 int
12046check_ff_value(p)
12047 char_u *p;
12048{
12049 return check_opt_strings(p, p_ff_values, FALSE);
12050}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012051
12052/*
12053 * Return the effective shiftwidth value for current buffer, using the
12054 * 'tabstop' value when 'shiftwidth' is zero.
12055 */
12056 long
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012057get_sw_value(buf)
12058 buf_T *buf;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012059{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012060 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012061}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012062
12063/*
12064 * Return the effective softtabstop value for the current buffer, using the
12065 * 'tabstop' value when 'softtabstop' is negative.
12066 */
12067 long
12068get_sts_value()
12069{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012070 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012071}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012072
12073/*
12074 * Check matchpairs option for "*initc".
12075 * If there is a match set "*initc" to the matching character and "*findc" to
12076 * the opposite character. Set "*backwards" to the direction.
12077 * When "switchit" is TRUE swap the direction.
12078 */
12079 void
12080find_mps_values(initc, findc, backwards, switchit)
12081 int *initc;
12082 int *findc;
12083 int *backwards;
12084 int switchit;
12085{
12086 char_u *ptr;
12087
12088 ptr = curbuf->b_p_mps;
12089 while (*ptr != NUL)
12090 {
12091#ifdef FEAT_MBYTE
12092 if (has_mbyte)
12093 {
12094 char_u *prev;
12095
12096 if (mb_ptr2char(ptr) == *initc)
12097 {
12098 if (switchit)
12099 {
12100 *findc = *initc;
12101 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12102 *backwards = TRUE;
12103 }
12104 else
12105 {
12106 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12107 *backwards = FALSE;
12108 }
12109 return;
12110 }
12111 prev = ptr;
12112 ptr += mb_ptr2len(ptr) + 1;
12113 if (mb_ptr2char(ptr) == *initc)
12114 {
12115 if (switchit)
12116 {
12117 *findc = *initc;
12118 *initc = mb_ptr2char(prev);
12119 *backwards = FALSE;
12120 }
12121 else
12122 {
12123 *findc = mb_ptr2char(prev);
12124 *backwards = TRUE;
12125 }
12126 return;
12127 }
12128 ptr += mb_ptr2len(ptr);
12129 }
12130 else
12131#endif
12132 {
12133 if (*ptr == *initc)
12134 {
12135 if (switchit)
12136 {
12137 *backwards = TRUE;
12138 *findc = *initc;
12139 *initc = ptr[2];
12140 }
12141 else
12142 {
12143 *backwards = FALSE;
12144 *findc = ptr[2];
12145 }
12146 return;
12147 }
12148 ptr += 2;
12149 if (*ptr == *initc)
12150 {
12151 if (switchit)
12152 {
12153 *backwards = FALSE;
12154 *findc = *initc;
12155 *initc = ptr[-2];
12156 }
12157 else
12158 {
12159 *backwards = TRUE;
12160 *findc = ptr[-2];
12161 }
12162 return;
12163 }
12164 ++ptr;
12165 }
12166 if (*ptr == ',')
12167 ++ptr;
12168 }
12169}
Bram Moolenaar597a4222014-06-25 14:39:50 +020012170
12171#if defined(FEAT_LINEBREAK) || defined(PROTO)
12172/*
12173 * This is called when 'breakindentopt' is changed and when a window is
12174 * initialized.
12175 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012176 static int
12177briopt_check(wp)
12178 win_T *wp;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012179{
12180 char_u *p;
12181 int bri_shift = 0;
12182 long bri_min = 20;
12183 int bri_sbr = FALSE;
12184
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012185 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012186 while (*p != NUL)
12187 {
12188 if (STRNCMP(p, "shift:", 6) == 0
12189 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
12190 {
12191 p += 6;
12192 bri_shift = getdigits(&p);
12193 }
12194 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
12195 {
12196 p += 4;
12197 bri_min = getdigits(&p);
12198 }
12199 else if (STRNCMP(p, "sbr", 3) == 0)
12200 {
12201 p += 3;
12202 bri_sbr = TRUE;
12203 }
12204 if (*p != ',' && *p != NUL)
12205 return FAIL;
12206 if (*p == ',')
12207 ++p;
12208 }
12209
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012210 wp->w_p_brishift = bri_shift;
12211 wp->w_p_brimin = bri_min;
12212 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012213
12214 return OK;
12215}
12216#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012217
12218/*
12219 * Get the local or global value of 'backupcopy'.
12220 */
12221 unsigned int
12222get_bkc_value(buf)
12223 buf_T *buf;
12224{
12225 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
12226}