blob: 08e2e5948061aa5ce36e32729c103c9318482bf6 [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.
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003659 * When "opt_flags" is non-zero skip 'encoding'.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003660 */
3661 static void
3662set_options_default(opt_flags)
3663 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3664{
3665 int i;
3666#ifdef FEAT_WINDOWS
3667 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003668 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003669#endif
3670
3671 for (i = 0; !istermoption(&options[i]); i++)
Bram Moolenaarb341dda2015-08-25 12:56:31 +02003672 if (!(options[i].flags & P_NODEFAULT)
3673 && (opt_flags == 0 || options[i].var != (char_u *)&p_enc))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003674 set_option_default(i, opt_flags, p_cp);
3675
3676#ifdef FEAT_WINDOWS
3677 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003678 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003679 win_comp_scroll(wp);
3680#else
3681 win_comp_scroll(curwin);
3682#endif
Bram Moolenaar5a4eceb2014-09-09 17:33:07 +02003683#ifdef FEAT_CINDENT
3684 parse_cino(curbuf);
3685#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003686}
3687
3688/*
3689 * Set the Vi-default value of a string option.
3690 * Used for 'sh', 'backupskip' and 'term'.
3691 */
3692 void
3693set_string_default(name, val)
3694 char *name;
3695 char_u *val;
3696{
3697 char_u *p;
3698 int opt_idx;
3699
3700 p = vim_strsave(val);
3701 if (p != NULL) /* we don't want a NULL */
3702 {
3703 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003704 if (opt_idx >= 0)
3705 {
3706 if (options[opt_idx].flags & P_DEF_ALLOCED)
3707 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3708 options[opt_idx].def_val[VI_DEFAULT] = p;
3709 options[opt_idx].flags |= P_DEF_ALLOCED;
3710 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003711 }
3712}
3713
3714/*
3715 * Set the Vi-default value of a number option.
3716 * Used for 'lines' and 'columns'.
3717 */
3718 void
3719set_number_default(name, val)
3720 char *name;
3721 long val;
3722{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003723 int opt_idx;
3724
3725 opt_idx = findoption((char_u *)name);
3726 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003727 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003728}
3729
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003730#if defined(EXITFREE) || defined(PROTO)
3731/*
3732 * Free all options.
3733 */
3734 void
3735free_all_options()
3736{
3737 int i;
3738
3739 for (i = 0; !istermoption(&options[i]); i++)
3740 {
3741 if (options[i].indir == PV_NONE)
3742 {
3743 /* global option: free value and default value. */
3744 if (options[i].flags & P_ALLOCED && options[i].var != NULL)
3745 free_string_option(*(char_u **)options[i].var);
3746 if (options[i].flags & P_DEF_ALLOCED)
3747 free_string_option(options[i].def_val[VI_DEFAULT]);
3748 }
3749 else if (options[i].var != VAR_WIN
3750 && (options[i].flags & P_STRING))
3751 /* buffer-local option: free global value */
3752 free_string_option(*(char_u **)options[i].var);
3753 }
3754}
3755#endif
3756
3757
Bram Moolenaar071d4272004-06-13 20:20:40 +00003758/*
3759 * Initialize the options, part two: After getting Rows and Columns and
3760 * setting 'term'.
3761 */
3762 void
3763set_init_2()
3764{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003765 int idx;
3766
Bram Moolenaar071d4272004-06-13 20:20:40 +00003767 /*
3768 * 'scroll' defaults to half the window height. Note that this default is
3769 * wrong when the window height changes.
3770 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003771 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003772 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003773 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003774 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003775 comp_col();
3776
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003777 /*
3778 * 'window' is only for backwards compatibility with Vi.
3779 * Default is Rows - 1.
3780 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003781 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003782 p_window = Rows - 1;
3783 set_number_default("window", Rows - 1);
3784
Bram Moolenaarf740b292006-02-16 22:11:02 +00003785 /* For DOS console the default is always black. */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003786#if !((defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003787 /*
3788 * If 'background' wasn't set by the user, try guessing the value,
3789 * depending on the terminal name. Only need to check for terminals
3790 * with a dark background, that can handle color.
3791 */
3792 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003793 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3794 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003795 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003796 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003797 /* don't mark it as set, when starting the GUI it may be
3798 * changed again */
3799 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003800 }
3801#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003802
3803#ifdef CURSOR_SHAPE
3804 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3805#endif
3806#ifdef FEAT_MOUSESHAPE
3807 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3808#endif
3809#ifdef FEAT_PRINTER
3810 (void)parse_printoptions(); /* parse 'printoptions' default value */
3811#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003812}
3813
3814/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00003815 * Return "dark" or "light" depending on the kind of terminal.
3816 * This is just guessing! Recognized are:
3817 * "linux" Linux console
3818 * "screen.linux" Linux console with screen
3819 * "cygwin" Cygwin shell
3820 * "putty" Putty program
3821 * We also check the COLORFGBG environment variable, which is set by
3822 * rxvt and derivatives. This variable contains either two or three
3823 * values separated by semicolons; we want the last value in either
3824 * case. If this value is 0-6 or 8, our background is dark.
3825 */
3826 static char_u *
3827term_bg_default()
3828{
Bram Moolenaarf740b292006-02-16 22:11:02 +00003829#if defined(MSDOS) || defined(OS2) || defined(WIN3264)
3830 /* DOS console nearly always black */
3831 return (char_u *)"dark";
3832#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00003833 char_u *p;
3834
Bram Moolenaarf740b292006-02-16 22:11:02 +00003835 if (STRCMP(T_NAME, "linux") == 0
3836 || STRCMP(T_NAME, "screen.linux") == 0
3837 || STRCMP(T_NAME, "cygwin") == 0
3838 || STRCMP(T_NAME, "putty") == 0
3839 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
3840 && (p = vim_strrchr(p, ';')) != NULL
3841 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
3842 && p[2] == NUL))
3843 return (char_u *)"dark";
3844 return (char_u *)"light";
3845#endif
3846}
3847
3848/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00003849 * Initialize the options, part three: After reading the .vimrc
3850 */
3851 void
3852set_init_3()
3853{
3854#if defined(UNIX) || defined(OS2) || defined(WIN3264)
3855/*
3856 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
3857 * This is done after other initializations, where 'shell' might have been
3858 * set, but only if they have not been set before.
3859 */
3860 char_u *p;
3861 int idx_srr;
3862 int do_srr;
3863#ifdef FEAT_QUICKFIX
3864 int idx_sp;
3865 int do_sp;
3866#endif
3867
3868 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003869 if (idx_srr < 0)
3870 do_srr = FALSE;
3871 else
3872 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003873#ifdef FEAT_QUICKFIX
3874 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003875 if (idx_sp < 0)
3876 do_sp = FALSE;
3877 else
3878 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003879#endif
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003880 p = get_isolated_shell_name();
Bram Moolenaar071d4272004-06-13 20:20:40 +00003881 if (p != NULL)
3882 {
3883 /*
3884 * Default for p_sp is "| tee", for p_srr is ">".
3885 * For known shells it is changed here to include stderr.
3886 */
3887 if ( fnamecmp(p, "csh") == 0
3888 || fnamecmp(p, "tcsh") == 0
3889# if defined(OS2) || defined(WIN3264) /* also check with .exe extension */
3890 || fnamecmp(p, "csh.exe") == 0
3891 || fnamecmp(p, "tcsh.exe") == 0
3892# endif
3893 )
3894 {
3895#if defined(FEAT_QUICKFIX)
3896 if (do_sp)
3897 {
3898# ifdef WIN3264
3899 p_sp = (char_u *)">&";
3900# else
3901 p_sp = (char_u *)"|& tee";
3902# endif
3903 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3904 }
3905#endif
3906 if (do_srr)
3907 {
3908 p_srr = (char_u *)">&";
3909 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3910 }
3911 }
3912 else
3913# ifndef OS2 /* Always use bourne shell style redirection if we reach this */
3914 if ( fnamecmp(p, "sh") == 0
3915 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003916 || fnamecmp(p, "mksh") == 0
3917 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003918 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003919 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003920 || fnamecmp(p, "bash") == 0
Bram Moolenaar75a8d742014-05-07 15:10:21 +02003921 || fnamecmp(p, "fish") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003922# ifdef WIN3264
3923 || fnamecmp(p, "cmd") == 0
3924 || fnamecmp(p, "sh.exe") == 0
3925 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003926 || fnamecmp(p, "mksh.exe") == 0
3927 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003928 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003929 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003930 || fnamecmp(p, "bash.exe") == 0
3931 || fnamecmp(p, "cmd.exe") == 0
3932# endif
3933 )
3934# endif
3935 {
3936#if defined(FEAT_QUICKFIX)
3937 if (do_sp)
3938 {
3939# ifdef WIN3264
3940 p_sp = (char_u *)">%s 2>&1";
3941# else
3942 p_sp = (char_u *)"2>&1| tee";
3943# endif
3944 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3945 }
3946#endif
3947 if (do_srr)
3948 {
3949 p_srr = (char_u *)">%s 2>&1";
3950 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3951 }
3952 }
3953 vim_free(p);
3954 }
3955#endif
3956
3957#if defined(MSDOS) || defined(WIN3264) || defined(OS2)
3958 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01003959 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
3960 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003961 * This is done after other initializations, where 'shell' might have been
3962 * set, but only if they have not been set before. Default for p_shcf is
3963 * "/c", for p_shq is "". For "sh" like shells it is changed here to
3964 * "-c" and "\"", but not for DJGPP, because it starts the shell without
3965 * command.com. And for Win32 we need to set p_sxq instead.
3966 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00003967 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003968 {
3969 int idx3;
3970
3971 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003972 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003973 {
3974 p_shcf = (char_u *)"-c";
3975 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3976 }
3977
3978# ifndef DJGPP
3979# ifdef WIN3264
3980 /* Somehow Win32 requires the quotes around the redirection too */
3981 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003982 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003983 {
3984 p_sxq = (char_u *)"\"";
3985 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3986 }
3987# else
3988 idx3 = findoption((char_u *)"shq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003989 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003990 {
3991 p_shq = (char_u *)"\"";
3992 options[idx3].def_val[VI_DEFAULT] = p_shq;
3993 }
3994# endif
3995# endif
3996 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01003997 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
3998 {
3999 int idx3;
4000
4001 /*
4002 * cmd.exe on Windows will strip the first and last double quote given
4003 * on the command line, e.g. most of the time things like:
4004 * cmd /c "my path/to/echo" "my args to echo"
4005 * become:
4006 * my path/to/echo" "my args to echo
4007 * when executed.
4008 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01004009 * To avoid this, set shellxquote to surround the command in
4010 * parenthesis. This appears to make most commands work, without
4011 * breaking commands that worked previously, such as
4012 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01004013 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01004014 idx3 = findoption((char_u *)"sxq");
4015 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4016 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004017 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004018 options[idx3].def_val[VI_DEFAULT] = p_sxq;
4019 }
4020
Bram Moolenaara64ba222012-02-12 23:23:31 +01004021 idx3 = findoption((char_u *)"shcf");
4022 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
4023 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01004024 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01004025 options[idx3].def_val[VI_DEFAULT] = p_shcf;
4026 }
4027 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004028#endif
4029
4030#ifdef FEAT_TITLE
4031 set_title_defaults();
4032#endif
4033}
4034
4035#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4036/*
4037 * When 'helplang' is still at its default value, set it to "lang".
4038 * Only the first two characters of "lang" are used.
4039 */
4040 void
4041set_helplang_default(lang)
4042 char_u *lang;
4043{
4044 int idx;
4045
4046 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4047 return;
4048 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004049 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004050 {
4051 if (options[idx].flags & P_ALLOCED)
4052 free_string_option(p_hlg);
4053 p_hlg = vim_strsave(lang);
4054 if (p_hlg == NULL)
4055 p_hlg = empty_option;
4056 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004057 {
4058 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4059 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4060 {
4061 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4062 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4063 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004064 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004065 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004066 options[idx].flags |= P_ALLOCED;
4067 }
4068}
4069#endif
4070
4071#ifdef FEAT_GUI
4072static char_u *gui_bg_default __ARGS((void));
4073
4074 static char_u *
4075gui_bg_default()
4076{
4077 if (gui_get_lightness(gui.back_pixel) < 127)
4078 return (char_u *)"dark";
4079 return (char_u *)"light";
4080}
4081
4082/*
4083 * Option initializations that can only be done after opening the GUI window.
4084 */
4085 void
4086init_gui_options()
4087{
4088 /* Set the 'background' option according to the lightness of the
4089 * background color, unless the user has set it already. */
4090 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4091 {
4092 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4093 highlight_changed();
4094 }
4095}
4096#endif
4097
4098#ifdef FEAT_TITLE
4099/*
4100 * 'title' and 'icon' only default to true if they have not been set or reset
4101 * in .vimrc and we can read the old value.
4102 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4103 * they can be reset. This reduces startup time when using X on a remote
4104 * machine.
4105 */
4106 void
4107set_title_defaults()
4108{
4109 int idx1;
4110 long val;
4111
4112 /*
4113 * If GUI is (going to be) used, we can always set the window title and
4114 * icon name. Saves a bit of time, because the X11 display server does
4115 * not need to be contacted.
4116 */
4117 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004118 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004119 {
4120#ifdef FEAT_GUI
4121 if (gui.starting || gui.in_use)
4122 val = TRUE;
4123 else
4124#endif
4125 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004126 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004127 p_title = val;
4128 }
4129 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004130 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004131 {
4132#ifdef FEAT_GUI
4133 if (gui.starting || gui.in_use)
4134 val = TRUE;
4135 else
4136#endif
4137 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004138 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004139 p_icon = val;
4140 }
4141}
4142#endif
4143
4144/*
4145 * Parse 'arg' for option settings.
4146 *
4147 * 'arg' may be IObuff, but only when no errors can be present and option
4148 * does not need to be expanded with option_expand().
4149 * "opt_flags":
4150 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004151 * OPT_GLOBAL for ":setglobal"
4152 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004153 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004154 * OPT_WINONLY to only set window-local options
4155 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004156 *
4157 * returns FAIL if an error is detected, OK otherwise
4158 */
4159 int
4160do_set(arg, opt_flags)
4161 char_u *arg; /* option string (may be written to!) */
4162 int opt_flags;
4163{
4164 int opt_idx;
4165 char_u *errmsg;
4166 char_u errbuf[80];
4167 char_u *startarg;
4168 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4169 int nextchar; /* next non-white char after option name */
4170 int afterchar; /* character just after option name */
4171 int len;
4172 int i;
4173 long value;
4174 int key;
4175 long_u flags; /* flags for current option */
4176 char_u *varp = NULL; /* pointer to variable for current option */
4177 int did_show = FALSE; /* already showed one value */
4178 int adding; /* "opt+=arg" */
4179 int prepending; /* "opt^=arg" */
4180 int removing; /* "opt-=arg" */
4181 int cp_val = 0;
4182 char_u key_name[2];
4183
4184 if (*arg == NUL)
4185 {
4186 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004187 did_show = TRUE;
4188 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004189 }
4190
4191 while (*arg != NUL) /* loop to process all options */
4192 {
4193 errmsg = NULL;
4194 startarg = arg; /* remember for error message */
4195
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004196 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4197 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004198 {
4199 /*
4200 * ":set all" show all options.
4201 * ":set all&" set all options to their default value.
4202 */
4203 arg += 3;
4204 if (*arg == '&')
4205 {
4206 ++arg;
4207 /* Only for :set command set global value of local options. */
4208 set_options_default(OPT_FREE | opt_flags);
Bram Moolenaarb341dda2015-08-25 12:56:31 +02004209 redraw_all_later(CLEAR);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004210 }
4211 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004212 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004213 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004214 did_show = TRUE;
4215 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004216 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004217 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004218 {
4219 showoptions(2, opt_flags);
4220 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004221 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004222 arg += 7;
4223 }
4224 else
4225 {
4226 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004227 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004228 {
4229 prefix = 0;
4230 arg += 2;
4231 }
4232 else if (STRNCMP(arg, "inv", 3) == 0)
4233 {
4234 prefix = 2;
4235 arg += 3;
4236 }
4237
4238 /* find end of name */
4239 key = 0;
4240 if (*arg == '<')
4241 {
4242 nextchar = 0;
4243 opt_idx = -1;
4244 /* look out for <t_>;> */
4245 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4246 len = 5;
4247 else
4248 {
4249 len = 1;
4250 while (arg[len] != NUL && arg[len] != '>')
4251 ++len;
4252 }
4253 if (arg[len] != '>')
4254 {
4255 errmsg = e_invarg;
4256 goto skip;
4257 }
4258 arg[len] = NUL; /* put NUL after name */
4259 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4260 opt_idx = findoption(arg + 1);
4261 arg[len++] = '>'; /* restore '>' */
4262 if (opt_idx == -1)
4263 key = find_key_option(arg + 1);
4264 }
4265 else
4266 {
4267 len = 0;
4268 /*
4269 * The two characters after "t_" may not be alphanumeric.
4270 */
4271 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4272 len = 4;
4273 else
4274 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4275 ++len;
4276 nextchar = arg[len];
4277 arg[len] = NUL; /* put NUL after name */
4278 opt_idx = findoption(arg);
4279 arg[len] = nextchar; /* restore nextchar */
4280 if (opt_idx == -1)
4281 key = find_key_option(arg);
4282 }
4283
4284 /* remember character after option name */
4285 afterchar = arg[len];
4286
4287 /* skip white space, allow ":set ai ?" */
4288 while (vim_iswhite(arg[len]))
4289 ++len;
4290
4291 adding = FALSE;
4292 prepending = FALSE;
4293 removing = FALSE;
4294 if (arg[len] != NUL && arg[len + 1] == '=')
4295 {
4296 if (arg[len] == '+')
4297 {
4298 adding = TRUE; /* "+=" */
4299 ++len;
4300 }
4301 else if (arg[len] == '^')
4302 {
4303 prepending = TRUE; /* "^=" */
4304 ++len;
4305 }
4306 else if (arg[len] == '-')
4307 {
4308 removing = TRUE; /* "-=" */
4309 ++len;
4310 }
4311 }
4312 nextchar = arg[len];
4313
4314 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4315 {
4316 errmsg = (char_u *)N_("E518: Unknown option");
4317 goto skip;
4318 }
4319
4320 if (opt_idx >= 0)
4321 {
4322 if (options[opt_idx].var == NULL) /* hidden option: skip */
4323 {
4324 /* Only give an error message when requesting the value of
4325 * a hidden option, ignore setting it. */
4326 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4327 && (!(options[opt_idx].flags & P_BOOL)
4328 || nextchar == '?'))
4329 errmsg = (char_u *)N_("E519: Option not supported");
4330 goto skip;
4331 }
4332
4333 flags = options[opt_idx].flags;
4334 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4335 }
4336 else
4337 {
4338 flags = P_STRING;
4339 if (key < 0)
4340 {
4341 key_name[0] = KEY2TERMCAP0(key);
4342 key_name[1] = KEY2TERMCAP1(key);
4343 }
4344 else
4345 {
4346 key_name[0] = KS_KEY;
4347 key_name[1] = (key & 0xff);
4348 }
4349 }
4350
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004351 /* Skip all options that are not window-local (used when showing
4352 * an already loaded buffer in a window). */
4353 if ((opt_flags & OPT_WINONLY)
4354 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4355 goto skip;
4356
Bram Moolenaara3227e22006-03-08 21:32:40 +00004357 /* Skip all options that are window-local (used for :vimgrep). */
4358 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4359 && options[opt_idx].var == VAR_WIN)
4360 goto skip;
4361
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004362 /* Disallow changing some options from modelines. */
4363 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004364 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004365 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004366 {
4367 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4368 goto skip;
4369 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004370#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004371 /* In diff mode some options are overruled. This avoids that
4372 * 'foldmethod' becomes "marker" instead of "diff" and that
4373 * "wrap" gets set. */
4374 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004375 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004376 && (options[opt_idx].indir == PV_FDM
4377 || options[opt_idx].indir == PV_WRAP))
4378 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004379#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004380 }
4381
4382#ifdef HAVE_SANDBOX
4383 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004384 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004385 {
4386 errmsg = (char_u *)_(e_sandbox);
4387 goto skip;
4388 }
4389#endif
4390
4391 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4392 {
4393 arg += len;
4394 cp_val = p_cp;
4395 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4396 {
4397 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4398 {
4399 cp_val = FALSE;
4400 arg += 3;
4401 }
4402 else /* "opt&vi": set to Vi default */
4403 {
4404 cp_val = TRUE;
4405 arg += 2;
4406 }
4407 }
4408 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
4409 && arg[1] != NUL && !vim_iswhite(arg[1]))
4410 {
4411 errmsg = e_trailing;
4412 goto skip;
4413 }
4414 }
4415
4416 /*
4417 * allow '=' and ':' as MSDOS command.com allows only one
4418 * '=' character per "set" command line. grrr. (jw)
4419 */
4420 if (nextchar == '?'
4421 || (prefix == 1
4422 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4423 && !(flags & P_BOOL)))
4424 {
4425 /*
4426 * print value
4427 */
4428 if (did_show)
4429 msg_putchar('\n'); /* cursor below last one */
4430 else
4431 {
4432 gotocmdline(TRUE); /* cursor at status line */
4433 did_show = TRUE; /* remember that we did a line */
4434 }
4435 if (opt_idx >= 0)
4436 {
4437 showoneopt(&options[opt_idx], opt_flags);
4438#ifdef FEAT_EVAL
4439 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004440 {
4441 /* Mention where the option was last set. */
4442 if (varp == options[opt_idx].var)
4443 last_set_msg(options[opt_idx].scriptID);
4444 else if ((int)options[opt_idx].indir & PV_WIN)
4445 last_set_msg(curwin->w_p_scriptID[
4446 (int)options[opt_idx].indir & PV_MASK]);
4447 else if ((int)options[opt_idx].indir & PV_BUF)
4448 last_set_msg(curbuf->b_p_scriptID[
4449 (int)options[opt_idx].indir & PV_MASK]);
4450 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004451#endif
4452 }
4453 else
4454 {
4455 char_u *p;
4456
4457 p = find_termcode(key_name);
4458 if (p == NULL)
4459 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004460 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004461 goto skip;
4462 }
4463 else
4464 (void)show_one_termcode(key_name, p, TRUE);
4465 }
4466 if (nextchar != '?'
4467 && nextchar != NUL && !vim_iswhite(afterchar))
4468 errmsg = e_trailing;
4469 }
4470 else
4471 {
4472 if (flags & P_BOOL) /* boolean */
4473 {
4474 if (nextchar == '=' || nextchar == ':')
4475 {
4476 errmsg = e_invarg;
4477 goto skip;
4478 }
4479
4480 /*
4481 * ":set opt!": invert
4482 * ":set opt&": reset to default value
4483 * ":set opt<": reset to global value
4484 */
4485 if (nextchar == '!')
4486 value = *(int *)(varp) ^ 1;
4487 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004488 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004489 ((flags & P_VI_DEF) || cp_val)
4490 ? VI_DEFAULT : VIM_DEFAULT];
4491 else if (nextchar == '<')
4492 {
4493 /* For 'autoread' -1 means to use global value. */
4494 if ((int *)varp == &curbuf->b_p_ar
4495 && opt_flags == OPT_LOCAL)
4496 value = -1;
4497 else
4498 value = *(int *)get_varp_scope(&(options[opt_idx]),
4499 OPT_GLOBAL);
4500 }
4501 else
4502 {
4503 /*
4504 * ":set invopt": invert
4505 * ":set opt" or ":set noopt": set or reset
4506 */
4507 if (nextchar != NUL && !vim_iswhite(afterchar))
4508 {
4509 errmsg = e_trailing;
4510 goto skip;
4511 }
4512 if (prefix == 2) /* inv */
4513 value = *(int *)(varp) ^ 1;
4514 else
4515 value = prefix;
4516 }
4517
4518 errmsg = set_bool_option(opt_idx, varp, (int)value,
4519 opt_flags);
4520 }
4521 else /* numeric or string */
4522 {
4523 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4524 || prefix != 1)
4525 {
4526 errmsg = e_invarg;
4527 goto skip;
4528 }
4529
4530 if (flags & P_NUM) /* numeric */
4531 {
4532 /*
4533 * Different ways to set a number option:
4534 * & set to default value
4535 * < set to global value
4536 * <xx> accept special key codes for 'wildchar'
4537 * c accept any non-digit for 'wildchar'
4538 * [-]0-9 set number
4539 * other error
4540 */
4541 ++arg;
4542 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004543 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004544 ((flags & P_VI_DEF) || cp_val)
4545 ? VI_DEFAULT : VIM_DEFAULT];
4546 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004547 {
4548 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4549 * use the global value. */
4550 if ((long *)varp == &curbuf->b_p_ul
4551 && opt_flags == OPT_LOCAL)
4552 value = NO_LOCAL_UNDOLEVEL;
4553 else
4554 value = *(long *)get_varp_scope(
4555 &(options[opt_idx]), OPT_GLOBAL);
4556 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004557 else if (((long *)varp == &p_wc
4558 || (long *)varp == &p_wcm)
4559 && (*arg == '<'
4560 || *arg == '^'
4561 || ((!arg[1] || vim_iswhite(arg[1]))
4562 && !VIM_ISDIGIT(*arg))))
4563 {
4564 value = string_to_key(arg);
4565 if (value == 0 && (long *)varp != &p_wcm)
4566 {
4567 errmsg = e_invarg;
4568 goto skip;
4569 }
4570 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004571 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4572 {
Bram Moolenaar18400e62015-01-27 15:58:40 +01004573 /* Allow negative (for 'undolevels'), octal and
4574 * hex numbers. */
Bram Moolenaar5d1bc782015-07-17 13:03:48 +02004575 vim_str2nr(arg, NULL, &i, TRUE, TRUE, &value, NULL, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004576 if (arg[i] != NUL && !vim_iswhite(arg[i]))
4577 {
4578 errmsg = e_invarg;
4579 goto skip;
4580 }
4581 }
4582 else
4583 {
4584 errmsg = (char_u *)N_("E521: Number required after =");
4585 goto skip;
4586 }
4587
4588 if (adding)
4589 value = *(long *)varp + value;
4590 if (prepending)
4591 value = *(long *)varp * value;
4592 if (removing)
4593 value = *(long *)varp - value;
4594 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004595 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004596 }
4597 else if (opt_idx >= 0) /* string */
4598 {
4599 char_u *save_arg = NULL;
4600 char_u *s = NULL;
Bram Moolenaar53744302015-07-17 17:38:22 +02004601 char_u *oldval = NULL; /* previous value if *varp */
Bram Moolenaar071d4272004-06-13 20:20:40 +00004602 char_u *newval;
Bram Moolenaar53744302015-07-17 17:38:22 +02004603 char_u *origval = NULL;
4604#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4605 char_u *saved_origval = NULL;
4606#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004607 unsigned newlen;
4608 int comma;
4609 int bs;
4610 int new_value_alloced; /* new string option
4611 was allocated */
4612
4613 /* When using ":set opt=val" for a global option
4614 * with a local value the local value will be
4615 * reset, use the global value here. */
4616 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004617 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004618 varp = options[opt_idx].var;
4619
4620 /* The old value is kept until we are sure that the
4621 * new value is valid. */
4622 oldval = *(char_u **)varp;
4623 if (nextchar == '&') /* set to default val */
4624 {
4625 newval = options[opt_idx].def_val[
4626 ((flags & P_VI_DEF) || cp_val)
4627 ? VI_DEFAULT : VIM_DEFAULT];
4628 if ((char_u **)varp == &p_bg)
4629 {
4630 /* guess the value of 'background' */
4631#ifdef FEAT_GUI
4632 if (gui.in_use)
4633 newval = gui_bg_default();
4634 else
4635#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004636 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004637 }
4638
4639 /* expand environment variables and ~ (since the
4640 * default value was already expanded, only
4641 * required when an environment variable was set
4642 * later */
4643 if (newval == NULL)
4644 newval = empty_option;
4645 else
4646 {
4647 s = option_expand(opt_idx, newval);
4648 if (s == NULL)
4649 s = newval;
4650 newval = vim_strsave(s);
4651 }
4652 new_value_alloced = TRUE;
4653 }
4654 else if (nextchar == '<') /* set to global val */
4655 {
4656 newval = vim_strsave(*(char_u **)get_varp_scope(
4657 &(options[opt_idx]), OPT_GLOBAL));
4658 new_value_alloced = TRUE;
4659 }
4660 else
4661 {
4662 ++arg; /* jump to after the '=' or ':' */
4663
4664 /*
4665 * Set 'keywordprg' to ":help" if an empty
4666 * value was passed to :set by the user.
4667 * Misuse errbuf[] for the resulting string.
4668 */
4669 if (varp == (char_u *)&p_kp
4670 && (*arg == NUL || *arg == ' '))
4671 {
4672 STRCPY(errbuf, ":help");
4673 save_arg = arg;
4674 arg = errbuf;
4675 }
4676 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004677 * Convert 'backspace' number to string, for
4678 * adding, prepending and removing string.
4679 */
4680 else if (varp == (char_u *)&p_bs
4681 && VIM_ISDIGIT(**(char_u **)varp))
4682 {
4683 i = getdigits((char_u **)varp);
4684 switch (i)
4685 {
4686 case 0:
4687 *(char_u **)varp = empty_option;
4688 break;
4689 case 1:
4690 *(char_u **)varp = vim_strsave(
4691 (char_u *)"indent,eol");
4692 break;
4693 case 2:
4694 *(char_u **)varp = vim_strsave(
4695 (char_u *)"indent,eol,start");
4696 break;
4697 }
4698 vim_free(oldval);
4699 oldval = *(char_u **)varp;
4700 }
4701 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004702 * Convert 'whichwrap' number to string, for
4703 * backwards compatibility with Vim 3.0.
4704 * Misuse errbuf[] for the resulting string.
4705 */
4706 else if (varp == (char_u *)&p_ww
4707 && VIM_ISDIGIT(*arg))
4708 {
4709 *errbuf = NUL;
4710 i = getdigits(&arg);
4711 if (i & 1)
4712 STRCAT(errbuf, "b,");
4713 if (i & 2)
4714 STRCAT(errbuf, "s,");
4715 if (i & 4)
4716 STRCAT(errbuf, "h,l,");
4717 if (i & 8)
4718 STRCAT(errbuf, "<,>,");
4719 if (i & 16)
4720 STRCAT(errbuf, "[,],");
4721 if (*errbuf != NUL) /* remove trailing , */
4722 errbuf[STRLEN(errbuf) - 1] = NUL;
4723 save_arg = arg;
4724 arg = errbuf;
4725 }
4726 /*
4727 * Remove '>' before 'dir' and 'bdir', for
4728 * backwards compatibility with version 3.0
4729 */
4730 else if ( *arg == '>'
4731 && (varp == (char_u *)&p_dir
4732 || varp == (char_u *)&p_bdir))
4733 {
4734 ++arg;
4735 }
4736
4737 /* When setting the local value of a global
4738 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004739 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004740 && (opt_flags & OPT_LOCAL))
4741 origval = *(char_u **)get_varp(
4742 &options[opt_idx]);
4743 else
4744 origval = oldval;
4745
4746 /*
4747 * Copy the new string into allocated memory.
4748 * Can't use set_string_option_direct(), because
4749 * we need to remove the backslashes.
4750 */
4751 /* get a bit too much */
4752 newlen = (unsigned)STRLEN(arg) + 1;
4753 if (adding || prepending || removing)
4754 newlen += (unsigned)STRLEN(origval) + 1;
4755 newval = alloc(newlen);
4756 if (newval == NULL) /* out of mem, don't change */
4757 break;
4758 s = newval;
4759
4760 /*
4761 * Copy the string, skip over escaped chars.
4762 * For MS-DOS and WIN32 backslashes before normal
4763 * file name characters are not removed, and keep
4764 * backslash at start, for "\\machine\path", but
4765 * do remove it for "\\\\machine\\path".
4766 * The reverse is found in ExpandOldSetting().
4767 */
4768 while (*arg && !vim_iswhite(*arg))
4769 {
4770 if (*arg == '\\' && arg[1] != NUL
4771#ifdef BACKSLASH_IN_FILENAME
4772 && !((flags & P_EXPAND)
4773 && vim_isfilec(arg[1])
4774 && (arg[1] != '\\'
4775 || (s == newval
4776 && arg[2] != '\\')))
4777#endif
4778 )
4779 ++arg; /* remove backslash */
4780#ifdef FEAT_MBYTE
4781 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00004782 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004783 {
4784 /* copy multibyte char */
4785 mch_memmove(s, arg, (size_t)i);
4786 arg += i;
4787 s += i;
4788 }
4789 else
4790#endif
4791 *s++ = *arg++;
4792 }
4793 *s = NUL;
4794
4795 /*
4796 * Expand environment variables and ~.
4797 * Don't do it when adding without inserting a
4798 * comma.
4799 */
4800 if (!(adding || prepending || removing)
4801 || (flags & P_COMMA))
4802 {
4803 s = option_expand(opt_idx, newval);
4804 if (s != NULL)
4805 {
4806 vim_free(newval);
4807 newlen = (unsigned)STRLEN(s) + 1;
4808 if (adding || prepending || removing)
4809 newlen += (unsigned)STRLEN(origval) + 1;
4810 newval = alloc(newlen);
4811 if (newval == NULL)
4812 break;
4813 STRCPY(newval, s);
4814 }
4815 }
4816
4817 /* locate newval[] in origval[] when removing it
4818 * and when adding to avoid duplicates */
4819 i = 0; /* init for GCC */
4820 if (removing || (flags & P_NODUP))
4821 {
4822 i = (int)STRLEN(newval);
4823 bs = 0;
4824 for (s = origval; *s; ++s)
4825 {
4826 if ((!(flags & P_COMMA)
4827 || s == origval
4828 || (s[-1] == ',' && !(bs & 1)))
4829 && STRNCMP(s, newval, i) == 0
4830 && (!(flags & P_COMMA)
4831 || s[i] == ','
4832 || s[i] == NUL))
4833 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004834 /* Count backslashes. Only a comma with an
4835 * even number of backslashes before it is
Bram Moolenaar071d4272004-06-13 20:20:40 +00004836 * recognized as a separator */
4837 if (s > origval && s[-1] == '\\')
4838 ++bs;
4839 else
4840 bs = 0;
4841 }
4842
4843 /* do not add if already there */
4844 if ((adding || prepending) && *s)
4845 {
4846 prepending = FALSE;
4847 adding = FALSE;
4848 STRCPY(newval, origval);
4849 }
4850 }
4851
4852 /* concatenate the two strings; add a ',' if
4853 * needed */
4854 if (adding || prepending)
4855 {
4856 comma = ((flags & P_COMMA) && *origval != NUL
4857 && *newval != NUL);
4858 if (adding)
4859 {
4860 i = (int)STRLEN(origval);
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004861 /* strip a trailing comma, would get 2 */
Bram Moolenaar0e7c4b92015-06-20 15:30:03 +02004862 if (comma && (flags & P_ONECOMMA) && i > 1
4863 && origval[i - 1] == ','
Bram Moolenaara7b7b1c2015-06-19 14:06:43 +02004864 && origval[i - 2] != '\\')
4865 i--;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004866 mch_memmove(newval + i + comma, newval,
4867 STRLEN(newval) + 1);
4868 mch_memmove(newval, origval, (size_t)i);
4869 }
4870 else
4871 {
4872 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004873 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004874 }
4875 if (comma)
4876 newval[i] = ',';
4877 }
4878
4879 /* Remove newval[] from origval[]. (Note: "i" has
4880 * been set above and is used here). */
4881 if (removing)
4882 {
4883 STRCPY(newval, origval);
4884 if (*s)
4885 {
4886 /* may need to remove a comma */
4887 if (flags & P_COMMA)
4888 {
4889 if (s == origval)
4890 {
4891 /* include comma after string */
4892 if (s[i] == ',')
4893 ++i;
4894 }
4895 else
4896 {
4897 /* include comma before string */
4898 --s;
4899 ++i;
4900 }
4901 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004902 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004903 }
4904 }
4905
4906 if (flags & P_FLAGLIST)
4907 {
4908 /* Remove flags that appear twice. */
4909 for (s = newval; *s; ++s)
4910 if ((!(flags & P_COMMA) || *s != ',')
4911 && vim_strchr(s + 1, *s) != NULL)
4912 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004913 STRMOVE(s, s + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004914 --s;
4915 }
4916 }
4917
4918 if (save_arg != NULL) /* number for 'whichwrap' */
4919 arg = save_arg;
4920 new_value_alloced = TRUE;
4921 }
4922
4923 /* Set the new value. */
4924 *(char_u **)(varp) = newval;
4925
Bram Moolenaar53744302015-07-17 17:38:22 +02004926#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02004927 if (!starting
4928# ifdef FEAT_CRYPT
4929 && options[opt_idx].indir != PV_KEY
4930# endif
Bram Moolenaar53744302015-07-17 17:38:22 +02004931 && origval != NULL)
4932 /* origval may be freed by
4933 * did_set_string_option(), make a copy. */
4934 saved_origval = vim_strsave(origval);
4935#endif
4936
Bram Moolenaar071d4272004-06-13 20:20:40 +00004937 /* Handle side effects, and set the global value for
4938 * ":set" on local options. */
4939 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
4940 new_value_alloced, oldval, errbuf, opt_flags);
4941
4942 /* If error detected, print the error message. */
4943 if (errmsg != NULL)
4944 goto skip;
Bram Moolenaar53744302015-07-17 17:38:22 +02004945#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
4946 if (saved_origval != NULL)
4947 {
4948 char_u buf_type[7];
4949
4950 sprintf((char *)buf_type, "%s",
4951 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02004952 set_vim_var_string(VV_OPTION_NEW,
4953 *(char_u **)varp, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02004954 set_vim_var_string(VV_OPTION_OLD, saved_origval, -1);
4955 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
4956 apply_autocmds(EVENT_OPTIONSET,
4957 (char_u *)options[opt_idx].fullname,
4958 NULL, FALSE, NULL);
4959 reset_v_option_vars();
4960 vim_free(saved_origval);
4961 }
4962#endif
4963
Bram Moolenaar071d4272004-06-13 20:20:40 +00004964 }
4965 else /* key code option */
4966 {
4967 char_u *p;
4968
4969 if (nextchar == '&')
4970 {
4971 if (add_termcap_entry(key_name, TRUE) == FAIL)
4972 errmsg = (char_u *)N_("E522: Not found in termcap");
4973 }
4974 else
4975 {
4976 ++arg; /* jump to after the '=' or ':' */
4977 for (p = arg; *p && !vim_iswhite(*p); ++p)
4978 if (*p == '\\' && p[1] != NUL)
4979 ++p;
4980 nextchar = *p;
4981 *p = NUL;
4982 add_termcode(key_name, arg, FALSE);
4983 *p = nextchar;
4984 }
4985 if (full_screen)
4986 ttest(FALSE);
4987 redraw_all_later(CLEAR);
4988 }
4989 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004990
Bram Moolenaar071d4272004-06-13 20:20:40 +00004991 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004992 did_set_option(opt_idx, opt_flags,
4993 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004994 }
4995
4996skip:
4997 /*
4998 * Advance to next argument.
4999 * - skip until a blank found, taking care of backslashes
5000 * - skip blanks
5001 * - skip one "=val" argument (for hidden options ":set gfn =xx")
5002 */
5003 for (i = 0; i < 2 ; ++i)
5004 {
5005 while (*arg != NUL && !vim_iswhite(*arg))
5006 if (*arg++ == '\\' && *arg != NUL)
5007 ++arg;
5008 arg = skipwhite(arg);
5009 if (*arg != '=')
5010 break;
5011 }
5012 }
5013
5014 if (errmsg != NULL)
5015 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00005016 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005017 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005018 if (i + (arg - startarg) < IOSIZE)
5019 {
5020 /* append the argument with the error */
5021 STRCAT(IObuff, ": ");
5022 mch_memmove(IObuff + i, startarg, (arg - startarg));
5023 IObuff[i + (arg - startarg)] = NUL;
5024 }
5025 /* make sure all characters are printable */
5026 trans_characters(IObuff, IOSIZE);
5027
5028 ++no_wait_return; /* wait_return done later */
5029 emsg(IObuff); /* show error highlighted */
5030 --no_wait_return;
5031
5032 return FAIL;
5033 }
5034
5035 arg = skipwhite(arg);
5036 }
5037
Bram Moolenaar26a60b42005-02-22 08:49:11 +00005038theend:
5039 if (silent_mode && did_show)
5040 {
5041 /* After displaying option values in silent mode. */
5042 silent_mode = FALSE;
5043 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
5044 msg_putchar('\n');
5045 cursor_on(); /* msg_start() switches it off */
5046 out_flush();
5047 silent_mode = TRUE;
5048 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
5049 }
5050
Bram Moolenaar071d4272004-06-13 20:20:40 +00005051 return OK;
5052}
5053
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005054/*
5055 * Call this when an option has been given a new value through a user command.
5056 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
5057 */
5058 static void
5059did_set_option(opt_idx, opt_flags, new_value)
5060 int opt_idx;
5061 int opt_flags; /* possibly with OPT_MODELINE */
5062 int new_value; /* value was replaced completely */
5063{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005064 long_u *p;
5065
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005066 options[opt_idx].flags |= P_WAS_SET;
5067
5068 /* When an option is set in the sandbox, from a modeline or in secure mode
5069 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005070 * flag. */
5071 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005072 if (secure
5073#ifdef HAVE_SANDBOX
5074 || sandbox != 0
5075#endif
5076 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005077 *p = *p | P_INSECURE;
5078 else if (new_value)
5079 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005080}
5081
Bram Moolenaar071d4272004-06-13 20:20:40 +00005082 static char_u *
5083illegal_char(errbuf, c)
5084 char_u *errbuf;
5085 int c;
5086{
5087 if (errbuf == NULL)
5088 return (char_u *)"";
5089 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005090 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005091 return errbuf;
5092}
5093
5094/*
5095 * Convert a key name or string into a key value.
5096 * Used for 'wildchar' and 'cedit' options.
5097 */
5098 static int
5099string_to_key(arg)
5100 char_u *arg;
5101{
5102 if (*arg == '<')
5103 return find_key_option(arg + 1);
5104 if (*arg == '^')
5105 return Ctrl_chr(arg[1]);
5106 return *arg;
5107}
5108
5109#ifdef FEAT_CMDWIN
5110/*
5111 * Check value of 'cedit' and set cedit_key.
5112 * Returns NULL if value is OK, error message otherwise.
5113 */
5114 static char_u *
5115check_cedit()
5116{
5117 int n;
5118
5119 if (*p_cedit == NUL)
5120 cedit_key = -1;
5121 else
5122 {
5123 n = string_to_key(p_cedit);
5124 if (vim_isprintc(n))
5125 return e_invarg;
5126 cedit_key = n;
5127 }
5128 return NULL;
5129}
5130#endif
5131
5132#ifdef FEAT_TITLE
5133/*
5134 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5135 * maketitle() to create and display it.
5136 * When switching the title or icon off, call mch_restore_title() to get
5137 * the old value back.
5138 */
5139 static void
5140did_set_title(icon)
5141 int icon; /* Did set icon instead of title */
5142{
5143 if (starting != NO_SCREEN
5144#ifdef FEAT_GUI
5145 && !gui.starting
5146#endif
5147 )
5148 {
5149 maketitle();
5150 if (icon)
5151 {
5152 if (!p_icon)
5153 mch_restore_title(2);
5154 }
5155 else
5156 {
5157 if (!p_title)
5158 mch_restore_title(1);
5159 }
5160 }
5161}
5162#endif
5163
5164/*
5165 * set_options_bin - called when 'bin' changes value.
5166 */
5167 void
5168set_options_bin(oldval, newval, opt_flags)
5169 int oldval;
5170 int newval;
5171 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5172{
5173 /*
5174 * The option values that are changed when 'bin' changes are
5175 * copied when 'bin is set and restored when 'bin' is reset.
5176 */
5177 if (newval)
5178 {
5179 if (!oldval) /* switched on */
5180 {
5181 if (!(opt_flags & OPT_GLOBAL))
5182 {
5183 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5184 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5185 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5186 curbuf->b_p_et_nobin = curbuf->b_p_et;
5187 }
5188 if (!(opt_flags & OPT_LOCAL))
5189 {
5190 p_tw_nobin = p_tw;
5191 p_wm_nobin = p_wm;
5192 p_ml_nobin = p_ml;
5193 p_et_nobin = p_et;
5194 }
5195 }
5196
5197 if (!(opt_flags & OPT_GLOBAL))
5198 {
5199 curbuf->b_p_tw = 0; /* no automatic line wrap */
5200 curbuf->b_p_wm = 0; /* no automatic line wrap */
5201 curbuf->b_p_ml = 0; /* no modelines */
5202 curbuf->b_p_et = 0; /* no expandtab */
5203 }
5204 if (!(opt_flags & OPT_LOCAL))
5205 {
5206 p_tw = 0;
5207 p_wm = 0;
5208 p_ml = FALSE;
5209 p_et = FALSE;
5210 p_bin = TRUE; /* needed when called for the "-b" argument */
5211 }
5212 }
5213 else if (oldval) /* switched off */
5214 {
5215 if (!(opt_flags & OPT_GLOBAL))
5216 {
5217 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5218 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5219 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5220 curbuf->b_p_et = curbuf->b_p_et_nobin;
5221 }
5222 if (!(opt_flags & OPT_LOCAL))
5223 {
5224 p_tw = p_tw_nobin;
5225 p_wm = p_wm_nobin;
5226 p_ml = p_ml_nobin;
5227 p_et = p_et_nobin;
5228 }
5229 }
5230}
5231
5232#ifdef FEAT_VIMINFO
5233/*
5234 * Find the parameter represented by the given character (eg ', :, ", or /),
5235 * and return its associated value in the 'viminfo' string.
5236 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005237 * If the parameter is not specified in the string or there is no following
5238 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005239 */
5240 int
5241get_viminfo_parameter(type)
5242 int type;
5243{
5244 char_u *p;
5245
5246 p = find_viminfo_parameter(type);
5247 if (p != NULL && VIM_ISDIGIT(*p))
5248 return atoi((char *)p);
5249 return -1;
5250}
5251
5252/*
5253 * Find the parameter represented by the given character (eg ''', ':', '"', or
5254 * '/') in the 'viminfo' option and return a pointer to the string after it.
5255 * Return NULL if the parameter is not specified in the string.
5256 */
5257 char_u *
5258find_viminfo_parameter(type)
5259 int type;
5260{
5261 char_u *p;
5262
5263 for (p = p_viminfo; *p; ++p)
5264 {
5265 if (*p == type)
5266 return p + 1;
5267 if (*p == 'n') /* 'n' is always the last one */
5268 break;
5269 p = vim_strchr(p, ','); /* skip until next ',' */
5270 if (p == NULL) /* hit the end without finding parameter */
5271 break;
5272 }
5273 return NULL;
5274}
5275#endif
5276
5277/*
5278 * Expand environment variables for some string options.
5279 * These string options cannot be indirect!
5280 * If "val" is NULL expand the current value of the option.
5281 * Return pointer to NameBuff, or NULL when not expanded.
5282 */
5283 static char_u *
5284option_expand(opt_idx, val)
5285 int opt_idx;
5286 char_u *val;
5287{
5288 /* if option doesn't need expansion nothing to do */
5289 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5290 return NULL;
5291
5292 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5293 * expand_env() would truncate the string. */
5294 if (val != NULL && STRLEN(val) > MAXPATHL)
5295 return NULL;
5296
5297 if (val == NULL)
5298 val = *(char_u **)options[opt_idx].var;
5299
5300 /*
5301 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5302 * Escape spaces when expanding 'tags', they are used to separate file
5303 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005304 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005305 */
5306 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005307 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005308#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005309 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5310#endif
5311 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005312 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5313 return NULL;
5314
5315 return NameBuff;
5316}
5317
5318/*
5319 * After setting various option values: recompute variables that depend on
5320 * option values.
5321 */
5322 static void
5323didset_options()
5324{
5325 /* initialize the table for 'iskeyword' et.al. */
5326 (void)init_chartab();
5327
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005328#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005329 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005330#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005331 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
Bram Moolenaar165bc692015-07-21 17:53:25 +02005332 (void)opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005333#ifdef FEAT_SESSION
5334 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5335 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5336#endif
5337#ifdef FEAT_FOLDING
5338 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5339#endif
5340 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
5341#ifdef FEAT_VIRTUALEDIT
5342 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5343#endif
5344#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5345 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5346#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005347#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005348 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005349 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005350 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005351#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005352#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5353 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5354#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005355#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005356 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5357#endif
5358#ifdef FEAT_CMDWIN
5359 /* set cedit_key */
5360 (void)check_cedit();
5361#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +02005362#ifdef FEAT_LINEBREAK
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005363 briopt_check(curwin);
Bram Moolenaar597a4222014-06-25 14:39:50 +02005364#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005365}
5366
5367/*
5368 * Check for string options that are NULL (normally only termcap options).
5369 */
5370 void
5371check_options()
5372{
5373 int opt_idx;
5374
5375 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5376 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5377 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5378}
5379
5380/*
5381 * Check string options in a buffer for NULL value.
5382 */
5383 void
5384check_buf_options(buf)
5385 buf_T *buf;
5386{
5387#if defined(FEAT_QUICKFIX)
5388 check_string_option(&buf->b_p_bh);
5389 check_string_option(&buf->b_p_bt);
5390#endif
5391#ifdef FEAT_MBYTE
5392 check_string_option(&buf->b_p_fenc);
5393#endif
5394 check_string_option(&buf->b_p_ff);
5395#ifdef FEAT_FIND_ID
5396 check_string_option(&buf->b_p_def);
5397 check_string_option(&buf->b_p_inc);
5398# ifdef FEAT_EVAL
5399 check_string_option(&buf->b_p_inex);
5400# endif
5401#endif
5402#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5403 check_string_option(&buf->b_p_inde);
5404 check_string_option(&buf->b_p_indk);
5405#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005406#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5407 check_string_option(&buf->b_p_bexpr);
5408#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005409#if defined(FEAT_CRYPT)
5410 check_string_option(&buf->b_p_cm);
5411#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005412#if defined(FEAT_EVAL)
5413 check_string_option(&buf->b_p_fex);
5414#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005415#ifdef FEAT_CRYPT
5416 check_string_option(&buf->b_p_key);
5417#endif
5418 check_string_option(&buf->b_p_kp);
5419 check_string_option(&buf->b_p_mps);
5420 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005421 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005422 check_string_option(&buf->b_p_isk);
5423#ifdef FEAT_COMMENTS
5424 check_string_option(&buf->b_p_com);
5425#endif
5426#ifdef FEAT_FOLDING
5427 check_string_option(&buf->b_p_cms);
5428#endif
5429 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005430#ifdef FEAT_TEXTOBJ
5431 check_string_option(&buf->b_p_qe);
5432#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005433#ifdef FEAT_SYN_HL
5434 check_string_option(&buf->b_p_syn);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005435#endif
5436#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005437 check_string_option(&buf->b_s.b_p_spc);
5438 check_string_option(&buf->b_s.b_p_spf);
5439 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005440#endif
5441#ifdef FEAT_SEARCHPATH
5442 check_string_option(&buf->b_p_sua);
5443#endif
5444#ifdef FEAT_CINDENT
5445 check_string_option(&buf->b_p_cink);
5446 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005447 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005448#endif
5449#ifdef FEAT_AUTOCMD
5450 check_string_option(&buf->b_p_ft);
5451#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005452#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5453 check_string_option(&buf->b_p_cinw);
5454#endif
5455#ifdef FEAT_INS_EXPAND
5456 check_string_option(&buf->b_p_cpt);
5457#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005458#ifdef FEAT_COMPL_FUNC
5459 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005460 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005461#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005462#ifdef FEAT_KEYMAP
5463 check_string_option(&buf->b_p_keymap);
5464#endif
5465#ifdef FEAT_QUICKFIX
5466 check_string_option(&buf->b_p_gp);
5467 check_string_option(&buf->b_p_mp);
5468 check_string_option(&buf->b_p_efm);
5469#endif
5470 check_string_option(&buf->b_p_ep);
5471 check_string_option(&buf->b_p_path);
5472 check_string_option(&buf->b_p_tags);
5473#ifdef FEAT_INS_EXPAND
5474 check_string_option(&buf->b_p_dict);
5475 check_string_option(&buf->b_p_tsr);
5476#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +01005477#ifdef FEAT_LISP
5478 check_string_option(&buf->b_p_lw);
5479#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005480 check_string_option(&buf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005481}
5482
5483/*
5484 * Free the string allocated for an option.
5485 * Checks for the string being empty_option. This may happen if we're out of
5486 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5487 * check_options().
5488 * Does NOT check for P_ALLOCED flag!
5489 */
5490 void
5491free_string_option(p)
5492 char_u *p;
5493{
5494 if (p != empty_option)
5495 vim_free(p);
5496}
5497
5498 void
5499clear_string_option(pp)
5500 char_u **pp;
5501{
5502 if (*pp != empty_option)
5503 vim_free(*pp);
5504 *pp = empty_option;
5505}
5506
5507 static void
5508check_string_option(pp)
5509 char_u **pp;
5510{
5511 if (*pp == NULL)
5512 *pp = empty_option;
5513}
5514
5515/*
5516 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5517 */
5518 void
5519set_term_option_alloced(p)
5520 char_u **p;
5521{
5522 int opt_idx;
5523
5524 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5525 if (options[opt_idx].var == (char_u *)p)
5526 {
5527 options[opt_idx].flags |= P_ALLOCED;
5528 return;
5529 }
5530 return; /* cannot happen: didn't find it! */
5531}
5532
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005533#if defined(FEAT_EVAL) || defined(PROTO)
5534/*
5535 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5536 * Return FALSE when it wasn't.
5537 * Return -1 for an unknown option.
5538 */
5539 int
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005540was_set_insecurely(opt, opt_flags)
5541 char_u *opt;
5542 int opt_flags;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005543{
5544 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005545 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005546
5547 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005548 {
5549 flagp = insecure_flag(idx, opt_flags);
5550 return (*flagp & P_INSECURE) != 0;
5551 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005552 EMSG2(_(e_intern2), "was_set_insecurely()");
5553 return -1;
5554}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005555
5556/*
5557 * Get a pointer to the flags used for the P_INSECURE flag of option
5558 * "opt_idx". For some local options a local flags field is used.
5559 */
5560 static long_u *
5561insecure_flag(opt_idx, opt_flags)
5562 int opt_idx;
5563 int opt_flags;
5564{
5565 if (opt_flags & OPT_LOCAL)
5566 switch ((int)options[opt_idx].indir)
5567 {
5568#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005569 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005570#endif
5571#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005572# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005573 case PV_FDE: return &curwin->w_p_fde_flags;
5574 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005575# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005576# ifdef FEAT_BEVAL
5577 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5578# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005579# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005580 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005581# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005582 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005583# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005584 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005585# endif
5586#endif
5587 }
5588
5589 /* Nothing special, return global flags field. */
5590 return &options[opt_idx].flags;
5591}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005592#endif
5593
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005594#ifdef FEAT_TITLE
5595static void redraw_titles __ARGS((void));
5596
5597/*
5598 * Redraw the window title and/or tab page text later.
5599 */
5600static void redraw_titles()
5601{
5602 need_maketitle = TRUE;
5603# ifdef FEAT_WINDOWS
5604 redraw_tabline = TRUE;
5605# endif
5606}
5607#endif
5608
Bram Moolenaar071d4272004-06-13 20:20:40 +00005609/*
5610 * Set a string option to a new value (without checking the effect).
5611 * The string is copied into allocated memory.
5612 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005613 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005614 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005615 */
5616 void
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005617set_string_option_direct(name, opt_idx, val, opt_flags, set_sid)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005618 char_u *name;
5619 int opt_idx;
5620 char_u *val;
5621 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar78a15312009-05-15 19:33:18 +00005622 int set_sid UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005623{
5624 char_u *s;
5625 char_u **varp;
5626 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005627 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005628
Bram Moolenaar89d40322006-08-29 15:30:07 +00005629 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005630 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005631 idx = findoption(name);
5632 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005633 {
5634 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar0b105412014-11-30 13:34:23 +01005635 EMSG2(_("For option %s"), name);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005636 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005637 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005638 }
5639
Bram Moolenaar89d40322006-08-29 15:30:07 +00005640 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005641 return;
5642
5643 s = vim_strsave(val);
5644 if (s != NULL)
5645 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005646 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005647 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005648 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005649 free_string_option(*varp);
5650 *varp = s;
5651
5652 /* For buffer/window local option may also set the global value. */
5653 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005654 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005655
Bram Moolenaar89d40322006-08-29 15:30:07 +00005656 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005657
5658 /* When setting both values of a global option with a local value,
5659 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005660 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005661 {
5662 free_string_option(*varp);
5663 *varp = empty_option;
5664 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005665# ifdef FEAT_EVAL
5666 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005667 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005668 set_sid == 0 ? current_SID : set_sid);
5669# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005670 }
5671}
5672
5673/*
5674 * Set global value for string option when it's a local option.
5675 */
5676 static void
5677set_string_option_global(opt_idx, varp)
5678 int opt_idx; /* option index */
5679 char_u **varp; /* pointer to option variable */
5680{
5681 char_u **p, *s;
5682
5683 /* the global value is always allocated */
5684 if (options[opt_idx].var == VAR_WIN)
5685 p = (char_u **)GLOBAL_WO(varp);
5686 else
5687 p = (char_u **)options[opt_idx].var;
5688 if (options[opt_idx].indir != PV_NONE
5689 && p != varp
5690 && (s = vim_strsave(*varp)) != NULL)
5691 {
5692 free_string_option(*p);
5693 *p = s;
5694 }
5695}
5696
5697/*
5698 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005699 *
5700 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005701 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005702 static char_u *
Bram Moolenaar071d4272004-06-13 20:20:40 +00005703set_string_option(opt_idx, value, opt_flags)
5704 int opt_idx;
5705 char_u *value;
5706 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5707{
5708 char_u *s;
5709 char_u **varp;
5710 char_u *oldval;
Bram Moolenaar53744302015-07-17 17:38:22 +02005711#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5712 char_u *saved_oldval = NULL;
5713#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005714 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005715
5716 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005717 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005718
5719 s = vim_strsave(value);
5720 if (s != NULL)
5721 {
5722 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5723 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005724 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005725 ? OPT_GLOBAL : OPT_LOCAL)
5726 : opt_flags);
5727 oldval = *varp;
5728 *varp = s;
Bram Moolenaar53744302015-07-17 17:38:22 +02005729
5730#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
Bram Moolenaar5cbb8db2015-07-17 23:08:29 +02005731 if (!starting
5732# ifdef FEAT_CRYPT
5733 && options[opt_idx].indir != PV_KEY
5734# endif
5735 )
Bram Moolenaar53744302015-07-17 17:38:22 +02005736 saved_oldval = vim_strsave(oldval);
5737#endif
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005738 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5739 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005740 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar53744302015-07-17 17:38:22 +02005741
5742 /* call autocomamnd after handling side effects */
5743#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
5744 if (saved_oldval != NULL)
5745 {
5746 char_u buf_type[7];
5747 sprintf((char *)buf_type, "%s",
5748 (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar9cac4242015-07-19 14:42:23 +02005749 set_vim_var_string(VV_OPTION_NEW, *varp, -1);
5750 set_vim_var_string(VV_OPTION_OLD, saved_oldval, -1);
Bram Moolenaar53744302015-07-17 17:38:22 +02005751 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
5752 apply_autocmds(EVENT_OPTIONSET, (char_u *)options[opt_idx].fullname, NULL, FALSE, NULL);
5753 reset_v_option_vars();
5754 vim_free(saved_oldval);
5755 }
5756#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005757 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005758 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005759}
5760
5761/*
5762 * Handle string options that need some action to perform when changed.
5763 * Returns NULL for success, or an error message for an error.
5764 */
5765 static char_u *
5766did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
5767 opt_flags)
5768 int opt_idx; /* index in options[] table */
5769 char_u **varp; /* pointer to the option variable */
5770 int new_value_alloced; /* new value was allocated */
5771 char_u *oldval; /* previous value of the option */
5772 char_u *errbuf; /* buffer for errors, or NULL */
5773 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5774{
5775 char_u *errmsg = NULL;
5776 char_u *s, *p;
5777 int did_chartab = FALSE;
5778 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005779 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00005780#ifdef FEAT_GUI
5781 /* set when changing an option that only requires a redraw in the GUI */
5782 int redraw_gui_only = FALSE;
5783#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005784
5785 /* Get the global option to compare with, otherwise we would have to check
5786 * two values for all local options. */
5787 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
5788
5789 /* Disallow changing some options from secure mode */
5790 if ((secure
5791#ifdef HAVE_SANDBOX
5792 || sandbox != 0
5793#endif
5794 ) && (options[opt_idx].flags & P_SECURE))
5795 {
5796 errmsg = e_secure;
5797 }
5798
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005799 /* Check for a "normal" file name in some options. Disallow a path
5800 * separator (slash and/or backslash), wildcards and characters that are
5801 * often illegal in a file name. */
5802 else if ((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005803 && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL)
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005804 {
5805 errmsg = e_invarg;
5806 }
5807
Bram Moolenaar071d4272004-06-13 20:20:40 +00005808 /* 'term' */
5809 else if (varp == &T_NAME)
5810 {
5811 if (T_NAME[0] == NUL)
5812 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
5813#ifdef FEAT_GUI
5814 if (gui.in_use)
5815 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
5816 else if (term_is_gui(T_NAME))
5817 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
5818#endif
5819 else if (set_termname(T_NAME) == FAIL)
5820 errmsg = (char_u *)N_("E522: Not found in termcap");
5821 else
5822 /* Screen colors may have changed. */
5823 redraw_later_clear();
5824 }
5825
5826 /* 'backupcopy' */
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005827 else if (gvarp == &p_bkc)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005828 {
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02005829 char_u *bkc = p_bkc;
5830 unsigned int *flags = &bkc_flags;
5831
5832 if (opt_flags & OPT_LOCAL)
5833 {
5834 bkc = curbuf->b_p_bkc;
5835 flags = &curbuf->b_bkc_flags;
5836 }
5837
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005838 if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
5839 /* make the local value empty: use the global value */
5840 *flags = 0;
5841 else
Bram Moolenaar071d4272004-06-13 20:20:40 +00005842 {
Bram Moolenaar84d17a62014-09-29 17:15:18 +02005843 if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
5844 errmsg = e_invarg;
5845 if ((((int)*flags & BKC_AUTO) != 0)
5846 + (((int)*flags & BKC_YES) != 0)
5847 + (((int)*flags & BKC_NO) != 0) != 1)
5848 {
5849 /* Must have exactly one of "auto", "yes" and "no". */
5850 (void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
5851 errmsg = e_invarg;
5852 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005853 }
5854 }
5855
5856 /* 'backupext' and 'patchmode' */
5857 else if (varp == &p_bex || varp == &p_pm)
5858 {
5859 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
5860 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
5861 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
5862 }
Bram Moolenaar597a4222014-06-25 14:39:50 +02005863#ifdef FEAT_LINEBREAK
5864 /* 'breakindentopt' */
5865 else if (varp == &curwin->w_p_briopt)
5866 {
Bram Moolenaar285ed7e2014-08-24 21:39:49 +02005867 if (briopt_check(curwin) == FAIL)
Bram Moolenaar597a4222014-06-25 14:39:50 +02005868 errmsg = e_invarg;
5869 }
5870#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005871
5872 /*
5873 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[]
5874 * If the new option is invalid, use old value. 'lisp' option: refill
5875 * chartab[] for '-' char
5876 */
5877 else if ( varp == &p_isi
5878 || varp == &(curbuf->b_p_isk)
5879 || varp == &p_isp
5880 || varp == &p_isf)
5881 {
5882 if (init_chartab() == FAIL)
5883 {
5884 did_chartab = TRUE; /* need to restore it below */
5885 errmsg = e_invarg; /* error in value */
5886 }
5887 }
5888
5889 /* 'helpfile' */
5890 else if (varp == &p_hf)
5891 {
5892 /* May compute new values for $VIM and $VIMRUNTIME */
5893 if (didset_vim)
5894 {
5895 vim_setenv((char_u *)"VIM", (char_u *)"");
5896 didset_vim = FALSE;
5897 }
5898 if (didset_vimruntime)
5899 {
5900 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
5901 didset_vimruntime = FALSE;
5902 }
5903 }
5904
Bram Moolenaar1a384422010-07-14 19:53:30 +02005905#ifdef FEAT_SYN_HL
5906 /* 'colorcolumn' */
5907 else if (varp == &curwin->w_p_cc)
5908 errmsg = check_colorcolumn(curwin);
5909#endif
5910
Bram Moolenaar071d4272004-06-13 20:20:40 +00005911#ifdef FEAT_MULTI_LANG
5912 /* 'helplang' */
5913 else if (varp == &p_hlg)
5914 {
5915 /* Check for "", "ab", "ab,cd", etc. */
5916 for (s = p_hlg; *s != NUL; s += 3)
5917 {
5918 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
5919 {
5920 errmsg = e_invarg;
5921 break;
5922 }
5923 if (s[2] == NUL)
5924 break;
5925 }
5926 }
5927#endif
5928
5929 /* 'highlight' */
5930 else if (varp == &p_hl)
5931 {
5932 if (highlight_changed() == FAIL)
5933 errmsg = e_invarg; /* invalid flags */
5934 }
5935
5936 /* 'nrformats' */
5937 else if (gvarp == &p_nf)
5938 {
5939 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
5940 errmsg = e_invarg;
5941 }
5942
5943#ifdef FEAT_SESSION
5944 /* 'sessionoptions' */
5945 else if (varp == &p_ssop)
5946 {
5947 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
5948 errmsg = e_invarg;
5949 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
5950 {
5951 /* Don't allow both "sesdir" and "curdir". */
5952 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
5953 errmsg = e_invarg;
5954 }
5955 }
5956 /* 'viewoptions' */
5957 else if (varp == &p_vop)
5958 {
5959 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
5960 errmsg = e_invarg;
5961 }
5962#endif
5963
5964 /* 'scrollopt' */
5965#ifdef FEAT_SCROLLBIND
5966 else if (varp == &p_sbo)
5967 {
5968 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
5969 errmsg = e_invarg;
5970 }
5971#endif
5972
5973 /* 'ambiwidth' */
5974#ifdef FEAT_MBYTE
5975 else if (varp == &p_ambw)
5976 {
5977 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
5978 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02005979 else if (set_chars_option(&p_lcs) != NULL)
5980 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
5981# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5982 else if (set_chars_option(&p_fcs) != NULL)
5983 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
5984# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005985 }
5986#endif
5987
5988 /* 'background' */
5989 else if (varp == &p_bg)
5990 {
5991 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
5992 {
5993#ifdef FEAT_EVAL
5994 int dark = (*p_bg == 'd');
5995#endif
5996
5997 init_highlight(FALSE, FALSE);
5998
5999#ifdef FEAT_EVAL
6000 if (dark != (*p_bg == 'd')
6001 && get_var_value((char_u *)"g:colors_name") != NULL)
6002 {
6003 /* The color scheme must have set 'background' back to another
6004 * value, that's not what we want here. Disable the color
6005 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00006006 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006007 free_string_option(p_bg);
6008 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
6009 check_string_option(&p_bg);
6010 init_highlight(FALSE, FALSE);
6011 }
6012#endif
6013 }
6014 else
6015 errmsg = e_invarg;
6016 }
6017
6018 /* 'wildmode' */
6019 else if (varp == &p_wim)
6020 {
6021 if (check_opt_wim() == FAIL)
6022 errmsg = e_invarg;
6023 }
6024
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006025#ifdef FEAT_CMDL_COMPL
6026 /* 'wildoptions' */
6027 else if (varp == &p_wop)
6028 {
6029 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
6030 errmsg = e_invarg;
6031 }
6032#endif
6033
Bram Moolenaar071d4272004-06-13 20:20:40 +00006034#ifdef FEAT_WAK
6035 /* 'winaltkeys' */
6036 else if (varp == &p_wak)
6037 {
6038 if (*p_wak == NUL
6039 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
6040 errmsg = e_invarg;
6041# ifdef FEAT_MENU
6042# ifdef FEAT_GUI_MOTIF
6043 else if (gui.in_use)
6044 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6045# else
6046# ifdef FEAT_GUI_GTK
6047 else if (gui.in_use)
6048 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
6049# endif
6050# endif
6051# endif
6052 }
6053#endif
6054
6055#ifdef FEAT_AUTOCMD
6056 /* 'eventignore' */
6057 else if (varp == &p_ei)
6058 {
6059 if (check_ei() == FAIL)
6060 errmsg = e_invarg;
6061 }
6062#endif
6063
6064#ifdef FEAT_MBYTE
6065 /* 'encoding' and 'fileencoding' */
6066 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc)
6067 {
6068 if (gvarp == &p_fenc)
6069 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00006070 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006071 errmsg = e_modifiable;
6072 else if (vim_strchr(*varp, ',') != NULL)
6073 /* No comma allowed in 'fileencoding'; catches confusing it
6074 * with 'fileencodings'. */
6075 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006076 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006077 {
6078# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006079 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006080 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006081# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006082 /* Add 'fileencoding' to the swap file. */
6083 ml_setflags(curbuf);
6084 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006085 }
6086 if (errmsg == NULL)
6087 {
6088 /* canonize the value, so that STRCMP() can be used on it */
6089 p = enc_canonize(*varp);
6090 if (p != NULL)
6091 {
6092 vim_free(*varp);
6093 *varp = p;
6094 }
6095 if (varp == &p_enc)
6096 {
6097 errmsg = mb_init();
6098# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006099 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006100# endif
6101 }
6102 }
6103
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006104# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006105 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
6106 {
6107 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
6108 if (STRCMP(p_tenc, "utf-8") != 0)
6109 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
6110 }
6111# endif
6112
6113 if (errmsg == NULL)
6114 {
6115# ifdef FEAT_KEYMAP
6116 /* When 'keymap' is used and 'encoding' changes, reload the keymap
6117 * (with another encoding). */
6118 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6119 (void)keymap_init();
6120# endif
6121
6122 /* When 'termencoding' is not empty and 'encoding' changes or when
6123 * 'termencoding' changes, need to setup for keyboard input and
6124 * display output conversion. */
6125 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6126 {
6127 convert_setup(&input_conv, p_tenc, p_enc);
6128 convert_setup(&output_conv, p_enc, p_tenc);
6129 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006130
6131# if defined(WIN3264) && defined(FEAT_MBYTE)
6132 /* $HOME may have characters in active code page. */
6133 if (varp == &p_enc)
6134 init_homedir();
6135# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006136 }
6137 }
6138#endif
6139
6140#if defined(FEAT_POSTSCRIPT)
6141 else if (varp == &p_penc)
6142 {
6143 /* Canonize printencoding if VIM standard one */
6144 p = enc_canonize(p_penc);
6145 if (p != NULL)
6146 {
6147 vim_free(p_penc);
6148 p_penc = p;
6149 }
6150 else
6151 {
6152 /* Ensure lower case and '-' for '_' */
6153 for (s = p_penc; *s != NUL; s++)
6154 {
6155 if (*s == '_')
6156 *s = '-';
6157 else
6158 *s = TOLOWER_ASC(*s);
6159 }
6160 }
6161 }
6162#endif
6163
Bram Moolenaar9372a112005-12-06 19:59:18 +00006164#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006165 else if (varp == &p_imak)
6166 {
6167 if (gui.in_use && !im_xim_isvalid_imactivate())
6168 errmsg = e_invarg;
6169 }
6170#endif
6171
6172#ifdef FEAT_KEYMAP
6173 else if (varp == &curbuf->b_p_keymap)
6174 {
6175 /* load or unload key mapping tables */
6176 errmsg = keymap_init();
6177
Bram Moolenaarfab06232009-03-04 03:13:35 +00006178 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006179 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006180 if (*curbuf->b_p_keymap != NUL)
6181 {
6182 /* Installed a new keymap, switch on using it. */
6183 curbuf->b_p_iminsert = B_IMODE_LMAP;
6184 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6185 curbuf->b_p_imsearch = B_IMODE_LMAP;
6186 }
6187 else
6188 {
6189 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6190 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6191 curbuf->b_p_iminsert = B_IMODE_NONE;
6192 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6193 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6194 }
6195 if ((opt_flags & OPT_LOCAL) == 0)
6196 {
6197 set_iminsert_global();
6198 set_imsearch_global();
6199 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006200# ifdef FEAT_WINDOWS
6201 status_redraw_curbuf();
6202# endif
6203 }
6204 }
6205#endif
6206
6207 /* 'fileformat' */
6208 else if (gvarp == &p_ff)
6209 {
6210 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6211 errmsg = e_modifiable;
6212 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6213 errmsg = e_invarg;
6214 else
6215 {
6216 /* may also change 'textmode' */
6217 if (get_fileformat(curbuf) == EOL_DOS)
6218 curbuf->b_p_tx = TRUE;
6219 else
6220 curbuf->b_p_tx = FALSE;
6221#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006222 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006223#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006224 /* update flag in swap file */
6225 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006226 /* Redraw needed when switching to/from "mac": a CR in the text
6227 * will be displayed differently. */
6228 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6229 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006230 }
6231 }
6232
6233 /* 'fileformats' */
6234 else if (varp == &p_ffs)
6235 {
6236 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6237 errmsg = e_invarg;
6238 else
6239 {
6240 /* also change 'textauto' */
6241 if (*p_ffs == NUL)
6242 p_ta = FALSE;
6243 else
6244 p_ta = TRUE;
6245 }
6246 }
6247
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006248#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006249 /* 'cryptkey' */
6250 else if (gvarp == &p_key)
6251 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006252# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006253 /* Make sure the ":set" command doesn't show the new value in the
6254 * history. */
6255 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006256# endif
6257 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6258 /* Need to update the swapfile. */
Bram Moolenaarbc563362015-06-09 18:35:25 +02006259 ml_set_crypt_key(curbuf, oldval,
6260 *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006261 }
6262
6263 else if (gvarp == &p_cm)
6264 {
6265 if (opt_flags & OPT_LOCAL)
6266 p = curbuf->b_p_cm;
6267 else
6268 p = p_cm;
6269 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6270 errmsg = e_invarg;
Bram Moolenaar8f4ac012014-08-10 13:38:34 +02006271 else if (crypt_self_test() == FAIL)
Bram Moolenaar49771f42010-07-20 17:32:38 +02006272 errmsg = e_invarg;
6273 else
6274 {
6275 /* When setting the global value to empty, make it "zip". */
6276 if (*p_cm == NUL)
6277 {
6278 if (new_value_alloced)
6279 free_string_option(p_cm);
6280 p_cm = vim_strsave((char_u *)"zip");
6281 new_value_alloced = TRUE;
6282 }
Bram Moolenaar2be79502014-08-13 21:58:28 +02006283 /* When using ":set cm=name" the local value is going to be empty.
6284 * Do that here, otherwise the crypt functions will still use the
6285 * local value. */
6286 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
6287 {
6288 free_string_option(curbuf->b_p_cm);
6289 curbuf->b_p_cm = empty_option;
6290 }
Bram Moolenaar49771f42010-07-20 17:32:38 +02006291
6292 /* Need to update the swapfile when the effective method changed.
6293 * Set "s" to the effective old value, "p" to the effective new
6294 * method and compare. */
6295 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6296 s = p_cm; /* was previously using the global value */
6297 else
6298 s = oldval;
6299 if (*curbuf->b_p_cm == NUL)
6300 p = p_cm; /* is now using the global value */
6301 else
6302 p = curbuf->b_p_cm;
6303 if (STRCMP(s, p) != 0)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006304 ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006305
6306 /* If the global value changes need to update the swapfile for all
6307 * buffers using that value. */
6308 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6309 {
6310 buf_T *buf;
6311
6312 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
6313 if (buf != curbuf && *buf->b_p_cm == NUL)
Bram Moolenaarbc563362015-06-09 18:35:25 +02006314 ml_set_crypt_key(buf, buf->b_p_key, oldval);
Bram Moolenaar49771f42010-07-20 17:32:38 +02006315 }
6316 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006317 }
6318#endif
6319
6320 /* 'matchpairs' */
6321 else if (gvarp == &p_mps)
6322 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006323#ifdef FEAT_MBYTE
6324 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006325 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006326 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006327 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006328 int x2 = -1;
6329 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006330
6331 if (*p != NUL)
6332 p += mb_ptr2len(p);
6333 if (*p != NUL)
6334 x2 = *p++;
6335 if (*p != NUL)
6336 {
6337 x3 = mb_ptr2char(p);
6338 p += mb_ptr2len(p);
6339 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006340 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006341 {
6342 errmsg = e_invarg;
6343 break;
6344 }
6345 if (*p == NUL)
6346 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006347 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006348 }
6349 else
6350#endif
6351 {
6352 /* Check for "x:y,x:y" */
6353 for (p = *varp; *p != NUL; p += 4)
6354 {
6355 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6356 {
6357 errmsg = e_invarg;
6358 break;
6359 }
6360 if (p[3] == NUL)
6361 break;
6362 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006363 }
6364 }
6365
6366#ifdef FEAT_COMMENTS
6367 /* 'comments' */
6368 else if (gvarp == &p_com)
6369 {
6370 for (s = *varp; *s; )
6371 {
6372 while (*s && *s != ':')
6373 {
6374 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6375 && !VIM_ISDIGIT(*s) && *s != '-')
6376 {
6377 errmsg = illegal_char(errbuf, *s);
6378 break;
6379 }
6380 ++s;
6381 }
6382 if (*s++ == NUL)
6383 errmsg = (char_u *)N_("E524: Missing colon");
6384 else if (*s == ',' || *s == NUL)
6385 errmsg = (char_u *)N_("E525: Zero length string");
6386 if (errmsg != NULL)
6387 break;
6388 while (*s && *s != ',')
6389 {
6390 if (*s == '\\' && s[1] != NUL)
6391 ++s;
6392 ++s;
6393 }
6394 s = skip_to_option_part(s);
6395 }
6396 }
6397#endif
6398
6399 /* 'listchars' */
6400 else if (varp == &p_lcs)
6401 {
6402 errmsg = set_chars_option(varp);
6403 }
6404
6405#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6406 /* 'fillchars' */
6407 else if (varp == &p_fcs)
6408 {
6409 errmsg = set_chars_option(varp);
6410 }
6411#endif
6412
6413#ifdef FEAT_CMDWIN
6414 /* 'cedit' */
6415 else if (varp == &p_cedit)
6416 {
6417 errmsg = check_cedit();
6418 }
6419#endif
6420
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006421 /* 'verbosefile' */
6422 else if (varp == &p_vfile)
6423 {
6424 verbose_stop();
6425 if (*p_vfile != NUL && verbose_open() == FAIL)
6426 errmsg = e_invarg;
6427 }
6428
Bram Moolenaar071d4272004-06-13 20:20:40 +00006429#ifdef FEAT_VIMINFO
6430 /* 'viminfo' */
6431 else if (varp == &p_viminfo)
6432 {
6433 for (s = p_viminfo; *s;)
6434 {
6435 /* Check it's a valid character */
6436 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6437 {
6438 errmsg = illegal_char(errbuf, *s);
6439 break;
6440 }
6441 if (*s == 'n') /* name is always last one */
6442 {
6443 break;
6444 }
6445 else if (*s == 'r') /* skip until next ',' */
6446 {
6447 while (*++s && *s != ',')
6448 ;
6449 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006450 else if (*s == '%')
6451 {
6452 /* optional number */
6453 while (vim_isdigit(*++s))
6454 ;
6455 }
6456 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006457 ++s; /* no extra chars */
6458 else /* must have a number */
6459 {
6460 while (vim_isdigit(*++s))
6461 ;
6462
6463 if (!VIM_ISDIGIT(*(s - 1)))
6464 {
6465 if (errbuf != NULL)
6466 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006467 sprintf((char *)errbuf,
6468 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006469 transchar_byte(*(s - 1)));
6470 errmsg = errbuf;
6471 }
6472 else
6473 errmsg = (char_u *)"";
6474 break;
6475 }
6476 }
6477 if (*s == ',')
6478 ++s;
6479 else if (*s)
6480 {
6481 if (errbuf != NULL)
6482 errmsg = (char_u *)N_("E527: Missing comma");
6483 else
6484 errmsg = (char_u *)"";
6485 break;
6486 }
6487 }
6488 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6489 errmsg = (char_u *)N_("E528: Must specify a ' value");
6490 }
6491#endif /* FEAT_VIMINFO */
6492
6493 /* terminal options */
6494 else if (istermoption(&options[opt_idx]) && full_screen)
6495 {
6496 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6497 if (varp == &T_CCO)
6498 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006499 int colors = atoi((char *)T_CCO);
6500
6501 /* Only reinitialize colors if t_Co value has really changed to
6502 * avoid expensive reload of colorscheme if t_Co is set to the
6503 * same value multiple times. */
6504 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006505 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006506 t_colors = colors;
6507 if (t_colors <= 1)
6508 {
6509 if (new_value_alloced)
6510 vim_free(T_CCO);
6511 T_CCO = empty_option;
6512 }
6513 /* We now have a different color setup, initialize it again. */
6514 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006515 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006516 }
6517 ttest(FALSE);
6518 if (varp == &T_ME)
6519 {
6520 out_str(T_ME);
6521 redraw_later(CLEAR);
6522#if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32))
6523 /* Since t_me has been set, this probably means that the user
6524 * wants to use this as default colors. Need to reset default
6525 * background/foreground colors. */
6526 mch_set_normal_colors();
6527#endif
6528 }
6529 }
6530
6531#ifdef FEAT_LINEBREAK
6532 /* 'showbreak' */
6533 else if (varp == &p_sbr)
6534 {
6535 for (s = p_sbr; *s; )
6536 {
6537 if (ptr2cells(s) != 1)
6538 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006539 mb_ptr_adv(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006540 }
6541 }
6542#endif
6543
6544#ifdef FEAT_GUI
6545 /* 'guifont' */
6546 else if (varp == &p_guifont)
6547 {
6548 if (gui.in_use)
6549 {
6550 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006551# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006552 /*
6553 * Put up a font dialog and let the user select a new value.
6554 * If this is cancelled go back to the old value but don't
6555 * give an error message.
6556 */
6557 if (STRCMP(p, "*") == 0)
6558 {
6559 p = gui_mch_font_dialog(oldval);
6560
6561 if (new_value_alloced)
6562 free_string_option(p_guifont);
6563
6564 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6565 new_value_alloced = TRUE;
6566 }
6567# endif
6568 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6569 {
6570# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6571 if (STRCMP(p_guifont, "*") == 0)
6572 {
6573 /* Dialog was cancelled: Keep the old value without giving
6574 * an error message. */
6575 if (new_value_alloced)
6576 free_string_option(p_guifont);
6577 p_guifont = vim_strsave(oldval);
6578 new_value_alloced = TRUE;
6579 }
6580 else
6581# endif
6582 errmsg = (char_u *)N_("E596: Invalid font(s)");
6583 }
6584 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006585 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006586 }
6587# ifdef FEAT_XFONTSET
6588 else if (varp == &p_guifontset)
6589 {
6590 if (STRCMP(p_guifontset, "*") == 0)
6591 errmsg = (char_u *)N_("E597: can't select fontset");
6592 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6593 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006594 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006595 }
6596# endif
6597# ifdef FEAT_MBYTE
6598 else if (varp == &p_guifontwide)
6599 {
6600 if (STRCMP(p_guifontwide, "*") == 0)
6601 errmsg = (char_u *)N_("E533: can't select wide font");
6602 else if (gui_get_wide_font() == FAIL)
6603 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006604 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006605 }
6606# endif
6607#endif
6608
6609#ifdef CURSOR_SHAPE
6610 /* 'guicursor' */
6611 else if (varp == &p_guicursor)
6612 errmsg = parse_shape_opt(SHAPE_CURSOR);
6613#endif
6614
6615#ifdef FEAT_MOUSESHAPE
6616 /* 'mouseshape' */
6617 else if (varp == &p_mouseshape)
6618 {
6619 errmsg = parse_shape_opt(SHAPE_MOUSE);
6620 update_mouseshape(-1);
6621 }
6622#endif
6623
6624#ifdef FEAT_PRINTER
6625 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006626 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006627# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006628 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006629 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006630# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006631#endif
6632
6633#ifdef FEAT_LANGMAP
6634 /* 'langmap' */
6635 else if (varp == &p_langmap)
6636 langmap_set();
6637#endif
6638
6639#ifdef FEAT_LINEBREAK
6640 /* 'breakat' */
6641 else if (varp == &p_breakat)
6642 fill_breakat_flags();
6643#endif
6644
6645#ifdef FEAT_TITLE
6646 /* 'titlestring' and 'iconstring' */
6647 else if (varp == &p_titlestring || varp == &p_iconstring)
6648 {
6649# ifdef FEAT_STL_OPT
6650 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6651
6652 /* NULL => statusline syntax */
6653 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6654 stl_syntax |= flagval;
6655 else
6656 stl_syntax &= ~flagval;
6657# endif
6658 did_set_title(varp == &p_iconstring);
6659
6660 }
6661#endif
6662
6663#ifdef FEAT_GUI
6664 /* 'guioptions' */
6665 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006666 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006667 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006668 redraw_gui_only = TRUE;
6669 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006670#endif
6671
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006672#if defined(FEAT_GUI_TABLINE)
6673 /* 'guitablabel' */
6674 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006675 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006676 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006677 redraw_gui_only = TRUE;
6678 }
6679 /* 'guitabtooltip' */
6680 else if (varp == &p_gtt)
6681 {
6682 redraw_gui_only = TRUE;
6683 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006684#endif
6685
Bram Moolenaar071d4272004-06-13 20:20:40 +00006686#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6687 /* 'ttymouse' */
6688 else if (varp == &p_ttym)
6689 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006690 /* Switch the mouse off before changing the escape sequences used for
6691 * that. */
6692 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006693 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6694 errmsg = e_invarg;
6695 else
6696 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006697 if (termcap_active)
6698 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006699 }
6700#endif
6701
Bram Moolenaar071d4272004-06-13 20:20:40 +00006702 /* 'selection' */
6703 else if (varp == &p_sel)
6704 {
6705 if (*p_sel == NUL
6706 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6707 errmsg = e_invarg;
6708 }
6709
6710 /* 'selectmode' */
6711 else if (varp == &p_slm)
6712 {
6713 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6714 errmsg = e_invarg;
6715 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006716
6717#ifdef FEAT_BROWSE
6718 /* 'browsedir' */
6719 else if (varp == &p_bsdir)
6720 {
6721 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
6722 && !mch_isdir(p_bsdir))
6723 errmsg = e_invarg;
6724 }
6725#endif
6726
Bram Moolenaar071d4272004-06-13 20:20:40 +00006727 /* 'keymodel' */
6728 else if (varp == &p_km)
6729 {
6730 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
6731 errmsg = e_invarg;
6732 else
6733 {
6734 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
6735 km_startsel = (vim_strchr(p_km, 'a') != NULL);
6736 }
6737 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006738
6739 /* 'mousemodel' */
6740 else if (varp == &p_mousem)
6741 {
6742 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
6743 errmsg = e_invarg;
6744#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
6745 else if (*p_mousem != *oldval)
6746 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
6747 * to create or delete the popup menus. */
6748 gui_motif_update_mousemodel(root_menu);
6749#endif
6750 }
6751
6752 /* 'switchbuf' */
6753 else if (varp == &p_swb)
6754 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00006755 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006756 errmsg = e_invarg;
6757 }
6758
6759 /* 'debug' */
6760 else if (varp == &p_debug)
6761 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00006762 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006763 errmsg = e_invarg;
6764 }
6765
6766 /* 'display' */
6767 else if (varp == &p_dy)
6768 {
6769 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
6770 errmsg = e_invarg;
6771 else
6772 (void)init_chartab();
6773
6774 }
6775
6776#ifdef FEAT_VERTSPLIT
6777 /* 'eadirection' */
6778 else if (varp == &p_ead)
6779 {
6780 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
6781 errmsg = e_invarg;
6782 }
6783#endif
6784
6785#ifdef FEAT_CLIPBOARD
6786 /* 'clipboard' */
6787 else if (varp == &p_cb)
6788 errmsg = check_clipboard_option();
6789#endif
6790
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00006791#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006792 /* When 'spelllang' or 'spellfile' is set and there is a window for this
6793 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006794 else if (varp == &(curwin->w_s->b_p_spl)
6795 || varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00006796 {
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006797 win_T *wp;
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006798 int l;
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006799
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006800 if (varp == &(curwin->w_s->b_p_spf))
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006801 {
Bram Moolenaar2683c8e2014-11-19 19:33:16 +01006802 l = (int)STRLEN(curwin->w_s->b_p_spf);
6803 if (l > 0 && (l < 4 || STRCMP(curwin->w_s->b_p_spf + l - 4,
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006804 ".add") != 0))
6805 errmsg = e_invarg;
6806 }
6807
6808 if (errmsg == NULL)
6809 {
6810 FOR_ALL_WINDOWS(wp)
6811 if (wp->w_buffer == curbuf && wp->w_p_spell)
6812 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006813 errmsg = did_set_spelllang(wp);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006814# ifdef FEAT_WINDOWS
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006815 break;
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006816# endif
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006817 }
6818 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006819 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006820 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006821 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006822 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006823 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006824 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006825 /* 'spellsuggest' */
6826 else if (varp == &p_sps)
6827 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00006828 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006829 errmsg = e_invarg;
6830 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00006831 /* 'mkspellmem' */
6832 else if (varp == &p_msm)
6833 {
6834 if (spell_check_msm() != OK)
6835 errmsg = e_invarg;
6836 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006837#endif
6838
Bram Moolenaar071d4272004-06-13 20:20:40 +00006839#ifdef FEAT_QUICKFIX
6840 /* When 'bufhidden' is set, check for valid value. */
6841 else if (gvarp == &p_bh)
6842 {
6843 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
6844 errmsg = e_invarg;
6845 }
6846
6847 /* When 'buftype' is set, check for valid value. */
6848 else if (gvarp == &p_bt)
6849 {
6850 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
6851 errmsg = e_invarg;
6852 else
6853 {
6854# ifdef FEAT_WINDOWS
6855 if (curwin->w_status_height)
6856 {
6857 curwin->w_redr_status = TRUE;
6858 redraw_later(VALID);
6859 }
6860# endif
6861 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar5075aad2010-01-27 15:58:13 +01006862# ifdef FEAT_TITLE
6863 redraw_titles();
6864# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006865 }
6866 }
6867#endif
6868
6869#ifdef FEAT_STL_OPT
6870 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006871 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006872 {
6873 int wid;
6874
6875 if (varp == &p_ruf) /* reset ru_wid first */
6876 ru_wid = 0;
6877 s = *varp;
6878 if (varp == &p_ruf && *s == '%')
6879 {
6880 /* set ru_wid if 'ruf' starts with "%99(" */
6881 if (*++s == '-') /* ignore a '-' */
6882 s++;
6883 wid = getdigits(&s);
6884 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
6885 ru_wid = wid;
6886 else
6887 errmsg = check_stl_option(p_ruf);
6888 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00006889 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00006890 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006891 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006892 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006893 comp_col();
6894 }
6895#endif
6896
6897#ifdef FEAT_INS_EXPAND
6898 /* check if it is a valid value for 'complete' -- Acevedo */
6899 else if (gvarp == &p_cpt)
6900 {
6901 for (s = *varp; *s;)
6902 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02006903 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006904 s++;
6905 if (!*s)
6906 break;
6907 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
6908 {
6909 errmsg = illegal_char(errbuf, *s);
6910 break;
6911 }
6912 if (*++s != NUL && *s != ',' && *s != ' ')
6913 {
6914 if (s[-1] == 'k' || s[-1] == 's')
6915 {
6916 /* skip optional filename after 'k' and 's' */
6917 while (*s && *s != ',' && *s != ' ')
6918 {
6919 if (*s == '\\')
6920 ++s;
6921 ++s;
6922 }
6923 }
6924 else
6925 {
6926 if (errbuf != NULL)
6927 {
6928 sprintf((char *)errbuf,
6929 _("E535: Illegal character after <%c>"),
6930 *--s);
6931 errmsg = errbuf;
6932 }
6933 else
6934 errmsg = (char_u *)"";
6935 break;
6936 }
6937 }
6938 }
6939 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00006940
6941 /* 'completeopt' */
6942 else if (varp == &p_cot)
6943 {
6944 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
6945 errmsg = e_invarg;
6946 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006947#endif /* FEAT_INS_EXPAND */
6948
6949
6950#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
6951 else if (varp == &p_toolbar)
6952 {
6953 if (opt_strings_flags(p_toolbar, p_toolbar_values,
6954 &toolbar_flags, TRUE) != OK)
6955 errmsg = e_invarg;
6956 else
6957 {
6958 out_flush();
6959 gui_mch_show_toolbar((toolbar_flags &
6960 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6961 }
6962 }
6963#endif
6964
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006965#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006966 /* 'toolbariconsize': GTK+ 2 only */
6967 else if (varp == &p_tbis)
6968 {
6969 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
6970 errmsg = e_invarg;
6971 else
6972 {
6973 out_flush();
6974 gui_mch_show_toolbar((toolbar_flags &
6975 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6976 }
6977 }
6978#endif
6979
6980 /* 'pastetoggle': translate key codes like in a mapping */
6981 else if (varp == &p_pt)
6982 {
6983 if (*p_pt)
6984 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00006985 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006986 if (p != NULL)
6987 {
6988 if (new_value_alloced)
6989 free_string_option(p_pt);
6990 p_pt = p;
6991 new_value_alloced = TRUE;
6992 }
6993 }
6994 }
6995
6996 /* 'backspace' */
6997 else if (varp == &p_bs)
6998 {
6999 if (VIM_ISDIGIT(*p_bs))
7000 {
7001 if (*p_bs >'2' || p_bs[1] != NUL)
7002 errmsg = e_invarg;
7003 }
7004 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
7005 errmsg = e_invarg;
7006 }
Bram Moolenaar165bc692015-07-21 17:53:25 +02007007 else if (varp == &p_bo)
7008 {
7009 if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK)
7010 errmsg = e_invarg;
7011 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007012
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007013#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00007014 /* 'casemap' */
7015 else if (varp == &p_cmp)
7016 {
7017 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
7018 errmsg = e_invarg;
7019 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00007020#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007021
7022#ifdef FEAT_DIFF
7023 /* 'diffopt' */
7024 else if (varp == &p_dip)
7025 {
7026 if (diffopt_changed() == FAIL)
7027 errmsg = e_invarg;
7028 }
7029#endif
7030
7031#ifdef FEAT_FOLDING
7032 /* 'foldmethod' */
7033 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
7034 {
7035 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
7036 || *curwin->w_p_fdm == NUL)
7037 errmsg = e_invarg;
7038 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007039 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007040 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01007041 if (foldmethodIsDiff(curwin))
7042 newFoldLevel();
7043 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007044 }
7045# ifdef FEAT_EVAL
7046 /* 'foldexpr' */
7047 else if (varp == &curwin->w_p_fde)
7048 {
7049 if (foldmethodIsExpr(curwin))
7050 foldUpdateAll(curwin);
7051 }
7052# endif
7053 /* 'foldmarker' */
7054 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
7055 {
7056 p = vim_strchr(*varp, ',');
7057 if (p == NULL)
7058 errmsg = (char_u *)N_("E536: comma required");
7059 else if (p == *varp || p[1] == NUL)
7060 errmsg = e_invarg;
7061 else if (foldmethodIsMarker(curwin))
7062 foldUpdateAll(curwin);
7063 }
7064 /* 'commentstring' */
7065 else if (gvarp == &p_cms)
7066 {
7067 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
7068 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
7069 }
7070 /* 'foldopen' */
7071 else if (varp == &p_fdo)
7072 {
7073 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
7074 errmsg = e_invarg;
7075 }
7076 /* 'foldclose' */
7077 else if (varp == &p_fcl)
7078 {
7079 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
7080 errmsg = e_invarg;
7081 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00007082 /* 'foldignore' */
7083 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
7084 {
7085 if (foldmethodIsIndent(curwin))
7086 foldUpdateAll(curwin);
7087 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007088#endif
7089
7090#ifdef FEAT_VIRTUALEDIT
7091 /* 'virtualedit' */
7092 else if (varp == &p_ve)
7093 {
7094 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
7095 errmsg = e_invarg;
7096 else if (STRCMP(p_ve, oldval) != 0)
7097 {
7098 /* Recompute cursor position in case the new 've' setting
7099 * changes something. */
7100 validate_virtcol();
7101 coladvance(curwin->w_virtcol);
7102 }
7103 }
7104#endif
7105
7106#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
7107 else if (varp == &p_csqf)
7108 {
7109 if (p_csqf != NULL)
7110 {
7111 p = p_csqf;
7112 while (*p != NUL)
7113 {
7114 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
7115 || p[1] == NUL
7116 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
7117 || (p[2] != NUL && p[2] != ','))
7118 {
7119 errmsg = e_invarg;
7120 break;
7121 }
7122 else if (p[2] == NUL)
7123 break;
7124 else
7125 p += 3;
7126 }
7127 }
7128 }
7129#endif
7130
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007131#ifdef FEAT_CINDENT
7132 /* 'cinoptions' */
7133 else if (gvarp == &p_cino)
7134 {
7135 /* TODO: recognize errors */
7136 parse_cino(curbuf);
7137 }
7138#endif
7139
Bram Moolenaarb5a7a8b2014-08-06 14:52:30 +02007140#if defined(FEAT_RENDER_OPTIONS)
7141 else if (varp == &p_rop && gui.in_use)
7142 {
7143 if (!gui_mch_set_rendering_options(p_rop))
7144 errmsg = e_invarg;
7145 }
7146#endif
7147
Bram Moolenaar071d4272004-06-13 20:20:40 +00007148 /* Options that are a list of flags. */
7149 else
7150 {
7151 p = NULL;
7152 if (varp == &p_ww)
7153 p = (char_u *)WW_ALL;
7154 if (varp == &p_shm)
7155 p = (char_u *)SHM_ALL;
7156 else if (varp == &(p_cpo))
7157 p = (char_u *)CPO_ALL;
7158 else if (varp == &(curbuf->b_p_fo))
7159 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007160#ifdef FEAT_CONCEAL
7161 else if (varp == &curwin->w_p_cocu)
7162 p = (char_u *)COCU_ALL;
7163#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007164 else if (varp == &p_mouse)
7165 {
7166#ifdef FEAT_MOUSE
7167 p = (char_u *)MOUSE_ALL;
7168#else
7169 if (*p_mouse != NUL)
7170 errmsg = (char_u *)N_("E538: No mouse support");
7171#endif
7172 }
7173#if defined(FEAT_GUI)
7174 else if (varp == &p_go)
7175 p = (char_u *)GO_ALL;
7176#endif
7177 if (p != NULL)
7178 {
7179 for (s = *varp; *s; ++s)
7180 if (vim_strchr(p, *s) == NULL)
7181 {
7182 errmsg = illegal_char(errbuf, *s);
7183 break;
7184 }
7185 }
7186 }
7187
7188 /*
7189 * If error detected, restore the previous value.
7190 */
7191 if (errmsg != NULL)
7192 {
7193 if (new_value_alloced)
7194 free_string_option(*varp);
7195 *varp = oldval;
7196 /*
7197 * When resetting some values, need to act on it.
7198 */
7199 if (did_chartab)
7200 (void)init_chartab();
7201 if (varp == &p_hl)
7202 (void)highlight_changed();
7203 }
7204 else
7205 {
7206#ifdef FEAT_EVAL
7207 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007208 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007209#endif
7210 /*
7211 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007212 * Use "free_oldval", because recursiveness may change the flags under
7213 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007214 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007215 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007216 free_string_option(oldval);
7217 if (new_value_alloced)
7218 options[opt_idx].flags |= P_ALLOCED;
7219 else
7220 options[opt_idx].flags &= ~P_ALLOCED;
7221
7222 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007223 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007224 {
7225 /* global option with local value set to use global value; free
7226 * the local value and make it empty */
7227 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7228 free_string_option(*(char_u **)p);
7229 *(char_u **)p = empty_option;
7230 }
7231
7232 /* May set global value for local option. */
7233 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7234 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007235
7236#ifdef FEAT_AUTOCMD
7237 /*
7238 * Trigger the autocommand only after setting the flags.
7239 */
7240# ifdef FEAT_SYN_HL
7241 /* When 'syntax' is set, load the syntax of that name */
7242 if (varp == &(curbuf->b_p_syn))
7243 {
7244 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7245 curbuf->b_fname, TRUE, curbuf);
7246 }
7247# endif
7248 else if (varp == &(curbuf->b_p_ft))
7249 {
7250 /* 'filetype' is set, trigger the FileType autocommand */
7251 did_filetype = TRUE;
7252 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
7253 curbuf->b_fname, TRUE, curbuf);
7254 }
7255#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007256#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007257 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007258 {
7259 char_u fname[200];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007260 char_u *q = curwin->w_s->b_p_spl;
7261
7262 /* Skip the first name if it is "cjk". */
7263 if (STRNCMP(q, "cjk,", 4) == 0)
7264 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007265
7266 /*
7267 * Source the spell/LANG.vim in 'runtimepath'.
7268 * They could set 'spellcapcheck' depending on the language.
7269 * Use the first name in 'spelllang' up to '_region' or
7270 * '.encoding'.
7271 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007272 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007273 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7274 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007275 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007276 source_runtime(fname, TRUE);
7277 }
7278#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007279 }
7280
7281#ifdef FEAT_MOUSE
7282 if (varp == &p_mouse)
7283 {
7284# ifdef FEAT_MOUSE_TTY
7285 if (*p_mouse == NUL)
7286 mch_setmouse(FALSE); /* switch mouse off */
7287 else
7288# endif
7289 setmouse(); /* in case 'mouse' changed */
7290 }
7291#endif
7292
Bram Moolenaar913077c2012-03-28 19:59:04 +02007293 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01007294 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02007295 curwin->w_set_curswant = TRUE;
7296
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007297#ifdef FEAT_GUI
7298 /* check redraw when it's not a GUI option or the GUI is active. */
7299 if (!redraw_gui_only || gui.in_use)
7300#endif
7301 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007302
7303 return errmsg;
7304}
7305
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007306#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007307/*
7308 * Simple int comparison function for use with qsort()
7309 */
7310 static int
7311int_cmp(a, b)
7312 const void *a;
7313 const void *b;
7314{
7315 return *(const int *)a - *(const int *)b;
7316}
7317
7318/*
7319 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7320 * Returns error message, NULL if it's OK.
7321 */
7322 char_u *
7323check_colorcolumn(wp)
7324 win_T *wp;
7325{
7326 char_u *s;
7327 int col;
7328 int count = 0;
7329 int color_cols[256];
7330 int i;
7331 int j = 0;
7332
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007333 if (wp->w_buffer == NULL)
7334 return NULL; /* buffer was closed */
7335
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007336 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007337 {
7338 if (*s == '-' || *s == '+')
7339 {
7340 /* -N and +N: add to 'textwidth' */
7341 col = (*s == '-') ? -1 : 1;
7342 ++s;
7343 if (!VIM_ISDIGIT(*s))
7344 return e_invarg;
7345 col = col * getdigits(&s);
7346 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007347 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007348 col += wp->w_buffer->b_p_tw;
7349 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007350 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007351 }
7352 else if (VIM_ISDIGIT(*s))
7353 col = getdigits(&s);
7354 else
7355 return e_invarg;
7356 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007357skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007358 if (*s == NUL)
7359 break;
7360 if (*s != ',')
7361 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007362 if (*++s == NUL)
7363 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007364 }
7365
7366 vim_free(wp->w_p_cc_cols);
7367 if (count == 0)
7368 wp->w_p_cc_cols = NULL;
7369 else
7370 {
7371 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7372 if (wp->w_p_cc_cols != NULL)
7373 {
7374 /* sort the columns for faster usage on screen redraw inside
7375 * win_line() */
7376 qsort(color_cols, count, sizeof(int), int_cmp);
7377
7378 for (i = 0; i < count; ++i)
7379 /* skip duplicates */
7380 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7381 wp->w_p_cc_cols[j++] = color_cols[i];
7382 wp->w_p_cc_cols[j] = -1; /* end marker */
7383 }
7384 }
7385
7386 return NULL; /* no error */
7387}
7388#endif
7389
Bram Moolenaar071d4272004-06-13 20:20:40 +00007390/*
7391 * Handle setting 'listchars' or 'fillchars'.
7392 * Returns error message, NULL if it's OK.
7393 */
7394 static char_u *
7395set_chars_option(varp)
7396 char_u **varp;
7397{
7398 int round, i, len, entries;
7399 char_u *p, *s;
7400 int c1, c2 = 0;
7401 struct charstab
7402 {
7403 int *cp;
7404 char *name;
7405 };
7406#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7407 static struct charstab filltab[] =
7408 {
7409 {&fill_stl, "stl"},
7410 {&fill_stlnc, "stlnc"},
7411 {&fill_vert, "vert"},
7412 {&fill_fold, "fold"},
7413 {&fill_diff, "diff"},
7414 };
7415#endif
7416 static struct charstab lcstab[] =
7417 {
7418 {&lcs_eol, "eol"},
7419 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007420 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007421 {&lcs_prec, "precedes"},
Bram Moolenaar4c6b3b22015-04-21 19:10:48 +02007422 {&lcs_space, "space"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007423 {&lcs_tab2, "tab"},
7424 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007425#ifdef FEAT_CONCEAL
7426 {&lcs_conceal, "conceal"},
7427#else
7428 {NULL, "conceal"},
7429#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007430 };
7431 struct charstab *tab;
7432
7433#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7434 if (varp == &p_lcs)
7435#endif
7436 {
7437 tab = lcstab;
7438 entries = sizeof(lcstab) / sizeof(struct charstab);
7439 }
7440#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7441 else
7442 {
7443 tab = filltab;
7444 entries = sizeof(filltab) / sizeof(struct charstab);
7445 }
7446#endif
7447
7448 /* first round: check for valid value, second round: assign values */
7449 for (round = 0; round <= 1; ++round)
7450 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007451 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007452 {
7453 /* After checking that the value is valid: set defaults: space for
7454 * 'fillchars', NUL for 'listchars' */
7455 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007456 if (tab[i].cp != NULL)
7457 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007458 if (varp == &p_lcs)
7459 lcs_tab1 = NUL;
7460#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7461 else
7462 fill_diff = '-';
7463#endif
7464 }
7465 p = *varp;
7466 while (*p)
7467 {
7468 for (i = 0; i < entries; ++i)
7469 {
7470 len = (int)STRLEN(tab[i].name);
7471 if (STRNCMP(p, tab[i].name, len) == 0
7472 && p[len] == ':'
7473 && p[len + 1] != NUL)
7474 {
7475 s = p + len + 1;
7476#ifdef FEAT_MBYTE
7477 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007478 if (mb_char2cells(c1) > 1)
7479 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007480#else
7481 c1 = *s++;
7482#endif
7483 if (tab[i].cp == &lcs_tab2)
7484 {
7485 if (*s == NUL)
7486 continue;
7487#ifdef FEAT_MBYTE
7488 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007489 if (mb_char2cells(c2) > 1)
7490 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007491#else
7492 c2 = *s++;
7493#endif
7494 }
7495 if (*s == ',' || *s == NUL)
7496 {
7497 if (round)
7498 {
7499 if (tab[i].cp == &lcs_tab2)
7500 {
7501 lcs_tab1 = c1;
7502 lcs_tab2 = c2;
7503 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007504 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007505 *(tab[i].cp) = c1;
7506
7507 }
7508 p = s;
7509 break;
7510 }
7511 }
7512 }
7513
7514 if (i == entries)
7515 return e_invarg;
7516 if (*p == ',')
7517 ++p;
7518 }
7519 }
7520
7521 return NULL; /* no error */
7522}
7523
7524#ifdef FEAT_STL_OPT
7525/*
7526 * Check validity of options with the 'statusline' format.
7527 * Return error message or NULL.
7528 */
7529 char_u *
7530check_stl_option(s)
7531 char_u *s;
7532{
7533 int itemcnt = 0;
7534 int groupdepth = 0;
7535 static char_u errbuf[80];
7536
7537 while (*s && itemcnt < STL_MAX_ITEM)
7538 {
7539 /* Check for valid keys after % sequences */
7540 while (*s && *s != '%')
7541 s++;
7542 if (!*s)
7543 break;
7544 s++;
7545 if (*s != '%' && *s != ')')
7546 ++itemcnt;
7547 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7548 {
7549 s++;
7550 continue;
7551 }
7552 if (*s == ')')
7553 {
7554 s++;
7555 if (--groupdepth < 0)
7556 break;
7557 continue;
7558 }
7559 if (*s == '-')
7560 s++;
7561 while (VIM_ISDIGIT(*s))
7562 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007563 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007564 continue;
7565 if (*s == '.')
7566 {
7567 s++;
7568 while (*s && VIM_ISDIGIT(*s))
7569 s++;
7570 }
7571 if (*s == '(')
7572 {
7573 groupdepth++;
7574 continue;
7575 }
7576 if (vim_strchr(STL_ALL, *s) == NULL)
7577 {
7578 return illegal_char(errbuf, *s);
7579 }
7580 if (*s == '{')
7581 {
7582 s++;
7583 while (*s != '}' && *s)
7584 s++;
7585 if (*s != '}')
7586 return (char_u *)N_("E540: Unclosed expression sequence");
7587 }
7588 }
7589 if (itemcnt >= STL_MAX_ITEM)
7590 return (char_u *)N_("E541: too many items");
7591 if (groupdepth != 0)
7592 return (char_u *)N_("E542: unbalanced groups");
7593 return NULL;
7594}
7595#endif
7596
7597#ifdef FEAT_CLIPBOARD
7598/*
7599 * Extract the items in the 'clipboard' option and set global values.
7600 */
7601 static char_u *
7602check_clipboard_option()
7603{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007604 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007605 int new_autoselect_star = FALSE;
7606 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007607 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007608 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007609 regprog_T *new_exclude_prog = NULL;
7610 char_u *errmsg = NULL;
7611 char_u *p;
7612
7613 for (p = p_cb; *p != NUL; )
7614 {
7615 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7616 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007617 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007618 p += 7;
7619 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007620 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007621 && (p[11] == ',' || p[11] == NUL))
7622 {
7623 new_unnamed |= CLIP_UNNAMED_PLUS;
7624 p += 11;
7625 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007626 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007627 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007628 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007629 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007630 p += 10;
7631 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007632 else if (STRNCMP(p, "autoselectplus", 14) == 0
7633 && (p[14] == ',' || p[14] == NUL))
7634 {
7635 new_autoselect_plus = TRUE;
7636 p += 14;
7637 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007638 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007639 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007640 {
7641 new_autoselectml = TRUE;
7642 p += 12;
7643 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007644 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7645 {
7646 new_html = TRUE;
7647 p += 4;
7648 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007649 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7650 {
7651 p += 8;
7652 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7653 if (new_exclude_prog == NULL)
7654 errmsg = e_invarg;
7655 break;
7656 }
7657 else
7658 {
7659 errmsg = e_invarg;
7660 break;
7661 }
7662 if (*p == ',')
7663 ++p;
7664 }
7665 if (errmsg == NULL)
7666 {
7667 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007668 clip_autoselect_star = new_autoselect_star;
7669 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007670 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007671 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02007672 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007673 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02007674#ifdef FEAT_GUI_GTK
7675 if (gui.in_use)
7676 {
7677 gui_gtk_set_selection_targets();
7678 gui_gtk_set_dnd_targets();
7679 }
7680#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007681 }
7682 else
Bram Moolenaar473de612013-06-08 18:19:48 +02007683 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007684
7685 return errmsg;
7686}
7687#endif
7688
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007689#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007690/*
7691 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
7692 * Return error message when failed, NULL when OK.
7693 */
7694 static char_u *
Bram Moolenaar860cae12010-06-05 23:22:07 +02007695compile_cap_prog(synblock)
7696 synblock_T *synblock;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007697{
Bram Moolenaar860cae12010-06-05 23:22:07 +02007698 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007699 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007700
Bram Moolenaar860cae12010-06-05 23:22:07 +02007701 if (*synblock->b_p_spc == NUL)
7702 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007703 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007704 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007705 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007706 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007707 if (re != NULL)
7708 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007709 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02007710 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02007711 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007712 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007713 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007714 return e_invarg;
7715 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007716 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007717 }
7718
Bram Moolenaar473de612013-06-08 18:19:48 +02007719 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007720 return NULL;
7721}
7722#endif
7723
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007724#if defined(FEAT_EVAL) || defined(PROTO)
7725/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007726 * Set the scriptID for an option, taking care of setting the buffer- or
7727 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007728 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007729 static void
7730set_option_scriptID_idx(opt_idx, opt_flags, id)
7731 int opt_idx;
7732 int opt_flags;
7733 int id;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007734{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007735 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
7736 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007737
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007738 /* Remember where the option was set. For local options need to do that
7739 * in the buffer or window structure. */
7740 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007741 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007742 if (both || (opt_flags & OPT_LOCAL))
7743 {
7744 if (indir & PV_BUF)
7745 curbuf->b_p_scriptID[indir & PV_MASK] = id;
7746 else if (indir & PV_WIN)
7747 curwin->w_p_scriptID[indir & PV_MASK] = id;
7748 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007749}
7750#endif
7751
Bram Moolenaar071d4272004-06-13 20:20:40 +00007752/*
7753 * Set the value of a boolean option, and take care of side effects.
7754 * Returns NULL for success, or an error message for an error.
7755 */
7756 static char_u *
7757set_bool_option(opt_idx, varp, value, opt_flags)
7758 int opt_idx; /* index in options[] table */
7759 char_u *varp; /* pointer to the option variable */
7760 int value; /* new value */
7761 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
7762{
7763 int old_value = *(int *)varp;
7764
Bram Moolenaar071d4272004-06-13 20:20:40 +00007765 /* Disallow changing some options from secure mode */
7766 if ((secure
7767#ifdef HAVE_SANDBOX
7768 || sandbox != 0
7769#endif
7770 ) && (options[opt_idx].flags & P_SECURE))
7771 return e_secure;
7772
7773 *(int *)varp = value; /* set the new value */
7774#ifdef FEAT_EVAL
7775 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007776 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007777#endif
7778
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00007779#ifdef FEAT_GUI
7780 need_mouse_correct = TRUE;
7781#endif
7782
Bram Moolenaar071d4272004-06-13 20:20:40 +00007783 /* May set global value for local option. */
7784 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
7785 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
7786
7787 /*
7788 * Handle side effects of changing a bool option.
7789 */
7790
7791 /* 'compatible' */
7792 if ((int *)varp == &p_cp)
7793 {
7794 compatible_set();
7795 }
7796
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007797#ifdef FEAT_PERSISTENT_UNDO
7798 /* 'undofile' */
7799 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
7800 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007801 /* Only take action when the option was set. When reset we do not
7802 * delete the undo file, the option may be set again without making
7803 * any changes in between. */
7804 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007805 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007806 char_u hash[UNDO_HASH_SIZE];
7807 buf_T *save_curbuf = curbuf;
7808
7809 for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007810 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007811 /* When 'undofile' is set globally: for every buffer, otherwise
7812 * only for the current buffer: Try to read in the undofile,
7813 * if one exists, the buffer wasn't changed and the buffer was
7814 * loaded */
7815 if ((curbuf == save_curbuf
7816 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
7817 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
7818 {
7819 u_compute_hash(hash);
7820 u_read_undo(NULL, hash, curbuf->b_fname);
7821 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007822 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007823 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007824 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007825 }
7826#endif
7827
Bram Moolenaar071d4272004-06-13 20:20:40 +00007828 else if ((int *)varp == &curbuf->b_p_ro)
7829 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007830 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007831 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
7832 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007833
7834 /* when 'readonly' is set may give W10 again */
7835 if (curbuf->b_p_ro)
7836 curbuf->b_did_warn = FALSE;
7837
Bram Moolenaar071d4272004-06-13 20:20:40 +00007838#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007839 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007840#endif
7841 }
7842
Bram Moolenaar9c449722010-07-20 18:44:27 +02007843#ifdef FEAT_GUI
7844 else if ((int *)varp == &p_mh)
7845 {
7846 if (!p_mh)
7847 gui_mch_mousehide(FALSE);
7848 }
7849#endif
7850
Bram Moolenaara539df02010-08-01 14:35:05 +02007851#ifdef FEAT_TITLE
7852 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007853 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007854 {
7855 redraw_titles();
7856 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007857 /* when 'endofline' is changed, redraw the window title */
7858 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007859 {
7860 redraw_titles();
7861 }
Bram Moolenaar34d72d42015-07-17 14:18:08 +02007862 /* when 'fixeol' is changed, redraw the window title */
7863 else if ((int *)varp == &curbuf->b_p_fixeol)
7864 {
7865 redraw_titles();
7866 }
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007867# ifdef FEAT_MBYTE
7868 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00007869 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007870 {
7871 redraw_titles();
7872 }
7873# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007874#endif
7875
7876 /* when 'bin' is set also set some other options */
7877 else if ((int *)varp == &curbuf->b_p_bin)
7878 {
7879 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
7880#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007881 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007882#endif
7883 }
7884
7885#ifdef FEAT_AUTOCMD
7886 /* when 'buflisted' changes, trigger autocommands */
7887 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
7888 {
7889 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
7890 NULL, NULL, TRUE, curbuf);
7891 }
7892#endif
7893
7894 /* when 'swf' is set, create swapfile, when reset remove swapfile */
7895 else if ((int *)varp == &curbuf->b_p_swf)
7896 {
7897 if (curbuf->b_p_swf && p_uc)
7898 ml_open_file(curbuf); /* create the swap file */
7899 else
Bram Moolenaard55de222007-05-06 13:38:48 +00007900 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
7901 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007902 mf_close_file(curbuf, TRUE); /* remove the swap file */
7903 }
7904
7905 /* when 'terse' is set change 'shortmess' */
7906 else if ((int *)varp == &p_terse)
7907 {
7908 char_u *p;
7909
7910 p = vim_strchr(p_shm, SHM_SEARCH);
7911
7912 /* insert 's' in p_shm */
7913 if (p_terse && p == NULL)
7914 {
7915 STRCPY(IObuff, p_shm);
7916 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007917 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007918 }
7919 /* remove 's' from p_shm */
7920 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007921 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007922 }
7923
7924 /* when 'paste' is set or reset also change other options */
7925 else if ((int *)varp == &p_paste)
7926 {
7927 paste_option_changed();
7928 }
7929
7930 /* when 'insertmode' is set from an autocommand need to do work here */
7931 else if ((int *)varp == &p_im)
7932 {
7933 if (p_im)
7934 {
7935 if ((State & INSERT) == 0)
7936 need_start_insertmode = TRUE;
7937 stop_insert_mode = FALSE;
7938 }
7939 else
7940 {
7941 need_start_insertmode = FALSE;
7942 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00007943 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007944 clear_cmdline = TRUE; /* remove "(insert)" */
7945 restart_edit = 0;
7946 }
7947 }
7948
7949 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
7950 else if ((int *)varp == &p_ic && p_hls)
7951 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007952 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007953 }
7954
7955#ifdef FEAT_SEARCH_EXTRA
7956 /* when 'hlsearch' is set or reset: reset no_hlsearch */
7957 else if ((int *)varp == &p_hls)
7958 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01007959 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007960 }
7961#endif
7962
7963#ifdef FEAT_SCROLLBIND
7964 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
7965 * at the end of normal_cmd() */
7966 else if ((int *)varp == &curwin->w_p_scb)
7967 {
7968 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02007969 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007970 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02007971 curwin->w_scbind_pos = curwin->w_topline;
7972 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007973 }
7974#endif
7975
7976#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
7977 /* There can be only one window with 'previewwindow' set. */
7978 else if ((int *)varp == &curwin->w_p_pvw)
7979 {
7980 if (curwin->w_p_pvw)
7981 {
7982 win_T *win;
7983
7984 for (win = firstwin; win != NULL; win = win->w_next)
7985 if (win->w_p_pvw && win != curwin)
7986 {
7987 curwin->w_p_pvw = FALSE;
7988 return (char_u *)N_("E590: A preview window already exists");
7989 }
7990 }
7991 }
7992#endif
7993
7994 /* when 'textmode' is set or reset also change 'fileformat' */
7995 else if ((int *)varp == &curbuf->b_p_tx)
7996 {
7997 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
7998 }
7999
8000 /* when 'textauto' is set or reset also change 'fileformats' */
8001 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008002 set_string_option_direct((char_u *)"ffs", -1,
8003 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008004 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008005
8006 /*
8007 * When 'lisp' option changes include/exclude '-' in
8008 * keyword characters.
8009 */
8010#ifdef FEAT_LISP
8011 else if (varp == (char_u *)&(curbuf->b_p_lisp))
8012 {
8013 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
8014 }
8015#endif
8016
8017#ifdef FEAT_TITLE
8018 /* when 'title' changed, may need to change the title; same for 'icon' */
8019 else if ((int *)varp == &p_title)
8020 {
8021 did_set_title(FALSE);
8022 }
8023
8024 else if ((int *)varp == &p_icon)
8025 {
8026 did_set_title(TRUE);
8027 }
8028#endif
8029
8030 else if ((int *)varp == &curbuf->b_changed)
8031 {
8032 if (!value)
8033 save_file_ff(curbuf); /* Buffer is unchanged */
8034#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008035 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008036#endif
8037#ifdef FEAT_AUTOCMD
8038 modified_was_set = value;
8039#endif
8040 }
8041
8042#ifdef BACKSLASH_IN_FILENAME
8043 else if ((int *)varp == &p_ssl)
8044 {
8045 if (p_ssl)
8046 {
8047 psepc = '/';
8048 psepcN = '\\';
8049 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008050 }
8051 else
8052 {
8053 psepc = '\\';
8054 psepcN = '/';
8055 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00008056 }
8057
8058 /* need to adjust the file name arguments and buffer names. */
8059 buflist_slash_adjust();
8060 alist_slash_adjust();
8061# ifdef FEAT_EVAL
8062 scriptnames_slash_adjust();
8063# endif
8064 }
8065#endif
8066
8067 /* If 'wrap' is set, set w_leftcol to zero. */
8068 else if ((int *)varp == &curwin->w_p_wrap)
8069 {
8070 if (curwin->w_p_wrap)
8071 curwin->w_leftcol = 0;
8072 }
8073
8074#ifdef FEAT_WINDOWS
8075 else if ((int *)varp == &p_ea)
8076 {
8077 if (p_ea && !old_value)
8078 win_equal(curwin, FALSE, 0);
8079 }
8080#endif
8081
8082 else if ((int *)varp == &p_wiv)
8083 {
8084 /*
8085 * When 'weirdinvert' changed, set/reset 't_xs'.
8086 * Then set 'weirdinvert' according to value of 't_xs'.
8087 */
8088 if (p_wiv && !old_value)
8089 T_XS = (char_u *)"y";
8090 else if (!p_wiv && old_value)
8091 T_XS = empty_option;
8092 p_wiv = (*T_XS != NUL);
8093 }
8094
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00008095#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00008096 else if ((int *)varp == &p_beval)
8097 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008098 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008099 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01008100 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008101 gui_mch_disable_beval_area(balloonEval);
8102 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008103#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008104
Bram Moolenaar8dff8182006-04-06 20:18:50 +00008105#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008106 else if ((int *)varp == &p_acd)
8107 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00008108 /* Change directories when the 'acd' option is set now. */
8109 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00008110 }
8111#endif
8112
8113#ifdef FEAT_DIFF
8114 /* 'diff' */
8115 else if ((int *)varp == &curwin->w_p_diff)
8116 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008117 /* May add or remove the buffer from the list of diff buffers. */
8118 diff_buf_adjust(curwin);
8119# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008120 if (foldmethodIsDiff(curwin))
8121 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008122# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008123 }
8124#endif
8125
8126#ifdef USE_IM_CONTROL
8127 /* 'imdisable' */
8128 else if ((int *)varp == &p_imdisable)
8129 {
8130 /* Only de-activate it here, it will be enabled when changing mode. */
8131 if (p_imdisable)
8132 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02008133 else if (State & INSERT)
8134 /* When the option is set from an autocommand, it may need to take
8135 * effect right away. */
8136 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008137 }
8138#endif
8139
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00008140#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008141 /* 'spell' */
8142 else if ((int *)varp == &curwin->w_p_spell)
8143 {
8144 if (curwin->w_p_spell)
8145 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008146 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008147 if (errmsg != NULL)
8148 EMSG(_(errmsg));
8149 }
8150 }
8151#endif
8152
Bram Moolenaar071d4272004-06-13 20:20:40 +00008153#ifdef FEAT_FKMAP
8154 else if ((int *)varp == &p_altkeymap)
8155 {
8156 if (old_value != p_altkeymap)
8157 {
8158 if (!p_altkeymap)
8159 {
8160 p_hkmap = p_fkmap;
8161 p_fkmap = 0;
8162 }
8163 else
8164 {
8165 p_fkmap = p_hkmap;
8166 p_hkmap = 0;
8167 }
8168 (void)init_chartab();
8169 }
8170 }
8171
8172 /*
8173 * In case some second language keymapping options have changed, check
8174 * and correct the setting in a consistent way.
8175 */
8176
8177 /*
8178 * If hkmap or fkmap are set, reset Arabic keymapping.
8179 */
8180 if ((p_hkmap || p_fkmap) && p_altkeymap)
8181 {
8182 p_altkeymap = p_fkmap;
8183# ifdef FEAT_ARABIC
8184 curwin->w_p_arab = FALSE;
8185# endif
8186 (void)init_chartab();
8187 }
8188
8189 /*
8190 * If hkmap set, reset Farsi keymapping.
8191 */
8192 if (p_hkmap && p_altkeymap)
8193 {
8194 p_altkeymap = 0;
8195 p_fkmap = 0;
8196# ifdef FEAT_ARABIC
8197 curwin->w_p_arab = FALSE;
8198# endif
8199 (void)init_chartab();
8200 }
8201
8202 /*
8203 * If fkmap set, reset Hebrew keymapping.
8204 */
8205 if (p_fkmap && !p_altkeymap)
8206 {
8207 p_altkeymap = 1;
8208 p_hkmap = 0;
8209# ifdef FEAT_ARABIC
8210 curwin->w_p_arab = FALSE;
8211# endif
8212 (void)init_chartab();
8213 }
8214#endif
8215
8216#ifdef FEAT_ARABIC
8217 if ((int *)varp == &curwin->w_p_arab)
8218 {
8219 if (curwin->w_p_arab)
8220 {
8221 /*
8222 * 'arabic' is set, handle various sub-settings.
8223 */
8224 if (!p_tbidi)
8225 {
8226 /* set rightleft mode */
8227 if (!curwin->w_p_rl)
8228 {
8229 curwin->w_p_rl = TRUE;
8230 changed_window_setting();
8231 }
8232
8233 /* Enable Arabic shaping (major part of what Arabic requires) */
8234 if (!p_arshape)
8235 {
8236 p_arshape = TRUE;
8237 redraw_later_clear();
8238 }
8239 }
8240
8241 /* Arabic requires a utf-8 encoding, inform the user if its not
8242 * set. */
8243 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008244 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008245 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8246
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008247 msg_source(hl_attr(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008248 MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
8249#ifdef FEAT_EVAL
8250 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8251#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008252 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008253
8254# ifdef FEAT_MBYTE
8255 /* set 'delcombine' */
8256 p_deco = TRUE;
8257# endif
8258
8259# ifdef FEAT_KEYMAP
8260 /* Force-set the necessary keymap for arabic */
8261 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8262 OPT_LOCAL);
8263# endif
8264# ifdef FEAT_FKMAP
8265 p_altkeymap = 0;
8266 p_hkmap = 0;
8267 p_fkmap = 0;
8268 (void)init_chartab();
8269# endif
8270 }
8271 else
8272 {
8273 /*
8274 * 'arabic' is reset, handle various sub-settings.
8275 */
8276 if (!p_tbidi)
8277 {
8278 /* reset rightleft mode */
8279 if (curwin->w_p_rl)
8280 {
8281 curwin->w_p_rl = FALSE;
8282 changed_window_setting();
8283 }
8284
8285 /* 'arabicshape' isn't reset, it is a global option and
8286 * another window may still need it "on". */
8287 }
8288
8289 /* 'delcombine' isn't reset, it is a global option and another
8290 * window may still want it "on". */
8291
8292# ifdef FEAT_KEYMAP
8293 /* Revert to the default keymap */
8294 curbuf->b_p_iminsert = B_IMODE_NONE;
8295 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8296# endif
8297 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008298 }
8299
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008300#endif
8301
Bram Moolenaar071d4272004-06-13 20:20:40 +00008302 /*
8303 * End of handling side effects for bool options.
8304 */
8305
Bram Moolenaar53744302015-07-17 17:38:22 +02008306 /* after handling side effects, call autocommand */
8307
Bram Moolenaar071d4272004-06-13 20:20:40 +00008308 options[opt_idx].flags |= P_WAS_SET;
8309
Bram Moolenaar53744302015-07-17 17:38:22 +02008310#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8311 if (!starting)
8312 {
8313 char_u buf_old[2], buf_new[2], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008314 vim_snprintf((char *)buf_old, 2, "%d", old_value ? TRUE: FALSE);
8315 vim_snprintf((char *)buf_new, 2, "%d", value ? TRUE: FALSE);
8316 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008317 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8318 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8319 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8320 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8321 reset_v_option_vars();
8322 }
8323#endif
8324
Bram Moolenaar071d4272004-06-13 20:20:40 +00008325 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008326 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008327 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008328 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008329 check_redraw(options[opt_idx].flags);
8330
8331 return NULL;
8332}
8333
8334/*
8335 * Set the value of a number option, and take care of side effects.
8336 * Returns NULL for success, or an error message for an error.
8337 */
8338 static char_u *
Bram Moolenaar555b2802005-05-19 21:08:39 +00008339set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008340 int opt_idx; /* index in options[] table */
8341 char_u *varp; /* pointer to the option variable */
8342 long value; /* new value */
8343 char_u *errbuf; /* buffer for error messages */
Bram Moolenaar555b2802005-05-19 21:08:39 +00008344 size_t errbuflen; /* length of "errbuf" */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008345 int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and
8346 OPT_MODELINE */
8347{
8348 char_u *errmsg = NULL;
8349 long old_value = *(long *)varp;
8350 long old_Rows = Rows; /* remember old Rows */
8351 long old_Columns = Columns; /* remember old Columns */
8352 long *pp = (long *)varp;
8353
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008354 /* Disallow changing some options from secure mode. */
8355 if ((secure
8356#ifdef HAVE_SANDBOX
8357 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008358#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008359 ) && (options[opt_idx].flags & P_SECURE))
8360 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008361
8362 *pp = value;
8363#ifdef FEAT_EVAL
8364 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008365 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008366#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008367#ifdef FEAT_GUI
8368 need_mouse_correct = TRUE;
8369#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008370
Bram Moolenaar14f24742012-08-08 18:01:05 +02008371 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008372 {
8373 errmsg = e_positive;
8374 curbuf->b_p_sw = curbuf->b_p_ts;
8375 }
8376
8377 /*
8378 * Number options that need some action when changed
8379 */
8380#ifdef FEAT_WINDOWS
8381 if (pp == &p_wh || pp == &p_hh)
8382 {
8383 if (p_wh < 1)
8384 {
8385 errmsg = e_positive;
8386 p_wh = 1;
8387 }
8388 if (p_wmh > p_wh)
8389 {
8390 errmsg = e_winheight;
8391 p_wh = p_wmh;
8392 }
8393 if (p_hh < 0)
8394 {
8395 errmsg = e_positive;
8396 p_hh = 0;
8397 }
8398
8399 /* Change window height NOW */
8400 if (lastwin != firstwin)
8401 {
8402 if (pp == &p_wh && curwin->w_height < p_wh)
8403 win_setheight((int)p_wh);
8404 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8405 win_setheight((int)p_hh);
8406 }
8407 }
8408
8409 /* 'winminheight' */
8410 else if (pp == &p_wmh)
8411 {
8412 if (p_wmh < 0)
8413 {
8414 errmsg = e_positive;
8415 p_wmh = 0;
8416 }
8417 if (p_wmh > p_wh)
8418 {
8419 errmsg = e_winheight;
8420 p_wmh = p_wh;
8421 }
8422 win_setminheight();
8423 }
8424
8425# ifdef FEAT_VERTSPLIT
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008426 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008427 {
8428 if (p_wiw < 1)
8429 {
8430 errmsg = e_positive;
8431 p_wiw = 1;
8432 }
8433 if (p_wmw > p_wiw)
8434 {
8435 errmsg = e_winwidth;
8436 p_wiw = p_wmw;
8437 }
8438
8439 /* Change window width NOW */
8440 if (lastwin != firstwin && curwin->w_width < p_wiw)
8441 win_setwidth((int)p_wiw);
8442 }
8443
8444 /* 'winminwidth' */
8445 else if (pp == &p_wmw)
8446 {
8447 if (p_wmw < 0)
8448 {
8449 errmsg = e_positive;
8450 p_wmw = 0;
8451 }
8452 if (p_wmw > p_wiw)
8453 {
8454 errmsg = e_winwidth;
8455 p_wmw = p_wiw;
8456 }
8457 win_setminheight();
8458 }
8459# endif
8460
8461#endif
8462
8463#ifdef FEAT_WINDOWS
8464 /* (re)set last window status line */
8465 else if (pp == &p_ls)
8466 {
8467 last_status(FALSE);
8468 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008469
8470 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008471 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008472 {
8473 shell_new_rows(); /* recompute window positions and heights */
8474 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008475#endif
8476
8477#ifdef FEAT_GUI
8478 else if (pp == &p_linespace)
8479 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008480 /* Recompute gui.char_height and resize the Vim window to keep the
8481 * same number of lines. */
8482 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008483 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008484 }
8485#endif
8486
8487#ifdef FEAT_FOLDING
8488 /* 'foldlevel' */
8489 else if (pp == &curwin->w_p_fdl)
8490 {
8491 if (curwin->w_p_fdl < 0)
8492 curwin->w_p_fdl = 0;
8493 newFoldLevel();
8494 }
8495
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008496 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008497 else if (pp == &curwin->w_p_fml)
8498 {
8499 foldUpdateAll(curwin);
8500 }
8501
8502 /* 'foldnestmax' */
8503 else if (pp == &curwin->w_p_fdn)
8504 {
8505 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8506 foldUpdateAll(curwin);
8507 }
8508
8509 /* 'foldcolumn' */
8510 else if (pp == &curwin->w_p_fdc)
8511 {
8512 if (curwin->w_p_fdc < 0)
8513 {
8514 errmsg = e_positive;
8515 curwin->w_p_fdc = 0;
8516 }
8517 else if (curwin->w_p_fdc > 12)
8518 {
8519 errmsg = e_invarg;
8520 curwin->w_p_fdc = 12;
8521 }
8522 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008523#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008524
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008525#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008526 /* 'shiftwidth' or 'tabstop' */
8527 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8528 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008529# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008530 if (foldmethodIsIndent(curwin))
8531 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008532# endif
8533# ifdef FEAT_CINDENT
8534 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8535 * parse 'cinoptions'. */
8536 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8537 parse_cino(curbuf);
8538# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008539 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008540#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008541
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008542#ifdef FEAT_MBYTE
8543 /* 'maxcombine' */
8544 else if (pp == &p_mco)
8545 {
8546 if (p_mco > MAX_MCO)
8547 p_mco = MAX_MCO;
8548 else if (p_mco < 0)
8549 p_mco = 0;
8550 screenclear(); /* will re-allocate the screen */
8551 }
8552#endif
8553
Bram Moolenaar071d4272004-06-13 20:20:40 +00008554 else if (pp == &curbuf->b_p_iminsert)
8555 {
8556 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8557 {
8558 errmsg = e_invarg;
8559 curbuf->b_p_iminsert = B_IMODE_NONE;
8560 }
8561 p_iminsert = curbuf->b_p_iminsert;
8562 if (termcap_active) /* don't do this in the alternate screen */
8563 showmode();
8564#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8565 /* Show/unshow value of 'keymap' in status lines. */
8566 status_redraw_curbuf();
8567#endif
8568 }
8569
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008570 else if (pp == &p_window)
8571 {
8572 if (p_window < 1)
8573 p_window = 1;
8574 else if (p_window >= Rows)
8575 p_window = Rows - 1;
8576 }
8577
Bram Moolenaar071d4272004-06-13 20:20:40 +00008578 else if (pp == &curbuf->b_p_imsearch)
8579 {
8580 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8581 {
8582 errmsg = e_invarg;
8583 curbuf->b_p_imsearch = B_IMODE_NONE;
8584 }
8585 p_imsearch = curbuf->b_p_imsearch;
8586 }
8587
8588#ifdef FEAT_TITLE
8589 /* if 'titlelen' has changed, redraw the title */
8590 else if (pp == &p_titlelen)
8591 {
8592 if (p_titlelen < 0)
8593 {
8594 errmsg = e_positive;
8595 p_titlelen = 85;
8596 }
8597 if (starting != NO_SCREEN && old_value != p_titlelen)
8598 need_maketitle = TRUE;
8599 }
8600#endif
8601
8602 /* if p_ch changed value, change the command line height */
8603 else if (pp == &p_ch)
8604 {
8605 if (p_ch < 1)
8606 {
8607 errmsg = e_positive;
8608 p_ch = 1;
8609 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008610 if (p_ch > Rows - min_rows() + 1)
8611 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008612
8613 /* Only compute the new window layout when startup has been
8614 * completed. Otherwise the frame sizes may be wrong. */
8615 if (p_ch != old_value && full_screen
8616#ifdef FEAT_GUI
8617 && !gui.starting
8618#endif
8619 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008620 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008621 }
8622
8623 /* when 'updatecount' changes from zero to non-zero, open swap files */
8624 else if (pp == &p_uc)
8625 {
8626 if (p_uc < 0)
8627 {
8628 errmsg = e_positive;
8629 p_uc = 100;
8630 }
8631 if (p_uc && !old_value)
8632 ml_open_files();
8633 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008634#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008635 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008636 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008637 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008638 {
8639 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008640 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008641 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008642 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008643 {
8644 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008645 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008646 }
8647 }
8648#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008649#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008650 else if (pp == &p_mzq)
8651 mzvim_reset_timer();
8652#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008653
8654 /* sync undo before 'undolevels' changes */
8655 else if (pp == &p_ul)
8656 {
8657 /* use the old value, otherwise u_sync() may not work properly */
8658 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00008659 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008660 p_ul = value;
8661 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01008662 else if (pp == &curbuf->b_p_ul)
8663 {
8664 /* use the old value, otherwise u_sync() may not work properly */
8665 curbuf->b_p_ul = old_value;
8666 u_sync(TRUE);
8667 curbuf->b_p_ul = value;
8668 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008669
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008670#ifdef FEAT_LINEBREAK
8671 /* 'numberwidth' must be positive */
8672 else if (pp == &curwin->w_p_nuw)
8673 {
8674 if (curwin->w_p_nuw < 1)
8675 {
8676 errmsg = e_positive;
8677 curwin->w_p_nuw = 1;
8678 }
8679 if (curwin->w_p_nuw > 10)
8680 {
8681 errmsg = e_invarg;
8682 curwin->w_p_nuw = 10;
8683 }
Bram Moolenaar1e7813a2015-03-31 18:31:03 +02008684 curwin->w_nrwidth_line_count = 0; /* trigger a redraw */
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008685 }
8686#endif
8687
Bram Moolenaar1a384422010-07-14 19:53:30 +02008688 else if (pp == &curbuf->b_p_tw)
8689 {
8690 if (curbuf->b_p_tw < 0)
8691 {
8692 errmsg = e_positive;
8693 curbuf->b_p_tw = 0;
8694 }
8695#ifdef FEAT_SYN_HL
8696# ifdef FEAT_WINDOWS
8697 {
8698 win_T *wp;
8699 tabpage_T *tp;
8700
8701 FOR_ALL_TAB_WINDOWS(tp, wp)
8702 check_colorcolumn(wp);
8703 }
8704# else
8705 check_colorcolumn(curwin);
8706# endif
8707#endif
8708 }
8709
Bram Moolenaar071d4272004-06-13 20:20:40 +00008710 /*
8711 * Check the bounds for numeric options here
8712 */
8713 if (Rows < min_rows() && full_screen)
8714 {
8715 if (errbuf != NULL)
8716 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008717 vim_snprintf((char *)errbuf, errbuflen,
8718 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00008719 errmsg = errbuf;
8720 }
8721 Rows = min_rows();
8722 }
8723 if (Columns < MIN_COLUMNS && full_screen)
8724 {
8725 if (errbuf != NULL)
8726 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008727 vim_snprintf((char *)errbuf, errbuflen,
8728 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008729 errmsg = errbuf;
8730 }
8731 Columns = MIN_COLUMNS;
8732 }
Bram Moolenaare057d402013-06-30 17:51:51 +02008733 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008734
8735#ifdef DJGPP
8736 /* avoid a crash by checking for a too large value of 'columns' */
8737 if (old_Columns != Columns && full_screen && term_console)
8738 mch_check_columns();
8739#endif
8740
8741 /*
8742 * If the screen (shell) height has been changed, assume it is the
8743 * physical screenheight.
8744 */
8745 if (old_Rows != Rows || old_Columns != Columns)
8746 {
8747 /* Changing the screen size is not allowed while updating the screen. */
8748 if (updating_screen)
8749 *pp = old_value;
8750 else if (full_screen
8751#ifdef FEAT_GUI
8752 && !gui.starting
8753#endif
8754 )
8755 set_shellsize((int)Columns, (int)Rows, TRUE);
8756 else
8757 {
8758 /* Postpone the resizing; check the size and cmdline position for
8759 * messages. */
8760 check_shellsize();
8761 if (cmdline_row > Rows - p_ch && Rows > p_ch)
8762 cmdline_row = Rows - p_ch;
8763 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00008764 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008765 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008766 }
8767
Bram Moolenaar071d4272004-06-13 20:20:40 +00008768 if (curbuf->b_p_ts <= 0)
8769 {
8770 errmsg = e_positive;
8771 curbuf->b_p_ts = 8;
8772 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008773 if (p_tm < 0)
8774 {
8775 errmsg = e_positive;
8776 p_tm = 0;
8777 }
8778 if ((curwin->w_p_scr <= 0
8779 || (curwin->w_p_scr > curwin->w_height
8780 && curwin->w_height > 0))
8781 && full_screen)
8782 {
8783 if (pp == &(curwin->w_p_scr))
8784 {
8785 if (curwin->w_p_scr != 0)
8786 errmsg = e_scroll;
8787 win_comp_scroll(curwin);
8788 }
8789 /* If 'scroll' became invalid because of a side effect silently adjust
8790 * it. */
8791 else if (curwin->w_p_scr <= 0)
8792 curwin->w_p_scr = 1;
8793 else /* curwin->w_p_scr > curwin->w_height */
8794 curwin->w_p_scr = curwin->w_height;
8795 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00008796 if (p_hi < 0)
8797 {
8798 errmsg = e_positive;
8799 p_hi = 0;
8800 }
Bram Moolenaar78159bb2014-06-25 11:48:54 +02008801 else if (p_hi > 10000)
8802 {
8803 errmsg = e_invarg;
8804 p_hi = 10000;
8805 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02008806 if (p_re < 0 || p_re > 2)
8807 {
8808 errmsg = e_invarg;
8809 p_re = 0;
8810 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008811 if (p_report < 0)
8812 {
8813 errmsg = e_positive;
8814 p_report = 1;
8815 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00008816 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008817 {
8818 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
8819 p_sj = Rows / 2;
8820 else
8821 {
8822 errmsg = e_scroll;
8823 p_sj = 1;
8824 }
8825 }
8826 if (p_so < 0 && full_screen)
8827 {
8828 errmsg = e_scroll;
8829 p_so = 0;
8830 }
8831 if (p_siso < 0 && full_screen)
8832 {
8833 errmsg = e_positive;
8834 p_siso = 0;
8835 }
8836#ifdef FEAT_CMDWIN
8837 if (p_cwh < 1)
8838 {
8839 errmsg = e_positive;
8840 p_cwh = 1;
8841 }
8842#endif
8843 if (p_ut < 0)
8844 {
8845 errmsg = e_positive;
8846 p_ut = 2000;
8847 }
8848 if (p_ss < 0)
8849 {
8850 errmsg = e_positive;
8851 p_ss = 0;
8852 }
8853
8854 /* May set global value for local option. */
8855 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8856 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
8857
8858 options[opt_idx].flags |= P_WAS_SET;
8859
Bram Moolenaar53744302015-07-17 17:38:22 +02008860#if defined(FEAT_AUTOCMD) && defined(FEAT_EVAL)
8861 if (!starting && errmsg == NULL)
8862 {
8863 char_u buf_old[11], buf_new[11], buf_type[7];
Bram Moolenaarfb9bc482015-07-17 22:04:48 +02008864 vim_snprintf((char *)buf_old, 10, "%ld", old_value);
8865 vim_snprintf((char *)buf_new, 10, "%ld", value);
8866 vim_snprintf((char *)buf_type, 7, "%s", (opt_flags & OPT_LOCAL) ? "local" : "global");
Bram Moolenaar53744302015-07-17 17:38:22 +02008867 set_vim_var_string(VV_OPTION_NEW, buf_new, -1);
8868 set_vim_var_string(VV_OPTION_OLD, buf_old, -1);
8869 set_vim_var_string(VV_OPTION_TYPE, buf_type, -1);
8870 apply_autocmds(EVENT_OPTIONSET, (char_u *) options[opt_idx].fullname, NULL, FALSE, NULL);
8871 reset_v_option_vars();
8872 }
8873#endif
8874
Bram Moolenaar071d4272004-06-13 20:20:40 +00008875 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008876 if (curwin->w_curswant != MAXCOL
Bram Moolenaar488eb262015-03-13 11:23:50 +01008877 && (options[opt_idx].flags & (P_CURSWANT | P_RALL)) != 0)
Bram Moolenaar913077c2012-03-28 19:59:04 +02008878 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008879 check_redraw(options[opt_idx].flags);
8880
8881 return errmsg;
8882}
8883
8884/*
8885 * Called after an option changed: check if something needs to be redrawn.
8886 */
8887 static void
8888check_redraw(flags)
8889 long_u flags;
8890{
8891 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008892 int doclear = (flags & P_RCLR) == P_RCLR;
8893 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008894
8895#ifdef FEAT_WINDOWS
8896 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
8897 status_redraw_all();
8898#endif
8899
8900 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
8901 changed_window_setting();
8902 if (flags & P_RBUF)
8903 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008904 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008905 redraw_all_later(CLEAR);
8906 else if (all)
8907 redraw_all_later(NOT_VALID);
8908}
8909
8910/*
8911 * Find index for option 'arg'.
8912 * Return -1 if not found.
8913 */
8914 static int
8915findoption(arg)
8916 char_u *arg;
8917{
8918 int opt_idx;
8919 char *s, *p;
8920 static short quick_tab[27] = {0, 0}; /* quick access table */
8921 int is_term_opt;
8922
8923 /*
8924 * For first call: Initialize the quick-access table.
8925 * It contains the index for the first option that starts with a certain
8926 * letter. There are 26 letters, plus the first "t_" option.
8927 */
8928 if (quick_tab[1] == 0)
8929 {
8930 p = options[0].fullname;
8931 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8932 {
8933 if (s[0] != p[0])
8934 {
8935 if (s[0] == 't' && s[1] == '_')
8936 quick_tab[26] = opt_idx;
8937 else
8938 quick_tab[CharOrdLow(s[0])] = opt_idx;
8939 }
8940 p = s;
8941 }
8942 }
8943
8944 /*
8945 * Check for name starting with an illegal character.
8946 */
8947#ifdef EBCDIC
8948 if (!islower(arg[0]))
8949#else
8950 if (arg[0] < 'a' || arg[0] > 'z')
8951#endif
8952 return -1;
8953
8954 is_term_opt = (arg[0] == 't' && arg[1] == '_');
8955 if (is_term_opt)
8956 opt_idx = quick_tab[26];
8957 else
8958 opt_idx = quick_tab[CharOrdLow(arg[0])];
8959 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8960 {
8961 if (STRCMP(arg, s) == 0) /* match full name */
8962 break;
8963 }
8964 if (s == NULL && !is_term_opt)
8965 {
8966 opt_idx = quick_tab[CharOrdLow(arg[0])];
8967 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
8968 {
8969 s = options[opt_idx].shortname;
8970 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
8971 break;
8972 s = NULL;
8973 }
8974 }
8975 if (s == NULL)
8976 opt_idx = -1;
8977 return opt_idx;
8978}
8979
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008980#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008981/*
8982 * Get the value for an option.
8983 *
8984 * Returns:
8985 * Number or Toggle option: 1, *numval gets value.
8986 * String option: 0, *stringval gets allocated string.
8987 * Hidden Number or Toggle option: -1.
8988 * hidden String option: -2.
8989 * unknown option: -3.
8990 */
8991 int
8992get_option_value(name, numval, stringval, opt_flags)
8993 char_u *name;
8994 long *numval;
Bram Moolenaar370df582010-06-22 05:16:38 +02008995 char_u **stringval; /* NULL when only checking existence */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008996 int opt_flags;
8997{
8998 int opt_idx;
8999 char_u *varp;
9000
9001 opt_idx = findoption(name);
9002 if (opt_idx < 0) /* unknown option */
9003 return -3;
9004
9005 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
9006
9007 if (options[opt_idx].flags & P_STRING)
9008 {
9009 if (varp == NULL) /* hidden option */
9010 return -2;
9011 if (stringval != NULL)
9012 {
9013#ifdef FEAT_CRYPT
9014 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00009015 if ((char_u **)varp == &curbuf->b_p_key
9016 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009017 *stringval = vim_strsave((char_u *)"*****");
9018 else
9019#endif
9020 *stringval = vim_strsave(*(char_u **)(varp));
9021 }
9022 return 0;
9023 }
9024
9025 if (varp == NULL) /* hidden option */
9026 return -1;
9027 if (options[opt_idx].flags & P_NUM)
9028 *numval = *(long *)varp;
9029 else
9030 {
9031 /* Special case: 'modified' is b_changed, but we also want to consider
9032 * it set when 'ff' or 'fenc' changed. */
9033 if ((int *)varp == &curbuf->b_changed)
9034 *numval = curbufIsChanged();
9035 else
9036 *numval = *(int *)varp;
9037 }
9038 return 1;
9039}
9040#endif
9041
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009042#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009043/*
9044 * Returns the option attributes and its value. Unlike the above function it
9045 * will return either global value or local value of the option depending on
9046 * what was requested, but it will never return global value if it was
9047 * requested to return local one and vice versa. Neither it will return
9048 * buffer-local value if it was requested to return window-local one.
9049 *
9050 * Pretends that option is absent if it is not present in the requested scope
9051 * (i.e. has no global, window-local or buffer-local value depending on
9052 * opt_type). Uses
9053 *
9054 * Returned flags:
Bram Moolenaar75a8d742014-05-07 15:10:21 +02009055 * 0 hidden or unknown option, also option that does not have requested
9056 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009057 * see SOPT_* in vim.h for other flags
9058 *
9059 * Possible opt_type values: see SREQ_* in vim.h
9060 */
9061 int
9062get_option_value_strict(name, numval, stringval, opt_type, from)
9063 char_u *name;
9064 long *numval;
9065 char_u **stringval; /* NULL when only obtaining attributes */
9066 int opt_type;
9067 void *from;
9068{
9069 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02009070 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009071 struct vimoption *p;
9072 int r = 0;
9073
9074 opt_idx = findoption(name);
9075 if (opt_idx < 0)
9076 return 0;
9077
9078 p = &(options[opt_idx]);
9079
9080 /* Hidden option */
9081 if (p->var == NULL)
9082 return 0;
9083
9084 if (p->flags & P_BOOL)
9085 r |= SOPT_BOOL;
9086 else if (p->flags & P_NUM)
9087 r |= SOPT_NUM;
9088 else if (p->flags & P_STRING)
9089 r |= SOPT_STRING;
9090
9091 if (p->indir == PV_NONE)
9092 {
9093 if (opt_type == SREQ_GLOBAL)
9094 r |= SOPT_GLOBAL;
9095 else
9096 return 0; /* Did not request global-only option */
9097 }
9098 else
9099 {
9100 if (p->indir & PV_BOTH)
9101 r |= SOPT_GLOBAL;
9102 else if (opt_type == SREQ_GLOBAL)
9103 return 0; /* Requested global option */
9104
9105 if (p->indir & PV_WIN)
9106 {
9107 if (opt_type == SREQ_BUF)
9108 return 0; /* Did not request window-local option */
9109 else
9110 r |= SOPT_WIN;
9111 }
9112 else if (p->indir & PV_BUF)
9113 {
9114 if (opt_type == SREQ_WIN)
9115 return 0; /* Did not request buffer-local option */
9116 else
9117 r |= SOPT_BUF;
9118 }
9119 }
9120
9121 if (stringval == NULL)
9122 return r;
9123
9124 if (opt_type == SREQ_GLOBAL)
9125 varp = p->var;
9126 else
9127 {
9128 if (opt_type == SREQ_BUF)
9129 {
9130 /* Special case: 'modified' is b_changed, but we also want to
9131 * consider it set when 'ff' or 'fenc' changed. */
9132 if (p->indir == PV_MOD)
9133 {
9134 *numval = bufIsChanged((buf_T *) from);
9135 varp = NULL;
9136 }
9137#ifdef FEAT_CRYPT
9138 else if (p->indir == PV_KEY)
9139 {
9140 /* never return the value of the crypt key */
9141 *stringval = NULL;
9142 varp = NULL;
9143 }
9144#endif
9145 else
9146 {
9147 aco_save_T aco;
9148 aucmd_prepbuf(&aco, (buf_T *) from);
9149 varp = get_varp(p);
9150 aucmd_restbuf(&aco);
9151 }
9152 }
9153 else if (opt_type == SREQ_WIN)
9154 {
9155 win_T *save_curwin;
9156 save_curwin = curwin;
9157 curwin = (win_T *) from;
9158 curbuf = curwin->w_buffer;
9159 varp = get_varp(p);
9160 curwin = save_curwin;
9161 curbuf = curwin->w_buffer;
9162 }
9163 if (varp == p->var)
9164 return (r | SOPT_UNSET);
9165 }
9166
9167 if (varp != NULL)
9168 {
9169 if (p->flags & P_STRING)
9170 *stringval = vim_strsave(*(char_u **)(varp));
9171 else if (p->flags & P_NUM)
9172 *numval = *(long *) varp;
9173 else
9174 *numval = *(int *)varp;
9175 }
9176
9177 return r;
9178}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009179
9180/*
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009181 * Iterate over options. First argument is a pointer to a pointer to a
9182 * structure inside options[] array, second is option type like in the above
9183 * function.
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009184 *
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009185 * If first argument points to NULL it is assumed that iteration just started
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009186 * and caller needs the very first value.
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +02009187 * If first argument points to the end marker function returns NULL and sets
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009188 * first argument to NULL.
9189 *
9190 * Returns full option name for current option on each call.
9191 */
9192 char_u *
9193option_iter_next(option, opt_type)
9194 void **option;
9195 int opt_type;
9196{
9197 struct vimoption *ret = NULL;
9198 do
9199 {
9200 if (*option == NULL)
9201 *option = (void *) options;
9202 else if (((struct vimoption *) (*option))->fullname == NULL)
9203 {
9204 *option = NULL;
9205 return NULL;
9206 }
9207 else
9208 *option = (void *) (((struct vimoption *) (*option)) + 1);
9209
9210 ret = ((struct vimoption *) (*option));
9211
9212 /* Hidden option */
9213 if (ret->var == NULL)
9214 {
9215 ret = NULL;
9216 continue;
9217 }
9218
9219 switch (opt_type)
9220 {
9221 case SREQ_GLOBAL:
9222 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9223 ret = NULL;
9224 break;
9225 case SREQ_BUF:
9226 if (!(ret->indir & PV_BUF))
9227 ret = NULL;
9228 break;
9229 case SREQ_WIN:
9230 if (!(ret->indir & PV_WIN))
9231 ret = NULL;
9232 break;
9233 default:
9234 EMSG2(_(e_intern2), "option_iter_next()");
9235 return NULL;
9236 }
9237 }
9238 while (ret == NULL);
9239
9240 return (char_u *)ret->fullname;
9241}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009242#endif
9243
Bram Moolenaar071d4272004-06-13 20:20:40 +00009244/*
9245 * Set the value of option "name".
9246 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009247 *
9248 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009249 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009250 char_u *
Bram Moolenaar071d4272004-06-13 20:20:40 +00009251set_option_value(name, number, string, opt_flags)
9252 char_u *name;
9253 long number;
9254 char_u *string;
9255 int opt_flags; /* OPT_LOCAL or 0 (both) */
9256{
9257 int opt_idx;
9258 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009259 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009260
9261 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009262 if (opt_idx < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009263 EMSG2(_("E355: Unknown option: %s"), name);
9264 else
9265 {
9266 flags = options[opt_idx].flags;
9267#ifdef HAVE_SANDBOX
9268 /* Disallow changing some options in the sandbox */
9269 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009270 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009271 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009272 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009273 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009274#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009275 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009276 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009277 else
9278 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009279 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009280 if (varp != NULL) /* hidden option is not changed */
9281 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009282 if (number == 0 && string != NULL)
9283 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009284 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009285
9286 /* Either we are given a string or we are setting option
9287 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009288 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009289 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009290 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009291 {
9292 /* There's another character after zeros or the string
9293 * is empty. In both cases, we are trying to set a
9294 * num option using a string. */
9295 EMSG3(_("E521: Number required: &%s = '%s'"),
9296 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009297 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009298
9299 }
9300 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009301 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009302 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009303 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009304 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009305 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009306 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009307 }
9308 }
9309 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009310 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009311}
9312
9313/*
9314 * Get the terminal code for a terminal option.
9315 * Returns NULL when not found.
9316 */
9317 char_u *
9318get_term_code(tname)
9319 char_u *tname;
9320{
9321 int opt_idx;
9322 char_u *varp;
9323
9324 if (tname[0] != 't' || tname[1] != '_' ||
9325 tname[2] == NUL || tname[3] == NUL)
9326 return NULL;
9327 if ((opt_idx = findoption(tname)) >= 0)
9328 {
9329 varp = get_varp(&(options[opt_idx]));
9330 if (varp != NULL)
9331 varp = *(char_u **)(varp);
9332 return varp;
9333 }
9334 return find_termcode(tname + 2);
9335}
9336
9337 char_u *
9338get_highlight_default()
9339{
9340 int i;
9341
9342 i = findoption((char_u *)"hl");
9343 if (i >= 0)
9344 return options[i].def_val[VI_DEFAULT];
9345 return (char_u *)NULL;
9346}
9347
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009348#if defined(FEAT_MBYTE) || defined(PROTO)
9349 char_u *
9350get_encoding_default()
9351{
9352 int i;
9353
9354 i = findoption((char_u *)"enc");
9355 if (i >= 0)
9356 return options[i].def_val[VI_DEFAULT];
9357 return (char_u *)NULL;
9358}
9359#endif
9360
Bram Moolenaar071d4272004-06-13 20:20:40 +00009361/*
9362 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9363 */
9364 static int
9365find_key_option(arg)
9366 char_u *arg;
9367{
9368 int key;
9369 int modifiers;
9370
9371 /*
9372 * Don't use get_special_key_code() for t_xx, we don't want it to call
9373 * add_termcap_entry().
9374 */
9375 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9376 key = TERMCAP2KEY(arg[2], arg[3]);
9377 else
9378 {
9379 --arg; /* put arg at the '<' */
9380 modifiers = 0;
Bram Moolenaar2a8ced02008-12-24 11:54:31 +00009381 key = find_special_key(&arg, &modifiers, TRUE, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009382 if (modifiers) /* can't handle modifiers here */
9383 key = 0;
9384 }
9385 return key;
9386}
9387
9388/*
9389 * if 'all' == 0: show changed options
9390 * if 'all' == 1: show all normal options
9391 * if 'all' == 2: show all terminal options
9392 */
9393 static void
9394showoptions(all, opt_flags)
9395 int all;
9396 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
9397{
9398 struct vimoption *p;
9399 int col;
9400 int isterm;
9401 char_u *varp;
9402 struct vimoption **items;
9403 int item_count;
9404 int run;
9405 int row, rows;
9406 int cols;
9407 int i;
9408 int len;
9409
9410#define INC 20
9411#define GAP 3
9412
9413 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9414 PARAM_COUNT));
9415 if (items == NULL)
9416 return;
9417
9418 /* Highlight title */
9419 if (all == 2)
9420 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9421 else if (opt_flags & OPT_GLOBAL)
9422 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9423 else if (opt_flags & OPT_LOCAL)
9424 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9425 else
9426 MSG_PUTS_TITLE(_("\n--- Options ---"));
9427
9428 /*
9429 * do the loop two times:
9430 * 1. display the short items
9431 * 2. display the long items (only strings and numbers)
9432 */
9433 for (run = 1; run <= 2 && !got_int; ++run)
9434 {
9435 /*
9436 * collect the items in items[]
9437 */
9438 item_count = 0;
9439 for (p = &options[0]; p->fullname != NULL; p++)
9440 {
9441 varp = NULL;
9442 isterm = istermoption(p);
9443 if (opt_flags != 0)
9444 {
9445 if (p->indir != PV_NONE && !isterm)
9446 varp = get_varp_scope(p, opt_flags);
9447 }
9448 else
9449 varp = get_varp(p);
9450 if (varp != NULL
9451 && ((all == 2 && isterm)
9452 || (all == 1 && !isterm)
9453 || (all == 0 && !optval_default(p, varp))))
9454 {
9455 if (p->flags & P_BOOL)
9456 len = 1; /* a toggle option fits always */
9457 else
9458 {
9459 option_value2string(p, opt_flags);
9460 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9461 }
9462 if ((len <= INC - GAP && run == 1) ||
9463 (len > INC - GAP && run == 2))
9464 items[item_count++] = p;
9465 }
9466 }
9467
9468 /*
9469 * display the items
9470 */
9471 if (run == 1)
9472 {
9473 cols = (Columns + GAP - 3) / INC;
9474 if (cols == 0)
9475 cols = 1;
9476 rows = (item_count + cols - 1) / cols;
9477 }
9478 else /* run == 2 */
9479 rows = item_count;
9480 for (row = 0; row < rows && !got_int; ++row)
9481 {
9482 msg_putchar('\n'); /* go to next line */
9483 if (got_int) /* 'q' typed in more */
9484 break;
9485 col = 0;
9486 for (i = row; i < item_count; i += rows)
9487 {
9488 msg_col = col; /* make columns */
9489 showoneopt(items[i], opt_flags);
9490 col += INC;
9491 }
9492 out_flush();
9493 ui_breakcheck();
9494 }
9495 }
9496 vim_free(items);
9497}
9498
9499/*
9500 * Return TRUE if option "p" has its default value.
9501 */
9502 static int
9503optval_default(p, varp)
9504 struct vimoption *p;
9505 char_u *varp;
9506{
9507 int dvi;
9508
9509 if (varp == NULL)
9510 return TRUE; /* hidden option is always at default */
9511 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9512 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009513 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009514 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009515 /* the cast to long is required for Manx C, long_i is
9516 * needed for MSVC */
9517 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009518 /* P_STRING */
9519 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9520}
9521
9522/*
9523 * showoneopt: show the value of one option
9524 * must not be called with a hidden option!
9525 */
9526 static void
9527showoneopt(p, opt_flags)
9528 struct vimoption *p;
9529 int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */
9530{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009531 char_u *varp;
9532 int save_silent = silent_mode;
9533
9534 silent_mode = FALSE;
9535 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009536
9537 varp = get_varp_scope(p, opt_flags);
9538
9539 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9540 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9541 ? !curbufIsChanged() : !*(int *)varp))
9542 MSG_PUTS("no");
9543 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9544 MSG_PUTS("--");
9545 else
9546 MSG_PUTS(" ");
9547 MSG_PUTS(p->fullname);
9548 if (!(p->flags & P_BOOL))
9549 {
9550 msg_putchar('=');
9551 /* put value string in NameBuff */
9552 option_value2string(p, opt_flags);
9553 msg_outtrans(NameBuff);
9554 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009555
9556 silent_mode = save_silent;
9557 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009558}
9559
9560/*
9561 * Write modified options as ":set" commands to a file.
9562 *
9563 * There are three values for "opt_flags":
9564 * OPT_GLOBAL: Write global option values and fresh values of
9565 * buffer-local options (used for start of a session
9566 * file).
9567 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
9568 * curwin (used for a vimrc file).
9569 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
9570 * and local values for window-local options of
9571 * curwin. Local values are also written when at the
9572 * default value, because a modeline or autocommand
9573 * may have set them when doing ":edit file" and the
9574 * user has set them back at the default or fresh
9575 * value.
9576 * When "local_only" is TRUE, don't write fresh
9577 * values, only local values (for ":mkview").
9578 * (fresh value = value used for a new buffer or window for a local option).
9579 *
9580 * Return FAIL on error, OK otherwise.
9581 */
9582 int
9583makeset(fd, opt_flags, local_only)
9584 FILE *fd;
9585 int opt_flags;
9586 int local_only;
9587{
9588 struct vimoption *p;
9589 char_u *varp; /* currently used value */
9590 char_u *varp_fresh; /* local value */
9591 char_u *varp_local = NULL; /* fresh value */
9592 char *cmd;
9593 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009594 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009595
9596 /*
9597 * The options that don't have a default (terminal name, columns, lines)
9598 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009599 * Do the loop over "options[]" twice: once for options with the
9600 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009601 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009602 for (pri = 1; pri >= 0; --pri)
9603 {
9604 for (p = &options[0]; !istermoption(p); p++)
9605 if (!(p->flags & P_NO_MKRC)
9606 && !istermoption(p)
9607 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009608 {
9609 /* skip global option when only doing locals */
9610 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
9611 continue;
9612
9613 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
9614 * file, they are always buffer-specific. */
9615 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
9616 continue;
9617
9618 /* Global values are only written when not at the default value. */
9619 varp = get_varp_scope(p, opt_flags);
9620 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
9621 continue;
9622
9623 round = 2;
9624 if (p->indir != PV_NONE)
9625 {
9626 if (p->var == VAR_WIN)
9627 {
9628 /* skip window-local option when only doing globals */
9629 if (!(opt_flags & OPT_LOCAL))
9630 continue;
9631 /* When fresh value of window-local option is not at the
9632 * default, need to write it too. */
9633 if (!(opt_flags & OPT_GLOBAL) && !local_only)
9634 {
9635 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
9636 if (!optval_default(p, varp_fresh))
9637 {
9638 round = 1;
9639 varp_local = varp;
9640 varp = varp_fresh;
9641 }
9642 }
9643 }
9644 }
9645
9646 /* Round 1: fresh value for window-local options.
9647 * Round 2: other values */
9648 for ( ; round <= 2; varp = varp_local, ++round)
9649 {
9650 if (round == 1 || (opt_flags & OPT_GLOBAL))
9651 cmd = "set";
9652 else
9653 cmd = "setlocal";
9654
9655 if (p->flags & P_BOOL)
9656 {
9657 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
9658 return FAIL;
9659 }
9660 else if (p->flags & P_NUM)
9661 {
9662 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
9663 return FAIL;
9664 }
9665 else /* P_STRING */
9666 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009667#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9668 int do_endif = FALSE;
9669
Bram Moolenaar071d4272004-06-13 20:20:40 +00009670 /* Don't set 'syntax' and 'filetype' again if the value is
9671 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009672 if (
9673# if defined(FEAT_SYN_HL)
9674 p->indir == PV_SYN
9675# if defined(FEAT_AUTOCMD)
9676 ||
9677# endif
9678# endif
9679# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009680 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009681# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009682 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00009683 {
9684 if (fprintf(fd, "if &%s != '%s'", p->fullname,
9685 *(char_u **)(varp)) < 0
9686 || put_eol(fd) < 0)
9687 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009688 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009689 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009690#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009691 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
9692 (p->flags & P_EXPAND) != 0) == FAIL)
9693 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009694#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9695 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009696 {
9697 if (put_line(fd, "endif") == FAIL)
9698 return FAIL;
9699 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009700#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009701 }
9702 }
9703 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009704 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009705 return OK;
9706}
9707
9708#if defined(FEAT_FOLDING) || defined(PROTO)
9709/*
9710 * Generate set commands for the local fold options only. Used when
9711 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
9712 */
9713 int
9714makefoldset(fd)
9715 FILE *fd;
9716{
9717 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
9718# ifdef FEAT_EVAL
9719 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
9720 == FAIL
9721# endif
9722 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
9723 == FAIL
9724 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
9725 == FAIL
9726 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
9727 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
9728 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
9729 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
9730 )
9731 return FAIL;
9732
9733 return OK;
9734}
9735#endif
9736
9737 static int
9738put_setstring(fd, cmd, name, valuep, expand)
9739 FILE *fd;
9740 char *cmd;
9741 char *name;
9742 char_u **valuep;
9743 int expand;
9744{
9745 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009746 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009747
9748 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9749 return FAIL;
9750 if (*valuep != NULL)
9751 {
9752 /* Output 'pastetoggle' as key names. For other
9753 * options some characters have to be escaped with
9754 * CTRL-V or backslash */
9755 if (valuep == &p_pt)
9756 {
9757 s = *valuep;
9758 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +00009759 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009760 return FAIL;
9761 }
9762 else if (expand)
9763 {
Bram Moolenaarf8441472011-04-28 17:24:58 +02009764 buf = alloc(MAXPATHL);
9765 if (buf == NULL)
9766 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009767 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
9768 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +02009769 {
9770 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009771 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009772 }
9773 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009774 }
9775 else if (put_escstr(fd, *valuep, 2) == FAIL)
9776 return FAIL;
9777 }
9778 if (put_eol(fd) < 0)
9779 return FAIL;
9780 return OK;
9781}
9782
9783 static int
9784put_setnum(fd, cmd, name, valuep)
9785 FILE *fd;
9786 char *cmd;
9787 char *name;
9788 long *valuep;
9789{
9790 long wc;
9791
9792 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9793 return FAIL;
9794 if (wc_use_keyname((char_u *)valuep, &wc))
9795 {
9796 /* print 'wildchar' and 'wildcharm' as a key name */
9797 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
9798 return FAIL;
9799 }
9800 else if (fprintf(fd, "%ld", *valuep) < 0)
9801 return FAIL;
9802 if (put_eol(fd) < 0)
9803 return FAIL;
9804 return OK;
9805}
9806
9807 static int
9808put_setbool(fd, cmd, name, value)
9809 FILE *fd;
9810 char *cmd;
9811 char *name;
9812 int value;
9813{
Bram Moolenaar893de922007-10-02 18:40:57 +00009814 if (value < 0) /* global/local option using global value */
9815 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009816 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
9817 || put_eol(fd) < 0)
9818 return FAIL;
9819 return OK;
9820}
9821
9822/*
9823 * Clear all the terminal options.
9824 * If the option has been allocated, free the memory.
9825 * Terminal options are never hidden or indirect.
9826 */
9827 void
9828clear_termoptions()
9829{
Bram Moolenaar071d4272004-06-13 20:20:40 +00009830 /*
9831 * Reset a few things before clearing the old options. This may cause
9832 * outputting a few things that the terminal doesn't understand, but the
9833 * screen will be cleared later, so this is OK.
9834 */
9835#ifdef FEAT_MOUSE_TTY
9836 mch_setmouse(FALSE); /* switch mouse off */
9837#endif
9838#ifdef FEAT_TITLE
9839 mch_restore_title(3); /* restore window titles */
9840#endif
9841#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
9842 /* When starting the GUI close the display opened for the clipboard.
9843 * After restoring the title, because that will need the display. */
9844 if (gui.starting)
9845 clear_xterm_clip();
9846#endif
9847#ifdef WIN3264
9848 /*
9849 * Check if this is allowed now.
9850 */
9851 if (can_end_termcap_mode(FALSE) == TRUE)
9852#endif
9853 stoptermcap(); /* stop termcap mode */
9854
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00009855 free_termoptions();
9856}
9857
9858 void
9859free_termoptions()
9860{
9861 struct vimoption *p;
9862
Bram Moolenaar071d4272004-06-13 20:20:40 +00009863 for (p = &options[0]; p->fullname != NULL; p++)
9864 if (istermoption(p))
9865 {
9866 if (p->flags & P_ALLOCED)
9867 free_string_option(*(char_u **)(p->var));
9868 if (p->flags & P_DEF_ALLOCED)
9869 free_string_option(p->def_val[VI_DEFAULT]);
9870 *(char_u **)(p->var) = empty_option;
9871 p->def_val[VI_DEFAULT] = empty_option;
9872 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
9873 }
9874 clear_termcodes();
9875}
9876
9877/*
Bram Moolenaar363cb672009-07-22 12:28:17 +00009878 * Free the string for one term option, if it was allocated.
9879 * Set the string to empty_option and clear allocated flag.
9880 * "var" points to the option value.
9881 */
9882 void
9883free_one_termoption(var)
9884 char_u *var;
9885{
9886 struct vimoption *p;
9887
9888 for (p = &options[0]; p->fullname != NULL; p++)
9889 if (p->var == var)
9890 {
9891 if (p->flags & P_ALLOCED)
9892 free_string_option(*(char_u **)(p->var));
9893 *(char_u **)(p->var) = empty_option;
9894 p->flags &= ~P_ALLOCED;
9895 break;
9896 }
9897}
9898
9899/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00009900 * Set the terminal option defaults to the current value.
9901 * Used after setting the terminal name.
9902 */
9903 void
9904set_term_defaults()
9905{
9906 struct vimoption *p;
9907
9908 for (p = &options[0]; p->fullname != NULL; p++)
9909 {
9910 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
9911 {
9912 if (p->flags & P_DEF_ALLOCED)
9913 {
9914 free_string_option(p->def_val[VI_DEFAULT]);
9915 p->flags &= ~P_DEF_ALLOCED;
9916 }
9917 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
9918 if (p->flags & P_ALLOCED)
9919 {
9920 p->flags |= P_DEF_ALLOCED;
9921 p->flags &= ~P_ALLOCED; /* don't free the value now */
9922 }
9923 }
9924 }
9925}
9926
9927/*
9928 * return TRUE if 'p' starts with 't_'
9929 */
9930 static int
9931istermoption(p)
9932 struct vimoption *p;
9933{
9934 return (p->fullname[0] == 't' && p->fullname[1] == '_');
9935}
9936
9937/*
9938 * Compute columns for ruler and shown command. 'sc_col' is also used to
9939 * decide what the maximum length of a message on the status line can be.
9940 * If there is a status line for the last window, 'sc_col' is independent
9941 * of 'ru_col'.
9942 */
9943
9944#define COL_RULER 17 /* columns needed by standard ruler */
9945
9946 void
9947comp_col()
9948{
9949#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
9950 int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin));
9951
9952 sc_col = 0;
9953 ru_col = 0;
9954 if (p_ru)
9955 {
9956#ifdef FEAT_STL_OPT
9957 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
9958#else
9959 ru_col = COL_RULER + 1;
9960#endif
9961 /* no last status line, adjust sc_col */
9962 if (!last_has_status)
9963 sc_col = ru_col;
9964 }
9965 if (p_sc)
9966 {
9967 sc_col += SHOWCMD_COLS;
9968 if (!p_ru || last_has_status) /* no need for separating space */
9969 ++sc_col;
9970 }
9971 sc_col = Columns - sc_col;
9972 ru_col = Columns - ru_col;
9973 if (sc_col <= 0) /* screen too narrow, will become a mess */
9974 sc_col = 1;
9975 if (ru_col <= 0)
9976 ru_col = 1;
9977#else
9978 sc_col = Columns;
9979 ru_col = Columns;
9980#endif
9981}
9982
9983/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009984 * Unset local option value, similar to ":set opt<".
9985 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009986 void
9987unset_global_local_option(name, from)
9988 char_u *name;
9989 void *from;
9990{
9991 struct vimoption *p;
9992 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009993 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009994
9995 opt_idx = findoption(name);
Bram Moolenaarbd8539a2015-08-11 18:53:03 +02009996 if (opt_idx < 0)
9997 return;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009998 p = &(options[opt_idx]);
9999
10000 switch ((int)p->indir)
10001 {
10002 /* global option with local value: use local value if it's been set */
10003 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010004 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010005 break;
10006 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010007 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010008 break;
10009 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010010 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010011 break;
10012 case PV_AR:
10013 buf->b_p_ar = -1;
10014 break;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010015 case PV_BKC:
10016 clear_string_option(&buf->b_p_bkc);
10017 buf->b_bkc_flags = 0;
10018 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010019 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010020 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010021 break;
10022#ifdef FEAT_FIND_ID
10023 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010024 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010025 break;
10026 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010027 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010028 break;
10029#endif
10030#ifdef FEAT_INS_EXPAND
10031 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010032 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010033 break;
10034 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010035 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010036 break;
10037#endif
10038#ifdef FEAT_QUICKFIX
10039 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010040 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010041 break;
10042 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010043 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010044 break;
10045 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010046 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010047 break;
10048#endif
10049#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10050 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010051 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010052 break;
10053#endif
10054#if defined(FEAT_CRYPT)
10055 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010056 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010057 break;
10058#endif
10059#ifdef FEAT_STL_OPT
10060 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +020010061 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010062 break;
10063#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010064 case PV_UL:
10065 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
10066 break;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010067#ifdef FEAT_LISP
10068 case PV_LW:
10069 clear_string_option(&buf->b_p_lw);
10070 break;
10071#endif
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +020010072 }
10073}
10074
10075/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000010076 * Get pointer to option variable, depending on local or global scope.
10077 */
10078 static char_u *
10079get_varp_scope(p, opt_flags)
10080 struct vimoption *p;
10081 int opt_flags;
10082{
10083 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
10084 {
10085 if (p->var == VAR_WIN)
10086 return (char_u *)GLOBAL_WO(get_varp(p));
10087 return p->var;
10088 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010089 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010090 {
10091 switch ((int)p->indir)
10092 {
10093#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010094 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
10095 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
10096 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010097#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010098 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
10099 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
10100 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010101 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010102 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010103#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010104 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
10105 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010106#endif
10107#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010108 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
10109 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010110#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010111#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10112 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
10113#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010114#if defined(FEAT_CRYPT)
10115 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
10116#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010117#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010118 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010119#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010120 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010121#ifdef FEAT_LISP
10122 case PV_LW: return (char_u *)&(curbuf->b_p_lw);
10123#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010124 case PV_BKC: return (char_u *)&(curbuf->b_p_bkc);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010125 }
10126 return NULL; /* "cannot happen" */
10127 }
10128 return get_varp(p);
10129}
10130
10131/*
10132 * Get pointer to option variable.
10133 */
10134 static char_u *
10135get_varp(p)
10136 struct vimoption *p;
10137{
10138 /* hidden option, always return NULL */
10139 if (p->var == NULL)
10140 return NULL;
10141
10142 switch ((int)p->indir)
10143 {
10144 case PV_NONE: return p->var;
10145
10146 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010147 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010148 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010149 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010150 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010151 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010152 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +000010153 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +000010154 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010155 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010156 ? (char_u *)&(curbuf->b_p_tags) : p->var;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010157 case PV_BKC: return *curbuf->b_p_bkc != NUL
10158 ? (char_u *)&(curbuf->b_p_bkc) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010159#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010160 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010161 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010162 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010163 ? (char_u *)&(curbuf->b_p_inc) : p->var;
10164#endif
10165#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010166 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010167 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010168 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010169 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
10170#endif
10171#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010172 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +000010173 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010174 case PV_GP: return *curbuf->b_p_gp != NUL
10175 ? (char_u *)&(curbuf->b_p_gp) : p->var;
10176 case PV_MP: return *curbuf->b_p_mp != NUL
10177 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010178#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010179#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10180 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
10181 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
10182#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010183#if defined(FEAT_CRYPT)
10184 case PV_CM: return *curbuf->b_p_cm != NUL
10185 ? (char_u *)&(curbuf->b_p_cm) : p->var;
10186#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010187#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010188 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010189 ? (char_u *)&(curwin->w_p_stl) : p->var;
10190#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010191 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
10192 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010193#ifdef FEAT_LISP
10194 case PV_LW: return *curbuf->b_p_lw != NUL
10195 ? (char_u *)&(curbuf->b_p_lw) : p->var;
10196#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010197
10198#ifdef FEAT_ARABIC
10199 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10200#endif
10201 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010202#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010203 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10204#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010205#ifdef FEAT_SYN_HL
10206 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10207 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010208 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010209#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010210#ifdef FEAT_DIFF
10211 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10212#endif
10213#ifdef FEAT_FOLDING
10214 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10215 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10216 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10217 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10218 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10219 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10220 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10221# ifdef FEAT_EVAL
10222 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10223 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10224# endif
10225 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10226#endif
10227 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010228 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010229#ifdef FEAT_LINEBREAK
10230 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10231#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010232#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010233 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
10234#endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010235#ifdef FEAT_VERTSPLIT
10236 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10237#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010238#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10239 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10240#endif
10241#ifdef FEAT_RIGHTLEFT
10242 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10243 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10244#endif
10245 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10246 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10247#ifdef FEAT_LINEBREAK
10248 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
Bram Moolenaar597a4222014-06-25 14:39:50 +020010249 case PV_BRI: return (char_u *)&(curwin->w_p_bri);
10250 case PV_BRIOPT: return (char_u *)&(curwin->w_p_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010251#endif
10252#ifdef FEAT_SCROLLBIND
10253 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10254#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010255#ifdef FEAT_CURSORBIND
10256 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10257#endif
10258#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010259 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10260 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010261#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010262
10263 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10264 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10265#ifdef FEAT_MBYTE
10266 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10267#endif
10268#if defined(FEAT_QUICKFIX)
10269 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10270 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
10271#endif
10272 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10273 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10274#ifdef FEAT_CINDENT
10275 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10276 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10277 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10278#endif
10279#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10280 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10281#endif
10282#ifdef FEAT_COMMENTS
10283 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10284#endif
10285#ifdef FEAT_FOLDING
10286 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10287#endif
10288#ifdef FEAT_INS_EXPAND
10289 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10290#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010291#ifdef FEAT_COMPL_FUNC
10292 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010293 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010294#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010295 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
Bram Moolenaar34d72d42015-07-17 14:18:08 +020010296 case PV_FIXEOL: return (char_u *)&(curbuf->b_p_fixeol);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010297 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10298#ifdef FEAT_MBYTE
10299 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10300#endif
10301 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10302#ifdef FEAT_AUTOCMD
10303 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10304#endif
10305 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010306 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010307 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10308 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10309 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10310 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10311#ifdef FEAT_FIND_ID
10312# ifdef FEAT_EVAL
10313 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10314# endif
10315#endif
10316#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10317 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10318 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10319#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010320#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010321 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10322#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010323#ifdef FEAT_CRYPT
10324 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10325#endif
10326#ifdef FEAT_LISP
10327 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10328#endif
10329 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10330 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10331 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10332 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10333 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010334 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010335#ifdef FEAT_TEXTOBJ
10336 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10337#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010338 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10339#ifdef FEAT_SMARTINDENT
10340 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10341#endif
10342#ifndef SHORT_FNAME
10343 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
10344#endif
10345 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10346#ifdef FEAT_SEARCHPATH
10347 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10348#endif
10349 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10350#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010351 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010352 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10353#endif
10354#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010355 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10356 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10357 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010358#endif
10359 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10360 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10361 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10362 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010363#ifdef FEAT_PERSISTENT_UNDO
10364 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10365#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010366 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10367#ifdef FEAT_KEYMAP
10368 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10369#endif
10370 default: EMSG(_("E356: get_varp ERROR"));
10371 }
10372 /* always return a valid pointer to avoid a crash! */
10373 return (char_u *)&(curbuf->b_p_wm);
10374}
10375
10376/*
10377 * Get the value of 'equalprg', either the buffer-local one or the global one.
10378 */
10379 char_u *
10380get_equalprg()
10381{
10382 if (*curbuf->b_p_ep == NUL)
10383 return p_ep;
10384 return curbuf->b_p_ep;
10385}
10386
10387#if defined(FEAT_WINDOWS) || defined(PROTO)
10388/*
10389 * Copy options from one window to another.
10390 * Used when splitting a window.
10391 */
10392 void
10393win_copy_options(wp_from, wp_to)
10394 win_T *wp_from;
10395 win_T *wp_to;
10396{
10397 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10398 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10399# ifdef FEAT_RIGHTLEFT
10400# ifdef FEAT_FKMAP
10401 /* Is this right? */
10402 wp_to->w_farsi = wp_from->w_farsi;
10403# endif
10404# endif
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020010405#if defined(FEAT_LINEBREAK)
10406 briopt_check(wp_to);
10407#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010408}
10409#endif
10410
10411/*
10412 * Copy the options from one winopt_T to another.
10413 * Doesn't free the old option values in "to", use clear_winopt() for that.
10414 * The 'scroll' option is not copied, because it depends on the window height.
10415 * The 'previewwindow' option is reset, there can be only one preview window.
10416 */
10417 void
10418copy_winopt(from, to)
10419 winopt_T *from;
10420 winopt_T *to;
10421{
10422#ifdef FEAT_ARABIC
10423 to->wo_arab = from->wo_arab;
10424#endif
10425 to->wo_list = from->wo_list;
10426 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010427 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010428#ifdef FEAT_LINEBREAK
10429 to->wo_nuw = from->wo_nuw;
10430#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010431#ifdef FEAT_RIGHTLEFT
10432 to->wo_rl = from->wo_rl;
10433 to->wo_rlc = vim_strsave(from->wo_rlc);
10434#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010435#ifdef FEAT_STL_OPT
10436 to->wo_stl = vim_strsave(from->wo_stl);
10437#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010438 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010439#ifdef FEAT_DIFF
10440 to->wo_wrap_save = from->wo_wrap_save;
10441#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010442#ifdef FEAT_LINEBREAK
10443 to->wo_lbr = from->wo_lbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020010444 to->wo_bri = from->wo_bri;
10445 to->wo_briopt = vim_strsave(from->wo_briopt);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010446#endif
10447#ifdef FEAT_SCROLLBIND
10448 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010449 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010450#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010451#ifdef FEAT_CURSORBIND
10452 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010453 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010454#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010455#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010456 to->wo_spell = from->wo_spell;
10457#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010458#ifdef FEAT_SYN_HL
10459 to->wo_cuc = from->wo_cuc;
10460 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010461 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010462#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010463#ifdef FEAT_DIFF
10464 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010465 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010466#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010467#ifdef FEAT_CONCEAL
10468 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010469 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010470#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010471#ifdef FEAT_FOLDING
10472 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010473 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010474 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010475 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010476 to->wo_fdi = vim_strsave(from->wo_fdi);
10477 to->wo_fml = from->wo_fml;
10478 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010479 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010480 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010481 to->wo_fdm_save = from->wo_diff_saved
10482 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010483 to->wo_fdn = from->wo_fdn;
10484# ifdef FEAT_EVAL
10485 to->wo_fde = vim_strsave(from->wo_fde);
10486 to->wo_fdt = vim_strsave(from->wo_fdt);
10487# endif
10488 to->wo_fmr = vim_strsave(from->wo_fmr);
10489#endif
10490 check_winopt(to); /* don't want NULL pointers */
10491}
10492
10493/*
10494 * Check string options in a window for a NULL value.
10495 */
10496 void
10497check_win_options(win)
10498 win_T *win;
10499{
10500 check_winopt(&win->w_onebuf_opt);
10501 check_winopt(&win->w_allbuf_opt);
10502}
10503
10504/*
10505 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10506 */
Bram Moolenaar8dc907d2014-06-25 14:44:10 +020010507 static void
Bram Moolenaar071d4272004-06-13 20:20:40 +000010508check_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010509 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010510{
10511#ifdef FEAT_FOLDING
10512 check_string_option(&wop->wo_fdi);
10513 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010514 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010515# ifdef FEAT_EVAL
10516 check_string_option(&wop->wo_fde);
10517 check_string_option(&wop->wo_fdt);
10518# endif
10519 check_string_option(&wop->wo_fmr);
10520#endif
10521#ifdef FEAT_RIGHTLEFT
10522 check_string_option(&wop->wo_rlc);
10523#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010524#ifdef FEAT_STL_OPT
10525 check_string_option(&wop->wo_stl);
10526#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010527#ifdef FEAT_SYN_HL
10528 check_string_option(&wop->wo_cc);
10529#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010530#ifdef FEAT_CONCEAL
10531 check_string_option(&wop->wo_cocu);
10532#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010533#ifdef FEAT_LINEBREAK
10534 check_string_option(&wop->wo_briopt);
10535#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010536}
10537
10538/*
10539 * Free the allocated memory inside a winopt_T.
10540 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010541 void
10542clear_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010543 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010544{
10545#ifdef FEAT_FOLDING
10546 clear_string_option(&wop->wo_fdi);
10547 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010548 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010549# ifdef FEAT_EVAL
10550 clear_string_option(&wop->wo_fde);
10551 clear_string_option(&wop->wo_fdt);
10552# endif
10553 clear_string_option(&wop->wo_fmr);
10554#endif
Bram Moolenaar597a4222014-06-25 14:39:50 +020010555#ifdef FEAT_LINEBREAK
10556 clear_string_option(&wop->wo_briopt);
10557#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010558#ifdef FEAT_RIGHTLEFT
10559 clear_string_option(&wop->wo_rlc);
10560#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010561#ifdef FEAT_STL_OPT
10562 clear_string_option(&wop->wo_stl);
10563#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010564#ifdef FEAT_SYN_HL
10565 clear_string_option(&wop->wo_cc);
10566#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010567#ifdef FEAT_CONCEAL
10568 clear_string_option(&wop->wo_cocu);
10569#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010570}
10571
10572/*
10573 * Copy global option values to local options for one buffer.
10574 * Used when creating a new buffer and sometimes when entering a buffer.
10575 * flags:
10576 * BCO_ENTER We will enter the buf buffer.
10577 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
10578 * appropriate.
10579 * BCO_NOHELP Don't copy the values to a help buffer.
10580 */
10581 void
10582buf_copy_options(buf, flags)
10583 buf_T *buf;
10584 int flags;
10585{
10586 int should_copy = TRUE;
10587 char_u *save_p_isk = NULL; /* init for GCC */
10588 int dont_do_help;
10589 int did_isk = FALSE;
10590
10591 /*
Bram Moolenaar1a384422010-07-14 19:53:30 +020010592 * Don't do anything if the buffer is invalid.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010593 */
10594 if (buf == NULL || !buf_valid(buf))
10595 return;
10596
10597 /*
10598 * Skip this when the option defaults have not been set yet. Happens when
10599 * main() allocates the first buffer.
10600 */
10601 if (p_cpo != NULL)
10602 {
10603 /*
10604 * Always copy when entering and 'cpo' contains 'S'.
10605 * Don't copy when already initialized.
10606 * Don't copy when 'cpo' contains 's' and not entering.
10607 * 'S' BCO_ENTER initialized 's' should_copy
10608 * yes yes X X TRUE
10609 * yes no yes X FALSE
10610 * no X yes X FALSE
10611 * X no no yes FALSE
10612 * X no no no TRUE
10613 * no yes no X TRUE
10614 */
10615 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
10616 && (buf->b_p_initialized
10617 || (!(flags & BCO_ENTER)
10618 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
10619 should_copy = FALSE;
10620
10621 if (should_copy || (flags & BCO_ALWAYS))
10622 {
10623 /* Don't copy the options specific to a help buffer when
10624 * BCO_NOHELP is given or the options were initialized already
10625 * (jumping back to a help file with CTRL-T or CTRL-O) */
10626 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
10627 || buf->b_p_initialized;
10628 if (dont_do_help) /* don't free b_p_isk */
10629 {
10630 save_p_isk = buf->b_p_isk;
10631 buf->b_p_isk = NULL;
10632 }
10633 /*
10634 * Always free the allocated strings.
10635 * If not already initialized, set 'readonly' and copy 'fileformat'.
10636 */
10637 if (!buf->b_p_initialized)
10638 {
10639 free_buf_options(buf, TRUE);
10640 buf->b_p_ro = FALSE; /* don't copy readonly */
10641 buf->b_p_tx = p_tx;
10642#ifdef FEAT_MBYTE
10643 buf->b_p_fenc = vim_strsave(p_fenc);
10644#endif
10645 buf->b_p_ff = vim_strsave(p_ff);
10646#if defined(FEAT_QUICKFIX)
10647 buf->b_p_bh = empty_option;
10648 buf->b_p_bt = empty_option;
10649#endif
10650 }
10651 else
10652 free_buf_options(buf, FALSE);
10653
10654 buf->b_p_ai = p_ai;
10655 buf->b_p_ai_nopaste = p_ai_nopaste;
10656 buf->b_p_sw = p_sw;
10657 buf->b_p_tw = p_tw;
10658 buf->b_p_tw_nopaste = p_tw_nopaste;
10659 buf->b_p_tw_nobin = p_tw_nobin;
10660 buf->b_p_wm = p_wm;
10661 buf->b_p_wm_nopaste = p_wm_nopaste;
10662 buf->b_p_wm_nobin = p_wm_nobin;
10663 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000010664#ifdef FEAT_MBYTE
10665 buf->b_p_bomb = p_bomb;
10666#endif
Bram Moolenaarb388be02015-07-22 22:19:38 +020010667 buf->b_p_fixeol = p_fixeol;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010668 buf->b_p_et = p_et;
10669 buf->b_p_et_nobin = p_et_nobin;
10670 buf->b_p_ml = p_ml;
10671 buf->b_p_ml_nobin = p_ml_nobin;
10672 buf->b_p_inf = p_inf;
10673 buf->b_p_swf = p_swf;
10674#ifdef FEAT_INS_EXPAND
10675 buf->b_p_cpt = vim_strsave(p_cpt);
10676#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010677#ifdef FEAT_COMPL_FUNC
10678 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010679 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010680#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010681 buf->b_p_sts = p_sts;
10682 buf->b_p_sts_nopaste = p_sts_nopaste;
10683#ifndef SHORT_FNAME
10684 buf->b_p_sn = p_sn;
10685#endif
10686#ifdef FEAT_COMMENTS
10687 buf->b_p_com = vim_strsave(p_com);
10688#endif
10689#ifdef FEAT_FOLDING
10690 buf->b_p_cms = vim_strsave(p_cms);
10691#endif
10692 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010693 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010694 buf->b_p_nf = vim_strsave(p_nf);
10695 buf->b_p_mps = vim_strsave(p_mps);
10696#ifdef FEAT_SMARTINDENT
10697 buf->b_p_si = p_si;
10698#endif
10699 buf->b_p_ci = p_ci;
10700#ifdef FEAT_CINDENT
10701 buf->b_p_cin = p_cin;
10702 buf->b_p_cink = vim_strsave(p_cink);
10703 buf->b_p_cino = vim_strsave(p_cino);
10704#endif
10705#ifdef FEAT_AUTOCMD
10706 /* Don't copy 'filetype', it must be detected */
10707 buf->b_p_ft = empty_option;
10708#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010709 buf->b_p_pi = p_pi;
10710#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10711 buf->b_p_cinw = vim_strsave(p_cinw);
10712#endif
10713#ifdef FEAT_LISP
10714 buf->b_p_lisp = p_lisp;
10715#endif
10716#ifdef FEAT_SYN_HL
10717 /* Don't copy 'syntax', it must be set */
10718 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010719 buf->b_p_smc = p_smc;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010720#endif
10721#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020010722 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010723 (void)compile_cap_prog(&buf->b_s);
10724 buf->b_s.b_p_spf = vim_strsave(p_spf);
10725 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010726#endif
10727#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10728 buf->b_p_inde = vim_strsave(p_inde);
10729 buf->b_p_indk = vim_strsave(p_indk);
10730#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010731#if defined(FEAT_EVAL)
10732 buf->b_p_fex = vim_strsave(p_fex);
10733#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010734#ifdef FEAT_CRYPT
10735 buf->b_p_key = vim_strsave(p_key);
10736#endif
10737#ifdef FEAT_SEARCHPATH
10738 buf->b_p_sua = vim_strsave(p_sua);
10739#endif
10740#ifdef FEAT_KEYMAP
10741 buf->b_p_keymap = vim_strsave(p_keymap);
10742 buf->b_kmap_state |= KEYMAP_INIT;
10743#endif
10744 /* This isn't really an option, but copying the langmap and IME
10745 * state from the current buffer is better than resetting it. */
10746 buf->b_p_iminsert = p_iminsert;
10747 buf->b_p_imsearch = p_imsearch;
10748
10749 /* options that are normally global but also have a local value
10750 * are not copied, start using the global value */
10751 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010752 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020010753 buf->b_p_bkc = empty_option;
10754 buf->b_bkc_flags = 0;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010755#ifdef FEAT_QUICKFIX
10756 buf->b_p_gp = empty_option;
10757 buf->b_p_mp = empty_option;
10758 buf->b_p_efm = empty_option;
10759#endif
10760 buf->b_p_ep = empty_option;
10761 buf->b_p_kp = empty_option;
10762 buf->b_p_path = empty_option;
10763 buf->b_p_tags = empty_option;
10764#ifdef FEAT_FIND_ID
10765 buf->b_p_def = empty_option;
10766 buf->b_p_inc = empty_option;
10767# ifdef FEAT_EVAL
10768 buf->b_p_inex = vim_strsave(p_inex);
10769# endif
10770#endif
10771#ifdef FEAT_INS_EXPAND
10772 buf->b_p_dict = empty_option;
10773 buf->b_p_tsr = empty_option;
10774#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010775#ifdef FEAT_TEXTOBJ
10776 buf->b_p_qe = vim_strsave(p_qe);
10777#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010778#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10779 buf->b_p_bexpr = empty_option;
10780#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010781#if defined(FEAT_CRYPT)
10782 buf->b_p_cm = empty_option;
10783#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010784#ifdef FEAT_PERSISTENT_UNDO
10785 buf->b_p_udf = p_udf;
10786#endif
Bram Moolenaaraf6c1312014-03-12 18:55:58 +010010787#ifdef FEAT_LISP
10788 buf->b_p_lw = empty_option;
10789#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010790
10791 /*
10792 * Don't copy the options set by ex_help(), use the saved values,
10793 * when going from a help buffer to a non-help buffer.
10794 * Don't touch these at all when BCO_NOHELP is used and going from
10795 * or to a help buffer.
10796 */
10797 if (dont_do_help)
10798 buf->b_p_isk = save_p_isk;
10799 else
10800 {
10801 buf->b_p_isk = vim_strsave(p_isk);
10802 did_isk = TRUE;
10803 buf->b_p_ts = p_ts;
10804 buf->b_help = FALSE;
10805#ifdef FEAT_QUICKFIX
10806 if (buf->b_p_bt[0] == 'h')
10807 clear_string_option(&buf->b_p_bt);
10808#endif
10809 buf->b_p_ma = p_ma;
10810 }
10811 }
10812
10813 /*
10814 * When the options should be copied (ignoring BCO_ALWAYS), set the
10815 * flag that indicates that the options have been initialized.
10816 */
10817 if (should_copy)
10818 buf->b_p_initialized = TRUE;
10819 }
10820
10821 check_buf_options(buf); /* make sure we don't have NULLs */
10822 if (did_isk)
10823 (void)buf_init_chartab(buf, FALSE);
10824}
10825
10826/*
10827 * Reset the 'modifiable' option and its default value.
10828 */
10829 void
10830reset_modifiable()
10831{
10832 int opt_idx;
10833
10834 curbuf->b_p_ma = FALSE;
10835 p_ma = FALSE;
10836 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000010837 if (opt_idx >= 0)
10838 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010839}
10840
10841/*
10842 * Set the global value for 'iminsert' to the local value.
10843 */
10844 void
10845set_iminsert_global()
10846{
10847 p_iminsert = curbuf->b_p_iminsert;
10848}
10849
10850/*
10851 * Set the global value for 'imsearch' to the local value.
10852 */
10853 void
10854set_imsearch_global()
10855{
10856 p_imsearch = curbuf->b_p_imsearch;
10857}
10858
10859#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
10860static int expand_option_idx = -1;
10861static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
10862static int expand_option_flags = 0;
10863
10864 void
10865set_context_in_set_cmd(xp, arg, opt_flags)
10866 expand_T *xp;
10867 char_u *arg;
10868 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
10869{
10870 int nextchar;
10871 long_u flags = 0; /* init for GCC */
10872 int opt_idx = 0; /* init for GCC */
10873 char_u *p;
10874 char_u *s;
10875 int is_term_option = FALSE;
10876 int key;
10877
10878 expand_option_flags = opt_flags;
10879
10880 xp->xp_context = EXPAND_SETTINGS;
10881 if (*arg == NUL)
10882 {
10883 xp->xp_pattern = arg;
10884 return;
10885 }
10886 p = arg + STRLEN(arg) - 1;
10887 if (*p == ' ' && *(p - 1) != '\\')
10888 {
10889 xp->xp_pattern = p + 1;
10890 return;
10891 }
10892 while (p > arg)
10893 {
10894 s = p;
10895 /* count number of backslashes before ' ' or ',' */
10896 if (*p == ' ' || *p == ',')
10897 {
10898 while (s > arg && *(s - 1) == '\\')
10899 --s;
10900 }
10901 /* break at a space with an even number of backslashes */
10902 if (*p == ' ' && ((p - s) & 1) == 0)
10903 {
10904 ++p;
10905 break;
10906 }
10907 --p;
10908 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000010909 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010910 {
10911 xp->xp_context = EXPAND_BOOL_SETTINGS;
10912 p += 2;
10913 }
10914 if (STRNCMP(p, "inv", 3) == 0)
10915 {
10916 xp->xp_context = EXPAND_BOOL_SETTINGS;
10917 p += 3;
10918 }
10919 xp->xp_pattern = arg = p;
10920 if (*arg == '<')
10921 {
10922 while (*p != '>')
10923 if (*p++ == NUL) /* expand terminal option name */
10924 return;
10925 key = get_special_key_code(arg + 1);
10926 if (key == 0) /* unknown name */
10927 {
10928 xp->xp_context = EXPAND_NOTHING;
10929 return;
10930 }
10931 nextchar = *++p;
10932 is_term_option = TRUE;
10933 expand_option_name[2] = KEY2TERMCAP0(key);
10934 expand_option_name[3] = KEY2TERMCAP1(key);
10935 }
10936 else
10937 {
10938 if (p[0] == 't' && p[1] == '_')
10939 {
10940 p += 2;
10941 if (*p != NUL)
10942 ++p;
10943 if (*p == NUL)
10944 return; /* expand option name */
10945 nextchar = *++p;
10946 is_term_option = TRUE;
10947 expand_option_name[2] = p[-2];
10948 expand_option_name[3] = p[-1];
10949 }
10950 else
10951 {
10952 /* Allow * wildcard */
10953 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
10954 p++;
10955 if (*p == NUL)
10956 return;
10957 nextchar = *p;
10958 *p = NUL;
10959 opt_idx = findoption(arg);
10960 *p = nextchar;
10961 if (opt_idx == -1 || options[opt_idx].var == NULL)
10962 {
10963 xp->xp_context = EXPAND_NOTHING;
10964 return;
10965 }
10966 flags = options[opt_idx].flags;
10967 if (flags & P_BOOL)
10968 {
10969 xp->xp_context = EXPAND_NOTHING;
10970 return;
10971 }
10972 }
10973 }
10974 /* handle "-=" and "+=" */
10975 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
10976 {
10977 ++p;
10978 nextchar = '=';
10979 }
10980 if ((nextchar != '=' && nextchar != ':')
10981 || xp->xp_context == EXPAND_BOOL_SETTINGS)
10982 {
10983 xp->xp_context = EXPAND_UNSUCCESSFUL;
10984 return;
10985 }
10986 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
10987 {
10988 xp->xp_context = EXPAND_OLD_SETTING;
10989 if (is_term_option)
10990 expand_option_idx = -1;
10991 else
10992 expand_option_idx = opt_idx;
10993 xp->xp_pattern = p + 1;
10994 return;
10995 }
10996 xp->xp_context = EXPAND_NOTHING;
10997 if (is_term_option || (flags & P_NUM))
10998 return;
10999
11000 xp->xp_pattern = p + 1;
11001
11002 if (flags & P_EXPAND)
11003 {
11004 p = options[opt_idx].var;
11005 if (p == (char_u *)&p_bdir
11006 || p == (char_u *)&p_dir
11007 || p == (char_u *)&p_path
11008 || p == (char_u *)&p_rtp
11009#ifdef FEAT_SEARCHPATH
11010 || p == (char_u *)&p_cdpath
11011#endif
11012#ifdef FEAT_SESSION
11013 || p == (char_u *)&p_vdir
11014#endif
11015 )
11016 {
11017 xp->xp_context = EXPAND_DIRECTORIES;
11018 if (p == (char_u *)&p_path
11019#ifdef FEAT_SEARCHPATH
11020 || p == (char_u *)&p_cdpath
11021#endif
11022 )
11023 xp->xp_backslash = XP_BS_THREE;
11024 else
11025 xp->xp_backslash = XP_BS_ONE;
11026 }
11027 else
11028 {
11029 xp->xp_context = EXPAND_FILES;
11030 /* for 'tags' need three backslashes for a space */
11031 if (p == (char_u *)&p_tags)
11032 xp->xp_backslash = XP_BS_THREE;
11033 else
11034 xp->xp_backslash = XP_BS_ONE;
11035 }
11036 }
11037
11038 /* For an option that is a list of file names, find the start of the
11039 * last file name. */
11040 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
11041 {
11042 /* count number of backslashes before ' ' or ',' */
11043 if (*p == ' ' || *p == ',')
11044 {
11045 s = p;
11046 while (s > xp->xp_pattern && *(s - 1) == '\\')
11047 --s;
11048 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
11049 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
11050 {
11051 xp->xp_pattern = p + 1;
11052 break;
11053 }
11054 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011055
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000011056#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000011057 /* for 'spellsuggest' start at "file:" */
11058 if (options[opt_idx].var == (char_u *)&p_sps
11059 && STRNCMP(p, "file:", 5) == 0)
11060 {
11061 xp->xp_pattern = p + 5;
11062 break;
11063 }
11064#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011065 }
11066
11067 return;
11068}
11069
11070 int
11071ExpandSettings(xp, regmatch, num_file, file)
11072 expand_T *xp;
11073 regmatch_T *regmatch;
11074 int *num_file;
11075 char_u ***file;
11076{
11077 int num_normal = 0; /* Nr of matching non-term-code settings */
11078 int num_term = 0; /* Nr of matching terminal code settings */
11079 int opt_idx;
11080 int match;
11081 int count = 0;
11082 char_u *str;
11083 int loop;
11084 int is_term_opt;
11085 char_u name_buf[MAX_KEY_NAME_LEN];
11086 static char *(names[]) = {"all", "termcap"};
11087 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
11088
11089 /* do this loop twice:
11090 * loop == 0: count the number of matching options
11091 * loop == 1: copy the matching options into allocated memory
11092 */
11093 for (loop = 0; loop <= 1; ++loop)
11094 {
11095 regmatch->rm_ic = ic;
11096 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
11097 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000011098 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
11099 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011100 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
11101 {
11102 if (loop == 0)
11103 num_normal++;
11104 else
11105 (*file)[count++] = vim_strsave((char_u *)names[match]);
11106 }
11107 }
11108 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
11109 opt_idx++)
11110 {
11111 if (options[opt_idx].var == NULL)
11112 continue;
11113 if (xp->xp_context == EXPAND_BOOL_SETTINGS
11114 && !(options[opt_idx].flags & P_BOOL))
11115 continue;
11116 is_term_opt = istermoption(&options[opt_idx]);
11117 if (is_term_opt && num_normal > 0)
11118 continue;
11119 match = FALSE;
11120 if (vim_regexec(regmatch, str, (colnr_T)0)
11121 || (options[opt_idx].shortname != NULL
11122 && vim_regexec(regmatch,
11123 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
11124 match = TRUE;
11125 else if (is_term_opt)
11126 {
11127 name_buf[0] = '<';
11128 name_buf[1] = 't';
11129 name_buf[2] = '_';
11130 name_buf[3] = str[2];
11131 name_buf[4] = str[3];
11132 name_buf[5] = '>';
11133 name_buf[6] = NUL;
11134 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11135 {
11136 match = TRUE;
11137 str = name_buf;
11138 }
11139 }
11140 if (match)
11141 {
11142 if (loop == 0)
11143 {
11144 if (is_term_opt)
11145 num_term++;
11146 else
11147 num_normal++;
11148 }
11149 else
11150 (*file)[count++] = vim_strsave(str);
11151 }
11152 }
11153 /*
11154 * Check terminal key codes, these are not in the option table
11155 */
11156 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
11157 {
11158 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
11159 {
11160 if (!isprint(str[0]) || !isprint(str[1]))
11161 continue;
11162
11163 name_buf[0] = 't';
11164 name_buf[1] = '_';
11165 name_buf[2] = str[0];
11166 name_buf[3] = str[1];
11167 name_buf[4] = NUL;
11168
11169 match = FALSE;
11170 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11171 match = TRUE;
11172 else
11173 {
11174 name_buf[0] = '<';
11175 name_buf[1] = 't';
11176 name_buf[2] = '_';
11177 name_buf[3] = str[0];
11178 name_buf[4] = str[1];
11179 name_buf[5] = '>';
11180 name_buf[6] = NUL;
11181
11182 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11183 match = TRUE;
11184 }
11185 if (match)
11186 {
11187 if (loop == 0)
11188 num_term++;
11189 else
11190 (*file)[count++] = vim_strsave(name_buf);
11191 }
11192 }
11193
11194 /*
11195 * Check special key names.
11196 */
11197 regmatch->rm_ic = TRUE; /* ignore case here */
11198 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
11199 {
11200 name_buf[0] = '<';
11201 STRCPY(name_buf + 1, str);
11202 STRCAT(name_buf, ">");
11203
11204 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
11205 {
11206 if (loop == 0)
11207 num_term++;
11208 else
11209 (*file)[count++] = vim_strsave(name_buf);
11210 }
11211 }
11212 }
11213 if (loop == 0)
11214 {
11215 if (num_normal > 0)
11216 *num_file = num_normal;
11217 else if (num_term > 0)
11218 *num_file = num_term;
11219 else
11220 return OK;
11221 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11222 if (*file == NULL)
11223 {
11224 *file = (char_u **)"";
11225 return FAIL;
11226 }
11227 }
11228 }
11229 return OK;
11230}
11231
11232 int
11233ExpandOldSetting(num_file, file)
11234 int *num_file;
11235 char_u ***file;
11236{
11237 char_u *var = NULL; /* init for GCC */
11238 char_u *buf;
11239
11240 *num_file = 0;
11241 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11242 if (*file == NULL)
11243 return FAIL;
11244
11245 /*
11246 * For a terminal key code expand_option_idx is < 0.
11247 */
11248 if (expand_option_idx < 0)
11249 {
11250 var = find_termcode(expand_option_name + 2);
11251 if (var == NULL)
11252 expand_option_idx = findoption(expand_option_name);
11253 }
11254
11255 if (expand_option_idx >= 0)
11256 {
11257 /* put string of option value in NameBuff */
11258 option_value2string(&options[expand_option_idx], expand_option_flags);
11259 var = NameBuff;
11260 }
11261 else if (var == NULL)
11262 var = (char_u *)"";
11263
11264 /* A backslash is required before some characters. This is the reverse of
11265 * what happens in do_set(). */
11266 buf = vim_strsave_escaped(var, escape_chars);
11267
11268 if (buf == NULL)
11269 {
11270 vim_free(*file);
11271 *file = NULL;
11272 return FAIL;
11273 }
11274
11275#ifdef BACKSLASH_IN_FILENAME
11276 /* For MS-Windows et al. we don't double backslashes at the start and
11277 * before a file name character. */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011278 for (var = buf; *var != NUL; mb_ptr_adv(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011279 if (var[0] == '\\' && var[1] == '\\'
11280 && expand_option_idx >= 0
11281 && (options[expand_option_idx].flags & P_EXPAND)
11282 && vim_isfilec(var[2])
11283 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011284 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011285#endif
11286
11287 *file[0] = buf;
11288 *num_file = 1;
11289 return OK;
11290}
11291#endif
11292
11293/*
11294 * Get the value for the numeric or string option *opp in a nice format into
11295 * NameBuff[]. Must not be called with a hidden option!
11296 */
11297 static void
11298option_value2string(opp, opt_flags)
11299 struct vimoption *opp;
11300 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
11301{
11302 char_u *varp;
11303
11304 varp = get_varp_scope(opp, opt_flags);
11305
11306 if (opp->flags & P_NUM)
11307 {
11308 long wc = 0;
11309
11310 if (wc_use_keyname(varp, &wc))
11311 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11312 else if (wc != 0)
11313 STRCPY(NameBuff, transchar((int)wc));
11314 else
11315 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11316 }
11317 else /* P_STRING */
11318 {
11319 varp = *(char_u **)(varp);
11320 if (varp == NULL) /* just in case */
11321 NameBuff[0] = NUL;
11322#ifdef FEAT_CRYPT
11323 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011324 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011325 STRCPY(NameBuff, "*****");
11326#endif
11327 else if (opp->flags & P_EXPAND)
11328 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11329 /* Translate 'pastetoggle' into special key names */
11330 else if ((char_u **)opp->var == &p_pt)
11331 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11332 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011333 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011334 }
11335}
11336
11337/*
11338 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11339 * printed as a keyname.
11340 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11341 */
11342 static int
11343wc_use_keyname(varp, wcp)
11344 char_u *varp;
11345 long *wcp;
11346{
11347 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11348 {
11349 *wcp = *(long *)varp;
11350 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11351 return TRUE;
11352 }
11353 return FALSE;
11354}
11355
Bram Moolenaar01615492015-02-03 13:00:38 +010011356#if defined(FEAT_LANGMAP) || defined(PROTO)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011357/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011358 * Any character has an equivalent 'langmap' character. This is used for
11359 * keyboards that have a special language mode that sends characters above
11360 * 128 (although other characters can be translated too). The "to" field is a
11361 * Vim command character. This avoids having to switch the keyboard back to
11362 * ASCII mode when leaving Insert mode.
11363 *
11364 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11365 * commands.
11366 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11367 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11368 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011369 */
Bram Moolenaar01615492015-02-03 13:00:38 +010011370# if defined(FEAT_MBYTE) || defined(PROTO)
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011371/*
11372 * With multi-byte support use growarray for 'langmap' chars >= 256
11373 */
11374typedef struct
11375{
11376 int from;
11377 int to;
11378} langmap_entry_T;
11379
11380static garray_T langmap_mapga;
11381static void langmap_set_entry __ARGS((int from, int to));
Bram Moolenaar071d4272004-06-13 20:20:40 +000011382
11383/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011384 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11385 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011386 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011387 static void
11388langmap_set_entry(from, to)
11389 int from;
11390 int to;
11391{
11392 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011393 int a = 0;
11394 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011395
11396 /* Do a binary search for an existing entry. */
11397 while (a != b)
11398 {
11399 int i = (a + b) / 2;
11400 int d = entries[i].from - from;
11401
11402 if (d == 0)
11403 {
11404 entries[i].to = to;
11405 return;
11406 }
11407 if (d < 0)
11408 a = i + 1;
11409 else
11410 b = i;
11411 }
11412
11413 if (ga_grow(&langmap_mapga, 1) != OK)
11414 return; /* out of memory */
11415
11416 /* insert new entry at position "a" */
11417 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11418 mch_memmove(entries + 1, entries,
11419 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11420 ++langmap_mapga.ga_len;
11421 entries[0].from = from;
11422 entries[0].to = to;
11423}
11424
11425/*
11426 * Apply 'langmap' to multi-byte character "c" and return the result.
11427 */
11428 int
11429langmap_adjust_mb(c)
11430 int c;
11431{
11432 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11433 int a = 0;
11434 int b = langmap_mapga.ga_len;
11435
11436 while (a != b)
11437 {
11438 int i = (a + b) / 2;
11439 int d = entries[i].from - c;
11440
11441 if (d == 0)
11442 return entries[i].to; /* found matching entry */
11443 if (d < 0)
11444 a = i + 1;
11445 else
11446 b = i;
11447 }
11448 return c; /* no entry found, return "c" unmodified */
11449}
11450# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011451
11452 static void
11453langmap_init()
11454{
11455 int i;
11456
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011457 for (i = 0; i < 256; i++)
11458 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11459# ifdef FEAT_MBYTE
11460 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11461# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011462}
11463
11464/*
11465 * Called when langmap option is set; the language map can be
11466 * changed at any time!
11467 */
11468 static void
11469langmap_set()
11470{
11471 char_u *p;
11472 char_u *p2;
11473 int from, to;
11474
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011475#ifdef FEAT_MBYTE
11476 ga_clear(&langmap_mapga); /* clear the previous map first */
11477#endif
11478 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011479
11480 for (p = p_langmap; p[0] != NUL; )
11481 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011482 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
11483 mb_ptr_adv(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011484 {
11485 if (p2[0] == '\\' && p2[1] != NUL)
11486 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011487 }
11488 if (p2[0] == ';')
11489 ++p2; /* abcd;ABCD form, p2 points to A */
11490 else
11491 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11492 while (p[0])
11493 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011494 if (p[0] == ',')
11495 {
11496 ++p;
11497 break;
11498 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011499 if (p[0] == '\\' && p[1] != NUL)
11500 ++p;
11501#ifdef FEAT_MBYTE
11502 from = (*mb_ptr2char)(p);
11503#else
11504 from = p[0];
11505#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011506 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011507 if (p2 == NULL)
11508 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011509 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011510 if (p[0] != ',')
11511 {
11512 if (p[0] == '\\')
11513 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011514#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011515 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011516#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011517 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011518#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011519 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011520 }
11521 else
11522 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011523 if (p2[0] != ',')
11524 {
11525 if (p2[0] == '\\')
11526 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011527#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011528 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011529#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011530 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011531#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011532 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011533 }
11534 if (to == NUL)
11535 {
11536 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
11537 transchar(from));
11538 return;
11539 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011540
11541#ifdef FEAT_MBYTE
11542 if (from >= 256)
11543 langmap_set_entry(from, to);
11544 else
11545#endif
11546 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011547
11548 /* Advance to next pair */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011549 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011550 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011551 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011552 mb_ptr_adv(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011553 if (*p == ';')
11554 {
11555 p = p2;
11556 if (p[0] != NUL)
11557 {
11558 if (p[0] != ',')
11559 {
11560 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
11561 return;
11562 }
11563 ++p;
11564 }
11565 break;
11566 }
11567 }
11568 }
11569 }
11570}
11571#endif
11572
11573/*
11574 * Return TRUE if format option 'x' is in effect.
11575 * Take care of no formatting when 'paste' is set.
11576 */
11577 int
11578has_format_option(x)
11579 int x;
11580{
11581 if (p_paste)
11582 return FALSE;
11583 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
11584}
11585
11586/*
11587 * Return TRUE if "x" is present in 'shortmess' option, or
11588 * 'shortmess' contains 'a' and "x" is present in SHM_A.
11589 */
11590 int
11591shortmess(x)
11592 int x;
11593{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010011594 return p_shm != NULL &&
11595 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000011596 || (vim_strchr(p_shm, 'a') != NULL
11597 && vim_strchr((char_u *)SHM_A, x) != NULL));
11598}
11599
11600/*
11601 * paste_option_changed() - Called after p_paste was set or reset.
11602 */
11603 static void
11604paste_option_changed()
11605{
11606 static int old_p_paste = FALSE;
11607 static int save_sm = 0;
11608#ifdef FEAT_CMDL_INFO
11609 static int save_ru = 0;
11610#endif
11611#ifdef FEAT_RIGHTLEFT
11612 static int save_ri = 0;
11613 static int save_hkmap = 0;
11614#endif
11615 buf_T *buf;
11616
11617 if (p_paste)
11618 {
11619 /*
11620 * Paste switched from off to on.
11621 * Save the current values, so they can be restored later.
11622 */
11623 if (!old_p_paste)
11624 {
11625 /* save options for each buffer */
11626 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11627 {
11628 buf->b_p_tw_nopaste = buf->b_p_tw;
11629 buf->b_p_wm_nopaste = buf->b_p_wm;
11630 buf->b_p_sts_nopaste = buf->b_p_sts;
11631 buf->b_p_ai_nopaste = buf->b_p_ai;
11632 }
11633
11634 /* save global options */
11635 save_sm = p_sm;
11636#ifdef FEAT_CMDL_INFO
11637 save_ru = p_ru;
11638#endif
11639#ifdef FEAT_RIGHTLEFT
11640 save_ri = p_ri;
11641 save_hkmap = p_hkmap;
11642#endif
11643 /* save global values for local buffer options */
11644 p_tw_nopaste = p_tw;
11645 p_wm_nopaste = p_wm;
11646 p_sts_nopaste = p_sts;
11647 p_ai_nopaste = p_ai;
11648 }
11649
11650 /*
11651 * Always set the option values, also when 'paste' is set when it is
11652 * already on.
11653 */
11654 /* set options for each buffer */
11655 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11656 {
11657 buf->b_p_tw = 0; /* textwidth is 0 */
11658 buf->b_p_wm = 0; /* wrapmargin is 0 */
11659 buf->b_p_sts = 0; /* softtabstop is 0 */
11660 buf->b_p_ai = 0; /* no auto-indent */
11661 }
11662
11663 /* set global options */
11664 p_sm = 0; /* no showmatch */
11665#ifdef FEAT_CMDL_INFO
11666# ifdef FEAT_WINDOWS
11667 if (p_ru)
11668 status_redraw_all(); /* redraw to remove the ruler */
11669# endif
11670 p_ru = 0; /* no ruler */
11671#endif
11672#ifdef FEAT_RIGHTLEFT
11673 p_ri = 0; /* no reverse insert */
11674 p_hkmap = 0; /* no Hebrew keyboard */
11675#endif
11676 /* set global values for local buffer options */
11677 p_tw = 0;
11678 p_wm = 0;
11679 p_sts = 0;
11680 p_ai = 0;
11681 }
11682
11683 /*
11684 * Paste switched from on to off: Restore saved values.
11685 */
11686 else if (old_p_paste)
11687 {
11688 /* restore options for each buffer */
11689 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11690 {
11691 buf->b_p_tw = buf->b_p_tw_nopaste;
11692 buf->b_p_wm = buf->b_p_wm_nopaste;
11693 buf->b_p_sts = buf->b_p_sts_nopaste;
11694 buf->b_p_ai = buf->b_p_ai_nopaste;
11695 }
11696
11697 /* restore global options */
11698 p_sm = save_sm;
11699#ifdef FEAT_CMDL_INFO
11700# ifdef FEAT_WINDOWS
11701 if (p_ru != save_ru)
11702 status_redraw_all(); /* redraw to draw the ruler */
11703# endif
11704 p_ru = save_ru;
11705#endif
11706#ifdef FEAT_RIGHTLEFT
11707 p_ri = save_ri;
11708 p_hkmap = save_hkmap;
11709#endif
11710 /* set global values for local buffer options */
11711 p_tw = p_tw_nopaste;
11712 p_wm = p_wm_nopaste;
11713 p_sts = p_sts_nopaste;
11714 p_ai = p_ai_nopaste;
11715 }
11716
11717 old_p_paste = p_paste;
11718}
11719
11720/*
11721 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
11722 *
11723 * Reset 'compatible' and set the values for options that didn't get set yet
11724 * to the Vim defaults.
11725 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011726 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011727 */
11728 void
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011729vimrc_found(fname, envname)
11730 char_u *fname;
11731 char_u *envname;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011732{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011733 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000011734 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011735 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011736
11737 if (!option_was_set((char_u *)"cp"))
11738 {
11739 p_cp = FALSE;
11740 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11741 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
11742 set_option_default(opt_idx, OPT_FREE, FALSE);
11743 didset_options();
11744 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011745
11746 if (fname != NULL)
11747 {
11748 p = vim_getenv(envname, &dofree);
11749 if (p == NULL)
11750 {
11751 /* Set $MYVIMRC to the first vimrc file found. */
11752 p = FullName_save(fname, FALSE);
11753 if (p != NULL)
11754 {
11755 vim_setenv(envname, p);
11756 vim_free(p);
11757 }
11758 }
11759 else if (dofree)
11760 vim_free(p);
11761 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011762}
11763
11764/*
11765 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
11766 */
11767 void
11768change_compatible(on)
11769 int on;
11770{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011771 int opt_idx;
11772
Bram Moolenaar071d4272004-06-13 20:20:40 +000011773 if (p_cp != on)
11774 {
11775 p_cp = on;
11776 compatible_set();
11777 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011778 opt_idx = findoption((char_u *)"cp");
11779 if (opt_idx >= 0)
11780 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011781}
11782
11783/*
11784 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020011785 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011786 */
11787 int
11788option_was_set(name)
11789 char_u *name;
11790{
11791 int idx;
11792
11793 idx = findoption(name);
11794 if (idx < 0) /* unknown option */
11795 return FALSE;
11796 if (options[idx].flags & P_WAS_SET)
11797 return TRUE;
11798 return FALSE;
11799}
11800
11801/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010011802 * Reset the flag indicating option "name" was set.
11803 */
11804 void
11805reset_option_was_set(name)
11806 char_u *name;
11807{
11808 int idx = findoption(name);
11809
11810 if (idx >= 0)
11811 options[idx].flags &= ~P_WAS_SET;
11812}
11813
11814/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011815 * compatible_set() - Called when 'compatible' has been set or unset.
11816 *
11817 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
11818 * flag) to a Vi compatible value.
11819 * When 'compatible' is unset: Set all options that have a different default
11820 * for Vim (without the P_VI_DEF flag) to that default.
11821 */
11822 static void
11823compatible_set()
11824{
11825 int opt_idx;
11826
11827 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11828 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
11829 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
11830 set_option_default(opt_idx, OPT_FREE, p_cp);
11831 didset_options();
11832}
11833
11834#ifdef FEAT_LINEBREAK
11835
11836# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
11837 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011838 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011839# endif
11840
11841/*
11842 * fill_breakat_flags() -- called when 'breakat' changes value.
11843 */
11844 static void
11845fill_breakat_flags()
11846{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011847 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011848 int i;
11849
11850 for (i = 0; i < 256; i++)
11851 breakat_flags[i] = FALSE;
11852
11853 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011854 for (p = p_breakat; *p; p++)
11855 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011856}
11857
11858# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011859 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011860# endif
11861
11862#endif
11863
11864/*
11865 * Check an option that can be a range of string values.
11866 *
11867 * Return OK for correct value, FAIL otherwise.
11868 * Empty is always OK.
11869 */
11870 static int
11871check_opt_strings(val, values, list)
11872 char_u *val;
11873 char **values;
11874 int list; /* when TRUE: accept a list of values */
11875{
11876 return opt_strings_flags(val, values, NULL, list);
11877}
11878
11879/*
11880 * Handle an option that can be a range of string values.
11881 * Set a flag in "*flagp" for each string present.
11882 *
11883 * Return OK for correct value, FAIL otherwise.
11884 * Empty is always OK.
11885 */
11886 static int
11887opt_strings_flags(val, values, flagp, list)
11888 char_u *val; /* new value */
11889 char **values; /* array of valid string values */
11890 unsigned *flagp;
11891 int list; /* when TRUE: accept a list of values */
11892{
11893 int i;
11894 int len;
11895 unsigned new_flags = 0;
11896
11897 while (*val)
11898 {
11899 for (i = 0; ; ++i)
11900 {
11901 if (values[i] == NULL) /* val not found in values[] */
11902 return FAIL;
11903
11904 len = (int)STRLEN(values[i]);
11905 if (STRNCMP(values[i], val, len) == 0
11906 && ((list && val[len] == ',') || val[len] == NUL))
11907 {
11908 val += len + (val[len] == ',');
11909 new_flags |= (1 << i);
11910 break; /* check next item in val list */
11911 }
11912 }
11913 }
11914 if (flagp != NULL)
11915 *flagp = new_flags;
11916
11917 return OK;
11918}
11919
11920/*
11921 * Read the 'wildmode' option, fill wim_flags[].
11922 */
11923 static int
11924check_opt_wim()
11925{
11926 char_u new_wim_flags[4];
11927 char_u *p;
11928 int i;
11929 int idx = 0;
11930
11931 for (i = 0; i < 4; ++i)
11932 new_wim_flags[i] = 0;
11933
11934 for (p = p_wim; *p; ++p)
11935 {
11936 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
11937 ;
11938 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
11939 return FAIL;
11940 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
11941 new_wim_flags[idx] |= WIM_LONGEST;
11942 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
11943 new_wim_flags[idx] |= WIM_FULL;
11944 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
11945 new_wim_flags[idx] |= WIM_LIST;
11946 else
11947 return FAIL;
11948 p += i;
11949 if (*p == NUL)
11950 break;
11951 if (*p == ',')
11952 {
11953 if (idx == 3)
11954 return FAIL;
11955 ++idx;
11956 }
11957 }
11958
11959 /* fill remaining entries with last flag */
11960 while (idx < 3)
11961 {
11962 new_wim_flags[idx + 1] = new_wim_flags[idx];
11963 ++idx;
11964 }
11965
11966 /* only when there are no errors, wim_flags[] is changed */
11967 for (i = 0; i < 4; ++i)
11968 wim_flags[i] = new_wim_flags[i];
11969 return OK;
11970}
11971
11972/*
11973 * Check if backspacing over something is allowed.
11974 */
11975 int
11976can_bs(what)
11977 int what; /* BS_INDENT, BS_EOL or BS_START */
11978{
11979 switch (*p_bs)
11980 {
11981 case '2': return TRUE;
11982 case '1': return (what != BS_START);
11983 case '0': return FALSE;
11984 }
11985 return vim_strchr(p_bs, what) != NULL;
11986}
11987
11988/*
11989 * Save the current values of 'fileformat' and 'fileencoding', so that we know
11990 * the file must be considered changed when the value is different.
11991 */
11992 void
11993save_file_ff(buf)
11994 buf_T *buf;
11995{
11996 buf->b_start_ffc = *buf->b_p_ff;
11997 buf->b_start_eol = buf->b_p_eol;
11998#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011999 buf->b_start_bomb = buf->b_p_bomb;
12000
Bram Moolenaar071d4272004-06-13 20:20:40 +000012001 /* Only use free/alloc when necessary, they take time. */
12002 if (buf->b_start_fenc == NULL
12003 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
12004 {
12005 vim_free(buf->b_start_fenc);
12006 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
12007 }
12008#endif
12009}
12010
12011/*
12012 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
12013 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012014 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
12015 * changed and 'binary' is not set.
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012016 * Also when 'endofline' was changed and 'fixeol' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012017 * When "ignore_empty" is true don't consider a new, empty buffer to be
12018 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000012019 */
12020 int
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012021file_ff_differs(buf, ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012022 buf_T *buf;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012023 int ignore_empty;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012024{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000012025 /* In a buffer that was never loaded the options are not valid. */
12026 if (buf->b_flags & BF_NEVERLOADED)
12027 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010012028 if (ignore_empty
12029 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012030 && buf->b_ml.ml_line_count == 1
12031 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
12032 return FALSE;
12033 if (buf->b_start_ffc != *buf->b_p_ff)
12034 return TRUE;
Bram Moolenaar34d72d42015-07-17 14:18:08 +020012035 if ((buf->b_p_bin || !buf->b_p_fixeol) && buf->b_start_eol != buf->b_p_eol)
Bram Moolenaar071d4272004-06-13 20:20:40 +000012036 return TRUE;
12037#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000012038 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
12039 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000012040 if (buf->b_start_fenc == NULL)
12041 return (*buf->b_p_fenc != NUL);
12042 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
12043#else
12044 return FALSE;
12045#endif
12046}
12047
12048/*
12049 * return OK if "p" is a valid fileformat name, FAIL otherwise.
12050 */
12051 int
12052check_ff_value(p)
12053 char_u *p;
12054{
12055 return check_opt_strings(p, p_ff_values, FALSE);
12056}
Bram Moolenaar14f24742012-08-08 18:01:05 +020012057
12058/*
12059 * Return the effective shiftwidth value for current buffer, using the
12060 * 'tabstop' value when 'shiftwidth' is zero.
12061 */
12062 long
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012063get_sw_value(buf)
12064 buf_T *buf;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012065{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012066 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020012067}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012068
12069/*
12070 * Return the effective softtabstop value for the current buffer, using the
12071 * 'tabstop' value when 'softtabstop' is negative.
12072 */
12073 long
12074get_sts_value()
12075{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010012076 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020012077}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010012078
12079/*
12080 * Check matchpairs option for "*initc".
12081 * If there is a match set "*initc" to the matching character and "*findc" to
12082 * the opposite character. Set "*backwards" to the direction.
12083 * When "switchit" is TRUE swap the direction.
12084 */
12085 void
12086find_mps_values(initc, findc, backwards, switchit)
12087 int *initc;
12088 int *findc;
12089 int *backwards;
12090 int switchit;
12091{
12092 char_u *ptr;
12093
12094 ptr = curbuf->b_p_mps;
12095 while (*ptr != NUL)
12096 {
12097#ifdef FEAT_MBYTE
12098 if (has_mbyte)
12099 {
12100 char_u *prev;
12101
12102 if (mb_ptr2char(ptr) == *initc)
12103 {
12104 if (switchit)
12105 {
12106 *findc = *initc;
12107 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12108 *backwards = TRUE;
12109 }
12110 else
12111 {
12112 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
12113 *backwards = FALSE;
12114 }
12115 return;
12116 }
12117 prev = ptr;
12118 ptr += mb_ptr2len(ptr) + 1;
12119 if (mb_ptr2char(ptr) == *initc)
12120 {
12121 if (switchit)
12122 {
12123 *findc = *initc;
12124 *initc = mb_ptr2char(prev);
12125 *backwards = FALSE;
12126 }
12127 else
12128 {
12129 *findc = mb_ptr2char(prev);
12130 *backwards = TRUE;
12131 }
12132 return;
12133 }
12134 ptr += mb_ptr2len(ptr);
12135 }
12136 else
12137#endif
12138 {
12139 if (*ptr == *initc)
12140 {
12141 if (switchit)
12142 {
12143 *backwards = TRUE;
12144 *findc = *initc;
12145 *initc = ptr[2];
12146 }
12147 else
12148 {
12149 *backwards = FALSE;
12150 *findc = ptr[2];
12151 }
12152 return;
12153 }
12154 ptr += 2;
12155 if (*ptr == *initc)
12156 {
12157 if (switchit)
12158 {
12159 *backwards = FALSE;
12160 *findc = *initc;
12161 *initc = ptr[-2];
12162 }
12163 else
12164 {
12165 *backwards = TRUE;
12166 *findc = ptr[-2];
12167 }
12168 return;
12169 }
12170 ++ptr;
12171 }
12172 if (*ptr == ',')
12173 ++ptr;
12174 }
12175}
Bram Moolenaar597a4222014-06-25 14:39:50 +020012176
12177#if defined(FEAT_LINEBREAK) || defined(PROTO)
12178/*
12179 * This is called when 'breakindentopt' is changed and when a window is
12180 * initialized.
12181 */
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012182 static int
12183briopt_check(wp)
12184 win_T *wp;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012185{
12186 char_u *p;
12187 int bri_shift = 0;
12188 long bri_min = 20;
12189 int bri_sbr = FALSE;
12190
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012191 p = wp->w_p_briopt;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012192 while (*p != NUL)
12193 {
12194 if (STRNCMP(p, "shift:", 6) == 0
12195 && ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
12196 {
12197 p += 6;
12198 bri_shift = getdigits(&p);
12199 }
12200 else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
12201 {
12202 p += 4;
12203 bri_min = getdigits(&p);
12204 }
12205 else if (STRNCMP(p, "sbr", 3) == 0)
12206 {
12207 p += 3;
12208 bri_sbr = TRUE;
12209 }
12210 if (*p != ',' && *p != NUL)
12211 return FAIL;
12212 if (*p == ',')
12213 ++p;
12214 }
12215
Bram Moolenaar285ed7e2014-08-24 21:39:49 +020012216 wp->w_p_brishift = bri_shift;
12217 wp->w_p_brimin = bri_min;
12218 wp->w_p_brisbr = bri_sbr;
Bram Moolenaar597a4222014-06-25 14:39:50 +020012219
12220 return OK;
12221}
12222#endif
Bram Moolenaarb8ee25a2014-09-23 15:45:08 +020012223
12224/*
12225 * Get the local or global value of 'backupcopy'.
12226 */
12227 unsigned int
12228get_bkc_value(buf)
12229 buf_T *buf;
12230{
12231 return buf->b_bkc_flags ? buf->b_bkc_flags : bkc_flags;
12232}