blob: a02d5c49167bac988f15c47f35dfe73319f044a8 [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 Moolenaar5e3cb7e2006-02-27 23:58:35 +000059#ifdef FEAT_QUICKFIX
Bram Moolenaara23ccb82006-02-27 00:08:02 +000060# define PV_BH OPT_BUF(BV_BH)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000061# define PV_BT OPT_BUF(BV_BT)
62# define PV_EFM OPT_BOTH(OPT_BUF(BV_EFM))
63# define PV_GP OPT_BOTH(OPT_BUF(BV_GP))
64# define PV_MP OPT_BOTH(OPT_BUF(BV_MP))
Bram Moolenaara23ccb82006-02-27 00:08:02 +000065#endif
66#define PV_BIN OPT_BUF(BV_BIN)
67#define PV_BL OPT_BUF(BV_BL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000068#ifdef FEAT_MBYTE
69# define PV_BOMB OPT_BUF(BV_BOMB)
70#endif
71#define PV_CI OPT_BUF(BV_CI)
72#ifdef FEAT_CINDENT
73# define PV_CIN OPT_BUF(BV_CIN)
74# define PV_CINK OPT_BUF(BV_CINK)
75# define PV_CINO OPT_BUF(BV_CINO)
76#endif
77#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
78# define PV_CINW OPT_BUF(BV_CINW)
79#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020080#define PV_CM OPT_BOTH(OPT_BUF(BV_CM))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000081#ifdef FEAT_FOLDING
82# define PV_CMS OPT_BUF(BV_CMS)
83#endif
84#ifdef FEAT_COMMENTS
85# define PV_COM OPT_BUF(BV_COM)
86#endif
87#ifdef FEAT_INS_EXPAND
88# define PV_CPT OPT_BUF(BV_CPT)
89# define PV_DICT OPT_BOTH(OPT_BUF(BV_DICT))
90# define PV_TSR OPT_BOTH(OPT_BUF(BV_TSR))
91#endif
92#ifdef FEAT_COMPL_FUNC
93# define PV_CFU OPT_BUF(BV_CFU)
94#endif
95#ifdef FEAT_FIND_ID
96# define PV_DEF OPT_BOTH(OPT_BUF(BV_DEF))
97# define PV_INC OPT_BOTH(OPT_BUF(BV_INC))
98#endif
99#define PV_EOL OPT_BUF(BV_EOL)
100#define PV_EP OPT_BOTH(OPT_BUF(BV_EP))
101#define PV_ET OPT_BUF(BV_ET)
102#ifdef FEAT_MBYTE
103# define PV_FENC OPT_BUF(BV_FENC)
104#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000105#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
106# define PV_BEXPR OPT_BOTH(OPT_BUF(BV_BEXPR))
107#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000108#ifdef FEAT_EVAL
109# define PV_FEX OPT_BUF(BV_FEX)
110#endif
111#define PV_FF OPT_BUF(BV_FF)
112#define PV_FLP OPT_BUF(BV_FLP)
113#define PV_FO OPT_BUF(BV_FO)
114#ifdef FEAT_AUTOCMD
115# define PV_FT OPT_BUF(BV_FT)
116#endif
117#define PV_IMI OPT_BUF(BV_IMI)
118#define PV_IMS OPT_BUF(BV_IMS)
119#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
120# define PV_INDE OPT_BUF(BV_INDE)
121# define PV_INDK OPT_BUF(BV_INDK)
122#endif
123#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
124# define PV_INEX OPT_BUF(BV_INEX)
125#endif
126#define PV_INF OPT_BUF(BV_INF)
127#define PV_ISK OPT_BUF(BV_ISK)
128#ifdef FEAT_CRYPT
129# define PV_KEY OPT_BUF(BV_KEY)
130#endif
131#ifdef FEAT_KEYMAP
132# define PV_KMAP OPT_BUF(BV_KMAP)
133#endif
134#define PV_KP OPT_BOTH(OPT_BUF(BV_KP))
135#ifdef FEAT_LISP
136# define PV_LISP OPT_BUF(BV_LISP)
137#endif
138#define PV_MA OPT_BUF(BV_MA)
139#define PV_ML OPT_BUF(BV_ML)
140#define PV_MOD OPT_BUF(BV_MOD)
141#define PV_MPS OPT_BUF(BV_MPS)
142#define PV_NF OPT_BUF(BV_NF)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000143#ifdef FEAT_COMPL_FUNC
144# define PV_OFU OPT_BUF(BV_OFU)
145#endif
146#define PV_PATH OPT_BOTH(OPT_BUF(BV_PATH))
147#define PV_PI OPT_BUF(BV_PI)
148#ifdef FEAT_TEXTOBJ
149# define PV_QE OPT_BUF(BV_QE)
150#endif
151#define PV_RO OPT_BUF(BV_RO)
152#ifdef FEAT_SMARTINDENT
153# define PV_SI OPT_BUF(BV_SI)
154#endif
155#ifndef SHORT_FNAME
156# define PV_SN OPT_BUF(BV_SN)
157#endif
158#ifdef FEAT_SYN_HL
159# define PV_SMC OPT_BUF(BV_SMC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000160# define PV_SYN OPT_BUF(BV_SYN)
161#endif
162#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000163# define PV_SPC OPT_BUF(BV_SPC)
164# define PV_SPF OPT_BUF(BV_SPF)
165# define PV_SPL OPT_BUF(BV_SPL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000166#endif
167#define PV_STS OPT_BUF(BV_STS)
168#ifdef FEAT_SEARCHPATH
169# define PV_SUA OPT_BUF(BV_SUA)
170#endif
171#define PV_SW OPT_BUF(BV_SW)
172#define PV_SWF OPT_BUF(BV_SWF)
173#define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS))
174#define PV_TS OPT_BUF(BV_TS)
175#define PV_TW OPT_BUF(BV_TW)
176#define PV_TX OPT_BUF(BV_TX)
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200177#ifdef FEAT_PERSISTENT_UNDO
178# define PV_UDF OPT_BUF(BV_UDF)
179#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000180#define PV_WM OPT_BUF(BV_WM)
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000181
182/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000183 * Definition of the PV_ values for window-local options.
184 * The WV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000185 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000186#define PV_LIST OPT_WIN(WV_LIST)
187#ifdef FEAT_ARABIC
188# define PV_ARAB OPT_WIN(WV_ARAB)
189#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000190#ifdef FEAT_DIFF
191# define PV_DIFF OPT_WIN(WV_DIFF)
192#endif
193#ifdef FEAT_FOLDING
194# define PV_FDC OPT_WIN(WV_FDC)
195# define PV_FEN OPT_WIN(WV_FEN)
196# define PV_FDI OPT_WIN(WV_FDI)
197# define PV_FDL OPT_WIN(WV_FDL)
198# define PV_FDM OPT_WIN(WV_FDM)
199# define PV_FML OPT_WIN(WV_FML)
200# define PV_FDN OPT_WIN(WV_FDN)
201# ifdef FEAT_EVAL
202# define PV_FDE OPT_WIN(WV_FDE)
203# define PV_FDT OPT_WIN(WV_FDT)
204# endif
205# define PV_FMR OPT_WIN(WV_FMR)
206#endif
207#ifdef FEAT_LINEBREAK
208# define PV_LBR OPT_WIN(WV_LBR)
209#endif
210#define PV_NU OPT_WIN(WV_NU)
Bram Moolenaar64486672010-05-16 15:46:46 +0200211#define PV_RNU OPT_WIN(WV_RNU)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000212#ifdef FEAT_LINEBREAK
213# define PV_NUW OPT_WIN(WV_NUW)
214#endif
215#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
216# define PV_PVW OPT_WIN(WV_PVW)
217#endif
218#ifdef FEAT_RIGHTLEFT
219# define PV_RL OPT_WIN(WV_RL)
220# define PV_RLC OPT_WIN(WV_RLC)
221#endif
222#ifdef FEAT_SCROLLBIND
223# define PV_SCBIND OPT_WIN(WV_SCBIND)
224#endif
225#define PV_SCROLL OPT_WIN(WV_SCROLL)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000226#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000227# define PV_SPELL OPT_WIN(WV_SPELL)
228#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000229#ifdef FEAT_SYN_HL
230# define PV_CUC OPT_WIN(WV_CUC)
231# define PV_CUL OPT_WIN(WV_CUL)
Bram Moolenaar1a384422010-07-14 19:53:30 +0200232# define PV_CC OPT_WIN(WV_CC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000233#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000234#ifdef FEAT_STL_OPT
235# define PV_STL OPT_BOTH(OPT_WIN(WV_STL))
236#endif
237#ifdef FEAT_WINDOWS
238# define PV_WFH OPT_WIN(WV_WFH)
239#endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +0000240#ifdef FEAT_VERTSPLIT
241# define PV_WFW OPT_WIN(WV_WFW)
242#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000243#define PV_WRAP OPT_WIN(WV_WRAP)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200244#ifdef FEAT_CURSORBIND
245# define PV_CRBIND OPT_WIN(WV_CRBIND)
246#endif
247#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200248# define PV_COCU OPT_WIN(WV_COCU)
249# define PV_COLE OPT_WIN(WV_COLE)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200250#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000251
252/* WV_ and BV_ values get typecasted to this for the "indir" field */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000253typedef enum
254{
Bram Moolenaar7d96acd2008-06-09 15:07:54 +0000255 PV_NONE = 0,
256 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000257} idopt_T;
258
259/*
260 * Options local to a window have a value local to a buffer and global to all
261 * buffers. Indicate this by setting "var" to VAR_WIN.
262 */
263#define VAR_WIN ((char_u *)-1)
264
265/*
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000266 * These are the global values for options which are also local to a buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000267 * Only to be used in option.c!
268 */
269static int p_ai;
270static int p_bin;
271#ifdef FEAT_MBYTE
272static int p_bomb;
273#endif
274#if defined(FEAT_QUICKFIX)
275static char_u *p_bh;
276static char_u *p_bt;
277#endif
278static int p_bl;
279static int p_ci;
280#ifdef FEAT_CINDENT
281static int p_cin;
282static char_u *p_cink;
283static char_u *p_cino;
284#endif
285#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
286static char_u *p_cinw;
287#endif
288#ifdef FEAT_COMMENTS
289static char_u *p_com;
290#endif
291#ifdef FEAT_FOLDING
292static char_u *p_cms;
293#endif
294#ifdef FEAT_INS_EXPAND
295static char_u *p_cpt;
296#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000297#ifdef FEAT_COMPL_FUNC
298static char_u *p_cfu;
Bram Moolenaare344bea2005-09-01 20:46:49 +0000299static char_u *p_ofu;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000300#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000301static int p_eol;
302static int p_et;
303#ifdef FEAT_MBYTE
304static char_u *p_fenc;
305#endif
306static char_u *p_ff;
307static char_u *p_fo;
Bram Moolenaar86b68352004-12-27 21:59:20 +0000308static char_u *p_flp;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000309#ifdef FEAT_AUTOCMD
310static char_u *p_ft;
311#endif
312static long p_iminsert;
313static long p_imsearch;
314#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
315static char_u *p_inex;
316#endif
317#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
318static char_u *p_inde;
319static char_u *p_indk;
320#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +0000321#if defined(FEAT_EVAL)
322static char_u *p_fex;
323#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000324static int p_inf;
325static char_u *p_isk;
326#ifdef FEAT_CRYPT
327static char_u *p_key;
328#endif
329#ifdef FEAT_LISP
330static int p_lisp;
331#endif
332static int p_ml;
333static int p_ma;
334static int p_mod;
335static char_u *p_mps;
336static char_u *p_nf;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000337static int p_pi;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000338#ifdef FEAT_TEXTOBJ
339static char_u *p_qe;
340#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000341static int p_ro;
342#ifdef FEAT_SMARTINDENT
343static int p_si;
344#endif
345#ifndef SHORT_FNAME
346static int p_sn;
347#endif
348static long p_sts;
349#if defined(FEAT_SEARCHPATH)
350static char_u *p_sua;
351#endif
352static long p_sw;
353static int p_swf;
354#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +0000355static long p_smc;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000356static char_u *p_syn;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000357#endif
358#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000359static char_u *p_spc;
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000360static char_u *p_spf;
Bram Moolenaar217ad922005-03-20 22:37:15 +0000361static char_u *p_spl;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000362#endif
363static long p_ts;
364static long p_tw;
365static int p_tx;
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200366#ifdef FEAT_PERSISTENT_UNDO
367static int p_udf;
368#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000369static long p_wm;
370#ifdef FEAT_KEYMAP
371static char_u *p_keymap;
372#endif
373
374/* Saved values for when 'bin' is set. */
375static int p_et_nobin;
376static int p_ml_nobin;
377static long p_tw_nobin;
378static long p_wm_nobin;
379
380/* Saved values for when 'paste' is set */
381static long p_tw_nopaste;
382static long p_wm_nopaste;
383static long p_sts_nopaste;
384static int p_ai_nopaste;
385
386struct vimoption
387{
388 char *fullname; /* full option name */
389 char *shortname; /* permissible abbreviation */
390 long_u flags; /* see below */
391 char_u *var; /* global option: pointer to variable;
392 * window-local option: VAR_WIN;
393 * buffer-local option: global value */
394 idopt_T indir; /* global option: PV_NONE;
395 * local option: indirect option index */
396 char_u *def_val[2]; /* default values for variable (vi and vim) */
397#ifdef FEAT_EVAL
398 scid_T scriptID; /* script in which the option was last set */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000399# define SCRIPTID_INIT , 0
400#else
401# define SCRIPTID_INIT
Bram Moolenaar071d4272004-06-13 20:20:40 +0000402#endif
403};
404
405#define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */
406#define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */
407
408/*
409 * Flags
410 */
411#define P_BOOL 0x01 /* the option is boolean */
412#define P_NUM 0x02 /* the option is numeric */
413#define P_STRING 0x04 /* the option is a string */
414#define P_ALLOCED 0x08 /* the string option is in allocated memory,
Bram Moolenaar363cb672009-07-22 12:28:17 +0000415 must use free_string_option() when
416 assigning new value. Not set if default is
417 the same. */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000418#define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
419 never be used for local or hidden options! */
420#define P_NODEFAULT 0x40 /* don't set to default value */
421#define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must
422 use vim_free() when assigning new value */
423#define P_WAS_SET 0x100 /* option has been set/reset */
424#define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */
425#define P_VI_DEF 0x400 /* Use Vi default for Vim */
426#define P_VIM 0x800 /* Vim option, reset when 'cp' set */
427
428 /* when option changed, what to display: */
429#define P_RSTAT 0x1000 /* redraw status lines */
430#define P_RWIN 0x2000 /* redraw current window */
431#define P_RBUF 0x4000 /* redraw current buffer */
432#define P_RALL 0x6000 /* redraw all windows */
433#define P_RCLR 0x7000 /* clear and redraw all */
434
435#define P_COMMA 0x8000 /* comma separated list */
Bram Moolenaar913077c2012-03-28 19:59:04 +0200436#define P_NODUP 0x10000L /* don't allow duplicate strings */
437#define P_FLAGLIST 0x20000L /* list of single-char flags */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000438
Bram Moolenaar913077c2012-03-28 19:59:04 +0200439#define P_SECURE 0x40000L /* cannot change in modeline or secure mode */
440#define P_GETTEXT 0x80000L /* expand default value with _() */
441#define P_NOGLOB 0x100000L /* do not use local value for global vimrc */
442#define P_NFNAME 0x200000L /* only normal file name chars allowed */
443#define P_INSECURE 0x400000L /* option was set from a modeline */
444#define P_PRI_MKRC 0x800000L /* priority for :mkvimrc (setting option has
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000445 side effects) */
Bram Moolenaar913077c2012-03-28 19:59:04 +0200446#define P_NO_ML 0x1000000L /* not allowed in modeline */
447#define P_CURSWANT 0x2000000L /* update curswant required; not needed when
448 * there is a redraw flag */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000449
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000450#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
451
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000452/* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used
453 * for the currency sign. */
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000454#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000455# define ISP_LATIN1 (char_u *)"@,~-255"
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000456#else
457# define ISP_LATIN1 (char_u *)"@,161-255"
458#endif
459
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000460/* The 16 bit MS-DOS version is low on space, make the string as short as
461 * possible when compiling with few features. */
462#if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
463 || defined(FEAT_VERTSPLIT) || defined(FEAT_CLIPBOARD) \
Bram Moolenaar860cae12010-06-05 23:22:07 +0200464 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) || defined(FEAT_CONCEAL)
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100465# 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 +0000466#else
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100467# 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 +0000468#endif
469
Bram Moolenaar071d4272004-06-13 20:20:40 +0000470/*
471 * options[] is initialized here.
472 * The order of the options MUST be alphabetic for ":set all" and findoption().
473 * All option names MUST start with a lowercase letter (for findoption()).
474 * Exception: "t_" options are at the end.
475 * The options with a NULL variable are 'hidden': a set command for them is
476 * ignored and they are not printed.
477 */
478static struct vimoption
479#ifdef FEAT_GUI_W16
480 _far
481#endif
482 options[] =
483{
Bram Moolenaar913077c2012-03-28 19:59:04 +0200484 {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000485#ifdef FEAT_RIGHTLEFT
486 (char_u *)&p_aleph, PV_NONE,
487#else
488 (char_u *)NULL, PV_NONE,
489#endif
490 {
491#if (defined(MSDOS) || defined(WIN3264) || defined(OS2)) && !defined(FEAT_GUI_W32)
492 (char_u *)128L,
493#else
494 (char_u *)224L,
495#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000496 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000497 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
498#if defined(FEAT_GUI) && defined(MACOS_X)
499 (char_u *)&p_antialias, PV_NONE,
500 {(char_u *)FALSE, (char_u *)FALSE}
501#else
502 (char_u *)NULL, PV_NONE,
503 {(char_u *)FALSE, (char_u *)FALSE}
504#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000505 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200506 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000507#ifdef FEAT_ARABIC
508 (char_u *)VAR_WIN, PV_ARAB,
509#else
510 (char_u *)NULL, PV_NONE,
511#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000512 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000513 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
514#ifdef FEAT_ARABIC
515 (char_u *)&p_arshape, PV_NONE,
516#else
517 (char_u *)NULL, PV_NONE,
518#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000519 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000520 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
521#ifdef FEAT_RIGHTLEFT
522 (char_u *)&p_ari, PV_NONE,
523#else
524 (char_u *)NULL, PV_NONE,
525#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000526 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000527 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
528#ifdef FEAT_FKMAP
529 (char_u *)&p_altkeymap, PV_NONE,
530#else
531 (char_u *)NULL, PV_NONE,
532#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000533 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000534 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
535#if defined(FEAT_MBYTE)
536 (char_u *)&p_ambw, PV_NONE,
537 {(char_u *)"single", (char_u *)0L}
538#else
539 (char_u *)NULL, PV_NONE,
540 {(char_u *)0L, (char_u *)0L}
541#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000542 SCRIPTID_INIT},
Bram Moolenaar8dff8182006-04-06 20:18:50 +0000543#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +0000544 {"autochdir", "acd", P_BOOL|P_VI_DEF,
545 (char_u *)&p_acd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000546 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000547#endif
548 {"autoindent", "ai", P_BOOL|P_VI_DEF,
549 (char_u *)&p_ai, PV_AI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000550 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000551 {"autoprint", "ap", P_BOOL|P_VI_DEF,
552 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000553 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000554 {"autoread", "ar", P_BOOL|P_VI_DEF,
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000555 (char_u *)&p_ar, PV_AR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000556 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000557 {"autowrite", "aw", P_BOOL|P_VI_DEF,
558 (char_u *)&p_aw, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000559 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000560 {"autowriteall","awa", P_BOOL|P_VI_DEF,
561 (char_u *)&p_awa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000562 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000563 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
564 (char_u *)&p_bg, PV_NONE,
565 {
566#if (defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI)
567 (char_u *)"dark",
568#else
569 (char_u *)"light",
570#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000571 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000572 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_COMMA|P_NODUP,
573 (char_u *)&p_bs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000574 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000575 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
576 (char_u *)&p_bk, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000577 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000578 {"backupcopy", "bkc", P_STRING|P_VIM|P_COMMA|P_NODUP,
579 (char_u *)&p_bkc, PV_NONE,
580#ifdef UNIX
581 {(char_u *)"yes", (char_u *)"auto"}
582#else
583 {(char_u *)"auto", (char_u *)"auto"}
584#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000585 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000586 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE,
587 (char_u *)&p_bdir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000588 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000589 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000590 (char_u *)&p_bex, PV_NONE,
591 {
592#ifdef VMS
593 (char_u *)"_",
594#else
595 (char_u *)"~",
596#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000597 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000598 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_COMMA,
599#ifdef FEAT_WILDIGN
600 (char_u *)&p_bsk, PV_NONE,
601 {(char_u *)"", (char_u *)0L}
602#else
603 (char_u *)NULL, PV_NONE,
604 {(char_u *)0L, (char_u *)0L}
605#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000606 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000607#ifdef FEAT_BEVAL
608 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
609 (char_u *)&p_bdlay, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000610 {(char_u *)600L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000611 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
612 (char_u *)&p_beval, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000613 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000614# ifdef FEAT_EVAL
Bram Moolenaar39f05632006-03-19 22:15:26 +0000615 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000616 (char_u *)&p_bexpr, PV_BEXPR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000617 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000618# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000619#endif
620 {"beautify", "bf", P_BOOL|P_VI_DEF,
621 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000622 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000623 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
624 (char_u *)&p_bin, PV_BIN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000625 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000626 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
627#ifdef MSDOS
628 (char_u *)&p_biosk, PV_NONE,
629#else
630 (char_u *)NULL, PV_NONE,
631#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000632 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000633 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
634#ifdef FEAT_MBYTE
635 (char_u *)&p_bomb, PV_BOMB,
636#else
637 (char_u *)NULL, PV_NONE,
638#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000639 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000640 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
641#ifdef FEAT_LINEBREAK
642 (char_u *)&p_breakat, PV_NONE,
643 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
644#else
645 (char_u *)NULL, PV_NONE,
646 {(char_u *)0L, (char_u *)0L}
647#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000648 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000649 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
650#ifdef FEAT_BROWSE
651 (char_u *)&p_bsdir, PV_NONE,
652 {(char_u *)"last", (char_u *)0L}
653#else
654 (char_u *)NULL, PV_NONE,
655 {(char_u *)0L, (char_u *)0L}
656#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000657 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000658 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
659#if defined(FEAT_QUICKFIX)
660 (char_u *)&p_bh, PV_BH,
661 {(char_u *)"", (char_u *)0L}
662#else
663 (char_u *)NULL, PV_NONE,
664 {(char_u *)0L, (char_u *)0L}
665#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000666 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000667 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
668 (char_u *)&p_bl, PV_BL,
669 {(char_u *)1L, (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000670 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000671 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
672#if defined(FEAT_QUICKFIX)
673 (char_u *)&p_bt, PV_BT,
674 {(char_u *)"", (char_u *)0L}
675#else
676 (char_u *)NULL, PV_NONE,
677 {(char_u *)0L, (char_u *)0L}
678#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000679 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000680 {"casemap", "cmp", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000681#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000682 (char_u *)&p_cmp, PV_NONE,
683 {(char_u *)"internal,keepascii", (char_u *)0L}
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000684#else
685 (char_u *)NULL, PV_NONE,
686 {(char_u *)0L, (char_u *)0L}
687#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000688 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000689 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
690#ifdef FEAT_SEARCHPATH
691 (char_u *)&p_cdpath, PV_NONE,
692 {(char_u *)",,", (char_u *)0L}
693#else
694 (char_u *)NULL, PV_NONE,
695 {(char_u *)0L, (char_u *)0L}
696#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000697 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000698 {"cedit", NULL, P_STRING,
699#ifdef FEAT_CMDWIN
700 (char_u *)&p_cedit, PV_NONE,
701 {(char_u *)"", (char_u *)CTRL_F_STR}
702#else
703 (char_u *)NULL, PV_NONE,
704 {(char_u *)0L, (char_u *)0L}
705#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000706 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000707 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
708#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
709 (char_u *)&p_ccv, PV_NONE,
710 {(char_u *)"", (char_u *)0L}
711#else
712 (char_u *)NULL, PV_NONE,
713 {(char_u *)0L, (char_u *)0L}
714#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000715 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000716 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
717#ifdef FEAT_CINDENT
718 (char_u *)&p_cin, PV_CIN,
719#else
720 (char_u *)NULL, PV_NONE,
721#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000722 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000723 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
724#ifdef FEAT_CINDENT
725 (char_u *)&p_cink, PV_CINK,
726 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (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 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
733#ifdef FEAT_CINDENT
734 (char_u *)&p_cino, PV_CINO,
735#else
736 (char_u *)NULL, PV_NONE,
737#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000738 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000739 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
740#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
741 (char_u *)&p_cinw, PV_CINW,
742 {(char_u *)"if,else,while,do,for,switch",
743 (char_u *)0L}
744#else
745 (char_u *)NULL, PV_NONE,
746 {(char_u *)0L, (char_u *)0L}
747#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000748 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000749 {"clipboard", "cb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
750#ifdef FEAT_CLIPBOARD
751 (char_u *)&p_cb, PV_NONE,
752# ifdef FEAT_XCLIPBOARD
753 {(char_u *)"autoselect,exclude:cons\\|linux",
754 (char_u *)0L}
755# else
756 {(char_u *)"", (char_u *)0L}
757# endif
758#else
759 (char_u *)NULL, PV_NONE,
760 {(char_u *)"", (char_u *)0L}
761#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000762 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000763 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
764 (char_u *)&p_ch, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000765 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000766 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
767#ifdef FEAT_CMDWIN
768 (char_u *)&p_cwh, PV_NONE,
769#else
770 (char_u *)NULL, PV_NONE,
771#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000772 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +0200773 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_RWIN,
774#ifdef FEAT_SYN_HL
775 (char_u *)VAR_WIN, PV_CC,
776#else
777 (char_u *)NULL, PV_NONE,
778#endif
779 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000780 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
781 (char_u *)&Columns, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000782 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200783 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000784#ifdef FEAT_COMMENTS
785 (char_u *)&p_com, PV_COM,
786 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
787 (char_u *)0L}
788#else
789 (char_u *)NULL, PV_NONE,
790 {(char_u *)0L, (char_u *)0L}
791#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000792 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200793 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000794#ifdef FEAT_FOLDING
795 (char_u *)&p_cms, PV_CMS,
796 {(char_u *)"/*%s*/", (char_u *)0L}
797#else
798 (char_u *)NULL, PV_NONE,
799 {(char_u *)0L, (char_u *)0L}
800#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000801 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000802 /* P_PRI_MKRC isn't needed here, optval_default()
803 * always returns TRUE for 'compatible' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000804 {"compatible", "cp", P_BOOL|P_RALL,
805 (char_u *)&p_cp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000806 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000807 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
808#ifdef FEAT_INS_EXPAND
809 (char_u *)&p_cpt, PV_CPT,
810 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
811#else
812 (char_u *)NULL, PV_NONE,
813 {(char_u *)0L, (char_u *)0L}
814#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000815 SCRIPTID_INIT},
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200816 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200817#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200818 (char_u *)VAR_WIN, PV_COCU,
819 {(char_u *)"", (char_u *)NULL}
820#else
821 (char_u *)NULL, PV_NONE,
822 {(char_u *)NULL, (char_u *)0L}
823#endif
824 SCRIPTID_INIT},
825 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
826#ifdef FEAT_CONCEAL
827 (char_u *)VAR_WIN, PV_COLE,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200828#else
829 (char_u *)NULL, PV_NONE,
830#endif
831 {(char_u *)0L, (char_u *)0L}
832 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000833 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
834#ifdef FEAT_COMPL_FUNC
835 (char_u *)&p_cfu, PV_CFU,
836 {(char_u *)"", (char_u *)0L}
837#else
838 (char_u *)NULL, PV_NONE,
839 {(char_u *)0L, (char_u *)0L}
840#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000841 SCRIPTID_INIT},
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000842 {"completeopt", "cot", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
843#ifdef FEAT_INS_EXPAND
844 (char_u *)&p_cot, PV_NONE,
Bram Moolenaarc270d802006-03-11 21:29:41 +0000845 {(char_u *)"menu,preview", (char_u *)0L}
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000846#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 Moolenaar071d4272004-06-13 20:20:40 +0000851 {"confirm", "cf", P_BOOL|P_VI_DEF,
852#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
853 (char_u *)&p_confirm, PV_NONE,
854#else
855 (char_u *)NULL, PV_NONE,
856#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000857 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000858 {"conskey", "consk",P_BOOL|P_VI_DEF,
859#ifdef MSDOS
860 (char_u *)&p_consk, PV_NONE,
861#else
862 (char_u *)NULL, PV_NONE,
863#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000864 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000865 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
866 (char_u *)&p_ci, PV_CI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000867 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000868 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
869 (char_u *)&p_cpo, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000870 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
871 SCRIPTID_INIT},
Bram Moolenaar49771f42010-07-20 17:32:38 +0200872 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200873#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200874 (char_u *)&p_cm, PV_CM,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200875 {(char_u *)"zip", (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200876#else
877 (char_u *)NULL, PV_NONE,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200878 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200879#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +0200880 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000881 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
882#ifdef FEAT_CSCOPE
883 (char_u *)&p_cspc, PV_NONE,
884#else
885 (char_u *)NULL, PV_NONE,
886#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000887 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000888 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
889#ifdef FEAT_CSCOPE
890 (char_u *)&p_csprg, PV_NONE,
891 {(char_u *)"cscope", (char_u *)0L}
892#else
893 (char_u *)NULL, PV_NONE,
894 {(char_u *)0L, (char_u *)0L}
895#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000896 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000897 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
898#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
899 (char_u *)&p_csqf, PV_NONE,
900 {(char_u *)"", (char_u *)0L}
901#else
902 (char_u *)NULL, PV_NONE,
903 {(char_u *)0L, (char_u *)0L}
904#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000905 SCRIPTID_INIT},
Bram Moolenaarf7befa92011-06-12 22:13:40 +0200906 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM,
907#ifdef FEAT_CSCOPE
908 (char_u *)&p_csre, PV_NONE,
909#else
910 (char_u *)NULL, PV_NONE,
911#endif
912 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000913 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
914#ifdef FEAT_CSCOPE
915 (char_u *)&p_cst, PV_NONE,
916#else
917 (char_u *)NULL, PV_NONE,
918#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000919 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000920 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
921#ifdef FEAT_CSCOPE
922 (char_u *)&p_csto, PV_NONE,
923#else
924 (char_u *)NULL, PV_NONE,
925#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000926 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000927 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
928#ifdef FEAT_CSCOPE
929 (char_u *)&p_csverbose, PV_NONE,
930#else
931 (char_u *)NULL, PV_NONE,
932#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000933 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200934 {"cursorbind", "crb", P_BOOL|P_VI_DEF,
935#ifdef FEAT_CURSORBIND
936 (char_u *)VAR_WIN, PV_CRBIND,
937#else
938 (char_u *)NULL, PV_NONE,
939#endif
940 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000941 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
942#ifdef FEAT_SYN_HL
943 (char_u *)VAR_WIN, PV_CUC,
944#else
945 (char_u *)NULL, PV_NONE,
946#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000947 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000948 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWIN,
949#ifdef FEAT_SYN_HL
950 (char_u *)VAR_WIN, PV_CUL,
951#else
952 (char_u *)NULL, PV_NONE,
953#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000954 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000955 {"debug", NULL, P_STRING|P_VI_DEF,
956 (char_u *)&p_debug, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000957 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200958 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000959#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000960 (char_u *)&p_def, PV_DEF,
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000961 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000962#else
963 (char_u *)NULL, PV_NONE,
964 {(char_u *)NULL, (char_u *)0L}
965#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000966 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000967 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
968#ifdef FEAT_MBYTE
969 (char_u *)&p_deco, PV_NONE,
970#else
971 (char_u *)NULL, PV_NONE,
972#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000973 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000974 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
975#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000976 (char_u *)&p_dict, PV_DICT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000977#else
978 (char_u *)NULL, PV_NONE,
979#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000980 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000981 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
982#ifdef FEAT_DIFF
983 (char_u *)VAR_WIN, PV_DIFF,
984#else
985 (char_u *)NULL, PV_NONE,
986#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000987 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200988 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000989#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
990 (char_u *)&p_dex, PV_NONE,
991 {(char_u *)"", (char_u *)0L}
992#else
993 (char_u *)NULL, PV_NONE,
994 {(char_u *)0L, (char_u *)0L}
995#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000996 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000997 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_COMMA|P_NODUP,
998#ifdef FEAT_DIFF
999 (char_u *)&p_dip, PV_NONE,
1000 {(char_u *)"filler", (char_u *)NULL}
1001#else
1002 (char_u *)NULL, PV_NONE,
1003 {(char_u *)"", (char_u *)NULL}
1004#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001005 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001006 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
1007#ifdef FEAT_DIGRAPHS
1008 (char_u *)&p_dg, PV_NONE,
1009#else
1010 (char_u *)NULL, PV_NONE,
1011#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001012 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001013 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE,
1014 (char_u *)&p_dir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001015 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001016 {"display", "dy", P_STRING|P_VI_DEF|P_COMMA|P_RALL|P_NODUP,
1017 (char_u *)&p_dy, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001018 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001019 {"eadirection", "ead", P_STRING|P_VI_DEF,
1020#ifdef FEAT_VERTSPLIT
1021 (char_u *)&p_ead, PV_NONE,
1022 {(char_u *)"both", (char_u *)0L}
1023#else
1024 (char_u *)NULL, PV_NONE,
1025 {(char_u *)NULL, (char_u *)0L}
1026#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001027 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001028 {"edcompatible","ed", P_BOOL|P_VI_DEF,
1029 (char_u *)&p_ed, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001030 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar865242e2010-07-14 21:12:05 +02001031 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001032#ifdef FEAT_MBYTE
1033 (char_u *)&p_enc, PV_NONE,
1034 {(char_u *)ENC_DFLT, (char_u *)0L}
1035#else
1036 (char_u *)NULL, PV_NONE,
1037 {(char_u *)0L, (char_u *)0L}
1038#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001039 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001040 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1041 (char_u *)&p_eol, PV_EOL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001042 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001043 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1044 (char_u *)&p_ea, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001045 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001046 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001047 (char_u *)&p_ep, PV_EP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001048 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001049 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1050 (char_u *)&p_eb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001051 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001052 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1053#ifdef FEAT_QUICKFIX
1054 (char_u *)&p_ef, PV_NONE,
1055 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1056#else
1057 (char_u *)NULL, PV_NONE,
1058 {(char_u *)NULL, (char_u *)0L}
1059#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001060 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001061 {"errorformat", "efm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1062#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001063 (char_u *)&p_efm, PV_EFM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001064 {(char_u *)DFLT_EFM, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001065#else
1066 (char_u *)NULL, PV_NONE,
1067 {(char_u *)NULL, (char_u *)0L}
1068#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001069 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001070 {"esckeys", "ek", P_BOOL|P_VIM,
1071 (char_u *)&p_ek, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001072 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001073 {"eventignore", "ei", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1074#ifdef FEAT_AUTOCMD
1075 (char_u *)&p_ei, PV_NONE,
1076#else
1077 (char_u *)NULL, PV_NONE,
1078#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001079 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001080 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1081 (char_u *)&p_et, PV_ET,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001082 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001083 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1084 (char_u *)&p_exrc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001085 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001086 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF|P_NO_MKRC,
1087#ifdef FEAT_MBYTE
1088 (char_u *)&p_fenc, PV_FENC,
1089 {(char_u *)"", (char_u *)0L}
1090#else
1091 (char_u *)NULL, PV_NONE,
1092 {(char_u *)0L, (char_u *)0L}
1093#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001094 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001095 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_COMMA,
1096#ifdef FEAT_MBYTE
1097 (char_u *)&p_fencs, PV_NONE,
1098 {(char_u *)"ucs-bom", (char_u *)0L}
1099#else
1100 (char_u *)NULL, PV_NONE,
1101 {(char_u *)0L, (char_u *)0L}
1102#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001103 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001104 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001105 (char_u *)&p_ff, PV_FF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001106 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001107 {"fileformats", "ffs", P_STRING|P_VIM|P_COMMA|P_NODUP,
1108 (char_u *)&p_ffs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001109 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1110 SCRIPTID_INIT},
Bram Moolenaar71afbfe2013-03-19 16:49:16 +01001111 {"fileignorecase", "fic", P_BOOL|P_VI_DEF,
1112 (char_u *)&p_fic, PV_NONE,
1113 {
1114#ifdef CASE_INSENSITIVE_FILENAME
1115 (char_u *)TRUE,
1116#else
1117 (char_u *)FALSE,
1118#endif
1119 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001120 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001121#ifdef FEAT_AUTOCMD
1122 (char_u *)&p_ft, PV_FT,
1123 {(char_u *)"", (char_u *)0L}
1124#else
1125 (char_u *)NULL, PV_NONE,
1126 {(char_u *)0L, (char_u *)0L}
1127#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001128 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001129 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1130#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1131 (char_u *)&p_fcs, PV_NONE,
1132 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1133#else
1134 (char_u *)NULL, PV_NONE,
1135 {(char_u *)"", (char_u *)0L}
1136#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001137 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001138 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1139#ifdef FEAT_FKMAP
1140 (char_u *)&p_fkmap, PV_NONE,
1141#else
1142 (char_u *)NULL, PV_NONE,
1143#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001144 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001145 {"flash", "fl", P_BOOL|P_VI_DEF,
1146 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001147 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001148#ifdef FEAT_FOLDING
1149 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_RWIN,
1150 (char_u *)&p_fcl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001151 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001152 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1153 (char_u *)VAR_WIN, PV_FDC,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001154 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001155 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1156 (char_u *)VAR_WIN, PV_FEN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001157 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001158 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1159# ifdef FEAT_EVAL
1160 (char_u *)VAR_WIN, PV_FDE,
1161 {(char_u *)"0", (char_u *)NULL}
1162# else
1163 (char_u *)NULL, PV_NONE,
1164 {(char_u *)NULL, (char_u *)0L}
1165# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001166 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001167 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1168 (char_u *)VAR_WIN, PV_FDI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001169 {(char_u *)"#", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001170 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
1171 (char_u *)VAR_WIN, PV_FDL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001172 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001173 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001174 (char_u *)&p_fdls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001175 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001176 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
1177 P_RWIN|P_COMMA|P_NODUP,
1178 (char_u *)VAR_WIN, PV_FMR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001179 {(char_u *)"{{{,}}}", (char_u *)NULL}
1180 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001181 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1182 (char_u *)VAR_WIN, PV_FDM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001183 {(char_u *)"manual", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001184 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1185 (char_u *)VAR_WIN, PV_FML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001186 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001187 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1188 (char_u *)VAR_WIN, PV_FDN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001189 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001190 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001191 (char_u *)&p_fdo, PV_NONE,
1192 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001193 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001194 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1195# ifdef FEAT_EVAL
1196 (char_u *)VAR_WIN, PV_FDT,
1197 {(char_u *)"foldtext()", (char_u *)NULL}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001198# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001199 (char_u *)NULL, PV_NONE,
1200 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001201# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001202 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001203#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001204 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001205#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001206 (char_u *)&p_fex, PV_FEX,
1207 {(char_u *)"", (char_u *)0L}
1208#else
1209 (char_u *)NULL, PV_NONE,
1210 {(char_u *)0L, (char_u *)0L}
1211#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001212 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001213 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1214 (char_u *)&p_fo, PV_FO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001215 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1216 SCRIPTID_INIT},
Bram Moolenaar86b68352004-12-27 21:59:20 +00001217 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1218 (char_u *)&p_flp, PV_FLP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001219 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1220 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001221 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1222 (char_u *)&p_fp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001223 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001224 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1225#ifdef HAVE_FSYNC
1226 (char_u *)&p_fs, PV_NONE,
1227 {(char_u *)TRUE, (char_u *)0L}
1228#else
1229 (char_u *)NULL, PV_NONE,
1230 {(char_u *)FALSE, (char_u *)0L}
1231#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001232 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001233 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1234 (char_u *)&p_gd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001235 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001236 {"graphic", "gr", P_BOOL|P_VI_DEF,
1237 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001238 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001239 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1240#ifdef FEAT_QUICKFIX
1241 (char_u *)&p_gefm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001242 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001243#else
1244 (char_u *)NULL, PV_NONE,
1245 {(char_u *)NULL, (char_u *)0L}
1246#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001247 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001248 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1249#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001250 (char_u *)&p_gp, PV_GP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001251 {
1252# ifdef WIN3264
1253 /* may be changed to "grep -n" in os_win32.c */
1254 (char_u *)"findstr /n",
1255# else
1256# ifdef UNIX
1257 /* Add an extra file name so that grep will always
1258 * insert a file name in the match line. */
1259 (char_u *)"grep -n $* /dev/null",
1260# else
1261# ifdef VMS
1262 (char_u *)"SEARCH/NUMBERS ",
1263# else
1264 (char_u *)"grep -n ",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001265# endif
1266# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001267# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001268 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001269#else
1270 (char_u *)NULL, PV_NONE,
1271 {(char_u *)NULL, (char_u *)0L}
1272#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001273 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001274 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1275#ifdef CURSOR_SHAPE
1276 (char_u *)&p_guicursor, PV_NONE,
1277 {
1278# ifdef FEAT_GUI
1279 (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",
1280# else /* MSDOS or Win32 console */
1281 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1282# endif
1283 (char_u *)0L}
1284#else
1285 (char_u *)NULL, PV_NONE,
1286 {(char_u *)NULL, (char_u *)0L}
1287#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001288 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001289 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
1290#ifdef FEAT_GUI
1291 (char_u *)&p_guifont, PV_NONE,
1292 {(char_u *)"", (char_u *)0L}
1293#else
1294 (char_u *)NULL, PV_NONE,
1295 {(char_u *)NULL, (char_u *)0L}
1296#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001297 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001298 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_COMMA,
1299#if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1300 (char_u *)&p_guifontset, PV_NONE,
1301 {(char_u *)"", (char_u *)0L}
1302#else
1303 (char_u *)NULL, PV_NONE,
1304 {(char_u *)NULL, (char_u *)0L}
1305#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001306 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001307 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
1308#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1309 (char_u *)&p_guifontwide, PV_NONE,
1310 {(char_u *)"", (char_u *)0L}
1311#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 Moolenaar071d4272004-06-13 20:20:40 +00001316 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001317#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001318 (char_u *)&p_ghr, PV_NONE,
1319#else
1320 (char_u *)NULL, PV_NONE,
1321#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001322 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001323 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001324#if defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001325 (char_u *)&p_go, PV_NONE,
1326# if defined(UNIX) && !defined(MACOS)
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001327 {(char_u *)"aegimrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001328# else
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001329 {(char_u *)"egmrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001330# endif
1331#else
1332 (char_u *)NULL, PV_NONE,
1333 {(char_u *)NULL, (char_u *)0L}
1334#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001335 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001336 {"guipty", NULL, P_BOOL|P_VI_DEF,
1337#if defined(FEAT_GUI)
1338 (char_u *)&p_guipty, PV_NONE,
1339#else
1340 (char_u *)NULL, PV_NONE,
1341#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001342 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar18144c82006-04-12 21:52:12 +00001343 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00001344#if defined(FEAT_GUI_TABLINE)
1345 (char_u *)&p_gtl, PV_NONE,
1346 {(char_u *)"", (char_u *)0L}
1347#else
1348 (char_u *)NULL, PV_NONE,
1349 {(char_u *)NULL, (char_u *)0L}
1350#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001351 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001352 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar57657d82006-04-21 22:12:41 +00001353#if defined(FEAT_GUI_TABLINE)
1354 (char_u *)&p_gtt, PV_NONE,
1355 {(char_u *)"", (char_u *)0L}
1356#else
1357 (char_u *)NULL, PV_NONE,
1358 {(char_u *)NULL, (char_u *)0L}
1359#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001360 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001361 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1362 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001363 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001364 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1365 (char_u *)&p_hf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001366 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1367 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001368 {"helpheight", "hh", P_NUM|P_VI_DEF,
1369#ifdef FEAT_WINDOWS
1370 (char_u *)&p_hh, PV_NONE,
1371#else
1372 (char_u *)NULL, PV_NONE,
1373#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001374 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001375 {"helplang", "hlg", P_STRING|P_VI_DEF|P_COMMA,
1376#ifdef FEAT_MULTI_LANG
1377 (char_u *)&p_hlg, PV_NONE,
1378 {(char_u *)"", (char_u *)0L}
1379#else
1380 (char_u *)NULL, PV_NONE,
1381 {(char_u *)0L, (char_u *)0L}
1382#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001383 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001384 {"hidden", "hid", P_BOOL|P_VI_DEF,
1385 (char_u *)&p_hid, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001386 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001387 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
1388 (char_u *)&p_hl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001389 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1390 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001391 {"history", "hi", P_NUM|P_VIM,
1392 (char_u *)&p_hi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001393 {(char_u *)0L, (char_u *)20L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001394 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1395#ifdef FEAT_RIGHTLEFT
1396 (char_u *)&p_hkmap, PV_NONE,
1397#else
1398 (char_u *)NULL, PV_NONE,
1399#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001400 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001401 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1402#ifdef FEAT_RIGHTLEFT
1403 (char_u *)&p_hkmapp, PV_NONE,
1404#else
1405 (char_u *)NULL, PV_NONE,
1406#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001407 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001408 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1409 (char_u *)&p_hls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001410 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001411 {"icon", NULL, P_BOOL|P_VI_DEF,
1412#ifdef FEAT_TITLE
1413 (char_u *)&p_icon, PV_NONE,
1414#else
1415 (char_u *)NULL, PV_NONE,
1416#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001417 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001418 {"iconstring", NULL, P_STRING|P_VI_DEF,
1419#ifdef FEAT_TITLE
1420 (char_u *)&p_iconstring, PV_NONE,
1421#else
1422 (char_u *)NULL, PV_NONE,
1423#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001424 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001425 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1426 (char_u *)&p_ic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001427 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001428 {"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
1429# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1430 (char_u *)&p_imaf, PV_NONE,
1431 {(char_u *)"", (char_u *)NULL}
1432# else
1433 (char_u *)NULL, PV_NONE,
1434 {(char_u *)NULL, (char_u *)0L}
1435# endif
1436 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001437 {"imactivatekey","imak",P_STRING|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001438#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001439 (char_u *)&p_imak, PV_NONE,
1440#else
1441 (char_u *)NULL, PV_NONE,
1442#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001443 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001444 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1445#ifdef USE_IM_CONTROL
1446 (char_u *)&p_imcmdline, PV_NONE,
1447#else
1448 (char_u *)NULL, PV_NONE,
1449#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001450 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001451 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1452#ifdef USE_IM_CONTROL
1453 (char_u *)&p_imdisable, PV_NONE,
1454#else
1455 (char_u *)NULL, PV_NONE,
1456#endif
1457#ifdef __sgi
1458 {(char_u *)TRUE, (char_u *)0L}
1459#else
1460 {(char_u *)FALSE, (char_u *)0L}
1461#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001462 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001463 {"iminsert", "imi", P_NUM|P_VI_DEF,
1464 (char_u *)&p_iminsert, PV_IMI,
1465#ifdef B_IMODE_IM
1466 {(char_u *)B_IMODE_IM, (char_u *)0L}
1467#else
1468 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1469#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001470 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001471 {"imsearch", "ims", P_NUM|P_VI_DEF,
1472 (char_u *)&p_imsearch, PV_IMS,
1473#ifdef B_IMODE_IM
1474 {(char_u *)B_IMODE_IM, (char_u *)0L}
1475#else
1476 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1477#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001478 SCRIPTID_INIT},
Bram Moolenaar4a460702013-06-29 14:42:26 +02001479 {"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001480# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1481 (char_u *)&p_imsf, PV_NONE,
1482 {(char_u *)"", (char_u *)NULL}
1483# else
1484 (char_u *)NULL, PV_NONE,
1485 {(char_u *)NULL, (char_u *)0L}
1486# endif
1487 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001488 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1489#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001490 (char_u *)&p_inc, PV_INC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001491 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1492#else
1493 (char_u *)NULL, PV_NONE,
1494 {(char_u *)0L, (char_u *)0L}
1495#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001496 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001497 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1498#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1499 (char_u *)&p_inex, PV_INEX,
1500 {(char_u *)"", (char_u *)0L}
1501#else
1502 (char_u *)NULL, PV_NONE,
1503 {(char_u *)0L, (char_u *)0L}
1504#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001505 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001506 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1507 (char_u *)&p_is, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001508 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001509 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1510#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1511 (char_u *)&p_inde, PV_INDE,
1512 {(char_u *)"", (char_u *)0L}
1513#else
1514 (char_u *)NULL, PV_NONE,
1515 {(char_u *)0L, (char_u *)0L}
1516#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001517 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001518 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
1519#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1520 (char_u *)&p_indk, PV_INDK,
1521 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1522#else
1523 (char_u *)NULL, PV_NONE,
1524 {(char_u *)0L, (char_u *)0L}
1525#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001526 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001527 {"infercase", "inf", P_BOOL|P_VI_DEF,
1528 (char_u *)&p_inf, PV_INF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001529 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001530 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1531 (char_u *)&p_im, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001532 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001533 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1534 (char_u *)&p_isf, PV_NONE,
1535 {
1536#ifdef BACKSLASH_IN_FILENAME
1537 /* Excluded are: & and ^ are special in cmd.exe
1538 * ( and ) are used in text separating fnames */
1539 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1540#else
1541# ifdef AMIGA
1542 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1543# else
1544# ifdef VMS
1545 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1546# else /* UNIX et al. */
1547# ifdef EBCDIC
1548 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1549# else
1550 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1551# endif
1552# endif
1553# endif
1554#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001555 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001556 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1557 (char_u *)&p_isi, PV_NONE,
1558 {
1559#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1560 (char_u *)"@,48-57,_,128-167,224-235",
1561#else
1562# ifdef EBCDIC
1563 /* TODO: EBCDIC Check this! @ == isalpha()*/
1564 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1565 "112-120,128,140-142,156,158,172,"
1566 "174,186,191,203-207,219-225,235-239,"
1567 "251-254",
1568# else
1569 (char_u *)"@,48-57,_,192-255",
1570# endif
1571#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001572 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001573 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1574 (char_u *)&p_isk, PV_ISK,
1575 {
1576#ifdef EBCDIC
1577 (char_u *)"@,240-249,_",
1578 /* TODO: EBCDIC Check this! @ == isalpha()*/
1579 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1580 "112-120,128,140-142,156,158,172,"
1581 "174,186,191,203-207,219-225,235-239,"
1582 "251-254",
1583#else
1584 (char_u *)"@,48-57,_",
1585# if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1586 (char_u *)"@,48-57,_,128-167,224-235"
1587# else
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001588 ISK_LATIN1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001589# endif
1590#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001591 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001592 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1593 (char_u *)&p_isp, PV_NONE,
1594 {
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001595#if defined(MSDOS) || defined(MSWIN) || defined(OS2) \
1596 || (defined(MACOS) && !defined(MACOS_X)) \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001597 || defined(VMS)
1598 (char_u *)"@,~-255",
1599#else
1600# ifdef EBCDIC
1601 /* all chars above 63 are printable */
1602 (char_u *)"63-255",
1603# else
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00001604 ISP_LATIN1,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001605# endif
1606#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001607 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001608 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1609 (char_u *)&p_js, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001610 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001611 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1612#ifdef FEAT_CRYPT
1613 (char_u *)&p_key, PV_KEY,
1614 {(char_u *)"", (char_u *)0L}
1615#else
1616 (char_u *)NULL, PV_NONE,
1617 {(char_u *)0L, (char_u *)0L}
1618#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001619 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001620 {"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 +00001621#ifdef FEAT_KEYMAP
1622 (char_u *)&p_keymap, PV_KMAP,
1623 {(char_u *)"", (char_u *)0L}
1624#else
1625 (char_u *)NULL, PV_NONE,
1626 {(char_u *)"", (char_u *)0L}
1627#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001628 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001629 {"keymodel", "km", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1630#ifdef FEAT_VISUAL
1631 (char_u *)&p_km, PV_NONE,
1632#else
1633 (char_u *)NULL, PV_NONE,
1634#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001635 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001636 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001637 (char_u *)&p_kp, PV_KP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001638 {
1639#if defined(MSDOS) || defined(MSWIN)
1640 (char_u *)":help",
1641#else
1642#ifdef VMS
1643 (char_u *)"help",
1644#else
1645# if defined(OS2)
1646 (char_u *)"view /",
1647# else
1648# ifdef USEMAN_S
1649 (char_u *)"man -s",
1650# else
1651 (char_u *)"man",
1652# endif
1653# endif
1654#endif
1655#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001656 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001657 {"langmap", "lmap", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1658#ifdef FEAT_LANGMAP
1659 (char_u *)&p_langmap, PV_NONE,
1660 {(char_u *)"", /* unmatched } */
1661#else
1662 (char_u *)NULL, PV_NONE,
1663 {(char_u *)NULL,
1664#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001665 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001666 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001667#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1668 (char_u *)&p_lm, PV_NONE,
1669#else
1670 (char_u *)NULL, PV_NONE,
1671#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001672 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001673 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1674#ifdef FEAT_WINDOWS
1675 (char_u *)&p_ls, PV_NONE,
1676#else
1677 (char_u *)NULL, PV_NONE,
1678#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001679 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001680 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1681 (char_u *)&p_lz, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001682 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001683 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1684#ifdef FEAT_LINEBREAK
1685 (char_u *)VAR_WIN, PV_LBR,
1686#else
1687 (char_u *)NULL, PV_NONE,
1688#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001689 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001690 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1691 (char_u *)&Rows, PV_NONE,
1692 {
1693#if defined(MSDOS) || defined(WIN3264) || defined(OS2)
1694 (char_u *)25L,
1695#else
1696 (char_u *)24L,
1697#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001698 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001699 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1700#ifdef FEAT_GUI
1701 (char_u *)&p_linespace, PV_NONE,
1702#else
1703 (char_u *)NULL, PV_NONE,
1704#endif
1705#ifdef FEAT_GUI_W32
1706 {(char_u *)1L, (char_u *)0L}
1707#else
1708 {(char_u *)0L, (char_u *)0L}
1709#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001710 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001711 {"lisp", NULL, P_BOOL|P_VI_DEF,
1712#ifdef FEAT_LISP
1713 (char_u *)&p_lisp, PV_LISP,
1714#else
1715 (char_u *)NULL, PV_NONE,
1716#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001717 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001718 {"lispwords", "lw", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1719#ifdef FEAT_LISP
1720 (char_u *)&p_lispwords, PV_NONE,
1721 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1722#else
1723 (char_u *)NULL, PV_NONE,
1724 {(char_u *)"", (char_u *)0L}
1725#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001726 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001727 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1728 (char_u *)VAR_WIN, PV_LIST,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001729 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001730 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1731 (char_u *)&p_lcs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001732 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001733 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1734 (char_u *)&p_lpl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001735 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001736#ifdef FEAT_GUI_MAC
1737 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
1738 (char_u *)&p_macatsui, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001739 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001740#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001741 {"magic", NULL, P_BOOL|P_VI_DEF,
1742 (char_u *)&p_magic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001743 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00001744 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001745#ifdef FEAT_QUICKFIX
1746 (char_u *)&p_mef, PV_NONE,
1747 {(char_u *)"", (char_u *)0L}
1748#else
1749 (char_u *)NULL, PV_NONE,
1750 {(char_u *)NULL, (char_u *)0L}
1751#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001752 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001753 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1754#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001755 (char_u *)&p_mp, PV_MP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001756# ifdef VMS
1757 {(char_u *)"MMS", (char_u *)0L}
1758# else
1759 {(char_u *)"make", (char_u *)0L}
1760# endif
1761#else
1762 (char_u *)NULL, PV_NONE,
1763 {(char_u *)NULL, (char_u *)0L}
1764#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001765 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001766 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
1767 (char_u *)&p_mps, PV_MPS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001768 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1769 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001770 {"matchtime", "mat", P_NUM|P_VI_DEF,
1771 (char_u *)&p_mat, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001772 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001773 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001774#ifdef FEAT_MBYTE
1775 (char_u *)&p_mco, PV_NONE,
1776#else
1777 (char_u *)NULL, PV_NONE,
1778#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001779 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001780 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1781#ifdef FEAT_EVAL
1782 (char_u *)&p_mfd, PV_NONE,
1783#else
1784 (char_u *)NULL, PV_NONE,
1785#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001786 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001787 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1788 (char_u *)&p_mmd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001789 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001790 {"maxmem", "mm", P_NUM|P_VI_DEF,
1791 (char_u *)&p_mm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001792 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1793 SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00001794 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1795 (char_u *)&p_mmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001796 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001797 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1798 (char_u *)&p_mmt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001799 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1800 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001801 {"menuitems", "mis", P_NUM|P_VI_DEF,
1802#ifdef FEAT_MENU
1803 (char_u *)&p_mis, PV_NONE,
1804#else
1805 (char_u *)NULL, PV_NONE,
1806#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001807 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001808 {"mesg", NULL, P_BOOL|P_VI_DEF,
1809 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001810 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001811 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001812#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001813 (char_u *)&p_msm, PV_NONE,
1814 {(char_u *)"460000,2000,500", (char_u *)0L}
1815#else
1816 (char_u *)NULL, PV_NONE,
1817 {(char_u *)0L, (char_u *)0L}
1818#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001819 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001820 {"modeline", "ml", P_BOOL|P_VIM,
1821 (char_u *)&p_ml, PV_ML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001822 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001823 {"modelines", "mls", P_NUM|P_VI_DEF,
1824 (char_u *)&p_mls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001825 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001826 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1827 (char_u *)&p_ma, PV_MA,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001828 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001829 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1830 (char_u *)&p_mod, PV_MOD,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001831 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001832 {"more", NULL, P_BOOL|P_VIM,
1833 (char_u *)&p_more, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001834 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001835 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
1836 (char_u *)&p_mouse, PV_NONE,
1837 {
1838#if defined(MSDOS) || defined(WIN3264)
1839 (char_u *)"a",
1840#else
1841 (char_u *)"",
1842#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001843 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001844 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
1845#ifdef FEAT_GUI
1846 (char_u *)&p_mousef, PV_NONE,
1847#else
1848 (char_u *)NULL, PV_NONE,
1849#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001850 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001851 {"mousehide", "mh", P_BOOL|P_VI_DEF,
1852#ifdef FEAT_GUI
1853 (char_u *)&p_mh, PV_NONE,
1854#else
1855 (char_u *)NULL, PV_NONE,
1856#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001857 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001858 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
1859 (char_u *)&p_mousem, PV_NONE,
1860 {
1861#if defined(MSDOS) || defined(MSWIN)
1862 (char_u *)"popup",
1863#else
1864# if defined(MACOS)
1865 (char_u *)"popup_setpos",
1866# else
1867 (char_u *)"extend",
1868# endif
1869#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001870 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001871 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1872#ifdef FEAT_MOUSESHAPE
1873 (char_u *)&p_mouseshape, PV_NONE,
1874 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
1875#else
1876 (char_u *)NULL, PV_NONE,
1877 {(char_u *)NULL, (char_u *)0L}
1878#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001879 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001880 {"mousetime", "mouset", P_NUM|P_VI_DEF,
1881 (char_u *)&p_mouset, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001882 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001883 {"mzquantum", "mzq", P_NUM,
1884#ifdef FEAT_MZSCHEME
1885 (char_u *)&p_mzq, PV_NONE,
1886#else
1887 (char_u *)NULL, PV_NONE,
1888#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001889 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001890 {"novice", NULL, P_BOOL|P_VI_DEF,
1891 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001892 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001893 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
1894 (char_u *)&p_nf, PV_NF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001895 {(char_u *)"octal,hex", (char_u *)0L}
1896 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001897 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
1898 (char_u *)VAR_WIN, PV_NU,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001899 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00001900 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
1901#ifdef FEAT_LINEBREAK
1902 (char_u *)VAR_WIN, PV_NUW,
1903#else
1904 (char_u *)NULL, PV_NONE,
1905#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001906 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
Bram Moolenaarf75a9632005-09-13 21:20:47 +00001907 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
Bram Moolenaare344bea2005-09-01 20:46:49 +00001908#ifdef FEAT_COMPL_FUNC
1909 (char_u *)&p_ofu, PV_OFU,
1910 {(char_u *)"", (char_u *)0L}
1911#else
1912 (char_u *)NULL, PV_NONE,
1913 {(char_u *)0L, (char_u *)0L}
1914#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001915 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001916 {"open", NULL, P_BOOL|P_VI_DEF,
1917 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001918 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar043545e2006-10-10 16:44:07 +00001919 {"opendevice", "odev", P_BOOL|P_VI_DEF,
1920#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1921 (char_u *)&p_odev, PV_NONE,
1922#else
1923 (char_u *)NULL, PV_NONE,
1924#endif
1925 {(char_u *)FALSE, (char_u *)FALSE}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001926 SCRIPTID_INIT},
Bram Moolenaar2c7a29c2005-12-12 22:02:31 +00001927 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
1928 (char_u *)&p_opfunc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001929 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001930 {"optimize", "opt", P_BOOL|P_VI_DEF,
1931 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001932 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001933 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001934 (char_u *)NULL, PV_NONE,
Bram Moolenaarb07269a2011-05-19 13:41:14 +02001935 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001936 {"paragraphs", "para", P_STRING|P_VI_DEF,
1937 (char_u *)&p_para, PV_NONE,
Bram Moolenaar57e48462008-03-12 16:38:55 +00001938 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001939 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001940 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001941 (char_u *)&p_paste, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001942 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001943 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
1944 (char_u *)&p_pt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001945 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001946 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
1947#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1948 (char_u *)&p_pex, PV_NONE,
1949 {(char_u *)"", (char_u *)0L}
1950#else
1951 (char_u *)NULL, PV_NONE,
1952 {(char_u *)0L, (char_u *)0L}
1953#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001954 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001955 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001956 (char_u *)&p_pm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001957 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001958 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001959 (char_u *)&p_path, PV_PATH,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001960 {
1961#if defined AMIGA || defined MSDOS || defined MSWIN
1962 (char_u *)".,,",
1963#else
1964# if defined(__EMX__)
1965 (char_u *)".,/emx/include,,",
1966# else /* Unix, probably */
1967 (char_u *)".,/usr/include,,",
1968# endif
1969#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001970 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001971 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
1972 (char_u *)&p_pi, PV_PI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001973 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00001974 {"previewheight", "pvh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001975#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
1976 (char_u *)&p_pvh, PV_NONE,
1977#else
1978 (char_u *)NULL, PV_NONE,
1979#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001980 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001981 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
1982#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
1983 (char_u *)VAR_WIN, PV_PVW,
1984#else
1985 (char_u *)NULL, PV_NONE,
1986#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001987 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001988 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001989#ifdef FEAT_PRINTER
1990 (char_u *)&p_pdev, PV_NONE,
1991 {(char_u *)"", (char_u *)0L}
1992#else
1993 (char_u *)NULL, PV_NONE,
1994 {(char_u *)NULL, (char_u *)0L}
1995#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001996 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001997 {"printencoding", "penc", P_STRING|P_VI_DEF,
1998#ifdef FEAT_POSTSCRIPT
1999 (char_u *)&p_penc, PV_NONE,
2000 {(char_u *)"", (char_u *)0L}
2001#else
2002 (char_u *)NULL, PV_NONE,
2003 {(char_u *)NULL, (char_u *)0L}
2004#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002005 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002006 {"printexpr", "pexpr", P_STRING|P_VI_DEF,
2007#ifdef FEAT_POSTSCRIPT
2008 (char_u *)&p_pexpr, PV_NONE,
2009 {(char_u *)"", (char_u *)0L}
2010#else
2011 (char_u *)NULL, PV_NONE,
2012 {(char_u *)NULL, (char_u *)0L}
2013#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002014 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002015 {"printfont", "pfn", P_STRING|P_VI_DEF,
2016#ifdef FEAT_PRINTER
2017 (char_u *)&p_pfn, PV_NONE,
2018 {
2019# ifdef MSWIN
2020 (char_u *)"Courier_New:h10",
2021# else
2022 (char_u *)"courier",
2023# endif
2024 (char_u *)0L}
2025#else
2026 (char_u *)NULL, PV_NONE,
2027 {(char_u *)NULL, (char_u *)0L}
2028#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002029 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002030 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
2031#ifdef FEAT_PRINTER
2032 (char_u *)&p_header, PV_NONE,
2033 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
2034#else
2035 (char_u *)NULL, PV_NONE,
2036 {(char_u *)NULL, (char_u *)0L}
2037#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002038 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002039 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
2040#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2041 (char_u *)&p_pmcs, PV_NONE,
2042 {(char_u *)"", (char_u *)0L}
2043#else
2044 (char_u *)NULL, PV_NONE,
2045 {(char_u *)NULL, (char_u *)0L}
2046#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002047 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002048 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2049#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2050 (char_u *)&p_pmfn, PV_NONE,
2051 {(char_u *)"", (char_u *)0L}
2052#else
2053 (char_u *)NULL, PV_NONE,
2054 {(char_u *)NULL, (char_u *)0L}
2055#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002056 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002057 {"printoptions", "popt", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2058#ifdef FEAT_PRINTER
2059 (char_u *)&p_popt, PV_NONE,
2060 {(char_u *)"", (char_u *)0L}
2061#else
2062 (char_u *)NULL, PV_NONE,
2063 {(char_u *)NULL, (char_u *)0L}
2064#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002065 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002066 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002067 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002068 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002069 {"pumheight", "ph", P_NUM|P_VI_DEF,
2070#ifdef FEAT_INS_EXPAND
2071 (char_u *)&p_ph, PV_NONE,
2072#else
2073 (char_u *)NULL, PV_NONE,
2074#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002075 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002076 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2077#ifdef FEAT_TEXTOBJ
2078 (char_u *)&p_qe, PV_QE,
2079 {(char_u *)"\\", (char_u *)0L}
2080#else
2081 (char_u *)NULL, PV_NONE,
2082 {(char_u *)NULL, (char_u *)0L}
2083#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002084 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002085 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2086 (char_u *)&p_ro, PV_RO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002087 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002088 {"redraw", NULL, P_BOOL|P_VI_DEF,
2089 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002090 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002091 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2092#ifdef FEAT_RELTIME
2093 (char_u *)&p_rdt, PV_NONE,
2094#else
2095 (char_u *)NULL, PV_NONE,
2096#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002097 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02002098 {"regexpengine", "re", P_NUM|P_VI_DEF,
2099 (char_u *)&p_re, PV_NONE,
2100 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002101 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2102 (char_u *)VAR_WIN, PV_RNU,
2103 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002104 {"remap", NULL, P_BOOL|P_VI_DEF,
2105 (char_u *)&p_remap, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002106 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002107 {"report", NULL, P_NUM|P_VI_DEF,
2108 (char_u *)&p_report, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002109 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002110 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2111#ifdef WIN3264
2112 (char_u *)&p_rs, PV_NONE,
2113#else
2114 (char_u *)NULL, PV_NONE,
2115#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002116 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002117 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2118#ifdef FEAT_RIGHTLEFT
2119 (char_u *)&p_ri, PV_NONE,
2120#else
2121 (char_u *)NULL, PV_NONE,
2122#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002123 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002124 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2125#ifdef FEAT_RIGHTLEFT
2126 (char_u *)VAR_WIN, PV_RL,
2127#else
2128 (char_u *)NULL, PV_NONE,
2129#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002130 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002131 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2132#ifdef FEAT_RIGHTLEFT
2133 (char_u *)VAR_WIN, PV_RLC,
2134 {(char_u *)"search", (char_u *)NULL}
2135#else
2136 (char_u *)NULL, PV_NONE,
2137 {(char_u *)NULL, (char_u *)0L}
2138#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002139 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002140 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2141#ifdef FEAT_CMDL_INFO
2142 (char_u *)&p_ru, PV_NONE,
2143#else
2144 (char_u *)NULL, PV_NONE,
2145#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002146 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002147 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2148#ifdef FEAT_STL_OPT
2149 (char_u *)&p_ruf, PV_NONE,
2150#else
2151 (char_u *)NULL, PV_NONE,
2152#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002153 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002154 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_COMMA|P_NODUP|P_SECURE,
2155 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002156 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2157 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002158 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2159 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002160 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002161 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2162#ifdef FEAT_SCROLLBIND
2163 (char_u *)VAR_WIN, PV_SCBIND,
2164#else
2165 (char_u *)NULL, PV_NONE,
2166#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002167 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002168 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2169 (char_u *)&p_sj, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002170 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002171 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2172 (char_u *)&p_so, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002173 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002174 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2175#ifdef FEAT_SCROLLBIND
2176 (char_u *)&p_sbo, PV_NONE,
2177 {(char_u *)"ver,jump", (char_u *)0L}
2178#else
2179 (char_u *)NULL, PV_NONE,
2180 {(char_u *)0L, (char_u *)0L}
2181#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002182 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002183 {"sections", "sect", P_STRING|P_VI_DEF,
2184 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002185 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2186 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002187 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2188 (char_u *)&p_secure, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002189 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002190 {"selection", "sel", P_STRING|P_VI_DEF,
2191#ifdef FEAT_VISUAL
2192 (char_u *)&p_sel, PV_NONE,
2193#else
2194 (char_u *)NULL, PV_NONE,
2195#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002196 {(char_u *)"inclusive", (char_u *)0L}
2197 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002198 {"selectmode", "slm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2199#ifdef FEAT_VISUAL
2200 (char_u *)&p_slm, PV_NONE,
2201#else
2202 (char_u *)NULL, PV_NONE,
2203#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002204 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002205 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2206#ifdef FEAT_SESSION
2207 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002208 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002209 (char_u *)0L}
2210#else
2211 (char_u *)NULL, PV_NONE,
2212 {(char_u *)0L, (char_u *)0L}
2213#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002214 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002215 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2216 (char_u *)&p_sh, PV_NONE,
2217 {
2218#ifdef VMS
2219 (char_u *)"-",
2220#else
2221# if defined(MSDOS)
2222 (char_u *)"command",
2223# else
2224# if defined(WIN16)
2225 (char_u *)"command.com",
2226# else
2227# if defined(WIN3264)
2228 (char_u *)"", /* set in set_init_1() */
2229# else
2230# if defined(OS2)
2231 (char_u *)"cmd.exe",
2232# else
2233# if defined(ARCHIE)
2234 (char_u *)"gos",
2235# else
2236 (char_u *)"sh",
2237# endif
2238# endif
2239# endif
2240# endif
2241# endif
2242#endif /* VMS */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002243 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002244 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2245 (char_u *)&p_shcf, PV_NONE,
2246 {
2247#if defined(MSDOS) || defined(MSWIN)
2248 (char_u *)"/c",
2249#else
2250# if defined(OS2)
2251 (char_u *)"/c",
2252# else
2253 (char_u *)"-c",
2254# endif
2255#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002256 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002257 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2258#ifdef FEAT_QUICKFIX
2259 (char_u *)&p_sp, PV_NONE,
2260 {
2261#if defined(UNIX) || defined(OS2)
2262# ifdef ARCHIE
2263 (char_u *)"2>",
2264# else
2265 (char_u *)"| tee",
2266# endif
2267#else
2268 (char_u *)">",
2269#endif
2270 (char_u *)0L}
2271#else
2272 (char_u *)NULL, PV_NONE,
2273 {(char_u *)0L, (char_u *)0L}
2274#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002275 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002276 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2277 (char_u *)&p_shq, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002278 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002279 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2280 (char_u *)&p_srr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002281 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002282 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2283#ifdef BACKSLASH_IN_FILENAME
2284 (char_u *)&p_ssl, PV_NONE,
2285#else
2286 (char_u *)NULL, PV_NONE,
2287#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002288 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002289 {"shelltemp", "stmp", P_BOOL,
2290 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002291 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002292 {"shelltype", "st", P_NUM|P_VI_DEF,
2293#ifdef AMIGA
2294 (char_u *)&p_st, PV_NONE,
2295#else
2296 (char_u *)NULL, PV_NONE,
2297#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002298 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002299 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2300 (char_u *)&p_sxq, PV_NONE,
2301 {
2302#if defined(UNIX) && defined(USE_SYSTEM) && !defined(__EMX__)
2303 (char_u *)"\"",
2304#else
2305 (char_u *)"",
2306#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002307 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002308 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
2309 (char_u *)&p_sxe, PV_NONE,
2310 {
2311#if defined(MSDOS) || defined(WIN16) || defined(WIN3264)
2312 (char_u *)"\"&|<>()@^",
2313#else
2314 (char_u *)"",
2315#endif
2316 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002317 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2318 (char_u *)&p_sr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002319 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002320 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2321 (char_u *)&p_sw, PV_SW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002322 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002323 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2324 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002325 {(char_u *)"", (char_u *)"filnxtToO"}
2326 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002327 {"shortname", "sn", P_BOOL|P_VI_DEF,
2328#ifdef SHORT_FNAME
2329 (char_u *)NULL, PV_NONE,
2330#else
2331 (char_u *)&p_sn, PV_SN,
2332#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002333 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002334 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2335#ifdef FEAT_LINEBREAK
2336 (char_u *)&p_sbr, PV_NONE,
2337#else
2338 (char_u *)NULL, PV_NONE,
2339#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002340 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002341 {"showcmd", "sc", P_BOOL|P_VIM,
2342#ifdef FEAT_CMDL_INFO
2343 (char_u *)&p_sc, PV_NONE,
2344#else
2345 (char_u *)NULL, PV_NONE,
2346#endif
2347 {(char_u *)FALSE,
2348#ifdef UNIX
2349 (char_u *)FALSE
2350#else
2351 (char_u *)TRUE
2352#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002353 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002354 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2355 (char_u *)&p_sft, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002356 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002357 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2358 (char_u *)&p_sm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002359 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002360 {"showmode", "smd", P_BOOL|P_VIM,
2361 (char_u *)&p_smd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002362 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002363 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2364#ifdef FEAT_WINDOWS
2365 (char_u *)&p_stal, PV_NONE,
2366#else
2367 (char_u *)NULL, PV_NONE,
2368#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002369 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002370 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2371 (char_u *)&p_ss, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002372 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002373 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2374 (char_u *)&p_siso, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002375 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002376 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2377 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002378 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002379 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2380 (char_u *)&p_scs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002381 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002382 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2383#ifdef FEAT_SMARTINDENT
2384 (char_u *)&p_si, PV_SI,
2385#else
2386 (char_u *)NULL, PV_NONE,
2387#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002388 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002389 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2390 (char_u *)&p_sta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002391 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002392 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2393 (char_u *)&p_sts, PV_STS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002394 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002395 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2396 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002397 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002398 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002399#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002400 (char_u *)VAR_WIN, PV_SPELL,
2401#else
2402 (char_u *)NULL, PV_NONE,
2403#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002404 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002405 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002406#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002407 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002408 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002409#else
2410 (char_u *)NULL, PV_NONE,
2411 {(char_u *)0L, (char_u *)0L}
2412#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002413 SCRIPTID_INIT},
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002414 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE|P_COMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002415#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002416 (char_u *)&p_spf, PV_SPF,
2417 {(char_u *)"", (char_u *)0L}
2418#else
2419 (char_u *)NULL, PV_NONE,
2420 {(char_u *)0L, (char_u *)0L}
2421#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002422 SCRIPTID_INIT},
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00002423 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002424#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002425 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002426 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002427#else
2428 (char_u *)NULL, PV_NONE,
2429 {(char_u *)0L, (char_u *)0L}
2430#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002431 SCRIPTID_INIT},
Bram Moolenaar28e4c8d2006-05-09 16:15:42 +00002432 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_COMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002433#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002434 (char_u *)&p_sps, PV_NONE,
2435 {(char_u *)"best", (char_u *)0L}
2436#else
2437 (char_u *)NULL, PV_NONE,
2438 {(char_u *)0L, (char_u *)0L}
2439#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002440 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002441 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2442#ifdef FEAT_WINDOWS
2443 (char_u *)&p_sb, PV_NONE,
2444#else
2445 (char_u *)NULL, PV_NONE,
2446#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002447 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002448 {"splitright", "spr", P_BOOL|P_VI_DEF,
2449#ifdef FEAT_VERTSPLIT
2450 (char_u *)&p_spr, PV_NONE,
2451#else
2452 (char_u *)NULL, PV_NONE,
2453#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002454 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002455 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2456 (char_u *)&p_sol, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002457 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002458 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2459#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002460 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002461#else
2462 (char_u *)NULL, PV_NONE,
2463#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002464 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002465 {"suffixes", "su", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2466 (char_u *)&p_su, PV_NONE,
2467 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002468 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002469 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002470#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002471 (char_u *)&p_sua, PV_SUA,
2472 {(char_u *)"", (char_u *)0L}
2473#else
2474 (char_u *)NULL, PV_NONE,
2475 {(char_u *)0L, (char_u *)0L}
2476#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002477 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002478 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2479 (char_u *)&p_swf, PV_SWF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002480 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002481 {"swapsync", "sws", P_STRING|P_VI_DEF,
2482 (char_u *)&p_sws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002483 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002484 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2485 (char_u *)&p_swb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002486 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002487 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2488#ifdef FEAT_SYN_HL
2489 (char_u *)&p_smc, PV_SMC,
2490 {(char_u *)3000L, (char_u *)0L}
2491#else
2492 (char_u *)NULL, PV_NONE,
2493 {(char_u *)0L, (char_u *)0L}
2494#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002495 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002496 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002497#ifdef FEAT_SYN_HL
2498 (char_u *)&p_syn, PV_SYN,
2499 {(char_u *)"", (char_u *)0L}
2500#else
2501 (char_u *)NULL, PV_NONE,
2502 {(char_u *)0L, (char_u *)0L}
2503#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002504 SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002505 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2506#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002507 (char_u *)&p_tal, PV_NONE,
2508#else
2509 (char_u *)NULL, PV_NONE,
2510#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002511 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002512 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2513#ifdef FEAT_WINDOWS
2514 (char_u *)&p_tpm, PV_NONE,
2515#else
2516 (char_u *)NULL, PV_NONE,
2517#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002518 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002519 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2520 (char_u *)&p_ts, PV_TS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002521 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002522 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2523 (char_u *)&p_tbs, PV_NONE,
2524#ifdef VMS /* binary searching doesn't appear to work on VMS */
2525 {(char_u *)0L, (char_u *)0L}
2526#else
2527 {(char_u *)TRUE, (char_u *)0L}
2528#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002529 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002530 {"taglength", "tl", P_NUM|P_VI_DEF,
2531 (char_u *)&p_tl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002532 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002533 {"tagrelative", "tr", P_BOOL|P_VIM,
2534 (char_u *)&p_tr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002535 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002536 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002537 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002538 {
2539#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2540 (char_u *)"./tags,./TAGS,tags,TAGS",
2541#else
2542 (char_u *)"./tags,tags",
2543#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002544 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002545 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2546 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002547 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002548 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2549 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002550 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002551 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2552#ifdef FEAT_ARABIC
2553 (char_u *)&p_tbidi, PV_NONE,
2554#else
2555 (char_u *)NULL, PV_NONE,
2556#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002557 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002558 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2559#ifdef FEAT_MBYTE
2560 (char_u *)&p_tenc, PV_NONE,
2561 {(char_u *)"", (char_u *)0L}
2562#else
2563 (char_u *)NULL, PV_NONE,
2564 {(char_u *)0L, (char_u *)0L}
2565#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002566 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002567 {"terse", NULL, P_BOOL|P_VI_DEF,
2568 (char_u *)&p_terse, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002569 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002570 {"textauto", "ta", P_BOOL|P_VIM,
2571 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002572 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2573 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002574 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2575 (char_u *)&p_tx, PV_TX,
2576 {
2577#ifdef USE_CRNL
2578 (char_u *)TRUE,
2579#else
2580 (char_u *)FALSE,
2581#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002582 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +02002583 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002584 (char_u *)&p_tw, PV_TW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002585 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002586 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
2587#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002588 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002589#else
2590 (char_u *)NULL, PV_NONE,
2591#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002592 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002593 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2594 (char_u *)&p_to, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002595 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002596 {"timeout", "to", P_BOOL|P_VI_DEF,
2597 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002598 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002599 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2600 (char_u *)&p_tm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002601 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002602 {"title", NULL, P_BOOL|P_VI_DEF,
2603#ifdef FEAT_TITLE
2604 (char_u *)&p_title, PV_NONE,
2605#else
2606 (char_u *)NULL, PV_NONE,
2607#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002608 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002609 {"titlelen", NULL, P_NUM|P_VI_DEF,
2610#ifdef FEAT_TITLE
2611 (char_u *)&p_titlelen, PV_NONE,
2612#else
2613 (char_u *)NULL, PV_NONE,
2614#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002615 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002616 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002617#ifdef FEAT_TITLE
2618 (char_u *)&p_titleold, PV_NONE,
2619 {(char_u *)N_("Thanks for flying Vim"),
2620 (char_u *)0L}
2621#else
2622 (char_u *)NULL, PV_NONE,
2623 {(char_u *)0L, (char_u *)0L}
2624#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002625 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002626 {"titlestring", NULL, P_STRING|P_VI_DEF,
2627#ifdef FEAT_TITLE
2628 (char_u *)&p_titlestring, PV_NONE,
2629#else
2630 (char_u *)NULL, PV_NONE,
2631#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002632 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002633#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
2634 {"toolbar", "tb", P_STRING|P_COMMA|P_VI_DEF|P_NODUP,
2635 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002636 {(char_u *)"icons,tooltips", (char_u *)0L}
2637 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002638#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002639#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002640 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
2641 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002642 {(char_u *)"small", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002643#endif
2644 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2645 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002646 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002647 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2648 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002649 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002650 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2651 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002652 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002653 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2654 (char_u *)&p_tf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002655 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002656 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2657#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2658 (char_u *)&p_ttym, PV_NONE,
2659#else
2660 (char_u *)NULL, PV_NONE,
2661#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002662 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002663 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2664 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002665 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002666 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2667 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002668 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002669 {"undodir", "udir", P_STRING|P_EXPAND|P_COMMA|P_NODUP|P_SECURE|P_VI_DEF,
2670#ifdef FEAT_PERSISTENT_UNDO
2671 (char_u *)&p_udir, PV_NONE,
2672 {(char_u *)".", (char_u *)0L}
2673#else
2674 (char_u *)NULL, PV_NONE,
2675 {(char_u *)0L, (char_u *)0L}
2676#endif
2677 SCRIPTID_INIT},
2678 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2679#ifdef FEAT_PERSISTENT_UNDO
2680 (char_u *)&p_udf, PV_UDF,
2681#else
2682 (char_u *)NULL, PV_NONE,
2683#endif
2684 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002685 {"undolevels", "ul", P_NUM|P_VI_DEF,
2686 (char_u *)&p_ul, PV_NONE,
2687 {
2688#if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS)
2689 (char_u *)1000L,
2690#else
2691 (char_u *)100L,
2692#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002693 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar59f931e2010-07-24 20:27:03 +02002694 {"undoreload", "ur", P_NUM|P_VI_DEF,
2695 (char_u *)&p_ur, PV_NONE,
2696 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002697 {"updatecount", "uc", P_NUM|P_VI_DEF,
2698 (char_u *)&p_uc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002699 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002700 {"updatetime", "ut", P_NUM|P_VI_DEF,
2701 (char_u *)&p_ut, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002702 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002703 {"verbose", "vbs", P_NUM|P_VI_DEF,
2704 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002705 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002706 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2707 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002708 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002709 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2710#ifdef FEAT_SESSION
2711 (char_u *)&p_vdir, PV_NONE,
2712 {(char_u *)DFLT_VDIR, (char_u *)0L}
2713#else
2714 (char_u *)NULL, PV_NONE,
2715 {(char_u *)0L, (char_u *)0L}
2716#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002717 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002718 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2719#ifdef FEAT_SESSION
2720 (char_u *)&p_vop, PV_NONE,
2721 {(char_u *)"folds,options,cursor", (char_u *)0L}
2722#else
2723 (char_u *)NULL, PV_NONE,
2724 {(char_u *)0L, (char_u *)0L}
2725#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002726 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002727 {"viminfo", "vi", P_STRING|P_COMMA|P_NODUP|P_SECURE,
2728#ifdef FEAT_VIMINFO
2729 (char_u *)&p_viminfo, PV_NONE,
2730#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
Bram Moolenaard812df62008-11-09 12:46:09 +00002731 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002732#else
2733# ifdef AMIGA
2734 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002735 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002736# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002737 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002738# endif
2739#endif
2740#else
2741 (char_u *)NULL, PV_NONE,
2742 {(char_u *)0L, (char_u *)0L}
2743#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002744 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02002745 {"virtualedit", "ve", P_STRING|P_COMMA|P_NODUP|P_VI_DEF|P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002746#ifdef FEAT_VIRTUALEDIT
2747 (char_u *)&p_ve, PV_NONE,
2748 {(char_u *)"", (char_u *)""}
2749#else
2750 (char_u *)NULL, PV_NONE,
2751 {(char_u *)0L, (char_u *)0L}
2752#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002753 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002754 {"visualbell", "vb", P_BOOL|P_VI_DEF,
2755 (char_u *)&p_vb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002756 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002757 {"w300", NULL, P_NUM|P_VI_DEF,
2758 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002759 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002760 {"w1200", NULL, P_NUM|P_VI_DEF,
2761 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002762 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002763 {"w9600", NULL, P_NUM|P_VI_DEF,
2764 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002765 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002766 {"warn", NULL, P_BOOL|P_VI_DEF,
2767 (char_u *)&p_warn, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002768 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002769 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
2770 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002771 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002772 {"whichwrap", "ww", P_STRING|P_VIM|P_COMMA|P_FLAGLIST,
2773 (char_u *)&p_ww, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002774 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002775 {"wildchar", "wc", P_NUM|P_VIM,
2776 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002777 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
2778 SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002779 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002780 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002781 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002782 {"wildignore", "wig", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2783#ifdef FEAT_WILDIGN
2784 (char_u *)&p_wig, PV_NONE,
2785#else
2786 (char_u *)NULL, PV_NONE,
2787#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002788 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002789 {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
2790 (char_u *)&p_wic, PV_NONE,
2791 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002792 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
2793#ifdef FEAT_WILDMENU
2794 (char_u *)&p_wmnu, PV_NONE,
2795#else
2796 (char_u *)NULL, PV_NONE,
2797#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002798 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002799 {"wildmode", "wim", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2800 (char_u *)&p_wim, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002801 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00002802 {"wildoptions", "wop", P_STRING|P_VI_DEF,
2803#ifdef FEAT_CMDL_COMPL
2804 (char_u *)&p_wop, PV_NONE,
2805 {(char_u *)"", (char_u *)0L}
2806#else
2807 (char_u *)NULL, PV_NONE,
2808 {(char_u *)NULL, (char_u *)0L}
2809#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002810 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002811 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
2812#ifdef FEAT_WAK
2813 (char_u *)&p_wak, PV_NONE,
2814 {(char_u *)"menu", (char_u *)0L}
2815#else
2816 (char_u *)NULL, PV_NONE,
2817 {(char_u *)NULL, (char_u *)0L}
2818#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002819 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002820 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00002821 (char_u *)&p_window, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002822 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002823 {"winheight", "wh", P_NUM|P_VI_DEF,
2824#ifdef FEAT_WINDOWS
2825 (char_u *)&p_wh, PV_NONE,
2826#else
2827 (char_u *)NULL, PV_NONE,
2828#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002829 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002830 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002831#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002832 (char_u *)VAR_WIN, PV_WFH,
2833#else
2834 (char_u *)NULL, PV_NONE,
2835#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002836 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002837 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
2838#ifdef FEAT_VERTSPLIT
2839 (char_u *)VAR_WIN, PV_WFW,
2840#else
2841 (char_u *)NULL, PV_NONE,
2842#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002843 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002844 {"winminheight", "wmh", P_NUM|P_VI_DEF,
2845#ifdef FEAT_WINDOWS
2846 (char_u *)&p_wmh, PV_NONE,
2847#else
2848 (char_u *)NULL, PV_NONE,
2849#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002850 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002851 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
2852#ifdef FEAT_VERTSPLIT
2853 (char_u *)&p_wmw, PV_NONE,
2854#else
2855 (char_u *)NULL, PV_NONE,
2856#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002857 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002858 {"winwidth", "wiw", P_NUM|P_VI_DEF,
2859#ifdef FEAT_VERTSPLIT
2860 (char_u *)&p_wiw, PV_NONE,
2861#else
2862 (char_u *)NULL, PV_NONE,
2863#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002864 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002865 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
2866 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002867 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002868 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
2869 (char_u *)&p_wm, PV_WM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002870 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002871 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
2872 (char_u *)&p_ws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002873 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002874 {"write", NULL, P_BOOL|P_VI_DEF,
2875 (char_u *)&p_write, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002876 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002877 {"writeany", "wa", P_BOOL|P_VI_DEF,
2878 (char_u *)&p_wa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002879 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002880 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
2881 (char_u *)&p_wb, PV_NONE,
2882 {
2883#ifdef FEAT_WRITEBACKUP
2884 (char_u *)TRUE,
2885#else
2886 (char_u *)FALSE,
2887#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002888 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002889 {"writedelay", "wd", P_NUM|P_VI_DEF,
2890 (char_u *)&p_wd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002891 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002892
2893/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002894#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00002895 (char_u *)&vvv, PV_NONE, \
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002896 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002897
2898 p_term("t_AB", T_CAB)
2899 p_term("t_AF", T_CAF)
2900 p_term("t_AL", T_CAL)
2901 p_term("t_al", T_AL)
2902 p_term("t_bc", T_BC)
2903 p_term("t_cd", T_CD)
2904 p_term("t_ce", T_CE)
2905 p_term("t_cl", T_CL)
2906 p_term("t_cm", T_CM)
2907 p_term("t_Co", T_CCO)
2908 p_term("t_CS", T_CCS)
2909 p_term("t_cs", T_CS)
2910#ifdef FEAT_VERTSPLIT
2911 p_term("t_CV", T_CSV)
2912#endif
2913 p_term("t_ut", T_UT)
2914 p_term("t_da", T_DA)
2915 p_term("t_db", T_DB)
2916 p_term("t_DL", T_CDL)
2917 p_term("t_dl", T_DL)
2918 p_term("t_fs", T_FS)
2919 p_term("t_IE", T_CIE)
2920 p_term("t_IS", T_CIS)
2921 p_term("t_ke", T_KE)
2922 p_term("t_ks", T_KS)
2923 p_term("t_le", T_LE)
2924 p_term("t_mb", T_MB)
2925 p_term("t_md", T_MD)
2926 p_term("t_me", T_ME)
2927 p_term("t_mr", T_MR)
2928 p_term("t_ms", T_MS)
2929 p_term("t_nd", T_ND)
2930 p_term("t_op", T_OP)
2931 p_term("t_RI", T_CRI)
2932 p_term("t_RV", T_CRV)
Bram Moolenaar9584b312013-03-13 19:29:28 +01002933 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002934 p_term("t_Sb", T_CSB)
2935 p_term("t_Sf", T_CSF)
2936 p_term("t_se", T_SE)
2937 p_term("t_so", T_SO)
2938 p_term("t_sr", T_SR)
2939 p_term("t_ts", T_TS)
2940 p_term("t_te", T_TE)
2941 p_term("t_ti", T_TI)
2942 p_term("t_ue", T_UE)
2943 p_term("t_us", T_US)
2944 p_term("t_vb", T_VB)
2945 p_term("t_ve", T_VE)
2946 p_term("t_vi", T_VI)
2947 p_term("t_vs", T_VS)
2948 p_term("t_WP", T_CWP)
2949 p_term("t_WS", T_CWS)
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002950 p_term("t_SI", T_CSI)
2951 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002952 p_term("t_xs", T_XS)
2953 p_term("t_ZH", T_CZH)
2954 p_term("t_ZR", T_CZR)
2955
2956/* terminal key codes are not in here */
2957
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002958 /* end marker */
2959 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002960};
2961
2962#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
2963
2964#ifdef FEAT_MBYTE
2965static char *(p_ambw_values[]) = {"single", "double", NULL};
2966#endif
2967static char *(p_bg_values[]) = {"light", "dark", NULL};
2968static char *(p_nf_values[]) = {"octal", "hex", "alpha", NULL};
2969static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02002970#ifdef FEAT_CRYPT
2971static char *(p_cm_values[]) = {"zip", "blowfish", NULL};
2972#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00002973#ifdef FEAT_CMDL_COMPL
2974static char *(p_wop_values[]) = {"tagfile", NULL};
2975#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002976#ifdef FEAT_WAK
2977static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
2978#endif
2979static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
2980#ifdef FEAT_VISUAL
2981static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
2982static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
2983#endif
2984#ifdef FEAT_VISUAL
2985static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
2986#endif
2987#ifdef FEAT_BROWSE
2988static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
2989#endif
2990#ifdef FEAT_SCROLLBIND
2991static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
2992#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00002993static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00002994#ifdef FEAT_VERTSPLIT
2995static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
2996#endif
2997#if defined(FEAT_QUICKFIX)
Bram Moolenaar21cf8232004-07-16 20:18:37 +00002998# ifdef FEAT_AUTOCMD
2999static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
3000# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003001static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003002# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003003static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
3004#endif
3005static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
3006#ifdef FEAT_FOLDING
3007static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003008# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00003009 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003010# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003011 NULL};
3012static char *(p_fcl_values[]) = {"all", NULL};
3013#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003014#ifdef FEAT_INS_EXPAND
Bram Moolenaarc270d802006-03-11 21:29:41 +00003015static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003016#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003017
3018static void set_option_default __ARGS((int, int opt_flags, int compatible));
3019static void set_options_default __ARGS((int opt_flags));
Bram Moolenaarf740b292006-02-16 22:11:02 +00003020static char_u *term_bg_default __ARGS((void));
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003021static void did_set_option __ARGS((int opt_idx, int opt_flags, int new_value));
Bram Moolenaar071d4272004-06-13 20:20:40 +00003022static char_u *illegal_char __ARGS((char_u *, int));
3023static int string_to_key __ARGS((char_u *arg));
3024#ifdef FEAT_CMDWIN
3025static char_u *check_cedit __ARGS((void));
3026#endif
3027#ifdef FEAT_TITLE
3028static void did_set_title __ARGS((int icon));
3029#endif
3030static char_u *option_expand __ARGS((int opt_idx, char_u *val));
3031static void didset_options __ARGS((void));
3032static void check_string_option __ARGS((char_u **pp));
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003033#if defined(FEAT_EVAL) || defined(PROTO)
3034static long_u *insecure_flag __ARGS((int opt_idx, int opt_flags));
3035#else
3036# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3037#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003038static void set_string_option_global __ARGS((int opt_idx, char_u **varp));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02003039static char_u *set_string_option __ARGS((int opt_idx, char_u *value, int opt_flags));
Bram Moolenaar071d4272004-06-13 20:20:40 +00003040static 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));
3041static char_u *set_chars_option __ARGS((char_u **varp));
Bram Moolenaar1a384422010-07-14 19:53:30 +02003042#ifdef FEAT_SYN_HL
3043static int int_cmp __ARGS((const void *a, const void *b));
3044#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003045#ifdef FEAT_CLIPBOARD
3046static char_u *check_clipboard_option __ARGS((void));
3047#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003048#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02003049static char_u *compile_cap_prog __ARGS((synblock_T *synblock));
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003050#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003051#ifdef FEAT_EVAL
3052static void set_option_scriptID_idx __ARGS((int opt_idx, int opt_flags, int id));
3053#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003054static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value, int opt_flags));
Bram Moolenaar555b2802005-05-19 21:08:39 +00003055static 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 +00003056static void check_redraw __ARGS((long_u flags));
3057static int findoption __ARGS((char_u *));
3058static int find_key_option __ARGS((char_u *));
3059static void showoptions __ARGS((int all, int opt_flags));
3060static int optval_default __ARGS((struct vimoption *, char_u *varp));
3061static void showoneopt __ARGS((struct vimoption *, int opt_flags));
3062static int put_setstring __ARGS((FILE *fd, char *cmd, char *name, char_u **valuep, int expand));
3063static int put_setnum __ARGS((FILE *fd, char *cmd, char *name, long *valuep));
3064static int put_setbool __ARGS((FILE *fd, char *cmd, char *name, int value));
3065static int istermoption __ARGS((struct vimoption *));
3066static char_u *get_varp_scope __ARGS((struct vimoption *p, int opt_flags));
3067static char_u *get_varp __ARGS((struct vimoption *));
3068static void option_value2string __ARGS((struct vimoption *, int opt_flags));
3069static int wc_use_keyname __ARGS((char_u *varp, long *wcp));
3070#ifdef FEAT_LANGMAP
3071static void langmap_init __ARGS((void));
3072static void langmap_set __ARGS((void));
3073#endif
3074static void paste_option_changed __ARGS((void));
3075static void compatible_set __ARGS((void));
3076#ifdef FEAT_LINEBREAK
3077static void fill_breakat_flags __ARGS((void));
3078#endif
3079static int opt_strings_flags __ARGS((char_u *val, char **values, unsigned *flagp, int list));
3080static int check_opt_strings __ARGS((char_u *val, char **values, int));
3081static int check_opt_wim __ARGS((void));
3082
3083/*
3084 * Initialize the options, first part.
3085 *
3086 * Called only once from main(), just after creating the first buffer.
3087 */
3088 void
3089set_init_1()
3090{
3091 char_u *p;
3092 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003093 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003094
3095#ifdef FEAT_LANGMAP
3096 langmap_init();
3097#endif
3098
3099 /* Be Vi compatible by default */
3100 p_cp = TRUE;
3101
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003102 /* Use POSIX compatibility when $VIM_POSIX is set. */
3103 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003104 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003105 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003106 set_string_default("shm", (char_u *)"A");
3107 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003108
Bram Moolenaar071d4272004-06-13 20:20:40 +00003109 /*
3110 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003111 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003112 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003113 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003114#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
3115# ifdef __EMX__
Bram Moolenaar7c626922005-02-07 22:01:03 +00003116 || ((p = mch_getenv((char_u *)"EMXSHELL")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003117# endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003118 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003119# ifdef WIN3264
Bram Moolenaar7c626922005-02-07 22:01:03 +00003120 || ((p = default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003121# endif
3122#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003123 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003124 set_string_default("sh", p);
3125
3126#ifdef FEAT_WILDIGN
3127 /*
3128 * Set the default for 'backupskip' to include environment variables for
3129 * temp files.
3130 */
3131 {
3132# ifdef UNIX
3133 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3134# else
3135 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3136# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003137 int len;
3138 garray_T ga;
3139 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003140
3141 ga_init2(&ga, 1, 100);
3142 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3143 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003144 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003145# ifdef UNIX
3146 if (*names[n] == NUL)
3147 p = (char_u *)"/tmp";
3148 else
3149# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003150 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003151 if (p != NULL && *p != NUL)
3152 {
3153 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003154 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003155 if (ga_grow(&ga, len) == OK)
3156 {
3157 if (ga.ga_len > 0)
3158 STRCAT(ga.ga_data, ",");
3159 STRCAT(ga.ga_data, p);
3160 add_pathsep(ga.ga_data);
3161 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003162 ga.ga_len += len;
3163 }
3164 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003165 if (mustfree)
3166 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003167 }
3168 if (ga.ga_data != NULL)
3169 {
3170 set_string_default("bsk", ga.ga_data);
3171 vim_free(ga.ga_data);
3172 }
3173 }
3174#endif
3175
3176 /*
3177 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3178 */
3179 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003180 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003181 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003182#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3183 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3184#endif
3185 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003186#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003187 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003188 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003189#else
3190# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003191 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003192 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003193# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003194 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003195# endif
3196#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003197 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003198 opt_idx = findoption((char_u *)"maxmem");
3199 if (opt_idx >= 0)
3200 {
3201#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
Bram Moolenaar427d51c2013-06-16 16:01:25 +02003202 if ((long)options[opt_idx].def_val[VI_DEFAULT] > (long)n
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003203 || (long)options[opt_idx].def_val[VI_DEFAULT] == 0L)
3204#endif
3205 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3206 }
3207 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003208 }
3209
3210#ifdef FEAT_GUI_W32
3211 /* force 'shortname' for Win32s */
3212 if (gui_is_win32s())
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003213 {
3214 opt_idx = findoption((char_u *)"shortname");
3215 if (opt_idx >= 0)
3216 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)TRUE;
3217 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003218#endif
3219
3220#ifdef FEAT_SEARCHPATH
3221 {
3222 char_u *cdpath;
3223 char_u *buf;
3224 int i;
3225 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003226 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003227
3228 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003229 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003230 if (cdpath != NULL)
3231 {
3232 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3233 if (buf != NULL)
3234 {
3235 buf[0] = ','; /* start with ",", current dir first */
3236 j = 1;
3237 for (i = 0; cdpath[i] != NUL; ++i)
3238 {
3239 if (vim_ispathlistsep(cdpath[i]))
3240 buf[j++] = ',';
3241 else
3242 {
3243 if (cdpath[i] == ' ' || cdpath[i] == ',')
3244 buf[j++] = '\\';
3245 buf[j++] = cdpath[i];
3246 }
3247 }
3248 buf[j] = NUL;
3249 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003250 if (opt_idx >= 0)
3251 {
3252 options[opt_idx].def_val[VI_DEFAULT] = buf;
3253 options[opt_idx].flags |= P_DEF_ALLOCED;
3254 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003255 else
3256 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003257 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003258 if (mustfree)
3259 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003260 }
3261 }
3262#endif
3263
3264#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(OS2) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
3265 /* Set print encoding on platforms that don't default to latin1 */
3266 set_string_default("penc",
3267# if defined(MSWIN) || defined(OS2)
3268 (char_u *)"cp1252"
3269# else
3270# ifdef VMS
3271 (char_u *)"dec-mcs"
3272# else
3273# ifdef EBCDIC
3274 (char_u *)"ebcdic-uk"
3275# else
3276# ifdef MAC
3277 (char_u *)"mac-roman"
3278# else /* HPUX */
3279 (char_u *)"hp-roman8"
3280# endif
3281# endif
3282# endif
3283# endif
3284 );
3285#endif
3286
3287#ifdef FEAT_POSTSCRIPT
3288 /* 'printexpr' must be allocated to be able to evaluate it. */
3289 set_string_default("pexpr",
Bram Moolenaared203462004-06-16 11:19:22 +00003290# if defined(MSWIN) || defined(MSDOS) || defined(OS2)
3291 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003292# else
3293# ifdef VMS
3294 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3295
3296# else
3297 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3298# endif
3299# endif
3300 );
3301#endif
3302
3303 /*
3304 * Set all the options (except the terminal options) to their default
3305 * value. Also set the global value for local options.
3306 */
3307 set_options_default(0);
3308
3309#ifdef FEAT_GUI
3310 if (found_reverse_arg)
3311 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3312#endif
3313
3314 curbuf->b_p_initialized = TRUE;
3315 curbuf->b_p_ar = -1; /* no local 'autoread' value */
3316 check_buf_options(curbuf);
3317 check_win_options(curwin);
3318 check_options();
3319
3320 /* Must be before option_expand(), because that one needs vim_isIDc() */
3321 didset_options();
3322
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003323#ifdef FEAT_SPELL
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003324 /* Use the current chartab for the generic chartab. */
3325 init_spell_chartab();
3326#endif
3327
Bram Moolenaar071d4272004-06-13 20:20:40 +00003328#ifdef FEAT_LINEBREAK
3329 /*
3330 * initialize the table for 'breakat'.
3331 */
3332 fill_breakat_flags();
3333#endif
3334
3335 /*
3336 * Expand environment variables and things like "~" for the defaults.
3337 * If option_expand() returns non-NULL the variable is expanded. This can
3338 * only happen for non-indirect options.
3339 * Also set the default to the expanded value, so ":set" does not list
3340 * them.
3341 * Don't set the P_ALLOCED flag, because we don't want to free the
3342 * default.
3343 */
3344 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3345 {
3346 if ((options[opt_idx].flags & P_GETTEXT)
3347 && options[opt_idx].var != NULL)
3348 p = (char_u *)_(*(char **)options[opt_idx].var);
3349 else
3350 p = option_expand(opt_idx, NULL);
3351 if (p != NULL && (p = vim_strsave(p)) != NULL)
3352 {
3353 *(char_u **)options[opt_idx].var = p;
3354 /* VIMEXP
3355 * Defaults for all expanded options are currently the same for Vi
3356 * and Vim. When this changes, add some code here! Also need to
3357 * split P_DEF_ALLOCED in two.
3358 */
3359 if (options[opt_idx].flags & P_DEF_ALLOCED)
3360 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3361 options[opt_idx].def_val[VI_DEFAULT] = p;
3362 options[opt_idx].flags |= P_DEF_ALLOCED;
3363 }
3364 }
3365
3366 /* Initialize the highlight_attr[] table. */
3367 highlight_changed();
3368
3369 save_file_ff(curbuf); /* Buffer is unchanged */
3370
3371 /* Parse default for 'wildmode' */
3372 check_opt_wim();
3373
3374#if defined(FEAT_ARABIC)
3375 /* Detect use of mlterm.
3376 * Mlterm is a terminal emulator akin to xterm that has some special
3377 * abilities (bidi namely).
3378 * NOTE: mlterm's author is being asked to 'set' a variable
3379 * instead of an environment variable due to inheritance.
3380 */
3381 if (mch_getenv((char_u *)"MLTERM") != NULL)
3382 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3383#endif
3384
3385#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
3386 /* Parse default for 'fillchars'. */
3387 (void)set_chars_option(&p_fcs);
3388#endif
3389
3390#ifdef FEAT_CLIPBOARD
3391 /* Parse default for 'clipboard' */
3392 (void)check_clipboard_option();
3393#endif
3394
3395#ifdef FEAT_MBYTE
3396# if defined(WIN3264) && defined(FEAT_GETTEXT)
3397 /*
3398 * If $LANG isn't set, try to get a good value for it. This makes the
3399 * right language be used automatically. Don't do this for English.
3400 */
3401 if (mch_getenv((char_u *)"LANG") == NULL)
3402 {
3403 char buf[20];
3404
3405 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3406 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3407 * only the first two. */
3408 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3409 (LPTSTR)buf, 20);
3410 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3411 {
3412 /* There are a few exceptions (probably more) */
3413 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3414 STRCPY(buf, "zh_TW");
3415 else if (STRNICMP(buf, "chs", 3) == 0
3416 || STRNICMP(buf, "zhc", 3) == 0)
3417 STRCPY(buf, "zh_CN");
3418 else if (STRNICMP(buf, "jp", 2) == 0)
3419 STRCPY(buf, "ja");
3420 else
3421 buf[2] = NUL; /* truncate to two-letter code */
3422 vim_setenv("LANG", buf);
3423 }
3424 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003425# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003426# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003427 /* Moved to os_mac_conv.c to avoid dependency problems. */
3428 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003429# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003430# endif
3431
3432 /* enc_locale() will try to find the encoding of the current locale. */
3433 p = enc_locale();
3434 if (p != NULL)
3435 {
3436 char_u *save_enc;
3437
3438 /* Try setting 'encoding' and check if the value is valid.
3439 * If not, go back to the default "latin1". */
3440 save_enc = p_enc;
3441 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003442 if (STRCMP(p_enc, "gb18030") == 0)
3443 {
3444 /* We don't support "gb18030", but "cp936" is a good substitute
3445 * for practical purposes, thus use that. It's not an alias to
3446 * still support conversion between gb18030 and utf-8. */
3447 p_enc = vim_strsave((char_u *)"cp936");
3448 vim_free(p);
3449 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003450 if (mb_init() == NULL)
3451 {
3452 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003453 if (opt_idx >= 0)
3454 {
3455 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3456 options[opt_idx].flags |= P_DEF_ALLOCED;
3457 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003458
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003459#if defined(MSDOS) || defined(MSWIN) || defined(OS2) || defined(MACOS) \
3460 || defined(VMS)
3461 if (STRCMP(p_enc, "latin1") == 0
3462# ifdef FEAT_MBYTE
3463 || enc_utf8
3464# endif
3465 )
3466 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003467 /* Adjust the default for 'isprint' and 'iskeyword' to match
3468 * latin1. Also set the defaults for when 'nocompatible' is
3469 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003470 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003471 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003472 set_string_option_direct((char_u *)"isk", -1,
3473 ISK_LATIN1, OPT_FREE, SID_NONE);
3474 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003475 if (opt_idx >= 0)
3476 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003477 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003478 if (opt_idx >= 0)
3479 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003480 (void)init_chartab();
3481 }
3482#endif
3483
Bram Moolenaar071d4272004-06-13 20:20:40 +00003484# if defined(WIN3264) && !defined(FEAT_GUI)
3485 /* Win32 console: When GetACP() returns a different value from
3486 * GetConsoleCP() set 'termencoding'. */
3487 if (GetACP() != GetConsoleCP())
3488 {
3489 char buf[50];
3490
3491 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3492 p_tenc = vim_strsave((char_u *)buf);
3493 if (p_tenc != NULL)
3494 {
3495 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003496 if (opt_idx >= 0)
3497 {
3498 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3499 options[opt_idx].flags |= P_DEF_ALLOCED;
3500 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003501 convert_setup(&input_conv, p_tenc, p_enc);
3502 convert_setup(&output_conv, p_enc, p_tenc);
3503 }
3504 else
3505 p_tenc = empty_option;
3506 }
3507# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003508# if defined(WIN3264) && defined(FEAT_MBYTE)
3509 /* $HOME may have characters in active code page. */
3510 init_homedir();
3511# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003512 }
3513 else
3514 {
3515 vim_free(p_enc);
3516 p_enc = save_enc;
3517 }
3518 }
3519#endif
3520
3521#ifdef FEAT_MULTI_LANG
3522 /* Set the default for 'helplang'. */
3523 set_helplang_default(get_mess_lang());
3524#endif
3525}
3526
3527/*
3528 * Set an option to its default value.
3529 * This does not take care of side effects!
3530 */
3531 static void
3532set_option_default(opt_idx, opt_flags, compatible)
3533 int opt_idx;
3534 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3535 int compatible; /* use Vi default value */
3536{
3537 char_u *varp; /* pointer to variable for current option */
3538 int dvi; /* index in def_val[] */
3539 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003540 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003541 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3542
3543 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3544 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003545 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003546 {
3547 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3548 if (flags & P_STRING)
3549 {
3550 /* Use set_string_option_direct() for local options to handle
3551 * freeing and allocating the value. */
3552 if (options[opt_idx].indir != PV_NONE)
3553 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003554 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003555 else
3556 {
3557 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3558 free_string_option(*(char_u **)(varp));
3559 *(char_u **)varp = options[opt_idx].def_val[dvi];
3560 options[opt_idx].flags &= ~P_ALLOCED;
3561 }
3562 }
3563 else if (flags & P_NUM)
3564 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003565 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003566 win_comp_scroll(curwin);
3567 else
3568 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003569 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003570 /* May also set global value for local option. */
3571 if (both)
3572 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3573 *(long *)varp;
3574 }
3575 }
3576 else /* P_BOOL */
3577 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003578 /* the cast to long is required for Manx C, long_i is needed for
3579 * MSVC */
3580 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003581#ifdef UNIX
3582 /* 'modeline' defaults to off for root */
3583 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3584 *(int *)varp = FALSE;
3585#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003586 /* May also set global value for local option. */
3587 if (both)
3588 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3589 *(int *)varp;
3590 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003591
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003592 /* The default value is not insecure. */
3593 flagsp = insecure_flag(opt_idx, opt_flags);
3594 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003595 }
3596
3597#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003598 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003599#endif
3600}
3601
3602/*
3603 * Set all options (except terminal options) to their default value.
3604 */
3605 static void
3606set_options_default(opt_flags)
3607 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3608{
3609 int i;
3610#ifdef FEAT_WINDOWS
3611 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003612 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003613#endif
3614
3615 for (i = 0; !istermoption(&options[i]); i++)
3616 if (!(options[i].flags & P_NODEFAULT))
3617 set_option_default(i, opt_flags, p_cp);
3618
3619#ifdef FEAT_WINDOWS
3620 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003621 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003622 win_comp_scroll(wp);
3623#else
3624 win_comp_scroll(curwin);
3625#endif
3626}
3627
3628/*
3629 * Set the Vi-default value of a string option.
3630 * Used for 'sh', 'backupskip' and 'term'.
3631 */
3632 void
3633set_string_default(name, val)
3634 char *name;
3635 char_u *val;
3636{
3637 char_u *p;
3638 int opt_idx;
3639
3640 p = vim_strsave(val);
3641 if (p != NULL) /* we don't want a NULL */
3642 {
3643 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003644 if (opt_idx >= 0)
3645 {
3646 if (options[opt_idx].flags & P_DEF_ALLOCED)
3647 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3648 options[opt_idx].def_val[VI_DEFAULT] = p;
3649 options[opt_idx].flags |= P_DEF_ALLOCED;
3650 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003651 }
3652}
3653
3654/*
3655 * Set the Vi-default value of a number option.
3656 * Used for 'lines' and 'columns'.
3657 */
3658 void
3659set_number_default(name, val)
3660 char *name;
3661 long val;
3662{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003663 int opt_idx;
3664
3665 opt_idx = findoption((char_u *)name);
3666 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003667 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003668}
3669
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003670#if defined(EXITFREE) || defined(PROTO)
3671/*
3672 * Free all options.
3673 */
3674 void
3675free_all_options()
3676{
3677 int i;
3678
3679 for (i = 0; !istermoption(&options[i]); i++)
3680 {
3681 if (options[i].indir == PV_NONE)
3682 {
3683 /* global option: free value and default value. */
3684 if (options[i].flags & P_ALLOCED && options[i].var != NULL)
3685 free_string_option(*(char_u **)options[i].var);
3686 if (options[i].flags & P_DEF_ALLOCED)
3687 free_string_option(options[i].def_val[VI_DEFAULT]);
3688 }
3689 else if (options[i].var != VAR_WIN
3690 && (options[i].flags & P_STRING))
3691 /* buffer-local option: free global value */
3692 free_string_option(*(char_u **)options[i].var);
3693 }
3694}
3695#endif
3696
3697
Bram Moolenaar071d4272004-06-13 20:20:40 +00003698/*
3699 * Initialize the options, part two: After getting Rows and Columns and
3700 * setting 'term'.
3701 */
3702 void
3703set_init_2()
3704{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003705 int idx;
3706
Bram Moolenaar071d4272004-06-13 20:20:40 +00003707 /*
3708 * 'scroll' defaults to half the window height. Note that this default is
3709 * wrong when the window height changes.
3710 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003711 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003712 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003713 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003714 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003715 comp_col();
3716
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003717 /*
3718 * 'window' is only for backwards compatibility with Vi.
3719 * Default is Rows - 1.
3720 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003721 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003722 p_window = Rows - 1;
3723 set_number_default("window", Rows - 1);
3724
Bram Moolenaarf740b292006-02-16 22:11:02 +00003725 /* For DOS console the default is always black. */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003726#if !((defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003727 /*
3728 * If 'background' wasn't set by the user, try guessing the value,
3729 * depending on the terminal name. Only need to check for terminals
3730 * with a dark background, that can handle color.
3731 */
3732 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003733 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3734 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003735 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003736 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003737 /* don't mark it as set, when starting the GUI it may be
3738 * changed again */
3739 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003740 }
3741#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003742
3743#ifdef CURSOR_SHAPE
3744 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3745#endif
3746#ifdef FEAT_MOUSESHAPE
3747 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3748#endif
3749#ifdef FEAT_PRINTER
3750 (void)parse_printoptions(); /* parse 'printoptions' default value */
3751#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003752}
3753
3754/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00003755 * Return "dark" or "light" depending on the kind of terminal.
3756 * This is just guessing! Recognized are:
3757 * "linux" Linux console
3758 * "screen.linux" Linux console with screen
3759 * "cygwin" Cygwin shell
3760 * "putty" Putty program
3761 * We also check the COLORFGBG environment variable, which is set by
3762 * rxvt and derivatives. This variable contains either two or three
3763 * values separated by semicolons; we want the last value in either
3764 * case. If this value is 0-6 or 8, our background is dark.
3765 */
3766 static char_u *
3767term_bg_default()
3768{
Bram Moolenaarf740b292006-02-16 22:11:02 +00003769#if defined(MSDOS) || defined(OS2) || defined(WIN3264)
3770 /* DOS console nearly always black */
3771 return (char_u *)"dark";
3772#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00003773 char_u *p;
3774
Bram Moolenaarf740b292006-02-16 22:11:02 +00003775 if (STRCMP(T_NAME, "linux") == 0
3776 || STRCMP(T_NAME, "screen.linux") == 0
3777 || STRCMP(T_NAME, "cygwin") == 0
3778 || STRCMP(T_NAME, "putty") == 0
3779 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
3780 && (p = vim_strrchr(p, ';')) != NULL
3781 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
3782 && p[2] == NUL))
3783 return (char_u *)"dark";
3784 return (char_u *)"light";
3785#endif
3786}
3787
3788/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00003789 * Initialize the options, part three: After reading the .vimrc
3790 */
3791 void
3792set_init_3()
3793{
3794#if defined(UNIX) || defined(OS2) || defined(WIN3264)
3795/*
3796 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
3797 * This is done after other initializations, where 'shell' might have been
3798 * set, but only if they have not been set before.
3799 */
3800 char_u *p;
3801 int idx_srr;
3802 int do_srr;
3803#ifdef FEAT_QUICKFIX
3804 int idx_sp;
3805 int do_sp;
3806#endif
3807
3808 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003809 if (idx_srr < 0)
3810 do_srr = FALSE;
3811 else
3812 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003813#ifdef FEAT_QUICKFIX
3814 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003815 if (idx_sp < 0)
3816 do_sp = FALSE;
3817 else
3818 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003819#endif
3820
3821 /*
3822 * Isolate the name of the shell:
3823 * - Skip beyond any path. E.g., "/usr/bin/csh -f" -> "csh -f".
3824 * - Remove any argument. E.g., "csh -f" -> "csh".
Bram Moolenaarae61bcf2010-05-13 13:12:06 +02003825 * But don't allow a space in the path, so that this works:
3826 * "/usr/bin/csh --rcfile ~/.cshrc"
3827 * But don't do that for Windows, it's common to have a space in the path.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003828 */
Bram Moolenaarae61bcf2010-05-13 13:12:06 +02003829#ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003830 p = gettail(p_sh);
3831 p = vim_strnsave(p, (int)(skiptowhite(p) - p));
Bram Moolenaarae61bcf2010-05-13 13:12:06 +02003832#else
3833 p = skiptowhite(p_sh);
3834 if (*p == NUL)
3835 {
3836 /* No white space, use the tail. */
3837 p = vim_strsave(gettail(p_sh));
3838 }
3839 else
3840 {
3841 char_u *p1, *p2;
3842
3843 /* Find the last path separator before the space. */
3844 p1 = p_sh;
3845 for (p2 = p_sh; p2 < p; mb_ptr_adv(p2))
3846 if (vim_ispathsep(*p2))
3847 p1 = p2 + 1;
3848 p = vim_strnsave(p1, (int)(p - p1));
3849 }
3850#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003851 if (p != NULL)
3852 {
3853 /*
3854 * Default for p_sp is "| tee", for p_srr is ">".
3855 * For known shells it is changed here to include stderr.
3856 */
3857 if ( fnamecmp(p, "csh") == 0
3858 || fnamecmp(p, "tcsh") == 0
3859# if defined(OS2) || defined(WIN3264) /* also check with .exe extension */
3860 || fnamecmp(p, "csh.exe") == 0
3861 || fnamecmp(p, "tcsh.exe") == 0
3862# endif
3863 )
3864 {
3865#if defined(FEAT_QUICKFIX)
3866 if (do_sp)
3867 {
3868# ifdef WIN3264
3869 p_sp = (char_u *)">&";
3870# else
3871 p_sp = (char_u *)"|& tee";
3872# endif
3873 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3874 }
3875#endif
3876 if (do_srr)
3877 {
3878 p_srr = (char_u *)">&";
3879 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3880 }
3881 }
3882 else
3883# ifndef OS2 /* Always use bourne shell style redirection if we reach this */
3884 if ( fnamecmp(p, "sh") == 0
3885 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003886 || fnamecmp(p, "mksh") == 0
3887 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003888 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003889 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003890 || fnamecmp(p, "bash") == 0
3891# ifdef WIN3264
3892 || fnamecmp(p, "cmd") == 0
3893 || fnamecmp(p, "sh.exe") == 0
3894 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003895 || fnamecmp(p, "mksh.exe") == 0
3896 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003897 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003898 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003899 || fnamecmp(p, "bash.exe") == 0
3900 || fnamecmp(p, "cmd.exe") == 0
3901# endif
3902 )
3903# endif
3904 {
3905#if defined(FEAT_QUICKFIX)
3906 if (do_sp)
3907 {
3908# ifdef WIN3264
3909 p_sp = (char_u *)">%s 2>&1";
3910# else
3911 p_sp = (char_u *)"2>&1| tee";
3912# endif
3913 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3914 }
3915#endif
3916 if (do_srr)
3917 {
3918 p_srr = (char_u *)">%s 2>&1";
3919 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3920 }
3921 }
3922 vim_free(p);
3923 }
3924#endif
3925
3926#if defined(MSDOS) || defined(WIN3264) || defined(OS2)
3927 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01003928 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
3929 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003930 * This is done after other initializations, where 'shell' might have been
3931 * set, but only if they have not been set before. Default for p_shcf is
3932 * "/c", for p_shq is "". For "sh" like shells it is changed here to
3933 * "-c" and "\"", but not for DJGPP, because it starts the shell without
3934 * command.com. And for Win32 we need to set p_sxq instead.
3935 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00003936 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003937 {
3938 int idx3;
3939
3940 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003941 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003942 {
3943 p_shcf = (char_u *)"-c";
3944 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3945 }
3946
3947# ifndef DJGPP
3948# ifdef WIN3264
3949 /* Somehow Win32 requires the quotes around the redirection too */
3950 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003951 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003952 {
3953 p_sxq = (char_u *)"\"";
3954 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3955 }
3956# else
3957 idx3 = findoption((char_u *)"shq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003958 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003959 {
3960 p_shq = (char_u *)"\"";
3961 options[idx3].def_val[VI_DEFAULT] = p_shq;
3962 }
3963# endif
3964# endif
3965 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01003966 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
3967 {
3968 int idx3;
3969
3970 /*
3971 * cmd.exe on Windows will strip the first and last double quote given
3972 * on the command line, e.g. most of the time things like:
3973 * cmd /c "my path/to/echo" "my args to echo"
3974 * become:
3975 * my path/to/echo" "my args to echo
3976 * when executed.
3977 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01003978 * To avoid this, set shellxquote to surround the command in
3979 * parenthesis. This appears to make most commands work, without
3980 * breaking commands that worked previously, such as
3981 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01003982 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01003983 idx3 = findoption((char_u *)"sxq");
3984 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
3985 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01003986 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01003987 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3988 }
3989
Bram Moolenaara64ba222012-02-12 23:23:31 +01003990 idx3 = findoption((char_u *)"shcf");
3991 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
3992 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01003993 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01003994 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3995 }
3996 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003997#endif
3998
3999#ifdef FEAT_TITLE
4000 set_title_defaults();
4001#endif
4002}
4003
4004#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4005/*
4006 * When 'helplang' is still at its default value, set it to "lang".
4007 * Only the first two characters of "lang" are used.
4008 */
4009 void
4010set_helplang_default(lang)
4011 char_u *lang;
4012{
4013 int idx;
4014
4015 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4016 return;
4017 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004018 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004019 {
4020 if (options[idx].flags & P_ALLOCED)
4021 free_string_option(p_hlg);
4022 p_hlg = vim_strsave(lang);
4023 if (p_hlg == NULL)
4024 p_hlg = empty_option;
4025 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004026 {
4027 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4028 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4029 {
4030 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4031 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4032 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004033 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004034 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004035 options[idx].flags |= P_ALLOCED;
4036 }
4037}
4038#endif
4039
4040#ifdef FEAT_GUI
4041static char_u *gui_bg_default __ARGS((void));
4042
4043 static char_u *
4044gui_bg_default()
4045{
4046 if (gui_get_lightness(gui.back_pixel) < 127)
4047 return (char_u *)"dark";
4048 return (char_u *)"light";
4049}
4050
4051/*
4052 * Option initializations that can only be done after opening the GUI window.
4053 */
4054 void
4055init_gui_options()
4056{
4057 /* Set the 'background' option according to the lightness of the
4058 * background color, unless the user has set it already. */
4059 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4060 {
4061 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4062 highlight_changed();
4063 }
4064}
4065#endif
4066
4067#ifdef FEAT_TITLE
4068/*
4069 * 'title' and 'icon' only default to true if they have not been set or reset
4070 * in .vimrc and we can read the old value.
4071 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4072 * they can be reset. This reduces startup time when using X on a remote
4073 * machine.
4074 */
4075 void
4076set_title_defaults()
4077{
4078 int idx1;
4079 long val;
4080
4081 /*
4082 * If GUI is (going to be) used, we can always set the window title and
4083 * icon name. Saves a bit of time, because the X11 display server does
4084 * not need to be contacted.
4085 */
4086 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004087 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004088 {
4089#ifdef FEAT_GUI
4090 if (gui.starting || gui.in_use)
4091 val = TRUE;
4092 else
4093#endif
4094 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004095 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004096 p_title = val;
4097 }
4098 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004099 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004100 {
4101#ifdef FEAT_GUI
4102 if (gui.starting || gui.in_use)
4103 val = TRUE;
4104 else
4105#endif
4106 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004107 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004108 p_icon = val;
4109 }
4110}
4111#endif
4112
4113/*
4114 * Parse 'arg' for option settings.
4115 *
4116 * 'arg' may be IObuff, but only when no errors can be present and option
4117 * does not need to be expanded with option_expand().
4118 * "opt_flags":
4119 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004120 * OPT_GLOBAL for ":setglobal"
4121 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004122 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004123 * OPT_WINONLY to only set window-local options
4124 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004125 *
4126 * returns FAIL if an error is detected, OK otherwise
4127 */
4128 int
4129do_set(arg, opt_flags)
4130 char_u *arg; /* option string (may be written to!) */
4131 int opt_flags;
4132{
4133 int opt_idx;
4134 char_u *errmsg;
4135 char_u errbuf[80];
4136 char_u *startarg;
4137 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4138 int nextchar; /* next non-white char after option name */
4139 int afterchar; /* character just after option name */
4140 int len;
4141 int i;
4142 long value;
4143 int key;
4144 long_u flags; /* flags for current option */
4145 char_u *varp = NULL; /* pointer to variable for current option */
4146 int did_show = FALSE; /* already showed one value */
4147 int adding; /* "opt+=arg" */
4148 int prepending; /* "opt^=arg" */
4149 int removing; /* "opt-=arg" */
4150 int cp_val = 0;
4151 char_u key_name[2];
4152
4153 if (*arg == NUL)
4154 {
4155 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004156 did_show = TRUE;
4157 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004158 }
4159
4160 while (*arg != NUL) /* loop to process all options */
4161 {
4162 errmsg = NULL;
4163 startarg = arg; /* remember for error message */
4164
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004165 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4166 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004167 {
4168 /*
4169 * ":set all" show all options.
4170 * ":set all&" set all options to their default value.
4171 */
4172 arg += 3;
4173 if (*arg == '&')
4174 {
4175 ++arg;
4176 /* Only for :set command set global value of local options. */
4177 set_options_default(OPT_FREE | opt_flags);
4178 }
4179 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004180 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004181 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004182 did_show = TRUE;
4183 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004184 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004185 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004186 {
4187 showoptions(2, opt_flags);
4188 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004189 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004190 arg += 7;
4191 }
4192 else
4193 {
4194 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004195 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004196 {
4197 prefix = 0;
4198 arg += 2;
4199 }
4200 else if (STRNCMP(arg, "inv", 3) == 0)
4201 {
4202 prefix = 2;
4203 arg += 3;
4204 }
4205
4206 /* find end of name */
4207 key = 0;
4208 if (*arg == '<')
4209 {
4210 nextchar = 0;
4211 opt_idx = -1;
4212 /* look out for <t_>;> */
4213 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4214 len = 5;
4215 else
4216 {
4217 len = 1;
4218 while (arg[len] != NUL && arg[len] != '>')
4219 ++len;
4220 }
4221 if (arg[len] != '>')
4222 {
4223 errmsg = e_invarg;
4224 goto skip;
4225 }
4226 arg[len] = NUL; /* put NUL after name */
4227 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4228 opt_idx = findoption(arg + 1);
4229 arg[len++] = '>'; /* restore '>' */
4230 if (opt_idx == -1)
4231 key = find_key_option(arg + 1);
4232 }
4233 else
4234 {
4235 len = 0;
4236 /*
4237 * The two characters after "t_" may not be alphanumeric.
4238 */
4239 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4240 len = 4;
4241 else
4242 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4243 ++len;
4244 nextchar = arg[len];
4245 arg[len] = NUL; /* put NUL after name */
4246 opt_idx = findoption(arg);
4247 arg[len] = nextchar; /* restore nextchar */
4248 if (opt_idx == -1)
4249 key = find_key_option(arg);
4250 }
4251
4252 /* remember character after option name */
4253 afterchar = arg[len];
4254
4255 /* skip white space, allow ":set ai ?" */
4256 while (vim_iswhite(arg[len]))
4257 ++len;
4258
4259 adding = FALSE;
4260 prepending = FALSE;
4261 removing = FALSE;
4262 if (arg[len] != NUL && arg[len + 1] == '=')
4263 {
4264 if (arg[len] == '+')
4265 {
4266 adding = TRUE; /* "+=" */
4267 ++len;
4268 }
4269 else if (arg[len] == '^')
4270 {
4271 prepending = TRUE; /* "^=" */
4272 ++len;
4273 }
4274 else if (arg[len] == '-')
4275 {
4276 removing = TRUE; /* "-=" */
4277 ++len;
4278 }
4279 }
4280 nextchar = arg[len];
4281
4282 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4283 {
4284 errmsg = (char_u *)N_("E518: Unknown option");
4285 goto skip;
4286 }
4287
4288 if (opt_idx >= 0)
4289 {
4290 if (options[opt_idx].var == NULL) /* hidden option: skip */
4291 {
4292 /* Only give an error message when requesting the value of
4293 * a hidden option, ignore setting it. */
4294 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4295 && (!(options[opt_idx].flags & P_BOOL)
4296 || nextchar == '?'))
4297 errmsg = (char_u *)N_("E519: Option not supported");
4298 goto skip;
4299 }
4300
4301 flags = options[opt_idx].flags;
4302 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4303 }
4304 else
4305 {
4306 flags = P_STRING;
4307 if (key < 0)
4308 {
4309 key_name[0] = KEY2TERMCAP0(key);
4310 key_name[1] = KEY2TERMCAP1(key);
4311 }
4312 else
4313 {
4314 key_name[0] = KS_KEY;
4315 key_name[1] = (key & 0xff);
4316 }
4317 }
4318
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004319 /* Skip all options that are not window-local (used when showing
4320 * an already loaded buffer in a window). */
4321 if ((opt_flags & OPT_WINONLY)
4322 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4323 goto skip;
4324
Bram Moolenaara3227e22006-03-08 21:32:40 +00004325 /* Skip all options that are window-local (used for :vimgrep). */
4326 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4327 && options[opt_idx].var == VAR_WIN)
4328 goto skip;
4329
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004330 /* Disallow changing some options from modelines. */
4331 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004332 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004333 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004334 {
4335 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4336 goto skip;
4337 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004338#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004339 /* In diff mode some options are overruled. This avoids that
4340 * 'foldmethod' becomes "marker" instead of "diff" and that
4341 * "wrap" gets set. */
4342 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004343 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004344 && (options[opt_idx].indir == PV_FDM
4345 || options[opt_idx].indir == PV_WRAP))
4346 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004347#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004348 }
4349
4350#ifdef HAVE_SANDBOX
4351 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004352 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004353 {
4354 errmsg = (char_u *)_(e_sandbox);
4355 goto skip;
4356 }
4357#endif
4358
4359 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4360 {
4361 arg += len;
4362 cp_val = p_cp;
4363 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4364 {
4365 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4366 {
4367 cp_val = FALSE;
4368 arg += 3;
4369 }
4370 else /* "opt&vi": set to Vi default */
4371 {
4372 cp_val = TRUE;
4373 arg += 2;
4374 }
4375 }
4376 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
4377 && arg[1] != NUL && !vim_iswhite(arg[1]))
4378 {
4379 errmsg = e_trailing;
4380 goto skip;
4381 }
4382 }
4383
4384 /*
4385 * allow '=' and ':' as MSDOS command.com allows only one
4386 * '=' character per "set" command line. grrr. (jw)
4387 */
4388 if (nextchar == '?'
4389 || (prefix == 1
4390 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4391 && !(flags & P_BOOL)))
4392 {
4393 /*
4394 * print value
4395 */
4396 if (did_show)
4397 msg_putchar('\n'); /* cursor below last one */
4398 else
4399 {
4400 gotocmdline(TRUE); /* cursor at status line */
4401 did_show = TRUE; /* remember that we did a line */
4402 }
4403 if (opt_idx >= 0)
4404 {
4405 showoneopt(&options[opt_idx], opt_flags);
4406#ifdef FEAT_EVAL
4407 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004408 {
4409 /* Mention where the option was last set. */
4410 if (varp == options[opt_idx].var)
4411 last_set_msg(options[opt_idx].scriptID);
4412 else if ((int)options[opt_idx].indir & PV_WIN)
4413 last_set_msg(curwin->w_p_scriptID[
4414 (int)options[opt_idx].indir & PV_MASK]);
4415 else if ((int)options[opt_idx].indir & PV_BUF)
4416 last_set_msg(curbuf->b_p_scriptID[
4417 (int)options[opt_idx].indir & PV_MASK]);
4418 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004419#endif
4420 }
4421 else
4422 {
4423 char_u *p;
4424
4425 p = find_termcode(key_name);
4426 if (p == NULL)
4427 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004428 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004429 goto skip;
4430 }
4431 else
4432 (void)show_one_termcode(key_name, p, TRUE);
4433 }
4434 if (nextchar != '?'
4435 && nextchar != NUL && !vim_iswhite(afterchar))
4436 errmsg = e_trailing;
4437 }
4438 else
4439 {
4440 if (flags & P_BOOL) /* boolean */
4441 {
4442 if (nextchar == '=' || nextchar == ':')
4443 {
4444 errmsg = e_invarg;
4445 goto skip;
4446 }
4447
4448 /*
4449 * ":set opt!": invert
4450 * ":set opt&": reset to default value
4451 * ":set opt<": reset to global value
4452 */
4453 if (nextchar == '!')
4454 value = *(int *)(varp) ^ 1;
4455 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004456 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004457 ((flags & P_VI_DEF) || cp_val)
4458 ? VI_DEFAULT : VIM_DEFAULT];
4459 else if (nextchar == '<')
4460 {
4461 /* For 'autoread' -1 means to use global value. */
4462 if ((int *)varp == &curbuf->b_p_ar
4463 && opt_flags == OPT_LOCAL)
4464 value = -1;
4465 else
4466 value = *(int *)get_varp_scope(&(options[opt_idx]),
4467 OPT_GLOBAL);
4468 }
4469 else
4470 {
4471 /*
4472 * ":set invopt": invert
4473 * ":set opt" or ":set noopt": set or reset
4474 */
4475 if (nextchar != NUL && !vim_iswhite(afterchar))
4476 {
4477 errmsg = e_trailing;
4478 goto skip;
4479 }
4480 if (prefix == 2) /* inv */
4481 value = *(int *)(varp) ^ 1;
4482 else
4483 value = prefix;
4484 }
4485
4486 errmsg = set_bool_option(opt_idx, varp, (int)value,
4487 opt_flags);
4488 }
4489 else /* numeric or string */
4490 {
4491 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4492 || prefix != 1)
4493 {
4494 errmsg = e_invarg;
4495 goto skip;
4496 }
4497
4498 if (flags & P_NUM) /* numeric */
4499 {
4500 /*
4501 * Different ways to set a number option:
4502 * & set to default value
4503 * < set to global value
4504 * <xx> accept special key codes for 'wildchar'
4505 * c accept any non-digit for 'wildchar'
4506 * [-]0-9 set number
4507 * other error
4508 */
4509 ++arg;
4510 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004511 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004512 ((flags & P_VI_DEF) || cp_val)
4513 ? VI_DEFAULT : VIM_DEFAULT];
4514 else if (nextchar == '<')
4515 value = *(long *)get_varp_scope(&(options[opt_idx]),
4516 OPT_GLOBAL);
4517 else if (((long *)varp == &p_wc
4518 || (long *)varp == &p_wcm)
4519 && (*arg == '<'
4520 || *arg == '^'
4521 || ((!arg[1] || vim_iswhite(arg[1]))
4522 && !VIM_ISDIGIT(*arg))))
4523 {
4524 value = string_to_key(arg);
4525 if (value == 0 && (long *)varp != &p_wcm)
4526 {
4527 errmsg = e_invarg;
4528 goto skip;
4529 }
4530 }
4531 /* allow negative numbers (for 'undolevels') */
4532 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4533 {
4534 i = 0;
4535 if (*arg == '-')
4536 i = 1;
4537#ifdef HAVE_STRTOL
4538 value = strtol((char *)arg, NULL, 0);
4539 if (arg[i] == '0' && TOLOWER_ASC(arg[i + 1]) == 'x')
4540 i += 2;
4541#else
4542 value = atol((char *)arg);
4543#endif
4544 while (VIM_ISDIGIT(arg[i]))
4545 ++i;
4546 if (arg[i] != NUL && !vim_iswhite(arg[i]))
4547 {
4548 errmsg = e_invarg;
4549 goto skip;
4550 }
4551 }
4552 else
4553 {
4554 errmsg = (char_u *)N_("E521: Number required after =");
4555 goto skip;
4556 }
4557
4558 if (adding)
4559 value = *(long *)varp + value;
4560 if (prepending)
4561 value = *(long *)varp * value;
4562 if (removing)
4563 value = *(long *)varp - value;
4564 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004565 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004566 }
4567 else if (opt_idx >= 0) /* string */
4568 {
4569 char_u *save_arg = NULL;
4570 char_u *s = NULL;
4571 char_u *oldval; /* previous value if *varp */
4572 char_u *newval;
4573 char_u *origval;
4574 unsigned newlen;
4575 int comma;
4576 int bs;
4577 int new_value_alloced; /* new string option
4578 was allocated */
4579
4580 /* When using ":set opt=val" for a global option
4581 * with a local value the local value will be
4582 * reset, use the global value here. */
4583 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004584 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004585 varp = options[opt_idx].var;
4586
4587 /* The old value is kept until we are sure that the
4588 * new value is valid. */
4589 oldval = *(char_u **)varp;
4590 if (nextchar == '&') /* set to default val */
4591 {
4592 newval = options[opt_idx].def_val[
4593 ((flags & P_VI_DEF) || cp_val)
4594 ? VI_DEFAULT : VIM_DEFAULT];
4595 if ((char_u **)varp == &p_bg)
4596 {
4597 /* guess the value of 'background' */
4598#ifdef FEAT_GUI
4599 if (gui.in_use)
4600 newval = gui_bg_default();
4601 else
4602#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004603 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004604 }
4605
4606 /* expand environment variables and ~ (since the
4607 * default value was already expanded, only
4608 * required when an environment variable was set
4609 * later */
4610 if (newval == NULL)
4611 newval = empty_option;
4612 else
4613 {
4614 s = option_expand(opt_idx, newval);
4615 if (s == NULL)
4616 s = newval;
4617 newval = vim_strsave(s);
4618 }
4619 new_value_alloced = TRUE;
4620 }
4621 else if (nextchar == '<') /* set to global val */
4622 {
4623 newval = vim_strsave(*(char_u **)get_varp_scope(
4624 &(options[opt_idx]), OPT_GLOBAL));
4625 new_value_alloced = TRUE;
4626 }
4627 else
4628 {
4629 ++arg; /* jump to after the '=' or ':' */
4630
4631 /*
4632 * Set 'keywordprg' to ":help" if an empty
4633 * value was passed to :set by the user.
4634 * Misuse errbuf[] for the resulting string.
4635 */
4636 if (varp == (char_u *)&p_kp
4637 && (*arg == NUL || *arg == ' '))
4638 {
4639 STRCPY(errbuf, ":help");
4640 save_arg = arg;
4641 arg = errbuf;
4642 }
4643 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004644 * Convert 'backspace' number to string, for
4645 * adding, prepending and removing string.
4646 */
4647 else if (varp == (char_u *)&p_bs
4648 && VIM_ISDIGIT(**(char_u **)varp))
4649 {
4650 i = getdigits((char_u **)varp);
4651 switch (i)
4652 {
4653 case 0:
4654 *(char_u **)varp = empty_option;
4655 break;
4656 case 1:
4657 *(char_u **)varp = vim_strsave(
4658 (char_u *)"indent,eol");
4659 break;
4660 case 2:
4661 *(char_u **)varp = vim_strsave(
4662 (char_u *)"indent,eol,start");
4663 break;
4664 }
4665 vim_free(oldval);
4666 oldval = *(char_u **)varp;
4667 }
4668 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004669 * Convert 'whichwrap' number to string, for
4670 * backwards compatibility with Vim 3.0.
4671 * Misuse errbuf[] for the resulting string.
4672 */
4673 else if (varp == (char_u *)&p_ww
4674 && VIM_ISDIGIT(*arg))
4675 {
4676 *errbuf = NUL;
4677 i = getdigits(&arg);
4678 if (i & 1)
4679 STRCAT(errbuf, "b,");
4680 if (i & 2)
4681 STRCAT(errbuf, "s,");
4682 if (i & 4)
4683 STRCAT(errbuf, "h,l,");
4684 if (i & 8)
4685 STRCAT(errbuf, "<,>,");
4686 if (i & 16)
4687 STRCAT(errbuf, "[,],");
4688 if (*errbuf != NUL) /* remove trailing , */
4689 errbuf[STRLEN(errbuf) - 1] = NUL;
4690 save_arg = arg;
4691 arg = errbuf;
4692 }
4693 /*
4694 * Remove '>' before 'dir' and 'bdir', for
4695 * backwards compatibility with version 3.0
4696 */
4697 else if ( *arg == '>'
4698 && (varp == (char_u *)&p_dir
4699 || varp == (char_u *)&p_bdir))
4700 {
4701 ++arg;
4702 }
4703
4704 /* When setting the local value of a global
4705 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004706 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004707 && (opt_flags & OPT_LOCAL))
4708 origval = *(char_u **)get_varp(
4709 &options[opt_idx]);
4710 else
4711 origval = oldval;
4712
4713 /*
4714 * Copy the new string into allocated memory.
4715 * Can't use set_string_option_direct(), because
4716 * we need to remove the backslashes.
4717 */
4718 /* get a bit too much */
4719 newlen = (unsigned)STRLEN(arg) + 1;
4720 if (adding || prepending || removing)
4721 newlen += (unsigned)STRLEN(origval) + 1;
4722 newval = alloc(newlen);
4723 if (newval == NULL) /* out of mem, don't change */
4724 break;
4725 s = newval;
4726
4727 /*
4728 * Copy the string, skip over escaped chars.
4729 * For MS-DOS and WIN32 backslashes before normal
4730 * file name characters are not removed, and keep
4731 * backslash at start, for "\\machine\path", but
4732 * do remove it for "\\\\machine\\path".
4733 * The reverse is found in ExpandOldSetting().
4734 */
4735 while (*arg && !vim_iswhite(*arg))
4736 {
4737 if (*arg == '\\' && arg[1] != NUL
4738#ifdef BACKSLASH_IN_FILENAME
4739 && !((flags & P_EXPAND)
4740 && vim_isfilec(arg[1])
4741 && (arg[1] != '\\'
4742 || (s == newval
4743 && arg[2] != '\\')))
4744#endif
4745 )
4746 ++arg; /* remove backslash */
4747#ifdef FEAT_MBYTE
4748 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00004749 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004750 {
4751 /* copy multibyte char */
4752 mch_memmove(s, arg, (size_t)i);
4753 arg += i;
4754 s += i;
4755 }
4756 else
4757#endif
4758 *s++ = *arg++;
4759 }
4760 *s = NUL;
4761
4762 /*
4763 * Expand environment variables and ~.
4764 * Don't do it when adding without inserting a
4765 * comma.
4766 */
4767 if (!(adding || prepending || removing)
4768 || (flags & P_COMMA))
4769 {
4770 s = option_expand(opt_idx, newval);
4771 if (s != NULL)
4772 {
4773 vim_free(newval);
4774 newlen = (unsigned)STRLEN(s) + 1;
4775 if (adding || prepending || removing)
4776 newlen += (unsigned)STRLEN(origval) + 1;
4777 newval = alloc(newlen);
4778 if (newval == NULL)
4779 break;
4780 STRCPY(newval, s);
4781 }
4782 }
4783
4784 /* locate newval[] in origval[] when removing it
4785 * and when adding to avoid duplicates */
4786 i = 0; /* init for GCC */
4787 if (removing || (flags & P_NODUP))
4788 {
4789 i = (int)STRLEN(newval);
4790 bs = 0;
4791 for (s = origval; *s; ++s)
4792 {
4793 if ((!(flags & P_COMMA)
4794 || s == origval
4795 || (s[-1] == ',' && !(bs & 1)))
4796 && STRNCMP(s, newval, i) == 0
4797 && (!(flags & P_COMMA)
4798 || s[i] == ','
4799 || s[i] == NUL))
4800 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004801 /* Count backslashes. Only a comma with an
4802 * even number of backslashes before it is
Bram Moolenaar071d4272004-06-13 20:20:40 +00004803 * recognized as a separator */
4804 if (s > origval && s[-1] == '\\')
4805 ++bs;
4806 else
4807 bs = 0;
4808 }
4809
4810 /* do not add if already there */
4811 if ((adding || prepending) && *s)
4812 {
4813 prepending = FALSE;
4814 adding = FALSE;
4815 STRCPY(newval, origval);
4816 }
4817 }
4818
4819 /* concatenate the two strings; add a ',' if
4820 * needed */
4821 if (adding || prepending)
4822 {
4823 comma = ((flags & P_COMMA) && *origval != NUL
4824 && *newval != NUL);
4825 if (adding)
4826 {
4827 i = (int)STRLEN(origval);
4828 mch_memmove(newval + i + comma, newval,
4829 STRLEN(newval) + 1);
4830 mch_memmove(newval, origval, (size_t)i);
4831 }
4832 else
4833 {
4834 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004835 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004836 }
4837 if (comma)
4838 newval[i] = ',';
4839 }
4840
4841 /* Remove newval[] from origval[]. (Note: "i" has
4842 * been set above and is used here). */
4843 if (removing)
4844 {
4845 STRCPY(newval, origval);
4846 if (*s)
4847 {
4848 /* may need to remove a comma */
4849 if (flags & P_COMMA)
4850 {
4851 if (s == origval)
4852 {
4853 /* include comma after string */
4854 if (s[i] == ',')
4855 ++i;
4856 }
4857 else
4858 {
4859 /* include comma before string */
4860 --s;
4861 ++i;
4862 }
4863 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004864 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004865 }
4866 }
4867
4868 if (flags & P_FLAGLIST)
4869 {
4870 /* Remove flags that appear twice. */
4871 for (s = newval; *s; ++s)
4872 if ((!(flags & P_COMMA) || *s != ',')
4873 && vim_strchr(s + 1, *s) != NULL)
4874 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004875 STRMOVE(s, s + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004876 --s;
4877 }
4878 }
4879
4880 if (save_arg != NULL) /* number for 'whichwrap' */
4881 arg = save_arg;
4882 new_value_alloced = TRUE;
4883 }
4884
4885 /* Set the new value. */
4886 *(char_u **)(varp) = newval;
4887
4888 /* Handle side effects, and set the global value for
4889 * ":set" on local options. */
4890 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
4891 new_value_alloced, oldval, errbuf, opt_flags);
4892
4893 /* If error detected, print the error message. */
4894 if (errmsg != NULL)
4895 goto skip;
4896 }
4897 else /* key code option */
4898 {
4899 char_u *p;
4900
4901 if (nextchar == '&')
4902 {
4903 if (add_termcap_entry(key_name, TRUE) == FAIL)
4904 errmsg = (char_u *)N_("E522: Not found in termcap");
4905 }
4906 else
4907 {
4908 ++arg; /* jump to after the '=' or ':' */
4909 for (p = arg; *p && !vim_iswhite(*p); ++p)
4910 if (*p == '\\' && p[1] != NUL)
4911 ++p;
4912 nextchar = *p;
4913 *p = NUL;
4914 add_termcode(key_name, arg, FALSE);
4915 *p = nextchar;
4916 }
4917 if (full_screen)
4918 ttest(FALSE);
4919 redraw_all_later(CLEAR);
4920 }
4921 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004922
Bram Moolenaar071d4272004-06-13 20:20:40 +00004923 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004924 did_set_option(opt_idx, opt_flags,
4925 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004926 }
4927
4928skip:
4929 /*
4930 * Advance to next argument.
4931 * - skip until a blank found, taking care of backslashes
4932 * - skip blanks
4933 * - skip one "=val" argument (for hidden options ":set gfn =xx")
4934 */
4935 for (i = 0; i < 2 ; ++i)
4936 {
4937 while (*arg != NUL && !vim_iswhite(*arg))
4938 if (*arg++ == '\\' && *arg != NUL)
4939 ++arg;
4940 arg = skipwhite(arg);
4941 if (*arg != '=')
4942 break;
4943 }
4944 }
4945
4946 if (errmsg != NULL)
4947 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00004948 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00004949 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004950 if (i + (arg - startarg) < IOSIZE)
4951 {
4952 /* append the argument with the error */
4953 STRCAT(IObuff, ": ");
4954 mch_memmove(IObuff + i, startarg, (arg - startarg));
4955 IObuff[i + (arg - startarg)] = NUL;
4956 }
4957 /* make sure all characters are printable */
4958 trans_characters(IObuff, IOSIZE);
4959
4960 ++no_wait_return; /* wait_return done later */
4961 emsg(IObuff); /* show error highlighted */
4962 --no_wait_return;
4963
4964 return FAIL;
4965 }
4966
4967 arg = skipwhite(arg);
4968 }
4969
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004970theend:
4971 if (silent_mode && did_show)
4972 {
4973 /* After displaying option values in silent mode. */
4974 silent_mode = FALSE;
4975 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
4976 msg_putchar('\n');
4977 cursor_on(); /* msg_start() switches it off */
4978 out_flush();
4979 silent_mode = TRUE;
4980 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
4981 }
4982
Bram Moolenaar071d4272004-06-13 20:20:40 +00004983 return OK;
4984}
4985
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004986/*
4987 * Call this when an option has been given a new value through a user command.
4988 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
4989 */
4990 static void
4991did_set_option(opt_idx, opt_flags, new_value)
4992 int opt_idx;
4993 int opt_flags; /* possibly with OPT_MODELINE */
4994 int new_value; /* value was replaced completely */
4995{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00004996 long_u *p;
4997
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004998 options[opt_idx].flags |= P_WAS_SET;
4999
5000 /* When an option is set in the sandbox, from a modeline or in secure mode
5001 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005002 * flag. */
5003 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005004 if (secure
5005#ifdef HAVE_SANDBOX
5006 || sandbox != 0
5007#endif
5008 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005009 *p = *p | P_INSECURE;
5010 else if (new_value)
5011 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005012}
5013
Bram Moolenaar071d4272004-06-13 20:20:40 +00005014 static char_u *
5015illegal_char(errbuf, c)
5016 char_u *errbuf;
5017 int c;
5018{
5019 if (errbuf == NULL)
5020 return (char_u *)"";
5021 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005022 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005023 return errbuf;
5024}
5025
5026/*
5027 * Convert a key name or string into a key value.
5028 * Used for 'wildchar' and 'cedit' options.
5029 */
5030 static int
5031string_to_key(arg)
5032 char_u *arg;
5033{
5034 if (*arg == '<')
5035 return find_key_option(arg + 1);
5036 if (*arg == '^')
5037 return Ctrl_chr(arg[1]);
5038 return *arg;
5039}
5040
5041#ifdef FEAT_CMDWIN
5042/*
5043 * Check value of 'cedit' and set cedit_key.
5044 * Returns NULL if value is OK, error message otherwise.
5045 */
5046 static char_u *
5047check_cedit()
5048{
5049 int n;
5050
5051 if (*p_cedit == NUL)
5052 cedit_key = -1;
5053 else
5054 {
5055 n = string_to_key(p_cedit);
5056 if (vim_isprintc(n))
5057 return e_invarg;
5058 cedit_key = n;
5059 }
5060 return NULL;
5061}
5062#endif
5063
5064#ifdef FEAT_TITLE
5065/*
5066 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5067 * maketitle() to create and display it.
5068 * When switching the title or icon off, call mch_restore_title() to get
5069 * the old value back.
5070 */
5071 static void
5072did_set_title(icon)
5073 int icon; /* Did set icon instead of title */
5074{
5075 if (starting != NO_SCREEN
5076#ifdef FEAT_GUI
5077 && !gui.starting
5078#endif
5079 )
5080 {
5081 maketitle();
5082 if (icon)
5083 {
5084 if (!p_icon)
5085 mch_restore_title(2);
5086 }
5087 else
5088 {
5089 if (!p_title)
5090 mch_restore_title(1);
5091 }
5092 }
5093}
5094#endif
5095
5096/*
5097 * set_options_bin - called when 'bin' changes value.
5098 */
5099 void
5100set_options_bin(oldval, newval, opt_flags)
5101 int oldval;
5102 int newval;
5103 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5104{
5105 /*
5106 * The option values that are changed when 'bin' changes are
5107 * copied when 'bin is set and restored when 'bin' is reset.
5108 */
5109 if (newval)
5110 {
5111 if (!oldval) /* switched on */
5112 {
5113 if (!(opt_flags & OPT_GLOBAL))
5114 {
5115 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5116 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5117 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5118 curbuf->b_p_et_nobin = curbuf->b_p_et;
5119 }
5120 if (!(opt_flags & OPT_LOCAL))
5121 {
5122 p_tw_nobin = p_tw;
5123 p_wm_nobin = p_wm;
5124 p_ml_nobin = p_ml;
5125 p_et_nobin = p_et;
5126 }
5127 }
5128
5129 if (!(opt_flags & OPT_GLOBAL))
5130 {
5131 curbuf->b_p_tw = 0; /* no automatic line wrap */
5132 curbuf->b_p_wm = 0; /* no automatic line wrap */
5133 curbuf->b_p_ml = 0; /* no modelines */
5134 curbuf->b_p_et = 0; /* no expandtab */
5135 }
5136 if (!(opt_flags & OPT_LOCAL))
5137 {
5138 p_tw = 0;
5139 p_wm = 0;
5140 p_ml = FALSE;
5141 p_et = FALSE;
5142 p_bin = TRUE; /* needed when called for the "-b" argument */
5143 }
5144 }
5145 else if (oldval) /* switched off */
5146 {
5147 if (!(opt_flags & OPT_GLOBAL))
5148 {
5149 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5150 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5151 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5152 curbuf->b_p_et = curbuf->b_p_et_nobin;
5153 }
5154 if (!(opt_flags & OPT_LOCAL))
5155 {
5156 p_tw = p_tw_nobin;
5157 p_wm = p_wm_nobin;
5158 p_ml = p_ml_nobin;
5159 p_et = p_et_nobin;
5160 }
5161 }
5162}
5163
5164#ifdef FEAT_VIMINFO
5165/*
5166 * Find the parameter represented by the given character (eg ', :, ", or /),
5167 * and return its associated value in the 'viminfo' string.
5168 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005169 * If the parameter is not specified in the string or there is no following
5170 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005171 */
5172 int
5173get_viminfo_parameter(type)
5174 int type;
5175{
5176 char_u *p;
5177
5178 p = find_viminfo_parameter(type);
5179 if (p != NULL && VIM_ISDIGIT(*p))
5180 return atoi((char *)p);
5181 return -1;
5182}
5183
5184/*
5185 * Find the parameter represented by the given character (eg ''', ':', '"', or
5186 * '/') in the 'viminfo' option and return a pointer to the string after it.
5187 * Return NULL if the parameter is not specified in the string.
5188 */
5189 char_u *
5190find_viminfo_parameter(type)
5191 int type;
5192{
5193 char_u *p;
5194
5195 for (p = p_viminfo; *p; ++p)
5196 {
5197 if (*p == type)
5198 return p + 1;
5199 if (*p == 'n') /* 'n' is always the last one */
5200 break;
5201 p = vim_strchr(p, ','); /* skip until next ',' */
5202 if (p == NULL) /* hit the end without finding parameter */
5203 break;
5204 }
5205 return NULL;
5206}
5207#endif
5208
5209/*
5210 * Expand environment variables for some string options.
5211 * These string options cannot be indirect!
5212 * If "val" is NULL expand the current value of the option.
5213 * Return pointer to NameBuff, or NULL when not expanded.
5214 */
5215 static char_u *
5216option_expand(opt_idx, val)
5217 int opt_idx;
5218 char_u *val;
5219{
5220 /* if option doesn't need expansion nothing to do */
5221 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5222 return NULL;
5223
5224 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5225 * expand_env() would truncate the string. */
5226 if (val != NULL && STRLEN(val) > MAXPATHL)
5227 return NULL;
5228
5229 if (val == NULL)
5230 val = *(char_u **)options[opt_idx].var;
5231
5232 /*
5233 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5234 * Escape spaces when expanding 'tags', they are used to separate file
5235 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005236 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005237 */
5238 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005239 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005240#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005241 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5242#endif
5243 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005244 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5245 return NULL;
5246
5247 return NameBuff;
5248}
5249
5250/*
5251 * After setting various option values: recompute variables that depend on
5252 * option values.
5253 */
5254 static void
5255didset_options()
5256{
5257 /* initialize the table for 'iskeyword' et.al. */
5258 (void)init_chartab();
5259
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005260#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005261 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005262#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005263 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
5264#ifdef FEAT_SESSION
5265 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5266 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5267#endif
5268#ifdef FEAT_FOLDING
5269 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5270#endif
5271 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
5272#ifdef FEAT_VIRTUALEDIT
5273 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5274#endif
5275#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5276 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5277#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005278#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005279 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005280 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005281 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005282#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005283#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5284 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5285#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005286#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005287 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5288#endif
5289#ifdef FEAT_CMDWIN
5290 /* set cedit_key */
5291 (void)check_cedit();
5292#endif
5293}
5294
5295/*
5296 * Check for string options that are NULL (normally only termcap options).
5297 */
5298 void
5299check_options()
5300{
5301 int opt_idx;
5302
5303 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5304 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5305 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5306}
5307
5308/*
5309 * Check string options in a buffer for NULL value.
5310 */
5311 void
5312check_buf_options(buf)
5313 buf_T *buf;
5314{
5315#if defined(FEAT_QUICKFIX)
5316 check_string_option(&buf->b_p_bh);
5317 check_string_option(&buf->b_p_bt);
5318#endif
5319#ifdef FEAT_MBYTE
5320 check_string_option(&buf->b_p_fenc);
5321#endif
5322 check_string_option(&buf->b_p_ff);
5323#ifdef FEAT_FIND_ID
5324 check_string_option(&buf->b_p_def);
5325 check_string_option(&buf->b_p_inc);
5326# ifdef FEAT_EVAL
5327 check_string_option(&buf->b_p_inex);
5328# endif
5329#endif
5330#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5331 check_string_option(&buf->b_p_inde);
5332 check_string_option(&buf->b_p_indk);
5333#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005334#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5335 check_string_option(&buf->b_p_bexpr);
5336#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005337#if defined(FEAT_CRYPT)
5338 check_string_option(&buf->b_p_cm);
5339#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005340#if defined(FEAT_EVAL)
5341 check_string_option(&buf->b_p_fex);
5342#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005343#ifdef FEAT_CRYPT
5344 check_string_option(&buf->b_p_key);
5345#endif
5346 check_string_option(&buf->b_p_kp);
5347 check_string_option(&buf->b_p_mps);
5348 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005349 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005350 check_string_option(&buf->b_p_isk);
5351#ifdef FEAT_COMMENTS
5352 check_string_option(&buf->b_p_com);
5353#endif
5354#ifdef FEAT_FOLDING
5355 check_string_option(&buf->b_p_cms);
5356#endif
5357 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005358#ifdef FEAT_TEXTOBJ
5359 check_string_option(&buf->b_p_qe);
5360#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005361#ifdef FEAT_SYN_HL
5362 check_string_option(&buf->b_p_syn);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005363#endif
5364#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005365 check_string_option(&buf->b_s.b_p_spc);
5366 check_string_option(&buf->b_s.b_p_spf);
5367 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005368#endif
5369#ifdef FEAT_SEARCHPATH
5370 check_string_option(&buf->b_p_sua);
5371#endif
5372#ifdef FEAT_CINDENT
5373 check_string_option(&buf->b_p_cink);
5374 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005375 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005376#endif
5377#ifdef FEAT_AUTOCMD
5378 check_string_option(&buf->b_p_ft);
5379#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005380#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5381 check_string_option(&buf->b_p_cinw);
5382#endif
5383#ifdef FEAT_INS_EXPAND
5384 check_string_option(&buf->b_p_cpt);
5385#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005386#ifdef FEAT_COMPL_FUNC
5387 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005388 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005389#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005390#ifdef FEAT_KEYMAP
5391 check_string_option(&buf->b_p_keymap);
5392#endif
5393#ifdef FEAT_QUICKFIX
5394 check_string_option(&buf->b_p_gp);
5395 check_string_option(&buf->b_p_mp);
5396 check_string_option(&buf->b_p_efm);
5397#endif
5398 check_string_option(&buf->b_p_ep);
5399 check_string_option(&buf->b_p_path);
5400 check_string_option(&buf->b_p_tags);
5401#ifdef FEAT_INS_EXPAND
5402 check_string_option(&buf->b_p_dict);
5403 check_string_option(&buf->b_p_tsr);
5404#endif
5405}
5406
5407/*
5408 * Free the string allocated for an option.
5409 * Checks for the string being empty_option. This may happen if we're out of
5410 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5411 * check_options().
5412 * Does NOT check for P_ALLOCED flag!
5413 */
5414 void
5415free_string_option(p)
5416 char_u *p;
5417{
5418 if (p != empty_option)
5419 vim_free(p);
5420}
5421
5422 void
5423clear_string_option(pp)
5424 char_u **pp;
5425{
5426 if (*pp != empty_option)
5427 vim_free(*pp);
5428 *pp = empty_option;
5429}
5430
5431 static void
5432check_string_option(pp)
5433 char_u **pp;
5434{
5435 if (*pp == NULL)
5436 *pp = empty_option;
5437}
5438
5439/*
5440 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5441 */
5442 void
5443set_term_option_alloced(p)
5444 char_u **p;
5445{
5446 int opt_idx;
5447
5448 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5449 if (options[opt_idx].var == (char_u *)p)
5450 {
5451 options[opt_idx].flags |= P_ALLOCED;
5452 return;
5453 }
5454 return; /* cannot happen: didn't find it! */
5455}
5456
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005457#if defined(FEAT_EVAL) || defined(PROTO)
5458/*
5459 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5460 * Return FALSE when it wasn't.
5461 * Return -1 for an unknown option.
5462 */
5463 int
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005464was_set_insecurely(opt, opt_flags)
5465 char_u *opt;
5466 int opt_flags;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005467{
5468 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005469 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005470
5471 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005472 {
5473 flagp = insecure_flag(idx, opt_flags);
5474 return (*flagp & P_INSECURE) != 0;
5475 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005476 EMSG2(_(e_intern2), "was_set_insecurely()");
5477 return -1;
5478}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005479
5480/*
5481 * Get a pointer to the flags used for the P_INSECURE flag of option
5482 * "opt_idx". For some local options a local flags field is used.
5483 */
5484 static long_u *
5485insecure_flag(opt_idx, opt_flags)
5486 int opt_idx;
5487 int opt_flags;
5488{
5489 if (opt_flags & OPT_LOCAL)
5490 switch ((int)options[opt_idx].indir)
5491 {
5492#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005493 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005494#endif
5495#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005496# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005497 case PV_FDE: return &curwin->w_p_fde_flags;
5498 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005499# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005500# ifdef FEAT_BEVAL
5501 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5502# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005503# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005504 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005505# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005506 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005507# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005508 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005509# endif
5510#endif
5511 }
5512
5513 /* Nothing special, return global flags field. */
5514 return &options[opt_idx].flags;
5515}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005516#endif
5517
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005518#ifdef FEAT_TITLE
5519static void redraw_titles __ARGS((void));
5520
5521/*
5522 * Redraw the window title and/or tab page text later.
5523 */
5524static void redraw_titles()
5525{
5526 need_maketitle = TRUE;
5527# ifdef FEAT_WINDOWS
5528 redraw_tabline = TRUE;
5529# endif
5530}
5531#endif
5532
Bram Moolenaar071d4272004-06-13 20:20:40 +00005533/*
5534 * Set a string option to a new value (without checking the effect).
5535 * The string is copied into allocated memory.
5536 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005537 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005538 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005539 */
5540 void
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005541set_string_option_direct(name, opt_idx, val, opt_flags, set_sid)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005542 char_u *name;
5543 int opt_idx;
5544 char_u *val;
5545 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar78a15312009-05-15 19:33:18 +00005546 int set_sid UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005547{
5548 char_u *s;
5549 char_u **varp;
5550 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005551 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005552
Bram Moolenaar89d40322006-08-29 15:30:07 +00005553 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005554 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005555 idx = findoption(name);
5556 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005557 {
5558 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar071d4272004-06-13 20:20:40 +00005559 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005560 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005561 }
5562
Bram Moolenaar89d40322006-08-29 15:30:07 +00005563 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005564 return;
5565
5566 s = vim_strsave(val);
5567 if (s != NULL)
5568 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005569 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005570 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005571 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005572 free_string_option(*varp);
5573 *varp = s;
5574
5575 /* For buffer/window local option may also set the global value. */
5576 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005577 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005578
Bram Moolenaar89d40322006-08-29 15:30:07 +00005579 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005580
5581 /* When setting both values of a global option with a local value,
5582 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005583 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005584 {
5585 free_string_option(*varp);
5586 *varp = empty_option;
5587 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005588# ifdef FEAT_EVAL
5589 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005590 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005591 set_sid == 0 ? current_SID : set_sid);
5592# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005593 }
5594}
5595
5596/*
5597 * Set global value for string option when it's a local option.
5598 */
5599 static void
5600set_string_option_global(opt_idx, varp)
5601 int opt_idx; /* option index */
5602 char_u **varp; /* pointer to option variable */
5603{
5604 char_u **p, *s;
5605
5606 /* the global value is always allocated */
5607 if (options[opt_idx].var == VAR_WIN)
5608 p = (char_u **)GLOBAL_WO(varp);
5609 else
5610 p = (char_u **)options[opt_idx].var;
5611 if (options[opt_idx].indir != PV_NONE
5612 && p != varp
5613 && (s = vim_strsave(*varp)) != NULL)
5614 {
5615 free_string_option(*p);
5616 *p = s;
5617 }
5618}
5619
5620/*
5621 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005622 *
5623 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005624 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005625 static char_u *
Bram Moolenaar071d4272004-06-13 20:20:40 +00005626set_string_option(opt_idx, value, opt_flags)
5627 int opt_idx;
5628 char_u *value;
5629 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5630{
5631 char_u *s;
5632 char_u **varp;
5633 char_u *oldval;
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005634 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005635
5636 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005637 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005638
5639 s = vim_strsave(value);
5640 if (s != NULL)
5641 {
5642 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5643 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005644 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005645 ? OPT_GLOBAL : OPT_LOCAL)
5646 : opt_flags);
5647 oldval = *varp;
5648 *varp = s;
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005649 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5650 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005651 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005652 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005653 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005654}
5655
5656/*
5657 * Handle string options that need some action to perform when changed.
5658 * Returns NULL for success, or an error message for an error.
5659 */
5660 static char_u *
5661did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
5662 opt_flags)
5663 int opt_idx; /* index in options[] table */
5664 char_u **varp; /* pointer to the option variable */
5665 int new_value_alloced; /* new value was allocated */
5666 char_u *oldval; /* previous value of the option */
5667 char_u *errbuf; /* buffer for errors, or NULL */
5668 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5669{
5670 char_u *errmsg = NULL;
5671 char_u *s, *p;
5672 int did_chartab = FALSE;
5673 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005674 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00005675#ifdef FEAT_GUI
5676 /* set when changing an option that only requires a redraw in the GUI */
5677 int redraw_gui_only = FALSE;
5678#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005679
5680 /* Get the global option to compare with, otherwise we would have to check
5681 * two values for all local options. */
5682 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
5683
5684 /* Disallow changing some options from secure mode */
5685 if ((secure
5686#ifdef HAVE_SANDBOX
5687 || sandbox != 0
5688#endif
5689 ) && (options[opt_idx].flags & P_SECURE))
5690 {
5691 errmsg = e_secure;
5692 }
5693
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005694 /* Check for a "normal" file name in some options. Disallow a path
5695 * separator (slash and/or backslash), wildcards and characters that are
5696 * often illegal in a file name. */
5697 else if ((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005698 && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL)
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005699 {
5700 errmsg = e_invarg;
5701 }
5702
Bram Moolenaar071d4272004-06-13 20:20:40 +00005703 /* 'term' */
5704 else if (varp == &T_NAME)
5705 {
5706 if (T_NAME[0] == NUL)
5707 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
5708#ifdef FEAT_GUI
5709 if (gui.in_use)
5710 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
5711 else if (term_is_gui(T_NAME))
5712 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
5713#endif
5714 else if (set_termname(T_NAME) == FAIL)
5715 errmsg = (char_u *)N_("E522: Not found in termcap");
5716 else
5717 /* Screen colors may have changed. */
5718 redraw_later_clear();
5719 }
5720
5721 /* 'backupcopy' */
5722 else if (varp == &p_bkc)
5723 {
5724 if (opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE) != OK)
5725 errmsg = e_invarg;
5726 if (((bkc_flags & BKC_AUTO) != 0)
5727 + ((bkc_flags & BKC_YES) != 0)
5728 + ((bkc_flags & BKC_NO) != 0) != 1)
5729 {
5730 /* Must have exactly one of "auto", "yes" and "no". */
5731 (void)opt_strings_flags(oldval, p_bkc_values, &bkc_flags, TRUE);
5732 errmsg = e_invarg;
5733 }
5734 }
5735
5736 /* 'backupext' and 'patchmode' */
5737 else if (varp == &p_bex || varp == &p_pm)
5738 {
5739 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
5740 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
5741 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
5742 }
5743
5744 /*
5745 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[]
5746 * If the new option is invalid, use old value. 'lisp' option: refill
5747 * chartab[] for '-' char
5748 */
5749 else if ( varp == &p_isi
5750 || varp == &(curbuf->b_p_isk)
5751 || varp == &p_isp
5752 || varp == &p_isf)
5753 {
5754 if (init_chartab() == FAIL)
5755 {
5756 did_chartab = TRUE; /* need to restore it below */
5757 errmsg = e_invarg; /* error in value */
5758 }
5759 }
5760
5761 /* 'helpfile' */
5762 else if (varp == &p_hf)
5763 {
5764 /* May compute new values for $VIM and $VIMRUNTIME */
5765 if (didset_vim)
5766 {
5767 vim_setenv((char_u *)"VIM", (char_u *)"");
5768 didset_vim = FALSE;
5769 }
5770 if (didset_vimruntime)
5771 {
5772 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
5773 didset_vimruntime = FALSE;
5774 }
5775 }
5776
Bram Moolenaar1a384422010-07-14 19:53:30 +02005777#ifdef FEAT_SYN_HL
5778 /* 'colorcolumn' */
5779 else if (varp == &curwin->w_p_cc)
5780 errmsg = check_colorcolumn(curwin);
5781#endif
5782
Bram Moolenaar071d4272004-06-13 20:20:40 +00005783#ifdef FEAT_MULTI_LANG
5784 /* 'helplang' */
5785 else if (varp == &p_hlg)
5786 {
5787 /* Check for "", "ab", "ab,cd", etc. */
5788 for (s = p_hlg; *s != NUL; s += 3)
5789 {
5790 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
5791 {
5792 errmsg = e_invarg;
5793 break;
5794 }
5795 if (s[2] == NUL)
5796 break;
5797 }
5798 }
5799#endif
5800
5801 /* 'highlight' */
5802 else if (varp == &p_hl)
5803 {
5804 if (highlight_changed() == FAIL)
5805 errmsg = e_invarg; /* invalid flags */
5806 }
5807
5808 /* 'nrformats' */
5809 else if (gvarp == &p_nf)
5810 {
5811 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
5812 errmsg = e_invarg;
5813 }
5814
5815#ifdef FEAT_SESSION
5816 /* 'sessionoptions' */
5817 else if (varp == &p_ssop)
5818 {
5819 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
5820 errmsg = e_invarg;
5821 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
5822 {
5823 /* Don't allow both "sesdir" and "curdir". */
5824 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
5825 errmsg = e_invarg;
5826 }
5827 }
5828 /* 'viewoptions' */
5829 else if (varp == &p_vop)
5830 {
5831 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
5832 errmsg = e_invarg;
5833 }
5834#endif
5835
5836 /* 'scrollopt' */
5837#ifdef FEAT_SCROLLBIND
5838 else if (varp == &p_sbo)
5839 {
5840 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
5841 errmsg = e_invarg;
5842 }
5843#endif
5844
5845 /* 'ambiwidth' */
5846#ifdef FEAT_MBYTE
5847 else if (varp == &p_ambw)
5848 {
5849 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
5850 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02005851 else if (set_chars_option(&p_lcs) != NULL)
5852 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
5853# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5854 else if (set_chars_option(&p_fcs) != NULL)
5855 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
5856# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005857 }
5858#endif
5859
5860 /* 'background' */
5861 else if (varp == &p_bg)
5862 {
5863 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
5864 {
5865#ifdef FEAT_EVAL
5866 int dark = (*p_bg == 'd');
5867#endif
5868
5869 init_highlight(FALSE, FALSE);
5870
5871#ifdef FEAT_EVAL
5872 if (dark != (*p_bg == 'd')
5873 && get_var_value((char_u *)"g:colors_name") != NULL)
5874 {
5875 /* The color scheme must have set 'background' back to another
5876 * value, that's not what we want here. Disable the color
5877 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00005878 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005879 free_string_option(p_bg);
5880 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
5881 check_string_option(&p_bg);
5882 init_highlight(FALSE, FALSE);
5883 }
5884#endif
5885 }
5886 else
5887 errmsg = e_invarg;
5888 }
5889
5890 /* 'wildmode' */
5891 else if (varp == &p_wim)
5892 {
5893 if (check_opt_wim() == FAIL)
5894 errmsg = e_invarg;
5895 }
5896
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00005897#ifdef FEAT_CMDL_COMPL
5898 /* 'wildoptions' */
5899 else if (varp == &p_wop)
5900 {
5901 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
5902 errmsg = e_invarg;
5903 }
5904#endif
5905
Bram Moolenaar071d4272004-06-13 20:20:40 +00005906#ifdef FEAT_WAK
5907 /* 'winaltkeys' */
5908 else if (varp == &p_wak)
5909 {
5910 if (*p_wak == NUL
5911 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
5912 errmsg = e_invarg;
5913# ifdef FEAT_MENU
5914# ifdef FEAT_GUI_MOTIF
5915 else if (gui.in_use)
5916 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
5917# else
5918# ifdef FEAT_GUI_GTK
5919 else if (gui.in_use)
5920 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
5921# endif
5922# endif
5923# endif
5924 }
5925#endif
5926
5927#ifdef FEAT_AUTOCMD
5928 /* 'eventignore' */
5929 else if (varp == &p_ei)
5930 {
5931 if (check_ei() == FAIL)
5932 errmsg = e_invarg;
5933 }
5934#endif
5935
5936#ifdef FEAT_MBYTE
5937 /* 'encoding' and 'fileencoding' */
5938 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc)
5939 {
5940 if (gvarp == &p_fenc)
5941 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00005942 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005943 errmsg = e_modifiable;
5944 else if (vim_strchr(*varp, ',') != NULL)
5945 /* No comma allowed in 'fileencoding'; catches confusing it
5946 * with 'fileencodings'. */
5947 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005948 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005949 {
5950# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005951 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005952 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00005953# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005954 /* Add 'fileencoding' to the swap file. */
5955 ml_setflags(curbuf);
5956 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005957 }
5958 if (errmsg == NULL)
5959 {
5960 /* canonize the value, so that STRCMP() can be used on it */
5961 p = enc_canonize(*varp);
5962 if (p != NULL)
5963 {
5964 vim_free(*varp);
5965 *varp = p;
5966 }
5967 if (varp == &p_enc)
5968 {
5969 errmsg = mb_init();
5970# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005971 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00005972# endif
5973 }
5974 }
5975
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005976# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005977 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
5978 {
5979 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
5980 if (STRCMP(p_tenc, "utf-8") != 0)
5981 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
5982 }
5983# endif
5984
5985 if (errmsg == NULL)
5986 {
5987# ifdef FEAT_KEYMAP
5988 /* When 'keymap' is used and 'encoding' changes, reload the keymap
5989 * (with another encoding). */
5990 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
5991 (void)keymap_init();
5992# endif
5993
5994 /* When 'termencoding' is not empty and 'encoding' changes or when
5995 * 'termencoding' changes, need to setup for keyboard input and
5996 * display output conversion. */
5997 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
5998 {
5999 convert_setup(&input_conv, p_tenc, p_enc);
6000 convert_setup(&output_conv, p_enc, p_tenc);
6001 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006002
6003# if defined(WIN3264) && defined(FEAT_MBYTE)
6004 /* $HOME may have characters in active code page. */
6005 if (varp == &p_enc)
6006 init_homedir();
6007# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006008 }
6009 }
6010#endif
6011
6012#if defined(FEAT_POSTSCRIPT)
6013 else if (varp == &p_penc)
6014 {
6015 /* Canonize printencoding if VIM standard one */
6016 p = enc_canonize(p_penc);
6017 if (p != NULL)
6018 {
6019 vim_free(p_penc);
6020 p_penc = p;
6021 }
6022 else
6023 {
6024 /* Ensure lower case and '-' for '_' */
6025 for (s = p_penc; *s != NUL; s++)
6026 {
6027 if (*s == '_')
6028 *s = '-';
6029 else
6030 *s = TOLOWER_ASC(*s);
6031 }
6032 }
6033 }
6034#endif
6035
Bram Moolenaar9372a112005-12-06 19:59:18 +00006036#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006037 else if (varp == &p_imak)
6038 {
6039 if (gui.in_use && !im_xim_isvalid_imactivate())
6040 errmsg = e_invarg;
6041 }
6042#endif
6043
6044#ifdef FEAT_KEYMAP
6045 else if (varp == &curbuf->b_p_keymap)
6046 {
6047 /* load or unload key mapping tables */
6048 errmsg = keymap_init();
6049
Bram Moolenaarfab06232009-03-04 03:13:35 +00006050 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006051 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006052 if (*curbuf->b_p_keymap != NUL)
6053 {
6054 /* Installed a new keymap, switch on using it. */
6055 curbuf->b_p_iminsert = B_IMODE_LMAP;
6056 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6057 curbuf->b_p_imsearch = B_IMODE_LMAP;
6058 }
6059 else
6060 {
6061 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6062 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6063 curbuf->b_p_iminsert = B_IMODE_NONE;
6064 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6065 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6066 }
6067 if ((opt_flags & OPT_LOCAL) == 0)
6068 {
6069 set_iminsert_global();
6070 set_imsearch_global();
6071 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006072# ifdef FEAT_WINDOWS
6073 status_redraw_curbuf();
6074# endif
6075 }
6076 }
6077#endif
6078
6079 /* 'fileformat' */
6080 else if (gvarp == &p_ff)
6081 {
6082 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6083 errmsg = e_modifiable;
6084 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6085 errmsg = e_invarg;
6086 else
6087 {
6088 /* may also change 'textmode' */
6089 if (get_fileformat(curbuf) == EOL_DOS)
6090 curbuf->b_p_tx = TRUE;
6091 else
6092 curbuf->b_p_tx = FALSE;
6093#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006094 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006095#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006096 /* update flag in swap file */
6097 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006098 /* Redraw needed when switching to/from "mac": a CR in the text
6099 * will be displayed differently. */
6100 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6101 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006102 }
6103 }
6104
6105 /* 'fileformats' */
6106 else if (varp == &p_ffs)
6107 {
6108 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6109 errmsg = e_invarg;
6110 else
6111 {
6112 /* also change 'textauto' */
6113 if (*p_ffs == NUL)
6114 p_ta = FALSE;
6115 else
6116 p_ta = TRUE;
6117 }
6118 }
6119
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006120#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006121 /* 'cryptkey' */
6122 else if (gvarp == &p_key)
6123 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006124# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006125 /* Make sure the ":set" command doesn't show the new value in the
6126 * history. */
6127 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006128# endif
6129 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6130 /* Need to update the swapfile. */
Bram Moolenaar49771f42010-07-20 17:32:38 +02006131 ml_set_crypt_key(curbuf, oldval, get_crypt_method(curbuf));
6132 }
6133
6134 else if (gvarp == &p_cm)
6135 {
6136 if (opt_flags & OPT_LOCAL)
6137 p = curbuf->b_p_cm;
6138 else
6139 p = p_cm;
6140 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6141 errmsg = e_invarg;
6142 else if (get_crypt_method(curbuf) > 0 && blowfish_self_test() == FAIL)
6143 errmsg = e_invarg;
6144 else
6145 {
6146 /* When setting the global value to empty, make it "zip". */
6147 if (*p_cm == NUL)
6148 {
6149 if (new_value_alloced)
6150 free_string_option(p_cm);
6151 p_cm = vim_strsave((char_u *)"zip");
6152 new_value_alloced = TRUE;
6153 }
6154
6155 /* Need to update the swapfile when the effective method changed.
6156 * Set "s" to the effective old value, "p" to the effective new
6157 * method and compare. */
6158 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6159 s = p_cm; /* was previously using the global value */
6160 else
6161 s = oldval;
6162 if (*curbuf->b_p_cm == NUL)
6163 p = p_cm; /* is now using the global value */
6164 else
6165 p = curbuf->b_p_cm;
6166 if (STRCMP(s, p) != 0)
6167 ml_set_crypt_key(curbuf, curbuf->b_p_key,
6168 crypt_method_from_string(s));
6169
6170 /* If the global value changes need to update the swapfile for all
6171 * buffers using that value. */
6172 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6173 {
6174 buf_T *buf;
6175
6176 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
6177 if (buf != curbuf && *buf->b_p_cm == NUL)
6178 ml_set_crypt_key(buf, buf->b_p_key,
6179 crypt_method_from_string(oldval));
6180 }
6181 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006182 }
6183#endif
6184
6185 /* 'matchpairs' */
6186 else if (gvarp == &p_mps)
6187 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006188#ifdef FEAT_MBYTE
6189 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006190 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006191 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006192 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006193 int x2 = -1;
6194 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006195
6196 if (*p != NUL)
6197 p += mb_ptr2len(p);
6198 if (*p != NUL)
6199 x2 = *p++;
6200 if (*p != NUL)
6201 {
6202 x3 = mb_ptr2char(p);
6203 p += mb_ptr2len(p);
6204 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006205 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006206 {
6207 errmsg = e_invarg;
6208 break;
6209 }
6210 if (*p == NUL)
6211 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006212 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006213 }
6214 else
6215#endif
6216 {
6217 /* Check for "x:y,x:y" */
6218 for (p = *varp; *p != NUL; p += 4)
6219 {
6220 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6221 {
6222 errmsg = e_invarg;
6223 break;
6224 }
6225 if (p[3] == NUL)
6226 break;
6227 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006228 }
6229 }
6230
6231#ifdef FEAT_COMMENTS
6232 /* 'comments' */
6233 else if (gvarp == &p_com)
6234 {
6235 for (s = *varp; *s; )
6236 {
6237 while (*s && *s != ':')
6238 {
6239 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6240 && !VIM_ISDIGIT(*s) && *s != '-')
6241 {
6242 errmsg = illegal_char(errbuf, *s);
6243 break;
6244 }
6245 ++s;
6246 }
6247 if (*s++ == NUL)
6248 errmsg = (char_u *)N_("E524: Missing colon");
6249 else if (*s == ',' || *s == NUL)
6250 errmsg = (char_u *)N_("E525: Zero length string");
6251 if (errmsg != NULL)
6252 break;
6253 while (*s && *s != ',')
6254 {
6255 if (*s == '\\' && s[1] != NUL)
6256 ++s;
6257 ++s;
6258 }
6259 s = skip_to_option_part(s);
6260 }
6261 }
6262#endif
6263
6264 /* 'listchars' */
6265 else if (varp == &p_lcs)
6266 {
6267 errmsg = set_chars_option(varp);
6268 }
6269
6270#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6271 /* 'fillchars' */
6272 else if (varp == &p_fcs)
6273 {
6274 errmsg = set_chars_option(varp);
6275 }
6276#endif
6277
6278#ifdef FEAT_CMDWIN
6279 /* 'cedit' */
6280 else if (varp == &p_cedit)
6281 {
6282 errmsg = check_cedit();
6283 }
6284#endif
6285
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006286 /* 'verbosefile' */
6287 else if (varp == &p_vfile)
6288 {
6289 verbose_stop();
6290 if (*p_vfile != NUL && verbose_open() == FAIL)
6291 errmsg = e_invarg;
6292 }
6293
Bram Moolenaar071d4272004-06-13 20:20:40 +00006294#ifdef FEAT_VIMINFO
6295 /* 'viminfo' */
6296 else if (varp == &p_viminfo)
6297 {
6298 for (s = p_viminfo; *s;)
6299 {
6300 /* Check it's a valid character */
6301 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6302 {
6303 errmsg = illegal_char(errbuf, *s);
6304 break;
6305 }
6306 if (*s == 'n') /* name is always last one */
6307 {
6308 break;
6309 }
6310 else if (*s == 'r') /* skip until next ',' */
6311 {
6312 while (*++s && *s != ',')
6313 ;
6314 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006315 else if (*s == '%')
6316 {
6317 /* optional number */
6318 while (vim_isdigit(*++s))
6319 ;
6320 }
6321 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006322 ++s; /* no extra chars */
6323 else /* must have a number */
6324 {
6325 while (vim_isdigit(*++s))
6326 ;
6327
6328 if (!VIM_ISDIGIT(*(s - 1)))
6329 {
6330 if (errbuf != NULL)
6331 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006332 sprintf((char *)errbuf,
6333 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006334 transchar_byte(*(s - 1)));
6335 errmsg = errbuf;
6336 }
6337 else
6338 errmsg = (char_u *)"";
6339 break;
6340 }
6341 }
6342 if (*s == ',')
6343 ++s;
6344 else if (*s)
6345 {
6346 if (errbuf != NULL)
6347 errmsg = (char_u *)N_("E527: Missing comma");
6348 else
6349 errmsg = (char_u *)"";
6350 break;
6351 }
6352 }
6353 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6354 errmsg = (char_u *)N_("E528: Must specify a ' value");
6355 }
6356#endif /* FEAT_VIMINFO */
6357
6358 /* terminal options */
6359 else if (istermoption(&options[opt_idx]) && full_screen)
6360 {
6361 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6362 if (varp == &T_CCO)
6363 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006364 int colors = atoi((char *)T_CCO);
6365
6366 /* Only reinitialize colors if t_Co value has really changed to
6367 * avoid expensive reload of colorscheme if t_Co is set to the
6368 * same value multiple times. */
6369 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006370 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006371 t_colors = colors;
6372 if (t_colors <= 1)
6373 {
6374 if (new_value_alloced)
6375 vim_free(T_CCO);
6376 T_CCO = empty_option;
6377 }
6378 /* We now have a different color setup, initialize it again. */
6379 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006380 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006381 }
6382 ttest(FALSE);
6383 if (varp == &T_ME)
6384 {
6385 out_str(T_ME);
6386 redraw_later(CLEAR);
6387#if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32))
6388 /* Since t_me has been set, this probably means that the user
6389 * wants to use this as default colors. Need to reset default
6390 * background/foreground colors. */
6391 mch_set_normal_colors();
6392#endif
6393 }
6394 }
6395
6396#ifdef FEAT_LINEBREAK
6397 /* 'showbreak' */
6398 else if (varp == &p_sbr)
6399 {
6400 for (s = p_sbr; *s; )
6401 {
6402 if (ptr2cells(s) != 1)
6403 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006404 mb_ptr_adv(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006405 }
6406 }
6407#endif
6408
6409#ifdef FEAT_GUI
6410 /* 'guifont' */
6411 else if (varp == &p_guifont)
6412 {
6413 if (gui.in_use)
6414 {
6415 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006416# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006417 /*
6418 * Put up a font dialog and let the user select a new value.
6419 * If this is cancelled go back to the old value but don't
6420 * give an error message.
6421 */
6422 if (STRCMP(p, "*") == 0)
6423 {
6424 p = gui_mch_font_dialog(oldval);
6425
6426 if (new_value_alloced)
6427 free_string_option(p_guifont);
6428
6429 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6430 new_value_alloced = TRUE;
6431 }
6432# endif
6433 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6434 {
6435# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6436 if (STRCMP(p_guifont, "*") == 0)
6437 {
6438 /* Dialog was cancelled: Keep the old value without giving
6439 * an error message. */
6440 if (new_value_alloced)
6441 free_string_option(p_guifont);
6442 p_guifont = vim_strsave(oldval);
6443 new_value_alloced = TRUE;
6444 }
6445 else
6446# endif
6447 errmsg = (char_u *)N_("E596: Invalid font(s)");
6448 }
6449 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006450 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006451 }
6452# ifdef FEAT_XFONTSET
6453 else if (varp == &p_guifontset)
6454 {
6455 if (STRCMP(p_guifontset, "*") == 0)
6456 errmsg = (char_u *)N_("E597: can't select fontset");
6457 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6458 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006459 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006460 }
6461# endif
6462# ifdef FEAT_MBYTE
6463 else if (varp == &p_guifontwide)
6464 {
6465 if (STRCMP(p_guifontwide, "*") == 0)
6466 errmsg = (char_u *)N_("E533: can't select wide font");
6467 else if (gui_get_wide_font() == FAIL)
6468 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006469 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006470 }
6471# endif
6472#endif
6473
6474#ifdef CURSOR_SHAPE
6475 /* 'guicursor' */
6476 else if (varp == &p_guicursor)
6477 errmsg = parse_shape_opt(SHAPE_CURSOR);
6478#endif
6479
6480#ifdef FEAT_MOUSESHAPE
6481 /* 'mouseshape' */
6482 else if (varp == &p_mouseshape)
6483 {
6484 errmsg = parse_shape_opt(SHAPE_MOUSE);
6485 update_mouseshape(-1);
6486 }
6487#endif
6488
6489#ifdef FEAT_PRINTER
6490 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006491 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006492# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006493 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006494 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006495# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006496#endif
6497
6498#ifdef FEAT_LANGMAP
6499 /* 'langmap' */
6500 else if (varp == &p_langmap)
6501 langmap_set();
6502#endif
6503
6504#ifdef FEAT_LINEBREAK
6505 /* 'breakat' */
6506 else if (varp == &p_breakat)
6507 fill_breakat_flags();
6508#endif
6509
6510#ifdef FEAT_TITLE
6511 /* 'titlestring' and 'iconstring' */
6512 else if (varp == &p_titlestring || varp == &p_iconstring)
6513 {
6514# ifdef FEAT_STL_OPT
6515 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6516
6517 /* NULL => statusline syntax */
6518 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6519 stl_syntax |= flagval;
6520 else
6521 stl_syntax &= ~flagval;
6522# endif
6523 did_set_title(varp == &p_iconstring);
6524
6525 }
6526#endif
6527
6528#ifdef FEAT_GUI
6529 /* 'guioptions' */
6530 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006531 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006532 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006533 redraw_gui_only = TRUE;
6534 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006535#endif
6536
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006537#if defined(FEAT_GUI_TABLINE)
6538 /* 'guitablabel' */
6539 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006540 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006541 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006542 redraw_gui_only = TRUE;
6543 }
6544 /* 'guitabtooltip' */
6545 else if (varp == &p_gtt)
6546 {
6547 redraw_gui_only = TRUE;
6548 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006549#endif
6550
Bram Moolenaar071d4272004-06-13 20:20:40 +00006551#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6552 /* 'ttymouse' */
6553 else if (varp == &p_ttym)
6554 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006555 /* Switch the mouse off before changing the escape sequences used for
6556 * that. */
6557 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006558 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6559 errmsg = e_invarg;
6560 else
6561 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006562 if (termcap_active)
6563 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006564 }
6565#endif
6566
6567#ifdef FEAT_VISUAL
6568 /* 'selection' */
6569 else if (varp == &p_sel)
6570 {
6571 if (*p_sel == NUL
6572 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6573 errmsg = e_invarg;
6574 }
6575
6576 /* 'selectmode' */
6577 else if (varp == &p_slm)
6578 {
6579 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6580 errmsg = e_invarg;
6581 }
6582#endif
6583
6584#ifdef FEAT_BROWSE
6585 /* 'browsedir' */
6586 else if (varp == &p_bsdir)
6587 {
6588 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
6589 && !mch_isdir(p_bsdir))
6590 errmsg = e_invarg;
6591 }
6592#endif
6593
6594#ifdef FEAT_VISUAL
6595 /* 'keymodel' */
6596 else if (varp == &p_km)
6597 {
6598 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
6599 errmsg = e_invarg;
6600 else
6601 {
6602 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
6603 km_startsel = (vim_strchr(p_km, 'a') != NULL);
6604 }
6605 }
6606#endif
6607
6608 /* 'mousemodel' */
6609 else if (varp == &p_mousem)
6610 {
6611 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
6612 errmsg = e_invarg;
6613#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
6614 else if (*p_mousem != *oldval)
6615 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
6616 * to create or delete the popup menus. */
6617 gui_motif_update_mousemodel(root_menu);
6618#endif
6619 }
6620
6621 /* 'switchbuf' */
6622 else if (varp == &p_swb)
6623 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00006624 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006625 errmsg = e_invarg;
6626 }
6627
6628 /* 'debug' */
6629 else if (varp == &p_debug)
6630 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00006631 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006632 errmsg = e_invarg;
6633 }
6634
6635 /* 'display' */
6636 else if (varp == &p_dy)
6637 {
6638 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
6639 errmsg = e_invarg;
6640 else
6641 (void)init_chartab();
6642
6643 }
6644
6645#ifdef FEAT_VERTSPLIT
6646 /* 'eadirection' */
6647 else if (varp == &p_ead)
6648 {
6649 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
6650 errmsg = e_invarg;
6651 }
6652#endif
6653
6654#ifdef FEAT_CLIPBOARD
6655 /* 'clipboard' */
6656 else if (varp == &p_cb)
6657 errmsg = check_clipboard_option();
6658#endif
6659
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00006660#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006661 /* When 'spelllang' or 'spellfile' is set and there is a window for this
6662 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006663 else if (varp == &(curbuf->b_s.b_p_spl) || varp == &(curbuf->b_s.b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00006664 {
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006665 win_T *wp;
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006666 int l;
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006667
Bram Moolenaar860cae12010-06-05 23:22:07 +02006668 if (varp == &(curbuf->b_s.b_p_spf))
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006669 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006670 l = (int)STRLEN(curbuf->b_s.b_p_spf);
6671 if (l > 0 && (l < 4 || STRCMP(curbuf->b_s.b_p_spf + l - 4,
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006672 ".add") != 0))
6673 errmsg = e_invarg;
6674 }
6675
6676 if (errmsg == NULL)
6677 {
6678 FOR_ALL_WINDOWS(wp)
6679 if (wp->w_buffer == curbuf && wp->w_p_spell)
6680 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006681 errmsg = did_set_spelllang(wp);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006682# ifdef FEAT_WINDOWS
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006683 break;
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006684# endif
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006685 }
6686 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006687 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006688 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006689 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006690 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006691 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006692 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006693 /* 'spellsuggest' */
6694 else if (varp == &p_sps)
6695 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00006696 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006697 errmsg = e_invarg;
6698 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00006699 /* 'mkspellmem' */
6700 else if (varp == &p_msm)
6701 {
6702 if (spell_check_msm() != OK)
6703 errmsg = e_invarg;
6704 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006705#endif
6706
Bram Moolenaar071d4272004-06-13 20:20:40 +00006707#ifdef FEAT_QUICKFIX
6708 /* When 'bufhidden' is set, check for valid value. */
6709 else if (gvarp == &p_bh)
6710 {
6711 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
6712 errmsg = e_invarg;
6713 }
6714
6715 /* When 'buftype' is set, check for valid value. */
6716 else if (gvarp == &p_bt)
6717 {
6718 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
6719 errmsg = e_invarg;
6720 else
6721 {
6722# ifdef FEAT_WINDOWS
6723 if (curwin->w_status_height)
6724 {
6725 curwin->w_redr_status = TRUE;
6726 redraw_later(VALID);
6727 }
6728# endif
6729 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar5075aad2010-01-27 15:58:13 +01006730# ifdef FEAT_TITLE
6731 redraw_titles();
6732# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006733 }
6734 }
6735#endif
6736
6737#ifdef FEAT_STL_OPT
6738 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006739 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006740 {
6741 int wid;
6742
6743 if (varp == &p_ruf) /* reset ru_wid first */
6744 ru_wid = 0;
6745 s = *varp;
6746 if (varp == &p_ruf && *s == '%')
6747 {
6748 /* set ru_wid if 'ruf' starts with "%99(" */
6749 if (*++s == '-') /* ignore a '-' */
6750 s++;
6751 wid = getdigits(&s);
6752 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
6753 ru_wid = wid;
6754 else
6755 errmsg = check_stl_option(p_ruf);
6756 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00006757 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00006758 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006759 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006760 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006761 comp_col();
6762 }
6763#endif
6764
6765#ifdef FEAT_INS_EXPAND
6766 /* check if it is a valid value for 'complete' -- Acevedo */
6767 else if (gvarp == &p_cpt)
6768 {
6769 for (s = *varp; *s;)
6770 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02006771 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006772 s++;
6773 if (!*s)
6774 break;
6775 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
6776 {
6777 errmsg = illegal_char(errbuf, *s);
6778 break;
6779 }
6780 if (*++s != NUL && *s != ',' && *s != ' ')
6781 {
6782 if (s[-1] == 'k' || s[-1] == 's')
6783 {
6784 /* skip optional filename after 'k' and 's' */
6785 while (*s && *s != ',' && *s != ' ')
6786 {
6787 if (*s == '\\')
6788 ++s;
6789 ++s;
6790 }
6791 }
6792 else
6793 {
6794 if (errbuf != NULL)
6795 {
6796 sprintf((char *)errbuf,
6797 _("E535: Illegal character after <%c>"),
6798 *--s);
6799 errmsg = errbuf;
6800 }
6801 else
6802 errmsg = (char_u *)"";
6803 break;
6804 }
6805 }
6806 }
6807 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00006808
6809 /* 'completeopt' */
6810 else if (varp == &p_cot)
6811 {
6812 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
6813 errmsg = e_invarg;
6814 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006815#endif /* FEAT_INS_EXPAND */
6816
6817
6818#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
6819 else if (varp == &p_toolbar)
6820 {
6821 if (opt_strings_flags(p_toolbar, p_toolbar_values,
6822 &toolbar_flags, TRUE) != OK)
6823 errmsg = e_invarg;
6824 else
6825 {
6826 out_flush();
6827 gui_mch_show_toolbar((toolbar_flags &
6828 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6829 }
6830 }
6831#endif
6832
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006833#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006834 /* 'toolbariconsize': GTK+ 2 only */
6835 else if (varp == &p_tbis)
6836 {
6837 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
6838 errmsg = e_invarg;
6839 else
6840 {
6841 out_flush();
6842 gui_mch_show_toolbar((toolbar_flags &
6843 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6844 }
6845 }
6846#endif
6847
6848 /* 'pastetoggle': translate key codes like in a mapping */
6849 else if (varp == &p_pt)
6850 {
6851 if (*p_pt)
6852 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00006853 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006854 if (p != NULL)
6855 {
6856 if (new_value_alloced)
6857 free_string_option(p_pt);
6858 p_pt = p;
6859 new_value_alloced = TRUE;
6860 }
6861 }
6862 }
6863
6864 /* 'backspace' */
6865 else if (varp == &p_bs)
6866 {
6867 if (VIM_ISDIGIT(*p_bs))
6868 {
6869 if (*p_bs >'2' || p_bs[1] != NUL)
6870 errmsg = e_invarg;
6871 }
6872 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
6873 errmsg = e_invarg;
6874 }
6875
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00006876#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006877 /* 'casemap' */
6878 else if (varp == &p_cmp)
6879 {
6880 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
6881 errmsg = e_invarg;
6882 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00006883#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006884
6885#ifdef FEAT_DIFF
6886 /* 'diffopt' */
6887 else if (varp == &p_dip)
6888 {
6889 if (diffopt_changed() == FAIL)
6890 errmsg = e_invarg;
6891 }
6892#endif
6893
6894#ifdef FEAT_FOLDING
6895 /* 'foldmethod' */
6896 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
6897 {
6898 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
6899 || *curwin->w_p_fdm == NUL)
6900 errmsg = e_invarg;
6901 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01006902 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006903 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01006904 if (foldmethodIsDiff(curwin))
6905 newFoldLevel();
6906 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006907 }
6908# ifdef FEAT_EVAL
6909 /* 'foldexpr' */
6910 else if (varp == &curwin->w_p_fde)
6911 {
6912 if (foldmethodIsExpr(curwin))
6913 foldUpdateAll(curwin);
6914 }
6915# endif
6916 /* 'foldmarker' */
6917 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
6918 {
6919 p = vim_strchr(*varp, ',');
6920 if (p == NULL)
6921 errmsg = (char_u *)N_("E536: comma required");
6922 else if (p == *varp || p[1] == NUL)
6923 errmsg = e_invarg;
6924 else if (foldmethodIsMarker(curwin))
6925 foldUpdateAll(curwin);
6926 }
6927 /* 'commentstring' */
6928 else if (gvarp == &p_cms)
6929 {
6930 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
6931 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
6932 }
6933 /* 'foldopen' */
6934 else if (varp == &p_fdo)
6935 {
6936 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
6937 errmsg = e_invarg;
6938 }
6939 /* 'foldclose' */
6940 else if (varp == &p_fcl)
6941 {
6942 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
6943 errmsg = e_invarg;
6944 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00006945 /* 'foldignore' */
6946 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
6947 {
6948 if (foldmethodIsIndent(curwin))
6949 foldUpdateAll(curwin);
6950 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006951#endif
6952
6953#ifdef FEAT_VIRTUALEDIT
6954 /* 'virtualedit' */
6955 else if (varp == &p_ve)
6956 {
6957 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
6958 errmsg = e_invarg;
6959 else if (STRCMP(p_ve, oldval) != 0)
6960 {
6961 /* Recompute cursor position in case the new 've' setting
6962 * changes something. */
6963 validate_virtcol();
6964 coladvance(curwin->w_virtcol);
6965 }
6966 }
6967#endif
6968
6969#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
6970 else if (varp == &p_csqf)
6971 {
6972 if (p_csqf != NULL)
6973 {
6974 p = p_csqf;
6975 while (*p != NUL)
6976 {
6977 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
6978 || p[1] == NUL
6979 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
6980 || (p[2] != NUL && p[2] != ','))
6981 {
6982 errmsg = e_invarg;
6983 break;
6984 }
6985 else if (p[2] == NUL)
6986 break;
6987 else
6988 p += 3;
6989 }
6990 }
6991 }
6992#endif
6993
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01006994#ifdef FEAT_CINDENT
6995 /* 'cinoptions' */
6996 else if (gvarp == &p_cino)
6997 {
6998 /* TODO: recognize errors */
6999 parse_cino(curbuf);
7000 }
7001#endif
7002
Bram Moolenaar071d4272004-06-13 20:20:40 +00007003 /* Options that are a list of flags. */
7004 else
7005 {
7006 p = NULL;
7007 if (varp == &p_ww)
7008 p = (char_u *)WW_ALL;
7009 if (varp == &p_shm)
7010 p = (char_u *)SHM_ALL;
7011 else if (varp == &(p_cpo))
7012 p = (char_u *)CPO_ALL;
7013 else if (varp == &(curbuf->b_p_fo))
7014 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007015#ifdef FEAT_CONCEAL
7016 else if (varp == &curwin->w_p_cocu)
7017 p = (char_u *)COCU_ALL;
7018#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007019 else if (varp == &p_mouse)
7020 {
7021#ifdef FEAT_MOUSE
7022 p = (char_u *)MOUSE_ALL;
7023#else
7024 if (*p_mouse != NUL)
7025 errmsg = (char_u *)N_("E538: No mouse support");
7026#endif
7027 }
7028#if defined(FEAT_GUI)
7029 else if (varp == &p_go)
7030 p = (char_u *)GO_ALL;
7031#endif
7032 if (p != NULL)
7033 {
7034 for (s = *varp; *s; ++s)
7035 if (vim_strchr(p, *s) == NULL)
7036 {
7037 errmsg = illegal_char(errbuf, *s);
7038 break;
7039 }
7040 }
7041 }
7042
7043 /*
7044 * If error detected, restore the previous value.
7045 */
7046 if (errmsg != NULL)
7047 {
7048 if (new_value_alloced)
7049 free_string_option(*varp);
7050 *varp = oldval;
7051 /*
7052 * When resetting some values, need to act on it.
7053 */
7054 if (did_chartab)
7055 (void)init_chartab();
7056 if (varp == &p_hl)
7057 (void)highlight_changed();
7058 }
7059 else
7060 {
7061#ifdef FEAT_EVAL
7062 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007063 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007064#endif
7065 /*
7066 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007067 * Use "free_oldval", because recursiveness may change the flags under
7068 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007069 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007070 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007071 free_string_option(oldval);
7072 if (new_value_alloced)
7073 options[opt_idx].flags |= P_ALLOCED;
7074 else
7075 options[opt_idx].flags &= ~P_ALLOCED;
7076
7077 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007078 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007079 {
7080 /* global option with local value set to use global value; free
7081 * the local value and make it empty */
7082 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7083 free_string_option(*(char_u **)p);
7084 *(char_u **)p = empty_option;
7085 }
7086
7087 /* May set global value for local option. */
7088 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7089 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007090
7091#ifdef FEAT_AUTOCMD
7092 /*
7093 * Trigger the autocommand only after setting the flags.
7094 */
7095# ifdef FEAT_SYN_HL
7096 /* When 'syntax' is set, load the syntax of that name */
7097 if (varp == &(curbuf->b_p_syn))
7098 {
7099 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7100 curbuf->b_fname, TRUE, curbuf);
7101 }
7102# endif
7103 else if (varp == &(curbuf->b_p_ft))
7104 {
7105 /* 'filetype' is set, trigger the FileType autocommand */
7106 did_filetype = TRUE;
7107 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
7108 curbuf->b_fname, TRUE, curbuf);
7109 }
7110#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007111#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007112 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007113 {
7114 char_u fname[200];
7115
7116 /*
7117 * Source the spell/LANG.vim in 'runtimepath'.
7118 * They could set 'spellcapcheck' depending on the language.
7119 * Use the first name in 'spelllang' up to '_region' or
7120 * '.encoding'.
7121 */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007122 for (p = curwin->w_s->b_p_spl; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007123 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7124 break;
7125 vim_snprintf((char *)fname, 200, "spell/%.*s.vim",
Bram Moolenaar860cae12010-06-05 23:22:07 +02007126 (int)(p - curwin->w_s->b_p_spl), curwin->w_s->b_p_spl);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007127 source_runtime(fname, TRUE);
7128 }
7129#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007130 }
7131
7132#ifdef FEAT_MOUSE
7133 if (varp == &p_mouse)
7134 {
7135# ifdef FEAT_MOUSE_TTY
7136 if (*p_mouse == NUL)
7137 mch_setmouse(FALSE); /* switch mouse off */
7138 else
7139# endif
7140 setmouse(); /* in case 'mouse' changed */
7141 }
7142#endif
7143
Bram Moolenaar913077c2012-03-28 19:59:04 +02007144 if (curwin->w_curswant != MAXCOL
7145 && (options[opt_idx].flags & (P_CURSWANT | P_RCLR)) != 0)
7146 curwin->w_set_curswant = TRUE;
7147
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007148#ifdef FEAT_GUI
7149 /* check redraw when it's not a GUI option or the GUI is active. */
7150 if (!redraw_gui_only || gui.in_use)
7151#endif
7152 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007153
7154 return errmsg;
7155}
7156
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007157#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007158/*
7159 * Simple int comparison function for use with qsort()
7160 */
7161 static int
7162int_cmp(a, b)
7163 const void *a;
7164 const void *b;
7165{
7166 return *(const int *)a - *(const int *)b;
7167}
7168
7169/*
7170 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7171 * Returns error message, NULL if it's OK.
7172 */
7173 char_u *
7174check_colorcolumn(wp)
7175 win_T *wp;
7176{
7177 char_u *s;
7178 int col;
7179 int count = 0;
7180 int color_cols[256];
7181 int i;
7182 int j = 0;
7183
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007184 if (wp->w_buffer == NULL)
7185 return NULL; /* buffer was closed */
7186
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007187 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007188 {
7189 if (*s == '-' || *s == '+')
7190 {
7191 /* -N and +N: add to 'textwidth' */
7192 col = (*s == '-') ? -1 : 1;
7193 ++s;
7194 if (!VIM_ISDIGIT(*s))
7195 return e_invarg;
7196 col = col * getdigits(&s);
7197 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007198 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007199 col += wp->w_buffer->b_p_tw;
7200 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007201 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007202 }
7203 else if (VIM_ISDIGIT(*s))
7204 col = getdigits(&s);
7205 else
7206 return e_invarg;
7207 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007208skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007209 if (*s == NUL)
7210 break;
7211 if (*s != ',')
7212 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007213 if (*++s == NUL)
7214 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007215 }
7216
7217 vim_free(wp->w_p_cc_cols);
7218 if (count == 0)
7219 wp->w_p_cc_cols = NULL;
7220 else
7221 {
7222 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7223 if (wp->w_p_cc_cols != NULL)
7224 {
7225 /* sort the columns for faster usage on screen redraw inside
7226 * win_line() */
7227 qsort(color_cols, count, sizeof(int), int_cmp);
7228
7229 for (i = 0; i < count; ++i)
7230 /* skip duplicates */
7231 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7232 wp->w_p_cc_cols[j++] = color_cols[i];
7233 wp->w_p_cc_cols[j] = -1; /* end marker */
7234 }
7235 }
7236
7237 return NULL; /* no error */
7238}
7239#endif
7240
Bram Moolenaar071d4272004-06-13 20:20:40 +00007241/*
7242 * Handle setting 'listchars' or 'fillchars'.
7243 * Returns error message, NULL if it's OK.
7244 */
7245 static char_u *
7246set_chars_option(varp)
7247 char_u **varp;
7248{
7249 int round, i, len, entries;
7250 char_u *p, *s;
7251 int c1, c2 = 0;
7252 struct charstab
7253 {
7254 int *cp;
7255 char *name;
7256 };
7257#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7258 static struct charstab filltab[] =
7259 {
7260 {&fill_stl, "stl"},
7261 {&fill_stlnc, "stlnc"},
7262 {&fill_vert, "vert"},
7263 {&fill_fold, "fold"},
7264 {&fill_diff, "diff"},
7265 };
7266#endif
7267 static struct charstab lcstab[] =
7268 {
7269 {&lcs_eol, "eol"},
7270 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007271 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007272 {&lcs_prec, "precedes"},
7273 {&lcs_tab2, "tab"},
7274 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007275#ifdef FEAT_CONCEAL
7276 {&lcs_conceal, "conceal"},
7277#else
7278 {NULL, "conceal"},
7279#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007280 };
7281 struct charstab *tab;
7282
7283#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7284 if (varp == &p_lcs)
7285#endif
7286 {
7287 tab = lcstab;
7288 entries = sizeof(lcstab) / sizeof(struct charstab);
7289 }
7290#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7291 else
7292 {
7293 tab = filltab;
7294 entries = sizeof(filltab) / sizeof(struct charstab);
7295 }
7296#endif
7297
7298 /* first round: check for valid value, second round: assign values */
7299 for (round = 0; round <= 1; ++round)
7300 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007301 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007302 {
7303 /* After checking that the value is valid: set defaults: space for
7304 * 'fillchars', NUL for 'listchars' */
7305 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007306 if (tab[i].cp != NULL)
7307 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007308 if (varp == &p_lcs)
7309 lcs_tab1 = NUL;
7310#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7311 else
7312 fill_diff = '-';
7313#endif
7314 }
7315 p = *varp;
7316 while (*p)
7317 {
7318 for (i = 0; i < entries; ++i)
7319 {
7320 len = (int)STRLEN(tab[i].name);
7321 if (STRNCMP(p, tab[i].name, len) == 0
7322 && p[len] == ':'
7323 && p[len + 1] != NUL)
7324 {
7325 s = p + len + 1;
7326#ifdef FEAT_MBYTE
7327 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007328 if (mb_char2cells(c1) > 1)
7329 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007330#else
7331 c1 = *s++;
7332#endif
7333 if (tab[i].cp == &lcs_tab2)
7334 {
7335 if (*s == NUL)
7336 continue;
7337#ifdef FEAT_MBYTE
7338 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007339 if (mb_char2cells(c2) > 1)
7340 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007341#else
7342 c2 = *s++;
7343#endif
7344 }
7345 if (*s == ',' || *s == NUL)
7346 {
7347 if (round)
7348 {
7349 if (tab[i].cp == &lcs_tab2)
7350 {
7351 lcs_tab1 = c1;
7352 lcs_tab2 = c2;
7353 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007354 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007355 *(tab[i].cp) = c1;
7356
7357 }
7358 p = s;
7359 break;
7360 }
7361 }
7362 }
7363
7364 if (i == entries)
7365 return e_invarg;
7366 if (*p == ',')
7367 ++p;
7368 }
7369 }
7370
7371 return NULL; /* no error */
7372}
7373
7374#ifdef FEAT_STL_OPT
7375/*
7376 * Check validity of options with the 'statusline' format.
7377 * Return error message or NULL.
7378 */
7379 char_u *
7380check_stl_option(s)
7381 char_u *s;
7382{
7383 int itemcnt = 0;
7384 int groupdepth = 0;
7385 static char_u errbuf[80];
7386
7387 while (*s && itemcnt < STL_MAX_ITEM)
7388 {
7389 /* Check for valid keys after % sequences */
7390 while (*s && *s != '%')
7391 s++;
7392 if (!*s)
7393 break;
7394 s++;
7395 if (*s != '%' && *s != ')')
7396 ++itemcnt;
7397 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7398 {
7399 s++;
7400 continue;
7401 }
7402 if (*s == ')')
7403 {
7404 s++;
7405 if (--groupdepth < 0)
7406 break;
7407 continue;
7408 }
7409 if (*s == '-')
7410 s++;
7411 while (VIM_ISDIGIT(*s))
7412 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007413 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007414 continue;
7415 if (*s == '.')
7416 {
7417 s++;
7418 while (*s && VIM_ISDIGIT(*s))
7419 s++;
7420 }
7421 if (*s == '(')
7422 {
7423 groupdepth++;
7424 continue;
7425 }
7426 if (vim_strchr(STL_ALL, *s) == NULL)
7427 {
7428 return illegal_char(errbuf, *s);
7429 }
7430 if (*s == '{')
7431 {
7432 s++;
7433 while (*s != '}' && *s)
7434 s++;
7435 if (*s != '}')
7436 return (char_u *)N_("E540: Unclosed expression sequence");
7437 }
7438 }
7439 if (itemcnt >= STL_MAX_ITEM)
7440 return (char_u *)N_("E541: too many items");
7441 if (groupdepth != 0)
7442 return (char_u *)N_("E542: unbalanced groups");
7443 return NULL;
7444}
7445#endif
7446
7447#ifdef FEAT_CLIPBOARD
7448/*
7449 * Extract the items in the 'clipboard' option and set global values.
7450 */
7451 static char_u *
7452check_clipboard_option()
7453{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007454 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007455 int new_autoselect_star = FALSE;
7456 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007457 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007458 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007459 regprog_T *new_exclude_prog = NULL;
7460 char_u *errmsg = NULL;
7461 char_u *p;
7462
7463 for (p = p_cb; *p != NUL; )
7464 {
7465 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7466 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007467 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007468 p += 7;
7469 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007470 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007471 && (p[11] == ',' || p[11] == NUL))
7472 {
7473 new_unnamed |= CLIP_UNNAMED_PLUS;
7474 p += 11;
7475 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007476 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007477 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007478 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007479 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007480 p += 10;
7481 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007482 else if (STRNCMP(p, "autoselectplus", 14) == 0
7483 && (p[14] == ',' || p[14] == NUL))
7484 {
7485 new_autoselect_plus = TRUE;
7486 p += 14;
7487 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007488 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007489 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007490 {
7491 new_autoselectml = TRUE;
7492 p += 12;
7493 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007494 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7495 {
7496 new_html = TRUE;
7497 p += 4;
7498 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007499 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7500 {
7501 p += 8;
7502 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7503 if (new_exclude_prog == NULL)
7504 errmsg = e_invarg;
7505 break;
7506 }
7507 else
7508 {
7509 errmsg = e_invarg;
7510 break;
7511 }
7512 if (*p == ',')
7513 ++p;
7514 }
7515 if (errmsg == NULL)
7516 {
7517 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007518 clip_autoselect_star = new_autoselect_star;
7519 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007520 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007521 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02007522 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007523 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02007524#ifdef FEAT_GUI_GTK
7525 if (gui.in_use)
7526 {
7527 gui_gtk_set_selection_targets();
7528 gui_gtk_set_dnd_targets();
7529 }
7530#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007531 }
7532 else
Bram Moolenaar473de612013-06-08 18:19:48 +02007533 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007534
7535 return errmsg;
7536}
7537#endif
7538
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007539#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007540/*
7541 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
7542 * Return error message when failed, NULL when OK.
7543 */
7544 static char_u *
Bram Moolenaar860cae12010-06-05 23:22:07 +02007545compile_cap_prog(synblock)
7546 synblock_T *synblock;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007547{
Bram Moolenaar860cae12010-06-05 23:22:07 +02007548 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007549 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007550
Bram Moolenaar860cae12010-06-05 23:22:07 +02007551 if (*synblock->b_p_spc == NUL)
7552 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007553 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007554 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007555 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007556 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007557 if (re != NULL)
7558 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007559 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02007560 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02007561 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007562 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007563 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007564 return e_invarg;
7565 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007566 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007567 }
7568
Bram Moolenaar473de612013-06-08 18:19:48 +02007569 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007570 return NULL;
7571}
7572#endif
7573
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007574#if defined(FEAT_EVAL) || defined(PROTO)
7575/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007576 * Set the scriptID for an option, taking care of setting the buffer- or
7577 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007578 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007579 static void
7580set_option_scriptID_idx(opt_idx, opt_flags, id)
7581 int opt_idx;
7582 int opt_flags;
7583 int id;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007584{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007585 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
7586 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007587
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007588 /* Remember where the option was set. For local options need to do that
7589 * in the buffer or window structure. */
7590 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007591 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007592 if (both || (opt_flags & OPT_LOCAL))
7593 {
7594 if (indir & PV_BUF)
7595 curbuf->b_p_scriptID[indir & PV_MASK] = id;
7596 else if (indir & PV_WIN)
7597 curwin->w_p_scriptID[indir & PV_MASK] = id;
7598 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007599}
7600#endif
7601
Bram Moolenaar071d4272004-06-13 20:20:40 +00007602/*
7603 * Set the value of a boolean option, and take care of side effects.
7604 * Returns NULL for success, or an error message for an error.
7605 */
7606 static char_u *
7607set_bool_option(opt_idx, varp, value, opt_flags)
7608 int opt_idx; /* index in options[] table */
7609 char_u *varp; /* pointer to the option variable */
7610 int value; /* new value */
7611 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
7612{
7613 int old_value = *(int *)varp;
7614
Bram Moolenaar071d4272004-06-13 20:20:40 +00007615 /* Disallow changing some options from secure mode */
7616 if ((secure
7617#ifdef HAVE_SANDBOX
7618 || sandbox != 0
7619#endif
7620 ) && (options[opt_idx].flags & P_SECURE))
7621 return e_secure;
7622
7623 *(int *)varp = value; /* set the new value */
7624#ifdef FEAT_EVAL
7625 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007626 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007627#endif
7628
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00007629#ifdef FEAT_GUI
7630 need_mouse_correct = TRUE;
7631#endif
7632
Bram Moolenaar071d4272004-06-13 20:20:40 +00007633 /* May set global value for local option. */
7634 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
7635 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
7636
7637 /*
7638 * Handle side effects of changing a bool option.
7639 */
7640
7641 /* 'compatible' */
7642 if ((int *)varp == &p_cp)
7643 {
7644 compatible_set();
7645 }
7646
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007647#ifdef FEAT_PERSISTENT_UNDO
7648 /* 'undofile' */
7649 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
7650 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007651 /* Only take action when the option was set. When reset we do not
7652 * delete the undo file, the option may be set again without making
7653 * any changes in between. */
7654 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007655 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007656 char_u hash[UNDO_HASH_SIZE];
7657 buf_T *save_curbuf = curbuf;
7658
7659 for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007660 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007661 /* When 'undofile' is set globally: for every buffer, otherwise
7662 * only for the current buffer: Try to read in the undofile,
7663 * if one exists, the buffer wasn't changed and the buffer was
7664 * loaded */
7665 if ((curbuf == save_curbuf
7666 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
7667 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
7668 {
7669 u_compute_hash(hash);
7670 u_read_undo(NULL, hash, curbuf->b_fname);
7671 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007672 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007673 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007674 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007675 }
7676#endif
7677
Bram Moolenaar071d4272004-06-13 20:20:40 +00007678 else if ((int *)varp == &curbuf->b_p_ro)
7679 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007680 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007681 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
7682 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007683
7684 /* when 'readonly' is set may give W10 again */
7685 if (curbuf->b_p_ro)
7686 curbuf->b_did_warn = FALSE;
7687
Bram Moolenaar071d4272004-06-13 20:20:40 +00007688#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007689 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007690#endif
7691 }
7692
Bram Moolenaar9c449722010-07-20 18:44:27 +02007693#ifdef FEAT_GUI
7694 else if ((int *)varp == &p_mh)
7695 {
7696 if (!p_mh)
7697 gui_mch_mousehide(FALSE);
7698 }
7699#endif
7700
Bram Moolenaara539df02010-08-01 14:35:05 +02007701#ifdef FEAT_TITLE
7702 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007703 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007704 {
7705 redraw_titles();
7706 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007707 /* when 'endofline' is changed, redraw the window title */
7708 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007709 {
7710 redraw_titles();
7711 }
7712# ifdef FEAT_MBYTE
7713 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00007714 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007715 {
7716 redraw_titles();
7717 }
7718# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007719#endif
7720
7721 /* when 'bin' is set also set some other options */
7722 else if ((int *)varp == &curbuf->b_p_bin)
7723 {
7724 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
7725#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007726 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007727#endif
7728 }
7729
7730#ifdef FEAT_AUTOCMD
7731 /* when 'buflisted' changes, trigger autocommands */
7732 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
7733 {
7734 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
7735 NULL, NULL, TRUE, curbuf);
7736 }
7737#endif
7738
7739 /* when 'swf' is set, create swapfile, when reset remove swapfile */
7740 else if ((int *)varp == &curbuf->b_p_swf)
7741 {
7742 if (curbuf->b_p_swf && p_uc)
7743 ml_open_file(curbuf); /* create the swap file */
7744 else
Bram Moolenaard55de222007-05-06 13:38:48 +00007745 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
7746 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007747 mf_close_file(curbuf, TRUE); /* remove the swap file */
7748 }
7749
7750 /* when 'terse' is set change 'shortmess' */
7751 else if ((int *)varp == &p_terse)
7752 {
7753 char_u *p;
7754
7755 p = vim_strchr(p_shm, SHM_SEARCH);
7756
7757 /* insert 's' in p_shm */
7758 if (p_terse && p == NULL)
7759 {
7760 STRCPY(IObuff, p_shm);
7761 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007762 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007763 }
7764 /* remove 's' from p_shm */
7765 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007766 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007767 }
7768
7769 /* when 'paste' is set or reset also change other options */
7770 else if ((int *)varp == &p_paste)
7771 {
7772 paste_option_changed();
7773 }
7774
7775 /* when 'insertmode' is set from an autocommand need to do work here */
7776 else if ((int *)varp == &p_im)
7777 {
7778 if (p_im)
7779 {
7780 if ((State & INSERT) == 0)
7781 need_start_insertmode = TRUE;
7782 stop_insert_mode = FALSE;
7783 }
7784 else
7785 {
7786 need_start_insertmode = FALSE;
7787 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00007788 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007789 clear_cmdline = TRUE; /* remove "(insert)" */
7790 restart_edit = 0;
7791 }
7792 }
7793
7794 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
7795 else if ((int *)varp == &p_ic && p_hls)
7796 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007797 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007798 }
7799
7800#ifdef FEAT_SEARCH_EXTRA
7801 /* when 'hlsearch' is set or reset: reset no_hlsearch */
7802 else if ((int *)varp == &p_hls)
7803 {
7804 no_hlsearch = FALSE;
7805 }
7806#endif
7807
7808#ifdef FEAT_SCROLLBIND
7809 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
7810 * at the end of normal_cmd() */
7811 else if ((int *)varp == &curwin->w_p_scb)
7812 {
7813 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02007814 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007815 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02007816 curwin->w_scbind_pos = curwin->w_topline;
7817 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007818 }
7819#endif
7820
7821#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
7822 /* There can be only one window with 'previewwindow' set. */
7823 else if ((int *)varp == &curwin->w_p_pvw)
7824 {
7825 if (curwin->w_p_pvw)
7826 {
7827 win_T *win;
7828
7829 for (win = firstwin; win != NULL; win = win->w_next)
7830 if (win->w_p_pvw && win != curwin)
7831 {
7832 curwin->w_p_pvw = FALSE;
7833 return (char_u *)N_("E590: A preview window already exists");
7834 }
7835 }
7836 }
7837#endif
7838
7839 /* when 'textmode' is set or reset also change 'fileformat' */
7840 else if ((int *)varp == &curbuf->b_p_tx)
7841 {
7842 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
7843 }
7844
7845 /* when 'textauto' is set or reset also change 'fileformats' */
7846 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007847 set_string_option_direct((char_u *)"ffs", -1,
7848 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007849 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007850
7851 /*
7852 * When 'lisp' option changes include/exclude '-' in
7853 * keyword characters.
7854 */
7855#ifdef FEAT_LISP
7856 else if (varp == (char_u *)&(curbuf->b_p_lisp))
7857 {
7858 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
7859 }
7860#endif
7861
7862#ifdef FEAT_TITLE
7863 /* when 'title' changed, may need to change the title; same for 'icon' */
7864 else if ((int *)varp == &p_title)
7865 {
7866 did_set_title(FALSE);
7867 }
7868
7869 else if ((int *)varp == &p_icon)
7870 {
7871 did_set_title(TRUE);
7872 }
7873#endif
7874
7875 else if ((int *)varp == &curbuf->b_changed)
7876 {
7877 if (!value)
7878 save_file_ff(curbuf); /* Buffer is unchanged */
7879#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007880 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007881#endif
7882#ifdef FEAT_AUTOCMD
7883 modified_was_set = value;
7884#endif
7885 }
7886
7887#ifdef BACKSLASH_IN_FILENAME
7888 else if ((int *)varp == &p_ssl)
7889 {
7890 if (p_ssl)
7891 {
7892 psepc = '/';
7893 psepcN = '\\';
7894 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00007895 }
7896 else
7897 {
7898 psepc = '\\';
7899 psepcN = '/';
7900 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00007901 }
7902
7903 /* need to adjust the file name arguments and buffer names. */
7904 buflist_slash_adjust();
7905 alist_slash_adjust();
7906# ifdef FEAT_EVAL
7907 scriptnames_slash_adjust();
7908# endif
7909 }
7910#endif
7911
7912 /* If 'wrap' is set, set w_leftcol to zero. */
7913 else if ((int *)varp == &curwin->w_p_wrap)
7914 {
7915 if (curwin->w_p_wrap)
7916 curwin->w_leftcol = 0;
7917 }
7918
7919#ifdef FEAT_WINDOWS
7920 else if ((int *)varp == &p_ea)
7921 {
7922 if (p_ea && !old_value)
7923 win_equal(curwin, FALSE, 0);
7924 }
7925#endif
7926
7927 else if ((int *)varp == &p_wiv)
7928 {
7929 /*
7930 * When 'weirdinvert' changed, set/reset 't_xs'.
7931 * Then set 'weirdinvert' according to value of 't_xs'.
7932 */
7933 if (p_wiv && !old_value)
7934 T_XS = (char_u *)"y";
7935 else if (!p_wiv && old_value)
7936 T_XS = empty_option;
7937 p_wiv = (*T_XS != NUL);
7938 }
7939
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00007940#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00007941 else if ((int *)varp == &p_beval)
7942 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01007943 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007944 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01007945 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007946 gui_mch_disable_beval_area(balloonEval);
7947 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00007948#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007949
Bram Moolenaar8dff8182006-04-06 20:18:50 +00007950#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00007951 else if ((int *)varp == &p_acd)
7952 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00007953 /* Change directories when the 'acd' option is set now. */
7954 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00007955 }
7956#endif
7957
7958#ifdef FEAT_DIFF
7959 /* 'diff' */
7960 else if ((int *)varp == &curwin->w_p_diff)
7961 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00007962 /* May add or remove the buffer from the list of diff buffers. */
7963 diff_buf_adjust(curwin);
7964# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00007965 if (foldmethodIsDiff(curwin))
7966 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00007967# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007968 }
7969#endif
7970
7971#ifdef USE_IM_CONTROL
7972 /* 'imdisable' */
7973 else if ((int *)varp == &p_imdisable)
7974 {
7975 /* Only de-activate it here, it will be enabled when changing mode. */
7976 if (p_imdisable)
7977 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02007978 else if (State & INSERT)
7979 /* When the option is set from an autocommand, it may need to take
7980 * effect right away. */
7981 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007982 }
7983#endif
7984
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007985#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00007986 /* 'spell' */
7987 else if ((int *)varp == &curwin->w_p_spell)
7988 {
7989 if (curwin->w_p_spell)
7990 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007991 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00007992 if (errmsg != NULL)
7993 EMSG(_(errmsg));
7994 }
7995 }
7996#endif
7997
Bram Moolenaar071d4272004-06-13 20:20:40 +00007998#ifdef FEAT_FKMAP
7999 else if ((int *)varp == &p_altkeymap)
8000 {
8001 if (old_value != p_altkeymap)
8002 {
8003 if (!p_altkeymap)
8004 {
8005 p_hkmap = p_fkmap;
8006 p_fkmap = 0;
8007 }
8008 else
8009 {
8010 p_fkmap = p_hkmap;
8011 p_hkmap = 0;
8012 }
8013 (void)init_chartab();
8014 }
8015 }
8016
8017 /*
8018 * In case some second language keymapping options have changed, check
8019 * and correct the setting in a consistent way.
8020 */
8021
8022 /*
8023 * If hkmap or fkmap are set, reset Arabic keymapping.
8024 */
8025 if ((p_hkmap || p_fkmap) && p_altkeymap)
8026 {
8027 p_altkeymap = p_fkmap;
8028# ifdef FEAT_ARABIC
8029 curwin->w_p_arab = FALSE;
8030# endif
8031 (void)init_chartab();
8032 }
8033
8034 /*
8035 * If hkmap set, reset Farsi keymapping.
8036 */
8037 if (p_hkmap && p_altkeymap)
8038 {
8039 p_altkeymap = 0;
8040 p_fkmap = 0;
8041# ifdef FEAT_ARABIC
8042 curwin->w_p_arab = FALSE;
8043# endif
8044 (void)init_chartab();
8045 }
8046
8047 /*
8048 * If fkmap set, reset Hebrew keymapping.
8049 */
8050 if (p_fkmap && !p_altkeymap)
8051 {
8052 p_altkeymap = 1;
8053 p_hkmap = 0;
8054# ifdef FEAT_ARABIC
8055 curwin->w_p_arab = FALSE;
8056# endif
8057 (void)init_chartab();
8058 }
8059#endif
8060
8061#ifdef FEAT_ARABIC
8062 if ((int *)varp == &curwin->w_p_arab)
8063 {
8064 if (curwin->w_p_arab)
8065 {
8066 /*
8067 * 'arabic' is set, handle various sub-settings.
8068 */
8069 if (!p_tbidi)
8070 {
8071 /* set rightleft mode */
8072 if (!curwin->w_p_rl)
8073 {
8074 curwin->w_p_rl = TRUE;
8075 changed_window_setting();
8076 }
8077
8078 /* Enable Arabic shaping (major part of what Arabic requires) */
8079 if (!p_arshape)
8080 {
8081 p_arshape = TRUE;
8082 redraw_later_clear();
8083 }
8084 }
8085
8086 /* Arabic requires a utf-8 encoding, inform the user if its not
8087 * set. */
8088 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008089 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008090 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8091
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008092 msg_source(hl_attr(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008093 MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
8094#ifdef FEAT_EVAL
8095 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8096#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008097 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008098
8099# ifdef FEAT_MBYTE
8100 /* set 'delcombine' */
8101 p_deco = TRUE;
8102# endif
8103
8104# ifdef FEAT_KEYMAP
8105 /* Force-set the necessary keymap for arabic */
8106 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8107 OPT_LOCAL);
8108# endif
8109# ifdef FEAT_FKMAP
8110 p_altkeymap = 0;
8111 p_hkmap = 0;
8112 p_fkmap = 0;
8113 (void)init_chartab();
8114# endif
8115 }
8116 else
8117 {
8118 /*
8119 * 'arabic' is reset, handle various sub-settings.
8120 */
8121 if (!p_tbidi)
8122 {
8123 /* reset rightleft mode */
8124 if (curwin->w_p_rl)
8125 {
8126 curwin->w_p_rl = FALSE;
8127 changed_window_setting();
8128 }
8129
8130 /* 'arabicshape' isn't reset, it is a global option and
8131 * another window may still need it "on". */
8132 }
8133
8134 /* 'delcombine' isn't reset, it is a global option and another
8135 * window may still want it "on". */
8136
8137# ifdef FEAT_KEYMAP
8138 /* Revert to the default keymap */
8139 curbuf->b_p_iminsert = B_IMODE_NONE;
8140 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8141# endif
8142 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008143 }
8144
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008145#endif
8146
Bram Moolenaar071d4272004-06-13 20:20:40 +00008147 /*
8148 * End of handling side effects for bool options.
8149 */
8150
8151 options[opt_idx].flags |= P_WAS_SET;
8152
8153 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008154 if (curwin->w_curswant != MAXCOL
8155 && (options[opt_idx].flags & (P_CURSWANT | P_RCLR)) != 0)
8156 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008157 check_redraw(options[opt_idx].flags);
8158
8159 return NULL;
8160}
8161
8162/*
8163 * Set the value of a number option, and take care of side effects.
8164 * Returns NULL for success, or an error message for an error.
8165 */
8166 static char_u *
Bram Moolenaar555b2802005-05-19 21:08:39 +00008167set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008168 int opt_idx; /* index in options[] table */
8169 char_u *varp; /* pointer to the option variable */
8170 long value; /* new value */
8171 char_u *errbuf; /* buffer for error messages */
Bram Moolenaar555b2802005-05-19 21:08:39 +00008172 size_t errbuflen; /* length of "errbuf" */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008173 int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and
8174 OPT_MODELINE */
8175{
8176 char_u *errmsg = NULL;
8177 long old_value = *(long *)varp;
8178 long old_Rows = Rows; /* remember old Rows */
8179 long old_Columns = Columns; /* remember old Columns */
8180 long *pp = (long *)varp;
8181
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008182 /* Disallow changing some options from secure mode. */
8183 if ((secure
8184#ifdef HAVE_SANDBOX
8185 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008186#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008187 ) && (options[opt_idx].flags & P_SECURE))
8188 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008189
8190 *pp = value;
8191#ifdef FEAT_EVAL
8192 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008193 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008194#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008195#ifdef FEAT_GUI
8196 need_mouse_correct = TRUE;
8197#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008198
Bram Moolenaar14f24742012-08-08 18:01:05 +02008199 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008200 {
8201 errmsg = e_positive;
8202 curbuf->b_p_sw = curbuf->b_p_ts;
8203 }
8204
8205 /*
8206 * Number options that need some action when changed
8207 */
8208#ifdef FEAT_WINDOWS
8209 if (pp == &p_wh || pp == &p_hh)
8210 {
8211 if (p_wh < 1)
8212 {
8213 errmsg = e_positive;
8214 p_wh = 1;
8215 }
8216 if (p_wmh > p_wh)
8217 {
8218 errmsg = e_winheight;
8219 p_wh = p_wmh;
8220 }
8221 if (p_hh < 0)
8222 {
8223 errmsg = e_positive;
8224 p_hh = 0;
8225 }
8226
8227 /* Change window height NOW */
8228 if (lastwin != firstwin)
8229 {
8230 if (pp == &p_wh && curwin->w_height < p_wh)
8231 win_setheight((int)p_wh);
8232 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8233 win_setheight((int)p_hh);
8234 }
8235 }
8236
8237 /* 'winminheight' */
8238 else if (pp == &p_wmh)
8239 {
8240 if (p_wmh < 0)
8241 {
8242 errmsg = e_positive;
8243 p_wmh = 0;
8244 }
8245 if (p_wmh > p_wh)
8246 {
8247 errmsg = e_winheight;
8248 p_wmh = p_wh;
8249 }
8250 win_setminheight();
8251 }
8252
8253# ifdef FEAT_VERTSPLIT
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008254 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008255 {
8256 if (p_wiw < 1)
8257 {
8258 errmsg = e_positive;
8259 p_wiw = 1;
8260 }
8261 if (p_wmw > p_wiw)
8262 {
8263 errmsg = e_winwidth;
8264 p_wiw = p_wmw;
8265 }
8266
8267 /* Change window width NOW */
8268 if (lastwin != firstwin && curwin->w_width < p_wiw)
8269 win_setwidth((int)p_wiw);
8270 }
8271
8272 /* 'winminwidth' */
8273 else if (pp == &p_wmw)
8274 {
8275 if (p_wmw < 0)
8276 {
8277 errmsg = e_positive;
8278 p_wmw = 0;
8279 }
8280 if (p_wmw > p_wiw)
8281 {
8282 errmsg = e_winwidth;
8283 p_wmw = p_wiw;
8284 }
8285 win_setminheight();
8286 }
8287# endif
8288
8289#endif
8290
8291#ifdef FEAT_WINDOWS
8292 /* (re)set last window status line */
8293 else if (pp == &p_ls)
8294 {
8295 last_status(FALSE);
8296 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008297
8298 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008299 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008300 {
8301 shell_new_rows(); /* recompute window positions and heights */
8302 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008303#endif
8304
8305#ifdef FEAT_GUI
8306 else if (pp == &p_linespace)
8307 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008308 /* Recompute gui.char_height and resize the Vim window to keep the
8309 * same number of lines. */
8310 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008311 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008312 }
8313#endif
8314
8315#ifdef FEAT_FOLDING
8316 /* 'foldlevel' */
8317 else if (pp == &curwin->w_p_fdl)
8318 {
8319 if (curwin->w_p_fdl < 0)
8320 curwin->w_p_fdl = 0;
8321 newFoldLevel();
8322 }
8323
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008324 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008325 else if (pp == &curwin->w_p_fml)
8326 {
8327 foldUpdateAll(curwin);
8328 }
8329
8330 /* 'foldnestmax' */
8331 else if (pp == &curwin->w_p_fdn)
8332 {
8333 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8334 foldUpdateAll(curwin);
8335 }
8336
8337 /* 'foldcolumn' */
8338 else if (pp == &curwin->w_p_fdc)
8339 {
8340 if (curwin->w_p_fdc < 0)
8341 {
8342 errmsg = e_positive;
8343 curwin->w_p_fdc = 0;
8344 }
8345 else if (curwin->w_p_fdc > 12)
8346 {
8347 errmsg = e_invarg;
8348 curwin->w_p_fdc = 12;
8349 }
8350 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008351#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008352
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008353#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008354 /* 'shiftwidth' or 'tabstop' */
8355 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8356 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008357# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008358 if (foldmethodIsIndent(curwin))
8359 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008360# endif
8361# ifdef FEAT_CINDENT
8362 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8363 * parse 'cinoptions'. */
8364 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8365 parse_cino(curbuf);
8366# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008367 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008368#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008369
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008370#ifdef FEAT_MBYTE
8371 /* 'maxcombine' */
8372 else if (pp == &p_mco)
8373 {
8374 if (p_mco > MAX_MCO)
8375 p_mco = MAX_MCO;
8376 else if (p_mco < 0)
8377 p_mco = 0;
8378 screenclear(); /* will re-allocate the screen */
8379 }
8380#endif
8381
Bram Moolenaar071d4272004-06-13 20:20:40 +00008382 else if (pp == &curbuf->b_p_iminsert)
8383 {
8384 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8385 {
8386 errmsg = e_invarg;
8387 curbuf->b_p_iminsert = B_IMODE_NONE;
8388 }
8389 p_iminsert = curbuf->b_p_iminsert;
8390 if (termcap_active) /* don't do this in the alternate screen */
8391 showmode();
8392#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8393 /* Show/unshow value of 'keymap' in status lines. */
8394 status_redraw_curbuf();
8395#endif
8396 }
8397
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008398 else if (pp == &p_window)
8399 {
8400 if (p_window < 1)
8401 p_window = 1;
8402 else if (p_window >= Rows)
8403 p_window = Rows - 1;
8404 }
8405
Bram Moolenaar071d4272004-06-13 20:20:40 +00008406 else if (pp == &curbuf->b_p_imsearch)
8407 {
8408 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8409 {
8410 errmsg = e_invarg;
8411 curbuf->b_p_imsearch = B_IMODE_NONE;
8412 }
8413 p_imsearch = curbuf->b_p_imsearch;
8414 }
8415
8416#ifdef FEAT_TITLE
8417 /* if 'titlelen' has changed, redraw the title */
8418 else if (pp == &p_titlelen)
8419 {
8420 if (p_titlelen < 0)
8421 {
8422 errmsg = e_positive;
8423 p_titlelen = 85;
8424 }
8425 if (starting != NO_SCREEN && old_value != p_titlelen)
8426 need_maketitle = TRUE;
8427 }
8428#endif
8429
8430 /* if p_ch changed value, change the command line height */
8431 else if (pp == &p_ch)
8432 {
8433 if (p_ch < 1)
8434 {
8435 errmsg = e_positive;
8436 p_ch = 1;
8437 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008438 if (p_ch > Rows - min_rows() + 1)
8439 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008440
8441 /* Only compute the new window layout when startup has been
8442 * completed. Otherwise the frame sizes may be wrong. */
8443 if (p_ch != old_value && full_screen
8444#ifdef FEAT_GUI
8445 && !gui.starting
8446#endif
8447 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008448 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008449 }
8450
8451 /* when 'updatecount' changes from zero to non-zero, open swap files */
8452 else if (pp == &p_uc)
8453 {
8454 if (p_uc < 0)
8455 {
8456 errmsg = e_positive;
8457 p_uc = 100;
8458 }
8459 if (p_uc && !old_value)
8460 ml_open_files();
8461 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008462#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008463 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008464 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008465 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008466 {
8467 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008468 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008469 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008470 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008471 {
8472 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008473 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008474 }
8475 }
8476#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008477#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008478 else if (pp == &p_mzq)
8479 mzvim_reset_timer();
8480#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008481
8482 /* sync undo before 'undolevels' changes */
8483 else if (pp == &p_ul)
8484 {
8485 /* use the old value, otherwise u_sync() may not work properly */
8486 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00008487 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008488 p_ul = value;
8489 }
8490
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008491#ifdef FEAT_LINEBREAK
8492 /* 'numberwidth' must be positive */
8493 else if (pp == &curwin->w_p_nuw)
8494 {
8495 if (curwin->w_p_nuw < 1)
8496 {
8497 errmsg = e_positive;
8498 curwin->w_p_nuw = 1;
8499 }
8500 if (curwin->w_p_nuw > 10)
8501 {
8502 errmsg = e_invarg;
8503 curwin->w_p_nuw = 10;
8504 }
8505 curwin->w_nrwidth_line_count = 0;
8506 }
8507#endif
8508
Bram Moolenaar1a384422010-07-14 19:53:30 +02008509 else if (pp == &curbuf->b_p_tw)
8510 {
8511 if (curbuf->b_p_tw < 0)
8512 {
8513 errmsg = e_positive;
8514 curbuf->b_p_tw = 0;
8515 }
8516#ifdef FEAT_SYN_HL
8517# ifdef FEAT_WINDOWS
8518 {
8519 win_T *wp;
8520 tabpage_T *tp;
8521
8522 FOR_ALL_TAB_WINDOWS(tp, wp)
8523 check_colorcolumn(wp);
8524 }
8525# else
8526 check_colorcolumn(curwin);
8527# endif
8528#endif
8529 }
8530
Bram Moolenaar071d4272004-06-13 20:20:40 +00008531 /*
8532 * Check the bounds for numeric options here
8533 */
8534 if (Rows < min_rows() && full_screen)
8535 {
8536 if (errbuf != NULL)
8537 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008538 vim_snprintf((char *)errbuf, errbuflen,
8539 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00008540 errmsg = errbuf;
8541 }
8542 Rows = min_rows();
8543 }
8544 if (Columns < MIN_COLUMNS && full_screen)
8545 {
8546 if (errbuf != NULL)
8547 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008548 vim_snprintf((char *)errbuf, errbuflen,
8549 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008550 errmsg = errbuf;
8551 }
8552 Columns = MIN_COLUMNS;
8553 }
Bram Moolenaare057d402013-06-30 17:51:51 +02008554 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008555
8556#ifdef DJGPP
8557 /* avoid a crash by checking for a too large value of 'columns' */
8558 if (old_Columns != Columns && full_screen && term_console)
8559 mch_check_columns();
8560#endif
8561
8562 /*
8563 * If the screen (shell) height has been changed, assume it is the
8564 * physical screenheight.
8565 */
8566 if (old_Rows != Rows || old_Columns != Columns)
8567 {
8568 /* Changing the screen size is not allowed while updating the screen. */
8569 if (updating_screen)
8570 *pp = old_value;
8571 else if (full_screen
8572#ifdef FEAT_GUI
8573 && !gui.starting
8574#endif
8575 )
8576 set_shellsize((int)Columns, (int)Rows, TRUE);
8577 else
8578 {
8579 /* Postpone the resizing; check the size and cmdline position for
8580 * messages. */
8581 check_shellsize();
8582 if (cmdline_row > Rows - p_ch && Rows > p_ch)
8583 cmdline_row = Rows - p_ch;
8584 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00008585 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008586 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008587 }
8588
Bram Moolenaar071d4272004-06-13 20:20:40 +00008589 if (curbuf->b_p_ts <= 0)
8590 {
8591 errmsg = e_positive;
8592 curbuf->b_p_ts = 8;
8593 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008594 if (p_tm < 0)
8595 {
8596 errmsg = e_positive;
8597 p_tm = 0;
8598 }
8599 if ((curwin->w_p_scr <= 0
8600 || (curwin->w_p_scr > curwin->w_height
8601 && curwin->w_height > 0))
8602 && full_screen)
8603 {
8604 if (pp == &(curwin->w_p_scr))
8605 {
8606 if (curwin->w_p_scr != 0)
8607 errmsg = e_scroll;
8608 win_comp_scroll(curwin);
8609 }
8610 /* If 'scroll' became invalid because of a side effect silently adjust
8611 * it. */
8612 else if (curwin->w_p_scr <= 0)
8613 curwin->w_p_scr = 1;
8614 else /* curwin->w_p_scr > curwin->w_height */
8615 curwin->w_p_scr = curwin->w_height;
8616 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00008617 if (p_hi < 0)
8618 {
8619 errmsg = e_positive;
8620 p_hi = 0;
8621 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02008622 if (p_re < 0 || p_re > 2)
8623 {
8624 errmsg = e_invarg;
8625 p_re = 0;
8626 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008627 if (p_report < 0)
8628 {
8629 errmsg = e_positive;
8630 p_report = 1;
8631 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00008632 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008633 {
8634 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
8635 p_sj = Rows / 2;
8636 else
8637 {
8638 errmsg = e_scroll;
8639 p_sj = 1;
8640 }
8641 }
8642 if (p_so < 0 && full_screen)
8643 {
8644 errmsg = e_scroll;
8645 p_so = 0;
8646 }
8647 if (p_siso < 0 && full_screen)
8648 {
8649 errmsg = e_positive;
8650 p_siso = 0;
8651 }
8652#ifdef FEAT_CMDWIN
8653 if (p_cwh < 1)
8654 {
8655 errmsg = e_positive;
8656 p_cwh = 1;
8657 }
8658#endif
8659 if (p_ut < 0)
8660 {
8661 errmsg = e_positive;
8662 p_ut = 2000;
8663 }
8664 if (p_ss < 0)
8665 {
8666 errmsg = e_positive;
8667 p_ss = 0;
8668 }
8669
8670 /* May set global value for local option. */
8671 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8672 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
8673
8674 options[opt_idx].flags |= P_WAS_SET;
8675
8676 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008677 if (curwin->w_curswant != MAXCOL
8678 && (options[opt_idx].flags & (P_CURSWANT | P_RCLR)) != 0)
8679 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008680 check_redraw(options[opt_idx].flags);
8681
8682 return errmsg;
8683}
8684
8685/*
8686 * Called after an option changed: check if something needs to be redrawn.
8687 */
8688 static void
8689check_redraw(flags)
8690 long_u flags;
8691{
8692 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008693 int doclear = (flags & P_RCLR) == P_RCLR;
8694 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008695
8696#ifdef FEAT_WINDOWS
8697 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
8698 status_redraw_all();
8699#endif
8700
8701 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
8702 changed_window_setting();
8703 if (flags & P_RBUF)
8704 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008705 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008706 redraw_all_later(CLEAR);
8707 else if (all)
8708 redraw_all_later(NOT_VALID);
8709}
8710
8711/*
8712 * Find index for option 'arg'.
8713 * Return -1 if not found.
8714 */
8715 static int
8716findoption(arg)
8717 char_u *arg;
8718{
8719 int opt_idx;
8720 char *s, *p;
8721 static short quick_tab[27] = {0, 0}; /* quick access table */
8722 int is_term_opt;
8723
8724 /*
8725 * For first call: Initialize the quick-access table.
8726 * It contains the index for the first option that starts with a certain
8727 * letter. There are 26 letters, plus the first "t_" option.
8728 */
8729 if (quick_tab[1] == 0)
8730 {
8731 p = options[0].fullname;
8732 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8733 {
8734 if (s[0] != p[0])
8735 {
8736 if (s[0] == 't' && s[1] == '_')
8737 quick_tab[26] = opt_idx;
8738 else
8739 quick_tab[CharOrdLow(s[0])] = opt_idx;
8740 }
8741 p = s;
8742 }
8743 }
8744
8745 /*
8746 * Check for name starting with an illegal character.
8747 */
8748#ifdef EBCDIC
8749 if (!islower(arg[0]))
8750#else
8751 if (arg[0] < 'a' || arg[0] > 'z')
8752#endif
8753 return -1;
8754
8755 is_term_opt = (arg[0] == 't' && arg[1] == '_');
8756 if (is_term_opt)
8757 opt_idx = quick_tab[26];
8758 else
8759 opt_idx = quick_tab[CharOrdLow(arg[0])];
8760 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8761 {
8762 if (STRCMP(arg, s) == 0) /* match full name */
8763 break;
8764 }
8765 if (s == NULL && !is_term_opt)
8766 {
8767 opt_idx = quick_tab[CharOrdLow(arg[0])];
8768 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
8769 {
8770 s = options[opt_idx].shortname;
8771 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
8772 break;
8773 s = NULL;
8774 }
8775 }
8776 if (s == NULL)
8777 opt_idx = -1;
8778 return opt_idx;
8779}
8780
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008781#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008782/*
8783 * Get the value for an option.
8784 *
8785 * Returns:
8786 * Number or Toggle option: 1, *numval gets value.
8787 * String option: 0, *stringval gets allocated string.
8788 * Hidden Number or Toggle option: -1.
8789 * hidden String option: -2.
8790 * unknown option: -3.
8791 */
8792 int
8793get_option_value(name, numval, stringval, opt_flags)
8794 char_u *name;
8795 long *numval;
Bram Moolenaar370df582010-06-22 05:16:38 +02008796 char_u **stringval; /* NULL when only checking existence */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008797 int opt_flags;
8798{
8799 int opt_idx;
8800 char_u *varp;
8801
8802 opt_idx = findoption(name);
8803 if (opt_idx < 0) /* unknown option */
8804 return -3;
8805
8806 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
8807
8808 if (options[opt_idx].flags & P_STRING)
8809 {
8810 if (varp == NULL) /* hidden option */
8811 return -2;
8812 if (stringval != NULL)
8813 {
8814#ifdef FEAT_CRYPT
8815 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00008816 if ((char_u **)varp == &curbuf->b_p_key
8817 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008818 *stringval = vim_strsave((char_u *)"*****");
8819 else
8820#endif
8821 *stringval = vim_strsave(*(char_u **)(varp));
8822 }
8823 return 0;
8824 }
8825
8826 if (varp == NULL) /* hidden option */
8827 return -1;
8828 if (options[opt_idx].flags & P_NUM)
8829 *numval = *(long *)varp;
8830 else
8831 {
8832 /* Special case: 'modified' is b_changed, but we also want to consider
8833 * it set when 'ff' or 'fenc' changed. */
8834 if ((int *)varp == &curbuf->b_changed)
8835 *numval = curbufIsChanged();
8836 else
8837 *numval = *(int *)varp;
8838 }
8839 return 1;
8840}
8841#endif
8842
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02008843#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
8844/*
8845 * Returns the option attributes and its value. Unlike the above function it
8846 * will return either global value or local value of the option depending on
8847 * what was requested, but it will never return global value if it was
8848 * requested to return local one and vice versa. Neither it will return
8849 * buffer-local value if it was requested to return window-local one.
8850 *
8851 * Pretends that option is absent if it is not present in the requested scope
8852 * (i.e. has no global, window-local or buffer-local value depending on
8853 * opt_type). Uses
8854 *
8855 * Returned flags:
8856 * 0 hidden or unknown option
8857 * see SOPT_* in vim.h for other flags
8858 *
8859 * Possible opt_type values: see SREQ_* in vim.h
8860 */
8861 int
8862get_option_value_strict(name, numval, stringval, opt_type, from)
8863 char_u *name;
8864 long *numval;
8865 char_u **stringval; /* NULL when only obtaining attributes */
8866 int opt_type;
8867 void *from;
8868{
8869 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02008870 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02008871 struct vimoption *p;
8872 int r = 0;
8873
8874 opt_idx = findoption(name);
8875 if (opt_idx < 0)
8876 return 0;
8877
8878 p = &(options[opt_idx]);
8879
8880 /* Hidden option */
8881 if (p->var == NULL)
8882 return 0;
8883
8884 if (p->flags & P_BOOL)
8885 r |= SOPT_BOOL;
8886 else if (p->flags & P_NUM)
8887 r |= SOPT_NUM;
8888 else if (p->flags & P_STRING)
8889 r |= SOPT_STRING;
8890
8891 if (p->indir == PV_NONE)
8892 {
8893 if (opt_type == SREQ_GLOBAL)
8894 r |= SOPT_GLOBAL;
8895 else
8896 return 0; /* Did not request global-only option */
8897 }
8898 else
8899 {
8900 if (p->indir & PV_BOTH)
8901 r |= SOPT_GLOBAL;
8902 else if (opt_type == SREQ_GLOBAL)
8903 return 0; /* Requested global option */
8904
8905 if (p->indir & PV_WIN)
8906 {
8907 if (opt_type == SREQ_BUF)
8908 return 0; /* Did not request window-local option */
8909 else
8910 r |= SOPT_WIN;
8911 }
8912 else if (p->indir & PV_BUF)
8913 {
8914 if (opt_type == SREQ_WIN)
8915 return 0; /* Did not request buffer-local option */
8916 else
8917 r |= SOPT_BUF;
8918 }
8919 }
8920
8921 if (stringval == NULL)
8922 return r;
8923
8924 if (opt_type == SREQ_GLOBAL)
8925 varp = p->var;
8926 else
8927 {
8928 if (opt_type == SREQ_BUF)
8929 {
8930 /* Special case: 'modified' is b_changed, but we also want to
8931 * consider it set when 'ff' or 'fenc' changed. */
8932 if (p->indir == PV_MOD)
8933 {
8934 *numval = bufIsChanged((buf_T *) from);
8935 varp = NULL;
8936 }
8937#ifdef FEAT_CRYPT
8938 else if (p->indir == PV_KEY)
8939 {
8940 /* never return the value of the crypt key */
8941 *stringval = NULL;
8942 varp = NULL;
8943 }
8944#endif
8945 else
8946 {
8947 aco_save_T aco;
8948 aucmd_prepbuf(&aco, (buf_T *) from);
8949 varp = get_varp(p);
8950 aucmd_restbuf(&aco);
8951 }
8952 }
8953 else if (opt_type == SREQ_WIN)
8954 {
8955 win_T *save_curwin;
8956 save_curwin = curwin;
8957 curwin = (win_T *) from;
8958 curbuf = curwin->w_buffer;
8959 varp = get_varp(p);
8960 curwin = save_curwin;
8961 curbuf = curwin->w_buffer;
8962 }
8963 if (varp == p->var)
8964 return (r | SOPT_UNSET);
8965 }
8966
8967 if (varp != NULL)
8968 {
8969 if (p->flags & P_STRING)
8970 *stringval = vim_strsave(*(char_u **)(varp));
8971 else if (p->flags & P_NUM)
8972 *numval = *(long *) varp;
8973 else
8974 *numval = *(int *)varp;
8975 }
8976
8977 return r;
8978}
8979#endif
8980
Bram Moolenaar071d4272004-06-13 20:20:40 +00008981/*
8982 * Set the value of option "name".
8983 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02008984 *
8985 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00008986 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02008987 char_u *
Bram Moolenaar071d4272004-06-13 20:20:40 +00008988set_option_value(name, number, string, opt_flags)
8989 char_u *name;
8990 long number;
8991 char_u *string;
8992 int opt_flags; /* OPT_LOCAL or 0 (both) */
8993{
8994 int opt_idx;
8995 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00008996 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008997
8998 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00008999 if (opt_idx < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009000 EMSG2(_("E355: Unknown option: %s"), name);
9001 else
9002 {
9003 flags = options[opt_idx].flags;
9004#ifdef HAVE_SANDBOX
9005 /* Disallow changing some options in the sandbox */
9006 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009007 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009008 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009009 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009010 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009011#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009012 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009013 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009014 else
9015 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009016 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009017 if (varp != NULL) /* hidden option is not changed */
9018 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009019 if (number == 0 && string != NULL)
9020 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009021 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009022
9023 /* Either we are given a string or we are setting option
9024 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009025 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009026 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009027 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009028 {
9029 /* There's another character after zeros or the string
9030 * is empty. In both cases, we are trying to set a
9031 * num option using a string. */
9032 EMSG3(_("E521: Number required: &%s = '%s'"),
9033 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009034 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009035
9036 }
9037 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009038 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009039 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009040 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009041 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009042 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009043 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009044 }
9045 }
9046 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009047 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009048}
9049
9050/*
9051 * Get the terminal code for a terminal option.
9052 * Returns NULL when not found.
9053 */
9054 char_u *
9055get_term_code(tname)
9056 char_u *tname;
9057{
9058 int opt_idx;
9059 char_u *varp;
9060
9061 if (tname[0] != 't' || tname[1] != '_' ||
9062 tname[2] == NUL || tname[3] == NUL)
9063 return NULL;
9064 if ((opt_idx = findoption(tname)) >= 0)
9065 {
9066 varp = get_varp(&(options[opt_idx]));
9067 if (varp != NULL)
9068 varp = *(char_u **)(varp);
9069 return varp;
9070 }
9071 return find_termcode(tname + 2);
9072}
9073
9074 char_u *
9075get_highlight_default()
9076{
9077 int i;
9078
9079 i = findoption((char_u *)"hl");
9080 if (i >= 0)
9081 return options[i].def_val[VI_DEFAULT];
9082 return (char_u *)NULL;
9083}
9084
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009085#if defined(FEAT_MBYTE) || defined(PROTO)
9086 char_u *
9087get_encoding_default()
9088{
9089 int i;
9090
9091 i = findoption((char_u *)"enc");
9092 if (i >= 0)
9093 return options[i].def_val[VI_DEFAULT];
9094 return (char_u *)NULL;
9095}
9096#endif
9097
Bram Moolenaar071d4272004-06-13 20:20:40 +00009098/*
9099 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9100 */
9101 static int
9102find_key_option(arg)
9103 char_u *arg;
9104{
9105 int key;
9106 int modifiers;
9107
9108 /*
9109 * Don't use get_special_key_code() for t_xx, we don't want it to call
9110 * add_termcap_entry().
9111 */
9112 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9113 key = TERMCAP2KEY(arg[2], arg[3]);
9114 else
9115 {
9116 --arg; /* put arg at the '<' */
9117 modifiers = 0;
Bram Moolenaar2a8ced02008-12-24 11:54:31 +00009118 key = find_special_key(&arg, &modifiers, TRUE, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009119 if (modifiers) /* can't handle modifiers here */
9120 key = 0;
9121 }
9122 return key;
9123}
9124
9125/*
9126 * if 'all' == 0: show changed options
9127 * if 'all' == 1: show all normal options
9128 * if 'all' == 2: show all terminal options
9129 */
9130 static void
9131showoptions(all, opt_flags)
9132 int all;
9133 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
9134{
9135 struct vimoption *p;
9136 int col;
9137 int isterm;
9138 char_u *varp;
9139 struct vimoption **items;
9140 int item_count;
9141 int run;
9142 int row, rows;
9143 int cols;
9144 int i;
9145 int len;
9146
9147#define INC 20
9148#define GAP 3
9149
9150 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9151 PARAM_COUNT));
9152 if (items == NULL)
9153 return;
9154
9155 /* Highlight title */
9156 if (all == 2)
9157 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9158 else if (opt_flags & OPT_GLOBAL)
9159 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9160 else if (opt_flags & OPT_LOCAL)
9161 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9162 else
9163 MSG_PUTS_TITLE(_("\n--- Options ---"));
9164
9165 /*
9166 * do the loop two times:
9167 * 1. display the short items
9168 * 2. display the long items (only strings and numbers)
9169 */
9170 for (run = 1; run <= 2 && !got_int; ++run)
9171 {
9172 /*
9173 * collect the items in items[]
9174 */
9175 item_count = 0;
9176 for (p = &options[0]; p->fullname != NULL; p++)
9177 {
9178 varp = NULL;
9179 isterm = istermoption(p);
9180 if (opt_flags != 0)
9181 {
9182 if (p->indir != PV_NONE && !isterm)
9183 varp = get_varp_scope(p, opt_flags);
9184 }
9185 else
9186 varp = get_varp(p);
9187 if (varp != NULL
9188 && ((all == 2 && isterm)
9189 || (all == 1 && !isterm)
9190 || (all == 0 && !optval_default(p, varp))))
9191 {
9192 if (p->flags & P_BOOL)
9193 len = 1; /* a toggle option fits always */
9194 else
9195 {
9196 option_value2string(p, opt_flags);
9197 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9198 }
9199 if ((len <= INC - GAP && run == 1) ||
9200 (len > INC - GAP && run == 2))
9201 items[item_count++] = p;
9202 }
9203 }
9204
9205 /*
9206 * display the items
9207 */
9208 if (run == 1)
9209 {
9210 cols = (Columns + GAP - 3) / INC;
9211 if (cols == 0)
9212 cols = 1;
9213 rows = (item_count + cols - 1) / cols;
9214 }
9215 else /* run == 2 */
9216 rows = item_count;
9217 for (row = 0; row < rows && !got_int; ++row)
9218 {
9219 msg_putchar('\n'); /* go to next line */
9220 if (got_int) /* 'q' typed in more */
9221 break;
9222 col = 0;
9223 for (i = row; i < item_count; i += rows)
9224 {
9225 msg_col = col; /* make columns */
9226 showoneopt(items[i], opt_flags);
9227 col += INC;
9228 }
9229 out_flush();
9230 ui_breakcheck();
9231 }
9232 }
9233 vim_free(items);
9234}
9235
9236/*
9237 * Return TRUE if option "p" has its default value.
9238 */
9239 static int
9240optval_default(p, varp)
9241 struct vimoption *p;
9242 char_u *varp;
9243{
9244 int dvi;
9245
9246 if (varp == NULL)
9247 return TRUE; /* hidden option is always at default */
9248 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9249 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009250 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009251 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009252 /* the cast to long is required for Manx C, long_i is
9253 * needed for MSVC */
9254 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009255 /* P_STRING */
9256 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9257}
9258
9259/*
9260 * showoneopt: show the value of one option
9261 * must not be called with a hidden option!
9262 */
9263 static void
9264showoneopt(p, opt_flags)
9265 struct vimoption *p;
9266 int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */
9267{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009268 char_u *varp;
9269 int save_silent = silent_mode;
9270
9271 silent_mode = FALSE;
9272 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009273
9274 varp = get_varp_scope(p, opt_flags);
9275
9276 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9277 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9278 ? !curbufIsChanged() : !*(int *)varp))
9279 MSG_PUTS("no");
9280 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9281 MSG_PUTS("--");
9282 else
9283 MSG_PUTS(" ");
9284 MSG_PUTS(p->fullname);
9285 if (!(p->flags & P_BOOL))
9286 {
9287 msg_putchar('=');
9288 /* put value string in NameBuff */
9289 option_value2string(p, opt_flags);
9290 msg_outtrans(NameBuff);
9291 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009292
9293 silent_mode = save_silent;
9294 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009295}
9296
9297/*
9298 * Write modified options as ":set" commands to a file.
9299 *
9300 * There are three values for "opt_flags":
9301 * OPT_GLOBAL: Write global option values and fresh values of
9302 * buffer-local options (used for start of a session
9303 * file).
9304 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
9305 * curwin (used for a vimrc file).
9306 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
9307 * and local values for window-local options of
9308 * curwin. Local values are also written when at the
9309 * default value, because a modeline or autocommand
9310 * may have set them when doing ":edit file" and the
9311 * user has set them back at the default or fresh
9312 * value.
9313 * When "local_only" is TRUE, don't write fresh
9314 * values, only local values (for ":mkview").
9315 * (fresh value = value used for a new buffer or window for a local option).
9316 *
9317 * Return FAIL on error, OK otherwise.
9318 */
9319 int
9320makeset(fd, opt_flags, local_only)
9321 FILE *fd;
9322 int opt_flags;
9323 int local_only;
9324{
9325 struct vimoption *p;
9326 char_u *varp; /* currently used value */
9327 char_u *varp_fresh; /* local value */
9328 char_u *varp_local = NULL; /* fresh value */
9329 char *cmd;
9330 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009331 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009332
9333 /*
9334 * The options that don't have a default (terminal name, columns, lines)
9335 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009336 * Do the loop over "options[]" twice: once for options with the
9337 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009338 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009339 for (pri = 1; pri >= 0; --pri)
9340 {
9341 for (p = &options[0]; !istermoption(p); p++)
9342 if (!(p->flags & P_NO_MKRC)
9343 && !istermoption(p)
9344 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009345 {
9346 /* skip global option when only doing locals */
9347 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
9348 continue;
9349
9350 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
9351 * file, they are always buffer-specific. */
9352 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
9353 continue;
9354
9355 /* Global values are only written when not at the default value. */
9356 varp = get_varp_scope(p, opt_flags);
9357 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
9358 continue;
9359
9360 round = 2;
9361 if (p->indir != PV_NONE)
9362 {
9363 if (p->var == VAR_WIN)
9364 {
9365 /* skip window-local option when only doing globals */
9366 if (!(opt_flags & OPT_LOCAL))
9367 continue;
9368 /* When fresh value of window-local option is not at the
9369 * default, need to write it too. */
9370 if (!(opt_flags & OPT_GLOBAL) && !local_only)
9371 {
9372 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
9373 if (!optval_default(p, varp_fresh))
9374 {
9375 round = 1;
9376 varp_local = varp;
9377 varp = varp_fresh;
9378 }
9379 }
9380 }
9381 }
9382
9383 /* Round 1: fresh value for window-local options.
9384 * Round 2: other values */
9385 for ( ; round <= 2; varp = varp_local, ++round)
9386 {
9387 if (round == 1 || (opt_flags & OPT_GLOBAL))
9388 cmd = "set";
9389 else
9390 cmd = "setlocal";
9391
9392 if (p->flags & P_BOOL)
9393 {
9394 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
9395 return FAIL;
9396 }
9397 else if (p->flags & P_NUM)
9398 {
9399 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
9400 return FAIL;
9401 }
9402 else /* P_STRING */
9403 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009404#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9405 int do_endif = FALSE;
9406
Bram Moolenaar071d4272004-06-13 20:20:40 +00009407 /* Don't set 'syntax' and 'filetype' again if the value is
9408 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009409 if (
9410# if defined(FEAT_SYN_HL)
9411 p->indir == PV_SYN
9412# if defined(FEAT_AUTOCMD)
9413 ||
9414# endif
9415# endif
9416# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009417 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009418# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009419 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00009420 {
9421 if (fprintf(fd, "if &%s != '%s'", p->fullname,
9422 *(char_u **)(varp)) < 0
9423 || put_eol(fd) < 0)
9424 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009425 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009426 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009427#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009428 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
9429 (p->flags & P_EXPAND) != 0) == FAIL)
9430 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009431#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9432 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009433 {
9434 if (put_line(fd, "endif") == FAIL)
9435 return FAIL;
9436 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009437#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009438 }
9439 }
9440 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009441 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009442 return OK;
9443}
9444
9445#if defined(FEAT_FOLDING) || defined(PROTO)
9446/*
9447 * Generate set commands for the local fold options only. Used when
9448 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
9449 */
9450 int
9451makefoldset(fd)
9452 FILE *fd;
9453{
9454 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
9455# ifdef FEAT_EVAL
9456 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
9457 == FAIL
9458# endif
9459 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
9460 == FAIL
9461 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
9462 == FAIL
9463 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
9464 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
9465 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
9466 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
9467 )
9468 return FAIL;
9469
9470 return OK;
9471}
9472#endif
9473
9474 static int
9475put_setstring(fd, cmd, name, valuep, expand)
9476 FILE *fd;
9477 char *cmd;
9478 char *name;
9479 char_u **valuep;
9480 int expand;
9481{
9482 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009483 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009484
9485 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9486 return FAIL;
9487 if (*valuep != NULL)
9488 {
9489 /* Output 'pastetoggle' as key names. For other
9490 * options some characters have to be escaped with
9491 * CTRL-V or backslash */
9492 if (valuep == &p_pt)
9493 {
9494 s = *valuep;
9495 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +00009496 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009497 return FAIL;
9498 }
9499 else if (expand)
9500 {
Bram Moolenaarf8441472011-04-28 17:24:58 +02009501 buf = alloc(MAXPATHL);
9502 if (buf == NULL)
9503 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009504 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
9505 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +02009506 {
9507 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009508 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009509 }
9510 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009511 }
9512 else if (put_escstr(fd, *valuep, 2) == FAIL)
9513 return FAIL;
9514 }
9515 if (put_eol(fd) < 0)
9516 return FAIL;
9517 return OK;
9518}
9519
9520 static int
9521put_setnum(fd, cmd, name, valuep)
9522 FILE *fd;
9523 char *cmd;
9524 char *name;
9525 long *valuep;
9526{
9527 long wc;
9528
9529 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9530 return FAIL;
9531 if (wc_use_keyname((char_u *)valuep, &wc))
9532 {
9533 /* print 'wildchar' and 'wildcharm' as a key name */
9534 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
9535 return FAIL;
9536 }
9537 else if (fprintf(fd, "%ld", *valuep) < 0)
9538 return FAIL;
9539 if (put_eol(fd) < 0)
9540 return FAIL;
9541 return OK;
9542}
9543
9544 static int
9545put_setbool(fd, cmd, name, value)
9546 FILE *fd;
9547 char *cmd;
9548 char *name;
9549 int value;
9550{
Bram Moolenaar893de922007-10-02 18:40:57 +00009551 if (value < 0) /* global/local option using global value */
9552 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009553 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
9554 || put_eol(fd) < 0)
9555 return FAIL;
9556 return OK;
9557}
9558
9559/*
9560 * Clear all the terminal options.
9561 * If the option has been allocated, free the memory.
9562 * Terminal options are never hidden or indirect.
9563 */
9564 void
9565clear_termoptions()
9566{
Bram Moolenaar071d4272004-06-13 20:20:40 +00009567 /*
9568 * Reset a few things before clearing the old options. This may cause
9569 * outputting a few things that the terminal doesn't understand, but the
9570 * screen will be cleared later, so this is OK.
9571 */
9572#ifdef FEAT_MOUSE_TTY
9573 mch_setmouse(FALSE); /* switch mouse off */
9574#endif
9575#ifdef FEAT_TITLE
9576 mch_restore_title(3); /* restore window titles */
9577#endif
9578#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
9579 /* When starting the GUI close the display opened for the clipboard.
9580 * After restoring the title, because that will need the display. */
9581 if (gui.starting)
9582 clear_xterm_clip();
9583#endif
9584#ifdef WIN3264
9585 /*
9586 * Check if this is allowed now.
9587 */
9588 if (can_end_termcap_mode(FALSE) == TRUE)
9589#endif
9590 stoptermcap(); /* stop termcap mode */
9591
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00009592 free_termoptions();
9593}
9594
9595 void
9596free_termoptions()
9597{
9598 struct vimoption *p;
9599
Bram Moolenaar071d4272004-06-13 20:20:40 +00009600 for (p = &options[0]; p->fullname != NULL; p++)
9601 if (istermoption(p))
9602 {
9603 if (p->flags & P_ALLOCED)
9604 free_string_option(*(char_u **)(p->var));
9605 if (p->flags & P_DEF_ALLOCED)
9606 free_string_option(p->def_val[VI_DEFAULT]);
9607 *(char_u **)(p->var) = empty_option;
9608 p->def_val[VI_DEFAULT] = empty_option;
9609 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
9610 }
9611 clear_termcodes();
9612}
9613
9614/*
Bram Moolenaar363cb672009-07-22 12:28:17 +00009615 * Free the string for one term option, if it was allocated.
9616 * Set the string to empty_option and clear allocated flag.
9617 * "var" points to the option value.
9618 */
9619 void
9620free_one_termoption(var)
9621 char_u *var;
9622{
9623 struct vimoption *p;
9624
9625 for (p = &options[0]; p->fullname != NULL; p++)
9626 if (p->var == var)
9627 {
9628 if (p->flags & P_ALLOCED)
9629 free_string_option(*(char_u **)(p->var));
9630 *(char_u **)(p->var) = empty_option;
9631 p->flags &= ~P_ALLOCED;
9632 break;
9633 }
9634}
9635
9636/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00009637 * Set the terminal option defaults to the current value.
9638 * Used after setting the terminal name.
9639 */
9640 void
9641set_term_defaults()
9642{
9643 struct vimoption *p;
9644
9645 for (p = &options[0]; p->fullname != NULL; p++)
9646 {
9647 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
9648 {
9649 if (p->flags & P_DEF_ALLOCED)
9650 {
9651 free_string_option(p->def_val[VI_DEFAULT]);
9652 p->flags &= ~P_DEF_ALLOCED;
9653 }
9654 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
9655 if (p->flags & P_ALLOCED)
9656 {
9657 p->flags |= P_DEF_ALLOCED;
9658 p->flags &= ~P_ALLOCED; /* don't free the value now */
9659 }
9660 }
9661 }
9662}
9663
9664/*
9665 * return TRUE if 'p' starts with 't_'
9666 */
9667 static int
9668istermoption(p)
9669 struct vimoption *p;
9670{
9671 return (p->fullname[0] == 't' && p->fullname[1] == '_');
9672}
9673
9674/*
9675 * Compute columns for ruler and shown command. 'sc_col' is also used to
9676 * decide what the maximum length of a message on the status line can be.
9677 * If there is a status line for the last window, 'sc_col' is independent
9678 * of 'ru_col'.
9679 */
9680
9681#define COL_RULER 17 /* columns needed by standard ruler */
9682
9683 void
9684comp_col()
9685{
9686#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
9687 int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin));
9688
9689 sc_col = 0;
9690 ru_col = 0;
9691 if (p_ru)
9692 {
9693#ifdef FEAT_STL_OPT
9694 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
9695#else
9696 ru_col = COL_RULER + 1;
9697#endif
9698 /* no last status line, adjust sc_col */
9699 if (!last_has_status)
9700 sc_col = ru_col;
9701 }
9702 if (p_sc)
9703 {
9704 sc_col += SHOWCMD_COLS;
9705 if (!p_ru || last_has_status) /* no need for separating space */
9706 ++sc_col;
9707 }
9708 sc_col = Columns - sc_col;
9709 ru_col = Columns - ru_col;
9710 if (sc_col <= 0) /* screen too narrow, will become a mess */
9711 sc_col = 1;
9712 if (ru_col <= 0)
9713 ru_col = 1;
9714#else
9715 sc_col = Columns;
9716 ru_col = Columns;
9717#endif
9718}
9719
9720/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009721 * Unset local option value, similar to ":set opt<".
9722 */
9723
9724 void
9725unset_global_local_option(name, from)
9726 char_u *name;
9727 void *from;
9728{
9729 struct vimoption *p;
9730 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009731 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009732
9733 opt_idx = findoption(name);
9734 p = &(options[opt_idx]);
9735
9736 switch ((int)p->indir)
9737 {
9738 /* global option with local value: use local value if it's been set */
9739 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009740 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009741 break;
9742 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009743 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009744 break;
9745 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009746 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009747 break;
9748 case PV_AR:
9749 buf->b_p_ar = -1;
9750 break;
9751 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009752 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009753 break;
9754#ifdef FEAT_FIND_ID
9755 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009756 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009757 break;
9758 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009759 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009760 break;
9761#endif
9762#ifdef FEAT_INS_EXPAND
9763 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009764 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009765 break;
9766 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009767 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009768 break;
9769#endif
9770#ifdef FEAT_QUICKFIX
9771 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009772 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009773 break;
9774 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009775 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009776 break;
9777 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009778 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009779 break;
9780#endif
9781#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9782 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009783 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009784 break;
9785#endif
9786#if defined(FEAT_CRYPT)
9787 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009788 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009789 break;
9790#endif
9791#ifdef FEAT_STL_OPT
9792 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009793 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009794 break;
9795#endif
9796 }
9797}
9798
9799/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00009800 * Get pointer to option variable, depending on local or global scope.
9801 */
9802 static char_u *
9803get_varp_scope(p, opt_flags)
9804 struct vimoption *p;
9805 int opt_flags;
9806{
9807 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
9808 {
9809 if (p->var == VAR_WIN)
9810 return (char_u *)GLOBAL_WO(get_varp(p));
9811 return p->var;
9812 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +00009813 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009814 {
9815 switch ((int)p->indir)
9816 {
9817#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009818 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
9819 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
9820 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009821#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009822 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
9823 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
9824 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +00009825 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009826 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009827#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009828 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
9829 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009830#endif
9831#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009832 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
9833 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009834#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00009835#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9836 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
9837#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02009838#if defined(FEAT_CRYPT)
9839 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
9840#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009841#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009842 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009843#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009844 }
9845 return NULL; /* "cannot happen" */
9846 }
9847 return get_varp(p);
9848}
9849
9850/*
9851 * Get pointer to option variable.
9852 */
9853 static char_u *
9854get_varp(p)
9855 struct vimoption *p;
9856{
9857 /* hidden option, always return NULL */
9858 if (p->var == NULL)
9859 return NULL;
9860
9861 switch ((int)p->indir)
9862 {
9863 case PV_NONE: return p->var;
9864
9865 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009866 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009867 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009868 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009869 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009870 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009871 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +00009872 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00009873 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009874 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009875 ? (char_u *)&(curbuf->b_p_tags) : p->var;
9876#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009877 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009878 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009879 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009880 ? (char_u *)&(curbuf->b_p_inc) : p->var;
9881#endif
9882#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009883 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009884 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009885 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009886 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
9887#endif
9888#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009889 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009890 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009891 case PV_GP: return *curbuf->b_p_gp != NUL
9892 ? (char_u *)&(curbuf->b_p_gp) : p->var;
9893 case PV_MP: return *curbuf->b_p_mp != NUL
9894 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009895#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00009896#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9897 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
9898 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
9899#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02009900#if defined(FEAT_CRYPT)
9901 case PV_CM: return *curbuf->b_p_cm != NUL
9902 ? (char_u *)&(curbuf->b_p_cm) : p->var;
9903#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009904#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009905 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009906 ? (char_u *)&(curwin->w_p_stl) : p->var;
9907#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009908
9909#ifdef FEAT_ARABIC
9910 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
9911#endif
9912 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00009913#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00009914 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
9915#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00009916#ifdef FEAT_SYN_HL
9917 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
9918 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +02009919 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00009920#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009921#ifdef FEAT_DIFF
9922 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
9923#endif
9924#ifdef FEAT_FOLDING
9925 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
9926 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
9927 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
9928 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
9929 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
9930 case PV_FML: return (char_u *)&(curwin->w_p_fml);
9931 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
9932# ifdef FEAT_EVAL
9933 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
9934 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
9935# endif
9936 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
9937#endif
9938 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +02009939 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009940#ifdef FEAT_LINEBREAK
9941 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
9942#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009943#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00009944 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
9945#endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00009946#ifdef FEAT_VERTSPLIT
9947 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
9948#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009949#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
9950 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
9951#endif
9952#ifdef FEAT_RIGHTLEFT
9953 case PV_RL: return (char_u *)&(curwin->w_p_rl);
9954 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
9955#endif
9956 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
9957 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
9958#ifdef FEAT_LINEBREAK
9959 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
9960#endif
9961#ifdef FEAT_SCROLLBIND
9962 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
9963#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +02009964#ifdef FEAT_CURSORBIND
9965 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
9966#endif
9967#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009968 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
9969 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
Bram Moolenaar860cae12010-06-05 23:22:07 +02009970#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009971
9972 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
9973 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
9974#ifdef FEAT_MBYTE
9975 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
9976#endif
9977#if defined(FEAT_QUICKFIX)
9978 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
9979 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
9980#endif
9981 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
9982 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
9983#ifdef FEAT_CINDENT
9984 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
9985 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
9986 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
9987#endif
9988#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
9989 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
9990#endif
9991#ifdef FEAT_COMMENTS
9992 case PV_COM: return (char_u *)&(curbuf->b_p_com);
9993#endif
9994#ifdef FEAT_FOLDING
9995 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
9996#endif
9997#ifdef FEAT_INS_EXPAND
9998 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
9999#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010000#ifdef FEAT_COMPL_FUNC
10001 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010002 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010003#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010004 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
10005 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10006#ifdef FEAT_MBYTE
10007 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10008#endif
10009 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10010#ifdef FEAT_AUTOCMD
10011 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10012#endif
10013 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010014 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010015 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10016 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10017 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10018 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10019#ifdef FEAT_FIND_ID
10020# ifdef FEAT_EVAL
10021 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10022# endif
10023#endif
10024#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10025 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10026 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10027#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010028#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010029 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10030#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010031#ifdef FEAT_CRYPT
10032 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10033#endif
10034#ifdef FEAT_LISP
10035 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10036#endif
10037 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10038 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10039 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10040 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10041 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010042 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010043#ifdef FEAT_TEXTOBJ
10044 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10045#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010046 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10047#ifdef FEAT_SMARTINDENT
10048 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10049#endif
10050#ifndef SHORT_FNAME
10051 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
10052#endif
10053 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10054#ifdef FEAT_SEARCHPATH
10055 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10056#endif
10057 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10058#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010059 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010060 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10061#endif
10062#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010063 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10064 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10065 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010066#endif
10067 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10068 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10069 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10070 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010071#ifdef FEAT_PERSISTENT_UNDO
10072 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10073#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010074 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10075#ifdef FEAT_KEYMAP
10076 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10077#endif
10078 default: EMSG(_("E356: get_varp ERROR"));
10079 }
10080 /* always return a valid pointer to avoid a crash! */
10081 return (char_u *)&(curbuf->b_p_wm);
10082}
10083
10084/*
10085 * Get the value of 'equalprg', either the buffer-local one or the global one.
10086 */
10087 char_u *
10088get_equalprg()
10089{
10090 if (*curbuf->b_p_ep == NUL)
10091 return p_ep;
10092 return curbuf->b_p_ep;
10093}
10094
10095#if defined(FEAT_WINDOWS) || defined(PROTO)
10096/*
10097 * Copy options from one window to another.
10098 * Used when splitting a window.
10099 */
10100 void
10101win_copy_options(wp_from, wp_to)
10102 win_T *wp_from;
10103 win_T *wp_to;
10104{
10105 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10106 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10107# ifdef FEAT_RIGHTLEFT
10108# ifdef FEAT_FKMAP
10109 /* Is this right? */
10110 wp_to->w_farsi = wp_from->w_farsi;
10111# endif
10112# endif
10113}
10114#endif
10115
10116/*
10117 * Copy the options from one winopt_T to another.
10118 * Doesn't free the old option values in "to", use clear_winopt() for that.
10119 * The 'scroll' option is not copied, because it depends on the window height.
10120 * The 'previewwindow' option is reset, there can be only one preview window.
10121 */
10122 void
10123copy_winopt(from, to)
10124 winopt_T *from;
10125 winopt_T *to;
10126{
10127#ifdef FEAT_ARABIC
10128 to->wo_arab = from->wo_arab;
10129#endif
10130 to->wo_list = from->wo_list;
10131 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010132 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010133#ifdef FEAT_LINEBREAK
10134 to->wo_nuw = from->wo_nuw;
10135#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010136#ifdef FEAT_RIGHTLEFT
10137 to->wo_rl = from->wo_rl;
10138 to->wo_rlc = vim_strsave(from->wo_rlc);
10139#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010140#ifdef FEAT_STL_OPT
10141 to->wo_stl = vim_strsave(from->wo_stl);
10142#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010143 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010144#ifdef FEAT_DIFF
10145 to->wo_wrap_save = from->wo_wrap_save;
10146#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010147#ifdef FEAT_LINEBREAK
10148 to->wo_lbr = from->wo_lbr;
10149#endif
10150#ifdef FEAT_SCROLLBIND
10151 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010152 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010153#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010154#ifdef FEAT_CURSORBIND
10155 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010156 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010157#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010158#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010159 to->wo_spell = from->wo_spell;
10160#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010161#ifdef FEAT_SYN_HL
10162 to->wo_cuc = from->wo_cuc;
10163 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010164 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010165#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010166#ifdef FEAT_DIFF
10167 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010168 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010169#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010170#ifdef FEAT_CONCEAL
10171 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010172 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010173#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010174#ifdef FEAT_FOLDING
10175 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010176 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010177 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010178 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010179 to->wo_fdi = vim_strsave(from->wo_fdi);
10180 to->wo_fml = from->wo_fml;
10181 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010182 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010183 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010184 to->wo_fdm_save = from->wo_diff_saved
10185 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010186 to->wo_fdn = from->wo_fdn;
10187# ifdef FEAT_EVAL
10188 to->wo_fde = vim_strsave(from->wo_fde);
10189 to->wo_fdt = vim_strsave(from->wo_fdt);
10190# endif
10191 to->wo_fmr = vim_strsave(from->wo_fmr);
10192#endif
10193 check_winopt(to); /* don't want NULL pointers */
10194}
10195
10196/*
10197 * Check string options in a window for a NULL value.
10198 */
10199 void
10200check_win_options(win)
10201 win_T *win;
10202{
10203 check_winopt(&win->w_onebuf_opt);
10204 check_winopt(&win->w_allbuf_opt);
10205}
10206
10207/*
10208 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10209 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010210 void
10211check_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010212 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010213{
10214#ifdef FEAT_FOLDING
10215 check_string_option(&wop->wo_fdi);
10216 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010217 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010218# ifdef FEAT_EVAL
10219 check_string_option(&wop->wo_fde);
10220 check_string_option(&wop->wo_fdt);
10221# endif
10222 check_string_option(&wop->wo_fmr);
10223#endif
10224#ifdef FEAT_RIGHTLEFT
10225 check_string_option(&wop->wo_rlc);
10226#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010227#ifdef FEAT_STL_OPT
10228 check_string_option(&wop->wo_stl);
10229#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010230#ifdef FEAT_SYN_HL
10231 check_string_option(&wop->wo_cc);
10232#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010233#ifdef FEAT_CONCEAL
10234 check_string_option(&wop->wo_cocu);
10235#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010236}
10237
10238/*
10239 * Free the allocated memory inside a winopt_T.
10240 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010241 void
10242clear_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010243 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010244{
10245#ifdef FEAT_FOLDING
10246 clear_string_option(&wop->wo_fdi);
10247 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010248 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010249# ifdef FEAT_EVAL
10250 clear_string_option(&wop->wo_fde);
10251 clear_string_option(&wop->wo_fdt);
10252# endif
10253 clear_string_option(&wop->wo_fmr);
10254#endif
10255#ifdef FEAT_RIGHTLEFT
10256 clear_string_option(&wop->wo_rlc);
10257#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010258#ifdef FEAT_STL_OPT
10259 clear_string_option(&wop->wo_stl);
10260#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010261#ifdef FEAT_SYN_HL
10262 clear_string_option(&wop->wo_cc);
10263#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010264#ifdef FEAT_CONCEAL
10265 clear_string_option(&wop->wo_cocu);
10266#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010267}
10268
10269/*
10270 * Copy global option values to local options for one buffer.
10271 * Used when creating a new buffer and sometimes when entering a buffer.
10272 * flags:
10273 * BCO_ENTER We will enter the buf buffer.
10274 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
10275 * appropriate.
10276 * BCO_NOHELP Don't copy the values to a help buffer.
10277 */
10278 void
10279buf_copy_options(buf, flags)
10280 buf_T *buf;
10281 int flags;
10282{
10283 int should_copy = TRUE;
10284 char_u *save_p_isk = NULL; /* init for GCC */
10285 int dont_do_help;
10286 int did_isk = FALSE;
10287
10288 /*
Bram Moolenaar1a384422010-07-14 19:53:30 +020010289 * Don't do anything if the buffer is invalid.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010290 */
10291 if (buf == NULL || !buf_valid(buf))
10292 return;
10293
10294 /*
10295 * Skip this when the option defaults have not been set yet. Happens when
10296 * main() allocates the first buffer.
10297 */
10298 if (p_cpo != NULL)
10299 {
10300 /*
10301 * Always copy when entering and 'cpo' contains 'S'.
10302 * Don't copy when already initialized.
10303 * Don't copy when 'cpo' contains 's' and not entering.
10304 * 'S' BCO_ENTER initialized 's' should_copy
10305 * yes yes X X TRUE
10306 * yes no yes X FALSE
10307 * no X yes X FALSE
10308 * X no no yes FALSE
10309 * X no no no TRUE
10310 * no yes no X TRUE
10311 */
10312 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
10313 && (buf->b_p_initialized
10314 || (!(flags & BCO_ENTER)
10315 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
10316 should_copy = FALSE;
10317
10318 if (should_copy || (flags & BCO_ALWAYS))
10319 {
10320 /* Don't copy the options specific to a help buffer when
10321 * BCO_NOHELP is given or the options were initialized already
10322 * (jumping back to a help file with CTRL-T or CTRL-O) */
10323 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
10324 || buf->b_p_initialized;
10325 if (dont_do_help) /* don't free b_p_isk */
10326 {
10327 save_p_isk = buf->b_p_isk;
10328 buf->b_p_isk = NULL;
10329 }
10330 /*
10331 * Always free the allocated strings.
10332 * If not already initialized, set 'readonly' and copy 'fileformat'.
10333 */
10334 if (!buf->b_p_initialized)
10335 {
10336 free_buf_options(buf, TRUE);
10337 buf->b_p_ro = FALSE; /* don't copy readonly */
10338 buf->b_p_tx = p_tx;
10339#ifdef FEAT_MBYTE
10340 buf->b_p_fenc = vim_strsave(p_fenc);
10341#endif
10342 buf->b_p_ff = vim_strsave(p_ff);
10343#if defined(FEAT_QUICKFIX)
10344 buf->b_p_bh = empty_option;
10345 buf->b_p_bt = empty_option;
10346#endif
10347 }
10348 else
10349 free_buf_options(buf, FALSE);
10350
10351 buf->b_p_ai = p_ai;
10352 buf->b_p_ai_nopaste = p_ai_nopaste;
10353 buf->b_p_sw = p_sw;
10354 buf->b_p_tw = p_tw;
10355 buf->b_p_tw_nopaste = p_tw_nopaste;
10356 buf->b_p_tw_nobin = p_tw_nobin;
10357 buf->b_p_wm = p_wm;
10358 buf->b_p_wm_nopaste = p_wm_nopaste;
10359 buf->b_p_wm_nobin = p_wm_nobin;
10360 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000010361#ifdef FEAT_MBYTE
10362 buf->b_p_bomb = p_bomb;
10363#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010364 buf->b_p_et = p_et;
10365 buf->b_p_et_nobin = p_et_nobin;
10366 buf->b_p_ml = p_ml;
10367 buf->b_p_ml_nobin = p_ml_nobin;
10368 buf->b_p_inf = p_inf;
10369 buf->b_p_swf = p_swf;
10370#ifdef FEAT_INS_EXPAND
10371 buf->b_p_cpt = vim_strsave(p_cpt);
10372#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010373#ifdef FEAT_COMPL_FUNC
10374 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010375 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010376#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010377 buf->b_p_sts = p_sts;
10378 buf->b_p_sts_nopaste = p_sts_nopaste;
10379#ifndef SHORT_FNAME
10380 buf->b_p_sn = p_sn;
10381#endif
10382#ifdef FEAT_COMMENTS
10383 buf->b_p_com = vim_strsave(p_com);
10384#endif
10385#ifdef FEAT_FOLDING
10386 buf->b_p_cms = vim_strsave(p_cms);
10387#endif
10388 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010389 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010390 buf->b_p_nf = vim_strsave(p_nf);
10391 buf->b_p_mps = vim_strsave(p_mps);
10392#ifdef FEAT_SMARTINDENT
10393 buf->b_p_si = p_si;
10394#endif
10395 buf->b_p_ci = p_ci;
10396#ifdef FEAT_CINDENT
10397 buf->b_p_cin = p_cin;
10398 buf->b_p_cink = vim_strsave(p_cink);
10399 buf->b_p_cino = vim_strsave(p_cino);
10400#endif
10401#ifdef FEAT_AUTOCMD
10402 /* Don't copy 'filetype', it must be detected */
10403 buf->b_p_ft = empty_option;
10404#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010405 buf->b_p_pi = p_pi;
10406#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10407 buf->b_p_cinw = vim_strsave(p_cinw);
10408#endif
10409#ifdef FEAT_LISP
10410 buf->b_p_lisp = p_lisp;
10411#endif
10412#ifdef FEAT_SYN_HL
10413 /* Don't copy 'syntax', it must be set */
10414 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010415 buf->b_p_smc = p_smc;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010416#endif
10417#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020010418 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010419 (void)compile_cap_prog(&buf->b_s);
10420 buf->b_s.b_p_spf = vim_strsave(p_spf);
10421 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010422#endif
10423#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10424 buf->b_p_inde = vim_strsave(p_inde);
10425 buf->b_p_indk = vim_strsave(p_indk);
10426#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010427#if defined(FEAT_EVAL)
10428 buf->b_p_fex = vim_strsave(p_fex);
10429#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010430#ifdef FEAT_CRYPT
10431 buf->b_p_key = vim_strsave(p_key);
10432#endif
10433#ifdef FEAT_SEARCHPATH
10434 buf->b_p_sua = vim_strsave(p_sua);
10435#endif
10436#ifdef FEAT_KEYMAP
10437 buf->b_p_keymap = vim_strsave(p_keymap);
10438 buf->b_kmap_state |= KEYMAP_INIT;
10439#endif
10440 /* This isn't really an option, but copying the langmap and IME
10441 * state from the current buffer is better than resetting it. */
10442 buf->b_p_iminsert = p_iminsert;
10443 buf->b_p_imsearch = p_imsearch;
10444
10445 /* options that are normally global but also have a local value
10446 * are not copied, start using the global value */
10447 buf->b_p_ar = -1;
10448#ifdef FEAT_QUICKFIX
10449 buf->b_p_gp = empty_option;
10450 buf->b_p_mp = empty_option;
10451 buf->b_p_efm = empty_option;
10452#endif
10453 buf->b_p_ep = empty_option;
10454 buf->b_p_kp = empty_option;
10455 buf->b_p_path = empty_option;
10456 buf->b_p_tags = empty_option;
10457#ifdef FEAT_FIND_ID
10458 buf->b_p_def = empty_option;
10459 buf->b_p_inc = empty_option;
10460# ifdef FEAT_EVAL
10461 buf->b_p_inex = vim_strsave(p_inex);
10462# endif
10463#endif
10464#ifdef FEAT_INS_EXPAND
10465 buf->b_p_dict = empty_option;
10466 buf->b_p_tsr = empty_option;
10467#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010468#ifdef FEAT_TEXTOBJ
10469 buf->b_p_qe = vim_strsave(p_qe);
10470#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010471#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10472 buf->b_p_bexpr = empty_option;
10473#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010474#if defined(FEAT_CRYPT)
10475 buf->b_p_cm = empty_option;
10476#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010477#ifdef FEAT_PERSISTENT_UNDO
10478 buf->b_p_udf = p_udf;
10479#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010480
10481 /*
10482 * Don't copy the options set by ex_help(), use the saved values,
10483 * when going from a help buffer to a non-help buffer.
10484 * Don't touch these at all when BCO_NOHELP is used and going from
10485 * or to a help buffer.
10486 */
10487 if (dont_do_help)
10488 buf->b_p_isk = save_p_isk;
10489 else
10490 {
10491 buf->b_p_isk = vim_strsave(p_isk);
10492 did_isk = TRUE;
10493 buf->b_p_ts = p_ts;
10494 buf->b_help = FALSE;
10495#ifdef FEAT_QUICKFIX
10496 if (buf->b_p_bt[0] == 'h')
10497 clear_string_option(&buf->b_p_bt);
10498#endif
10499 buf->b_p_ma = p_ma;
10500 }
10501 }
10502
10503 /*
10504 * When the options should be copied (ignoring BCO_ALWAYS), set the
10505 * flag that indicates that the options have been initialized.
10506 */
10507 if (should_copy)
10508 buf->b_p_initialized = TRUE;
10509 }
10510
10511 check_buf_options(buf); /* make sure we don't have NULLs */
10512 if (did_isk)
10513 (void)buf_init_chartab(buf, FALSE);
10514}
10515
10516/*
10517 * Reset the 'modifiable' option and its default value.
10518 */
10519 void
10520reset_modifiable()
10521{
10522 int opt_idx;
10523
10524 curbuf->b_p_ma = FALSE;
10525 p_ma = FALSE;
10526 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000010527 if (opt_idx >= 0)
10528 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010529}
10530
10531/*
10532 * Set the global value for 'iminsert' to the local value.
10533 */
10534 void
10535set_iminsert_global()
10536{
10537 p_iminsert = curbuf->b_p_iminsert;
10538}
10539
10540/*
10541 * Set the global value for 'imsearch' to the local value.
10542 */
10543 void
10544set_imsearch_global()
10545{
10546 p_imsearch = curbuf->b_p_imsearch;
10547}
10548
10549#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
10550static int expand_option_idx = -1;
10551static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
10552static int expand_option_flags = 0;
10553
10554 void
10555set_context_in_set_cmd(xp, arg, opt_flags)
10556 expand_T *xp;
10557 char_u *arg;
10558 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
10559{
10560 int nextchar;
10561 long_u flags = 0; /* init for GCC */
10562 int opt_idx = 0; /* init for GCC */
10563 char_u *p;
10564 char_u *s;
10565 int is_term_option = FALSE;
10566 int key;
10567
10568 expand_option_flags = opt_flags;
10569
10570 xp->xp_context = EXPAND_SETTINGS;
10571 if (*arg == NUL)
10572 {
10573 xp->xp_pattern = arg;
10574 return;
10575 }
10576 p = arg + STRLEN(arg) - 1;
10577 if (*p == ' ' && *(p - 1) != '\\')
10578 {
10579 xp->xp_pattern = p + 1;
10580 return;
10581 }
10582 while (p > arg)
10583 {
10584 s = p;
10585 /* count number of backslashes before ' ' or ',' */
10586 if (*p == ' ' || *p == ',')
10587 {
10588 while (s > arg && *(s - 1) == '\\')
10589 --s;
10590 }
10591 /* break at a space with an even number of backslashes */
10592 if (*p == ' ' && ((p - s) & 1) == 0)
10593 {
10594 ++p;
10595 break;
10596 }
10597 --p;
10598 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000010599 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010600 {
10601 xp->xp_context = EXPAND_BOOL_SETTINGS;
10602 p += 2;
10603 }
10604 if (STRNCMP(p, "inv", 3) == 0)
10605 {
10606 xp->xp_context = EXPAND_BOOL_SETTINGS;
10607 p += 3;
10608 }
10609 xp->xp_pattern = arg = p;
10610 if (*arg == '<')
10611 {
10612 while (*p != '>')
10613 if (*p++ == NUL) /* expand terminal option name */
10614 return;
10615 key = get_special_key_code(arg + 1);
10616 if (key == 0) /* unknown name */
10617 {
10618 xp->xp_context = EXPAND_NOTHING;
10619 return;
10620 }
10621 nextchar = *++p;
10622 is_term_option = TRUE;
10623 expand_option_name[2] = KEY2TERMCAP0(key);
10624 expand_option_name[3] = KEY2TERMCAP1(key);
10625 }
10626 else
10627 {
10628 if (p[0] == 't' && p[1] == '_')
10629 {
10630 p += 2;
10631 if (*p != NUL)
10632 ++p;
10633 if (*p == NUL)
10634 return; /* expand option name */
10635 nextchar = *++p;
10636 is_term_option = TRUE;
10637 expand_option_name[2] = p[-2];
10638 expand_option_name[3] = p[-1];
10639 }
10640 else
10641 {
10642 /* Allow * wildcard */
10643 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
10644 p++;
10645 if (*p == NUL)
10646 return;
10647 nextchar = *p;
10648 *p = NUL;
10649 opt_idx = findoption(arg);
10650 *p = nextchar;
10651 if (opt_idx == -1 || options[opt_idx].var == NULL)
10652 {
10653 xp->xp_context = EXPAND_NOTHING;
10654 return;
10655 }
10656 flags = options[opt_idx].flags;
10657 if (flags & P_BOOL)
10658 {
10659 xp->xp_context = EXPAND_NOTHING;
10660 return;
10661 }
10662 }
10663 }
10664 /* handle "-=" and "+=" */
10665 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
10666 {
10667 ++p;
10668 nextchar = '=';
10669 }
10670 if ((nextchar != '=' && nextchar != ':')
10671 || xp->xp_context == EXPAND_BOOL_SETTINGS)
10672 {
10673 xp->xp_context = EXPAND_UNSUCCESSFUL;
10674 return;
10675 }
10676 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
10677 {
10678 xp->xp_context = EXPAND_OLD_SETTING;
10679 if (is_term_option)
10680 expand_option_idx = -1;
10681 else
10682 expand_option_idx = opt_idx;
10683 xp->xp_pattern = p + 1;
10684 return;
10685 }
10686 xp->xp_context = EXPAND_NOTHING;
10687 if (is_term_option || (flags & P_NUM))
10688 return;
10689
10690 xp->xp_pattern = p + 1;
10691
10692 if (flags & P_EXPAND)
10693 {
10694 p = options[opt_idx].var;
10695 if (p == (char_u *)&p_bdir
10696 || p == (char_u *)&p_dir
10697 || p == (char_u *)&p_path
10698 || p == (char_u *)&p_rtp
10699#ifdef FEAT_SEARCHPATH
10700 || p == (char_u *)&p_cdpath
10701#endif
10702#ifdef FEAT_SESSION
10703 || p == (char_u *)&p_vdir
10704#endif
10705 )
10706 {
10707 xp->xp_context = EXPAND_DIRECTORIES;
10708 if (p == (char_u *)&p_path
10709#ifdef FEAT_SEARCHPATH
10710 || p == (char_u *)&p_cdpath
10711#endif
10712 )
10713 xp->xp_backslash = XP_BS_THREE;
10714 else
10715 xp->xp_backslash = XP_BS_ONE;
10716 }
10717 else
10718 {
10719 xp->xp_context = EXPAND_FILES;
10720 /* for 'tags' need three backslashes for a space */
10721 if (p == (char_u *)&p_tags)
10722 xp->xp_backslash = XP_BS_THREE;
10723 else
10724 xp->xp_backslash = XP_BS_ONE;
10725 }
10726 }
10727
10728 /* For an option that is a list of file names, find the start of the
10729 * last file name. */
10730 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
10731 {
10732 /* count number of backslashes before ' ' or ',' */
10733 if (*p == ' ' || *p == ',')
10734 {
10735 s = p;
10736 while (s > xp->xp_pattern && *(s - 1) == '\\')
10737 --s;
10738 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
10739 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
10740 {
10741 xp->xp_pattern = p + 1;
10742 break;
10743 }
10744 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000010745
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010746#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000010747 /* for 'spellsuggest' start at "file:" */
10748 if (options[opt_idx].var == (char_u *)&p_sps
10749 && STRNCMP(p, "file:", 5) == 0)
10750 {
10751 xp->xp_pattern = p + 5;
10752 break;
10753 }
10754#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010755 }
10756
10757 return;
10758}
10759
10760 int
10761ExpandSettings(xp, regmatch, num_file, file)
10762 expand_T *xp;
10763 regmatch_T *regmatch;
10764 int *num_file;
10765 char_u ***file;
10766{
10767 int num_normal = 0; /* Nr of matching non-term-code settings */
10768 int num_term = 0; /* Nr of matching terminal code settings */
10769 int opt_idx;
10770 int match;
10771 int count = 0;
10772 char_u *str;
10773 int loop;
10774 int is_term_opt;
10775 char_u name_buf[MAX_KEY_NAME_LEN];
10776 static char *(names[]) = {"all", "termcap"};
10777 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
10778
10779 /* do this loop twice:
10780 * loop == 0: count the number of matching options
10781 * loop == 1: copy the matching options into allocated memory
10782 */
10783 for (loop = 0; loop <= 1; ++loop)
10784 {
10785 regmatch->rm_ic = ic;
10786 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
10787 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000010788 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
10789 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010790 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
10791 {
10792 if (loop == 0)
10793 num_normal++;
10794 else
10795 (*file)[count++] = vim_strsave((char_u *)names[match]);
10796 }
10797 }
10798 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
10799 opt_idx++)
10800 {
10801 if (options[opt_idx].var == NULL)
10802 continue;
10803 if (xp->xp_context == EXPAND_BOOL_SETTINGS
10804 && !(options[opt_idx].flags & P_BOOL))
10805 continue;
10806 is_term_opt = istermoption(&options[opt_idx]);
10807 if (is_term_opt && num_normal > 0)
10808 continue;
10809 match = FALSE;
10810 if (vim_regexec(regmatch, str, (colnr_T)0)
10811 || (options[opt_idx].shortname != NULL
10812 && vim_regexec(regmatch,
10813 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
10814 match = TRUE;
10815 else if (is_term_opt)
10816 {
10817 name_buf[0] = '<';
10818 name_buf[1] = 't';
10819 name_buf[2] = '_';
10820 name_buf[3] = str[2];
10821 name_buf[4] = str[3];
10822 name_buf[5] = '>';
10823 name_buf[6] = NUL;
10824 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10825 {
10826 match = TRUE;
10827 str = name_buf;
10828 }
10829 }
10830 if (match)
10831 {
10832 if (loop == 0)
10833 {
10834 if (is_term_opt)
10835 num_term++;
10836 else
10837 num_normal++;
10838 }
10839 else
10840 (*file)[count++] = vim_strsave(str);
10841 }
10842 }
10843 /*
10844 * Check terminal key codes, these are not in the option table
10845 */
10846 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
10847 {
10848 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
10849 {
10850 if (!isprint(str[0]) || !isprint(str[1]))
10851 continue;
10852
10853 name_buf[0] = 't';
10854 name_buf[1] = '_';
10855 name_buf[2] = str[0];
10856 name_buf[3] = str[1];
10857 name_buf[4] = NUL;
10858
10859 match = FALSE;
10860 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10861 match = TRUE;
10862 else
10863 {
10864 name_buf[0] = '<';
10865 name_buf[1] = 't';
10866 name_buf[2] = '_';
10867 name_buf[3] = str[0];
10868 name_buf[4] = str[1];
10869 name_buf[5] = '>';
10870 name_buf[6] = NUL;
10871
10872 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10873 match = TRUE;
10874 }
10875 if (match)
10876 {
10877 if (loop == 0)
10878 num_term++;
10879 else
10880 (*file)[count++] = vim_strsave(name_buf);
10881 }
10882 }
10883
10884 /*
10885 * Check special key names.
10886 */
10887 regmatch->rm_ic = TRUE; /* ignore case here */
10888 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
10889 {
10890 name_buf[0] = '<';
10891 STRCPY(name_buf + 1, str);
10892 STRCAT(name_buf, ">");
10893
10894 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10895 {
10896 if (loop == 0)
10897 num_term++;
10898 else
10899 (*file)[count++] = vim_strsave(name_buf);
10900 }
10901 }
10902 }
10903 if (loop == 0)
10904 {
10905 if (num_normal > 0)
10906 *num_file = num_normal;
10907 else if (num_term > 0)
10908 *num_file = num_term;
10909 else
10910 return OK;
10911 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
10912 if (*file == NULL)
10913 {
10914 *file = (char_u **)"";
10915 return FAIL;
10916 }
10917 }
10918 }
10919 return OK;
10920}
10921
10922 int
10923ExpandOldSetting(num_file, file)
10924 int *num_file;
10925 char_u ***file;
10926{
10927 char_u *var = NULL; /* init for GCC */
10928 char_u *buf;
10929
10930 *num_file = 0;
10931 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
10932 if (*file == NULL)
10933 return FAIL;
10934
10935 /*
10936 * For a terminal key code expand_option_idx is < 0.
10937 */
10938 if (expand_option_idx < 0)
10939 {
10940 var = find_termcode(expand_option_name + 2);
10941 if (var == NULL)
10942 expand_option_idx = findoption(expand_option_name);
10943 }
10944
10945 if (expand_option_idx >= 0)
10946 {
10947 /* put string of option value in NameBuff */
10948 option_value2string(&options[expand_option_idx], expand_option_flags);
10949 var = NameBuff;
10950 }
10951 else if (var == NULL)
10952 var = (char_u *)"";
10953
10954 /* A backslash is required before some characters. This is the reverse of
10955 * what happens in do_set(). */
10956 buf = vim_strsave_escaped(var, escape_chars);
10957
10958 if (buf == NULL)
10959 {
10960 vim_free(*file);
10961 *file = NULL;
10962 return FAIL;
10963 }
10964
10965#ifdef BACKSLASH_IN_FILENAME
10966 /* For MS-Windows et al. we don't double backslashes at the start and
10967 * before a file name character. */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000010968 for (var = buf; *var != NUL; mb_ptr_adv(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010969 if (var[0] == '\\' && var[1] == '\\'
10970 && expand_option_idx >= 0
10971 && (options[expand_option_idx].flags & P_EXPAND)
10972 && vim_isfilec(var[2])
10973 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000010974 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010975#endif
10976
10977 *file[0] = buf;
10978 *num_file = 1;
10979 return OK;
10980}
10981#endif
10982
10983/*
10984 * Get the value for the numeric or string option *opp in a nice format into
10985 * NameBuff[]. Must not be called with a hidden option!
10986 */
10987 static void
10988option_value2string(opp, opt_flags)
10989 struct vimoption *opp;
10990 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
10991{
10992 char_u *varp;
10993
10994 varp = get_varp_scope(opp, opt_flags);
10995
10996 if (opp->flags & P_NUM)
10997 {
10998 long wc = 0;
10999
11000 if (wc_use_keyname(varp, &wc))
11001 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11002 else if (wc != 0)
11003 STRCPY(NameBuff, transchar((int)wc));
11004 else
11005 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11006 }
11007 else /* P_STRING */
11008 {
11009 varp = *(char_u **)(varp);
11010 if (varp == NULL) /* just in case */
11011 NameBuff[0] = NUL;
11012#ifdef FEAT_CRYPT
11013 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011014 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011015 STRCPY(NameBuff, "*****");
11016#endif
11017 else if (opp->flags & P_EXPAND)
11018 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11019 /* Translate 'pastetoggle' into special key names */
11020 else if ((char_u **)opp->var == &p_pt)
11021 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11022 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011023 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011024 }
11025}
11026
11027/*
11028 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11029 * printed as a keyname.
11030 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11031 */
11032 static int
11033wc_use_keyname(varp, wcp)
11034 char_u *varp;
11035 long *wcp;
11036{
11037 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11038 {
11039 *wcp = *(long *)varp;
11040 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11041 return TRUE;
11042 }
11043 return FALSE;
11044}
11045
11046#ifdef FEAT_LANGMAP
11047/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011048 * Any character has an equivalent 'langmap' character. This is used for
11049 * keyboards that have a special language mode that sends characters above
11050 * 128 (although other characters can be translated too). The "to" field is a
11051 * Vim command character. This avoids having to switch the keyboard back to
11052 * ASCII mode when leaving Insert mode.
11053 *
11054 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11055 * commands.
11056 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11057 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11058 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011059 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011060# ifdef FEAT_MBYTE
11061/*
11062 * With multi-byte support use growarray for 'langmap' chars >= 256
11063 */
11064typedef struct
11065{
11066 int from;
11067 int to;
11068} langmap_entry_T;
11069
11070static garray_T langmap_mapga;
11071static void langmap_set_entry __ARGS((int from, int to));
Bram Moolenaar071d4272004-06-13 20:20:40 +000011072
11073/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011074 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11075 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011076 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011077 static void
11078langmap_set_entry(from, to)
11079 int from;
11080 int to;
11081{
11082 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011083 int a = 0;
11084 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011085
11086 /* Do a binary search for an existing entry. */
11087 while (a != b)
11088 {
11089 int i = (a + b) / 2;
11090 int d = entries[i].from - from;
11091
11092 if (d == 0)
11093 {
11094 entries[i].to = to;
11095 return;
11096 }
11097 if (d < 0)
11098 a = i + 1;
11099 else
11100 b = i;
11101 }
11102
11103 if (ga_grow(&langmap_mapga, 1) != OK)
11104 return; /* out of memory */
11105
11106 /* insert new entry at position "a" */
11107 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11108 mch_memmove(entries + 1, entries,
11109 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11110 ++langmap_mapga.ga_len;
11111 entries[0].from = from;
11112 entries[0].to = to;
11113}
11114
11115/*
11116 * Apply 'langmap' to multi-byte character "c" and return the result.
11117 */
11118 int
11119langmap_adjust_mb(c)
11120 int c;
11121{
11122 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11123 int a = 0;
11124 int b = langmap_mapga.ga_len;
11125
11126 while (a != b)
11127 {
11128 int i = (a + b) / 2;
11129 int d = entries[i].from - c;
11130
11131 if (d == 0)
11132 return entries[i].to; /* found matching entry */
11133 if (d < 0)
11134 a = i + 1;
11135 else
11136 b = i;
11137 }
11138 return c; /* no entry found, return "c" unmodified */
11139}
11140# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011141
11142 static void
11143langmap_init()
11144{
11145 int i;
11146
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011147 for (i = 0; i < 256; i++)
11148 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11149# ifdef FEAT_MBYTE
11150 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11151# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011152}
11153
11154/*
11155 * Called when langmap option is set; the language map can be
11156 * changed at any time!
11157 */
11158 static void
11159langmap_set()
11160{
11161 char_u *p;
11162 char_u *p2;
11163 int from, to;
11164
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011165#ifdef FEAT_MBYTE
11166 ga_clear(&langmap_mapga); /* clear the previous map first */
11167#endif
11168 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011169
11170 for (p = p_langmap; p[0] != NUL; )
11171 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011172 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
11173 mb_ptr_adv(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011174 {
11175 if (p2[0] == '\\' && p2[1] != NUL)
11176 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011177 }
11178 if (p2[0] == ';')
11179 ++p2; /* abcd;ABCD form, p2 points to A */
11180 else
11181 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11182 while (p[0])
11183 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011184 if (p[0] == ',')
11185 {
11186 ++p;
11187 break;
11188 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011189 if (p[0] == '\\' && p[1] != NUL)
11190 ++p;
11191#ifdef FEAT_MBYTE
11192 from = (*mb_ptr2char)(p);
11193#else
11194 from = p[0];
11195#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011196 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011197 if (p2 == NULL)
11198 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011199 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011200 if (p[0] != ',')
11201 {
11202 if (p[0] == '\\')
11203 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011204#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011205 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011206#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011207 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011208#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011209 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011210 }
11211 else
11212 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011213 if (p2[0] != ',')
11214 {
11215 if (p2[0] == '\\')
11216 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011217#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011218 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011219#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011220 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011221#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011222 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011223 }
11224 if (to == NUL)
11225 {
11226 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
11227 transchar(from));
11228 return;
11229 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011230
11231#ifdef FEAT_MBYTE
11232 if (from >= 256)
11233 langmap_set_entry(from, to);
11234 else
11235#endif
11236 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011237
11238 /* Advance to next pair */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011239 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011240 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011241 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011242 mb_ptr_adv(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011243 if (*p == ';')
11244 {
11245 p = p2;
11246 if (p[0] != NUL)
11247 {
11248 if (p[0] != ',')
11249 {
11250 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
11251 return;
11252 }
11253 ++p;
11254 }
11255 break;
11256 }
11257 }
11258 }
11259 }
11260}
11261#endif
11262
11263/*
11264 * Return TRUE if format option 'x' is in effect.
11265 * Take care of no formatting when 'paste' is set.
11266 */
11267 int
11268has_format_option(x)
11269 int x;
11270{
11271 if (p_paste)
11272 return FALSE;
11273 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
11274}
11275
11276/*
11277 * Return TRUE if "x" is present in 'shortmess' option, or
11278 * 'shortmess' contains 'a' and "x" is present in SHM_A.
11279 */
11280 int
11281shortmess(x)
11282 int x;
11283{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010011284 return p_shm != NULL &&
11285 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000011286 || (vim_strchr(p_shm, 'a') != NULL
11287 && vim_strchr((char_u *)SHM_A, x) != NULL));
11288}
11289
11290/*
11291 * paste_option_changed() - Called after p_paste was set or reset.
11292 */
11293 static void
11294paste_option_changed()
11295{
11296 static int old_p_paste = FALSE;
11297 static int save_sm = 0;
11298#ifdef FEAT_CMDL_INFO
11299 static int save_ru = 0;
11300#endif
11301#ifdef FEAT_RIGHTLEFT
11302 static int save_ri = 0;
11303 static int save_hkmap = 0;
11304#endif
11305 buf_T *buf;
11306
11307 if (p_paste)
11308 {
11309 /*
11310 * Paste switched from off to on.
11311 * Save the current values, so they can be restored later.
11312 */
11313 if (!old_p_paste)
11314 {
11315 /* save options for each buffer */
11316 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11317 {
11318 buf->b_p_tw_nopaste = buf->b_p_tw;
11319 buf->b_p_wm_nopaste = buf->b_p_wm;
11320 buf->b_p_sts_nopaste = buf->b_p_sts;
11321 buf->b_p_ai_nopaste = buf->b_p_ai;
11322 }
11323
11324 /* save global options */
11325 save_sm = p_sm;
11326#ifdef FEAT_CMDL_INFO
11327 save_ru = p_ru;
11328#endif
11329#ifdef FEAT_RIGHTLEFT
11330 save_ri = p_ri;
11331 save_hkmap = p_hkmap;
11332#endif
11333 /* save global values for local buffer options */
11334 p_tw_nopaste = p_tw;
11335 p_wm_nopaste = p_wm;
11336 p_sts_nopaste = p_sts;
11337 p_ai_nopaste = p_ai;
11338 }
11339
11340 /*
11341 * Always set the option values, also when 'paste' is set when it is
11342 * already on.
11343 */
11344 /* set options for each buffer */
11345 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11346 {
11347 buf->b_p_tw = 0; /* textwidth is 0 */
11348 buf->b_p_wm = 0; /* wrapmargin is 0 */
11349 buf->b_p_sts = 0; /* softtabstop is 0 */
11350 buf->b_p_ai = 0; /* no auto-indent */
11351 }
11352
11353 /* set global options */
11354 p_sm = 0; /* no showmatch */
11355#ifdef FEAT_CMDL_INFO
11356# ifdef FEAT_WINDOWS
11357 if (p_ru)
11358 status_redraw_all(); /* redraw to remove the ruler */
11359# endif
11360 p_ru = 0; /* no ruler */
11361#endif
11362#ifdef FEAT_RIGHTLEFT
11363 p_ri = 0; /* no reverse insert */
11364 p_hkmap = 0; /* no Hebrew keyboard */
11365#endif
11366 /* set global values for local buffer options */
11367 p_tw = 0;
11368 p_wm = 0;
11369 p_sts = 0;
11370 p_ai = 0;
11371 }
11372
11373 /*
11374 * Paste switched from on to off: Restore saved values.
11375 */
11376 else if (old_p_paste)
11377 {
11378 /* restore options for each buffer */
11379 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11380 {
11381 buf->b_p_tw = buf->b_p_tw_nopaste;
11382 buf->b_p_wm = buf->b_p_wm_nopaste;
11383 buf->b_p_sts = buf->b_p_sts_nopaste;
11384 buf->b_p_ai = buf->b_p_ai_nopaste;
11385 }
11386
11387 /* restore global options */
11388 p_sm = save_sm;
11389#ifdef FEAT_CMDL_INFO
11390# ifdef FEAT_WINDOWS
11391 if (p_ru != save_ru)
11392 status_redraw_all(); /* redraw to draw the ruler */
11393# endif
11394 p_ru = save_ru;
11395#endif
11396#ifdef FEAT_RIGHTLEFT
11397 p_ri = save_ri;
11398 p_hkmap = save_hkmap;
11399#endif
11400 /* set global values for local buffer options */
11401 p_tw = p_tw_nopaste;
11402 p_wm = p_wm_nopaste;
11403 p_sts = p_sts_nopaste;
11404 p_ai = p_ai_nopaste;
11405 }
11406
11407 old_p_paste = p_paste;
11408}
11409
11410/*
11411 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
11412 *
11413 * Reset 'compatible' and set the values for options that didn't get set yet
11414 * to the Vim defaults.
11415 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011416 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011417 */
11418 void
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011419vimrc_found(fname, envname)
11420 char_u *fname;
11421 char_u *envname;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011422{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011423 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000011424 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011425 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011426
11427 if (!option_was_set((char_u *)"cp"))
11428 {
11429 p_cp = FALSE;
11430 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11431 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
11432 set_option_default(opt_idx, OPT_FREE, FALSE);
11433 didset_options();
11434 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011435
11436 if (fname != NULL)
11437 {
11438 p = vim_getenv(envname, &dofree);
11439 if (p == NULL)
11440 {
11441 /* Set $MYVIMRC to the first vimrc file found. */
11442 p = FullName_save(fname, FALSE);
11443 if (p != NULL)
11444 {
11445 vim_setenv(envname, p);
11446 vim_free(p);
11447 }
11448 }
11449 else if (dofree)
11450 vim_free(p);
11451 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011452}
11453
11454/*
11455 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
11456 */
11457 void
11458change_compatible(on)
11459 int on;
11460{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011461 int opt_idx;
11462
Bram Moolenaar071d4272004-06-13 20:20:40 +000011463 if (p_cp != on)
11464 {
11465 p_cp = on;
11466 compatible_set();
11467 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011468 opt_idx = findoption((char_u *)"cp");
11469 if (opt_idx >= 0)
11470 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011471}
11472
11473/*
11474 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020011475 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011476 */
11477 int
11478option_was_set(name)
11479 char_u *name;
11480{
11481 int idx;
11482
11483 idx = findoption(name);
11484 if (idx < 0) /* unknown option */
11485 return FALSE;
11486 if (options[idx].flags & P_WAS_SET)
11487 return TRUE;
11488 return FALSE;
11489}
11490
11491/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010011492 * Reset the flag indicating option "name" was set.
11493 */
11494 void
11495reset_option_was_set(name)
11496 char_u *name;
11497{
11498 int idx = findoption(name);
11499
11500 if (idx >= 0)
11501 options[idx].flags &= ~P_WAS_SET;
11502}
11503
11504/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011505 * compatible_set() - Called when 'compatible' has been set or unset.
11506 *
11507 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
11508 * flag) to a Vi compatible value.
11509 * When 'compatible' is unset: Set all options that have a different default
11510 * for Vim (without the P_VI_DEF flag) to that default.
11511 */
11512 static void
11513compatible_set()
11514{
11515 int opt_idx;
11516
11517 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11518 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
11519 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
11520 set_option_default(opt_idx, OPT_FREE, p_cp);
11521 didset_options();
11522}
11523
11524#ifdef FEAT_LINEBREAK
11525
11526# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
11527 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011528 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011529# endif
11530
11531/*
11532 * fill_breakat_flags() -- called when 'breakat' changes value.
11533 */
11534 static void
11535fill_breakat_flags()
11536{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011537 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011538 int i;
11539
11540 for (i = 0; i < 256; i++)
11541 breakat_flags[i] = FALSE;
11542
11543 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011544 for (p = p_breakat; *p; p++)
11545 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011546}
11547
11548# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011549 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011550# endif
11551
11552#endif
11553
11554/*
11555 * Check an option that can be a range of string values.
11556 *
11557 * Return OK for correct value, FAIL otherwise.
11558 * Empty is always OK.
11559 */
11560 static int
11561check_opt_strings(val, values, list)
11562 char_u *val;
11563 char **values;
11564 int list; /* when TRUE: accept a list of values */
11565{
11566 return opt_strings_flags(val, values, NULL, list);
11567}
11568
11569/*
11570 * Handle an option that can be a range of string values.
11571 * Set a flag in "*flagp" for each string present.
11572 *
11573 * Return OK for correct value, FAIL otherwise.
11574 * Empty is always OK.
11575 */
11576 static int
11577opt_strings_flags(val, values, flagp, list)
11578 char_u *val; /* new value */
11579 char **values; /* array of valid string values */
11580 unsigned *flagp;
11581 int list; /* when TRUE: accept a list of values */
11582{
11583 int i;
11584 int len;
11585 unsigned new_flags = 0;
11586
11587 while (*val)
11588 {
11589 for (i = 0; ; ++i)
11590 {
11591 if (values[i] == NULL) /* val not found in values[] */
11592 return FAIL;
11593
11594 len = (int)STRLEN(values[i]);
11595 if (STRNCMP(values[i], val, len) == 0
11596 && ((list && val[len] == ',') || val[len] == NUL))
11597 {
11598 val += len + (val[len] == ',');
11599 new_flags |= (1 << i);
11600 break; /* check next item in val list */
11601 }
11602 }
11603 }
11604 if (flagp != NULL)
11605 *flagp = new_flags;
11606
11607 return OK;
11608}
11609
11610/*
11611 * Read the 'wildmode' option, fill wim_flags[].
11612 */
11613 static int
11614check_opt_wim()
11615{
11616 char_u new_wim_flags[4];
11617 char_u *p;
11618 int i;
11619 int idx = 0;
11620
11621 for (i = 0; i < 4; ++i)
11622 new_wim_flags[i] = 0;
11623
11624 for (p = p_wim; *p; ++p)
11625 {
11626 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
11627 ;
11628 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
11629 return FAIL;
11630 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
11631 new_wim_flags[idx] |= WIM_LONGEST;
11632 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
11633 new_wim_flags[idx] |= WIM_FULL;
11634 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
11635 new_wim_flags[idx] |= WIM_LIST;
11636 else
11637 return FAIL;
11638 p += i;
11639 if (*p == NUL)
11640 break;
11641 if (*p == ',')
11642 {
11643 if (idx == 3)
11644 return FAIL;
11645 ++idx;
11646 }
11647 }
11648
11649 /* fill remaining entries with last flag */
11650 while (idx < 3)
11651 {
11652 new_wim_flags[idx + 1] = new_wim_flags[idx];
11653 ++idx;
11654 }
11655
11656 /* only when there are no errors, wim_flags[] is changed */
11657 for (i = 0; i < 4; ++i)
11658 wim_flags[i] = new_wim_flags[i];
11659 return OK;
11660}
11661
11662/*
11663 * Check if backspacing over something is allowed.
11664 */
11665 int
11666can_bs(what)
11667 int what; /* BS_INDENT, BS_EOL or BS_START */
11668{
11669 switch (*p_bs)
11670 {
11671 case '2': return TRUE;
11672 case '1': return (what != BS_START);
11673 case '0': return FALSE;
11674 }
11675 return vim_strchr(p_bs, what) != NULL;
11676}
11677
11678/*
11679 * Save the current values of 'fileformat' and 'fileencoding', so that we know
11680 * the file must be considered changed when the value is different.
11681 */
11682 void
11683save_file_ff(buf)
11684 buf_T *buf;
11685{
11686 buf->b_start_ffc = *buf->b_p_ff;
11687 buf->b_start_eol = buf->b_p_eol;
11688#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011689 buf->b_start_bomb = buf->b_p_bomb;
11690
Bram Moolenaar071d4272004-06-13 20:20:40 +000011691 /* Only use free/alloc when necessary, they take time. */
11692 if (buf->b_start_fenc == NULL
11693 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
11694 {
11695 vim_free(buf->b_start_fenc);
11696 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
11697 }
11698#endif
11699}
11700
11701/*
11702 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
11703 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011704 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
11705 * changed and 'binary' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010011706 * When "ignore_empty" is true don't consider a new, empty buffer to be
11707 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011708 */
11709 int
Bram Moolenaar164c60f2011-01-22 00:11:50 +010011710file_ff_differs(buf, ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011711 buf_T *buf;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010011712 int ignore_empty;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011713{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000011714 /* In a buffer that was never loaded the options are not valid. */
11715 if (buf->b_flags & BF_NEVERLOADED)
11716 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010011717 if (ignore_empty
11718 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011719 && buf->b_ml.ml_line_count == 1
11720 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
11721 return FALSE;
11722 if (buf->b_start_ffc != *buf->b_p_ff)
11723 return TRUE;
11724 if (buf->b_p_bin && buf->b_start_eol != buf->b_p_eol)
11725 return TRUE;
11726#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011727 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
11728 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011729 if (buf->b_start_fenc == NULL)
11730 return (*buf->b_p_fenc != NUL);
11731 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
11732#else
11733 return FALSE;
11734#endif
11735}
11736
11737/*
11738 * return OK if "p" is a valid fileformat name, FAIL otherwise.
11739 */
11740 int
11741check_ff_value(p)
11742 char_u *p;
11743{
11744 return check_opt_strings(p, p_ff_values, FALSE);
11745}
Bram Moolenaar14f24742012-08-08 18:01:05 +020011746
11747/*
11748 * Return the effective shiftwidth value for current buffer, using the
11749 * 'tabstop' value when 'shiftwidth' is zero.
11750 */
11751 long
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010011752get_sw_value(buf)
11753 buf_T *buf;
Bram Moolenaar14f24742012-08-08 18:01:05 +020011754{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010011755 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020011756}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020011757
11758/*
11759 * Return the effective softtabstop value for the current buffer, using the
11760 * 'tabstop' value when 'softtabstop' is negative.
11761 */
11762 long
11763get_sts_value()
11764{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010011765 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020011766}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010011767
11768/*
11769 * Check matchpairs option for "*initc".
11770 * If there is a match set "*initc" to the matching character and "*findc" to
11771 * the opposite character. Set "*backwards" to the direction.
11772 * When "switchit" is TRUE swap the direction.
11773 */
11774 void
11775find_mps_values(initc, findc, backwards, switchit)
11776 int *initc;
11777 int *findc;
11778 int *backwards;
11779 int switchit;
11780{
11781 char_u *ptr;
11782
11783 ptr = curbuf->b_p_mps;
11784 while (*ptr != NUL)
11785 {
11786#ifdef FEAT_MBYTE
11787 if (has_mbyte)
11788 {
11789 char_u *prev;
11790
11791 if (mb_ptr2char(ptr) == *initc)
11792 {
11793 if (switchit)
11794 {
11795 *findc = *initc;
11796 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
11797 *backwards = TRUE;
11798 }
11799 else
11800 {
11801 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
11802 *backwards = FALSE;
11803 }
11804 return;
11805 }
11806 prev = ptr;
11807 ptr += mb_ptr2len(ptr) + 1;
11808 if (mb_ptr2char(ptr) == *initc)
11809 {
11810 if (switchit)
11811 {
11812 *findc = *initc;
11813 *initc = mb_ptr2char(prev);
11814 *backwards = FALSE;
11815 }
11816 else
11817 {
11818 *findc = mb_ptr2char(prev);
11819 *backwards = TRUE;
11820 }
11821 return;
11822 }
11823 ptr += mb_ptr2len(ptr);
11824 }
11825 else
11826#endif
11827 {
11828 if (*ptr == *initc)
11829 {
11830 if (switchit)
11831 {
11832 *backwards = TRUE;
11833 *findc = *initc;
11834 *initc = ptr[2];
11835 }
11836 else
11837 {
11838 *backwards = FALSE;
11839 *findc = ptr[2];
11840 }
11841 return;
11842 }
11843 ptr += 2;
11844 if (*ptr == *initc)
11845 {
11846 if (switchit)
11847 {
11848 *backwards = FALSE;
11849 *findc = *initc;
11850 *initc = ptr[-2];
11851 }
11852 else
11853 {
11854 *backwards = TRUE;
11855 *findc = ptr[-2];
11856 }
11857 return;
11858 }
11859 ++ptr;
11860 }
11861 if (*ptr == ',')
11862 ++ptr;
11863 }
11864}