blob: 589e134445e054a9d4c4d2bef0536f74d2b3d94d [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
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +0100237#define PV_UL OPT_BOTH(OPT_BUF(BV_UL))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000238#ifdef FEAT_WINDOWS
239# define PV_WFH OPT_WIN(WV_WFH)
240#endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +0000241#ifdef FEAT_VERTSPLIT
242# define PV_WFW OPT_WIN(WV_WFW)
243#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000244#define PV_WRAP OPT_WIN(WV_WRAP)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200245#ifdef FEAT_CURSORBIND
246# define PV_CRBIND OPT_WIN(WV_CRBIND)
247#endif
248#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200249# define PV_COCU OPT_WIN(WV_COCU)
250# define PV_COLE OPT_WIN(WV_COLE)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200251#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000252
253/* WV_ and BV_ values get typecasted to this for the "indir" field */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000254typedef enum
255{
Bram Moolenaar7d96acd2008-06-09 15:07:54 +0000256 PV_NONE = 0,
257 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000258} idopt_T;
259
260/*
261 * Options local to a window have a value local to a buffer and global to all
262 * buffers. Indicate this by setting "var" to VAR_WIN.
263 */
264#define VAR_WIN ((char_u *)-1)
265
266/*
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000267 * These are the global values for options which are also local to a buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000268 * Only to be used in option.c!
269 */
270static int p_ai;
271static int p_bin;
272#ifdef FEAT_MBYTE
273static int p_bomb;
274#endif
275#if defined(FEAT_QUICKFIX)
276static char_u *p_bh;
277static char_u *p_bt;
278#endif
279static int p_bl;
280static int p_ci;
281#ifdef FEAT_CINDENT
282static int p_cin;
283static char_u *p_cink;
284static char_u *p_cino;
285#endif
286#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
287static char_u *p_cinw;
288#endif
289#ifdef FEAT_COMMENTS
290static char_u *p_com;
291#endif
292#ifdef FEAT_FOLDING
293static char_u *p_cms;
294#endif
295#ifdef FEAT_INS_EXPAND
296static char_u *p_cpt;
297#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000298#ifdef FEAT_COMPL_FUNC
299static char_u *p_cfu;
Bram Moolenaare344bea2005-09-01 20:46:49 +0000300static char_u *p_ofu;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000301#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000302static int p_eol;
303static int p_et;
304#ifdef FEAT_MBYTE
305static char_u *p_fenc;
306#endif
307static char_u *p_ff;
308static char_u *p_fo;
Bram Moolenaar86b68352004-12-27 21:59:20 +0000309static char_u *p_flp;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000310#ifdef FEAT_AUTOCMD
311static char_u *p_ft;
312#endif
313static long p_iminsert;
314static long p_imsearch;
315#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
316static char_u *p_inex;
317#endif
318#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
319static char_u *p_inde;
320static char_u *p_indk;
321#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +0000322#if defined(FEAT_EVAL)
323static char_u *p_fex;
324#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000325static int p_inf;
326static char_u *p_isk;
327#ifdef FEAT_CRYPT
328static char_u *p_key;
329#endif
330#ifdef FEAT_LISP
331static int p_lisp;
332#endif
333static int p_ml;
334static int p_ma;
335static int p_mod;
336static char_u *p_mps;
337static char_u *p_nf;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000338static int p_pi;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000339#ifdef FEAT_TEXTOBJ
340static char_u *p_qe;
341#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000342static int p_ro;
343#ifdef FEAT_SMARTINDENT
344static int p_si;
345#endif
346#ifndef SHORT_FNAME
347static int p_sn;
348#endif
349static long p_sts;
350#if defined(FEAT_SEARCHPATH)
351static char_u *p_sua;
352#endif
353static long p_sw;
354static int p_swf;
355#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +0000356static long p_smc;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000357static char_u *p_syn;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000358#endif
359#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000360static char_u *p_spc;
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000361static char_u *p_spf;
Bram Moolenaar217ad922005-03-20 22:37:15 +0000362static char_u *p_spl;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000363#endif
364static long p_ts;
365static long p_tw;
366static int p_tx;
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200367#ifdef FEAT_PERSISTENT_UNDO
368static int p_udf;
369#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000370static long p_wm;
371#ifdef FEAT_KEYMAP
372static char_u *p_keymap;
373#endif
374
375/* Saved values for when 'bin' is set. */
376static int p_et_nobin;
377static int p_ml_nobin;
378static long p_tw_nobin;
379static long p_wm_nobin;
380
381/* Saved values for when 'paste' is set */
382static long p_tw_nopaste;
383static long p_wm_nopaste;
384static long p_sts_nopaste;
385static int p_ai_nopaste;
386
387struct vimoption
388{
389 char *fullname; /* full option name */
390 char *shortname; /* permissible abbreviation */
391 long_u flags; /* see below */
392 char_u *var; /* global option: pointer to variable;
393 * window-local option: VAR_WIN;
394 * buffer-local option: global value */
395 idopt_T indir; /* global option: PV_NONE;
396 * local option: indirect option index */
397 char_u *def_val[2]; /* default values for variable (vi and vim) */
398#ifdef FEAT_EVAL
399 scid_T scriptID; /* script in which the option was last set */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000400# define SCRIPTID_INIT , 0
401#else
402# define SCRIPTID_INIT
Bram Moolenaar071d4272004-06-13 20:20:40 +0000403#endif
404};
405
406#define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */
407#define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */
408
409/*
410 * Flags
411 */
412#define P_BOOL 0x01 /* the option is boolean */
413#define P_NUM 0x02 /* the option is numeric */
414#define P_STRING 0x04 /* the option is a string */
415#define P_ALLOCED 0x08 /* the string option is in allocated memory,
Bram Moolenaar363cb672009-07-22 12:28:17 +0000416 must use free_string_option() when
417 assigning new value. Not set if default is
418 the same. */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000419#define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
420 never be used for local or hidden options! */
421#define P_NODEFAULT 0x40 /* don't set to default value */
422#define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must
423 use vim_free() when assigning new value */
424#define P_WAS_SET 0x100 /* option has been set/reset */
425#define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */
426#define P_VI_DEF 0x400 /* Use Vi default for Vim */
427#define P_VIM 0x800 /* Vim option, reset when 'cp' set */
428
429 /* when option changed, what to display: */
430#define P_RSTAT 0x1000 /* redraw status lines */
431#define P_RWIN 0x2000 /* redraw current window */
432#define P_RBUF 0x4000 /* redraw current buffer */
433#define P_RALL 0x6000 /* redraw all windows */
434#define P_RCLR 0x7000 /* clear and redraw all */
435
436#define P_COMMA 0x8000 /* comma separated list */
Bram Moolenaar913077c2012-03-28 19:59:04 +0200437#define P_NODUP 0x10000L /* don't allow duplicate strings */
438#define P_FLAGLIST 0x20000L /* list of single-char flags */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000439
Bram Moolenaar913077c2012-03-28 19:59:04 +0200440#define P_SECURE 0x40000L /* cannot change in modeline or secure mode */
441#define P_GETTEXT 0x80000L /* expand default value with _() */
442#define P_NOGLOB 0x100000L /* do not use local value for global vimrc */
443#define P_NFNAME 0x200000L /* only normal file name chars allowed */
444#define P_INSECURE 0x400000L /* option was set from a modeline */
445#define P_PRI_MKRC 0x800000L /* priority for :mkvimrc (setting option has
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000446 side effects) */
Bram Moolenaar913077c2012-03-28 19:59:04 +0200447#define P_NO_ML 0x1000000L /* not allowed in modeline */
448#define P_CURSWANT 0x2000000L /* update curswant required; not needed when
449 * there is a redraw flag */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000450
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000451#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
452
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000453/* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used
454 * for the currency sign. */
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000455#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000456# define ISP_LATIN1 (char_u *)"@,~-255"
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000457#else
458# define ISP_LATIN1 (char_u *)"@,161-255"
459#endif
460
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000461/* The 16 bit MS-DOS version is low on space, make the string as short as
462 * possible when compiling with few features. */
463#if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
464 || defined(FEAT_VERTSPLIT) || defined(FEAT_CLIPBOARD) \
Bram Moolenaar860cae12010-06-05 23:22:07 +0200465 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) || defined(FEAT_CONCEAL)
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100466# 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 +0000467#else
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100468# 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 +0000469#endif
470
Bram Moolenaar071d4272004-06-13 20:20:40 +0000471/*
472 * options[] is initialized here.
473 * The order of the options MUST be alphabetic for ":set all" and findoption().
474 * All option names MUST start with a lowercase letter (for findoption()).
475 * Exception: "t_" options are at the end.
476 * The options with a NULL variable are 'hidden': a set command for them is
477 * ignored and they are not printed.
478 */
479static struct vimoption
480#ifdef FEAT_GUI_W16
481 _far
482#endif
483 options[] =
484{
Bram Moolenaar913077c2012-03-28 19:59:04 +0200485 {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000486#ifdef FEAT_RIGHTLEFT
487 (char_u *)&p_aleph, PV_NONE,
488#else
489 (char_u *)NULL, PV_NONE,
490#endif
491 {
492#if (defined(MSDOS) || defined(WIN3264) || defined(OS2)) && !defined(FEAT_GUI_W32)
493 (char_u *)128L,
494#else
495 (char_u *)224L,
496#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000497 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000498 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
499#if defined(FEAT_GUI) && defined(MACOS_X)
500 (char_u *)&p_antialias, PV_NONE,
501 {(char_u *)FALSE, (char_u *)FALSE}
502#else
503 (char_u *)NULL, PV_NONE,
504 {(char_u *)FALSE, (char_u *)FALSE}
505#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000506 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200507 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000508#ifdef FEAT_ARABIC
509 (char_u *)VAR_WIN, PV_ARAB,
510#else
511 (char_u *)NULL, PV_NONE,
512#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000513 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000514 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
515#ifdef FEAT_ARABIC
516 (char_u *)&p_arshape, PV_NONE,
517#else
518 (char_u *)NULL, PV_NONE,
519#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000520 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000521 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
522#ifdef FEAT_RIGHTLEFT
523 (char_u *)&p_ari, PV_NONE,
524#else
525 (char_u *)NULL, PV_NONE,
526#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000527 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000528 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
529#ifdef FEAT_FKMAP
530 (char_u *)&p_altkeymap, PV_NONE,
531#else
532 (char_u *)NULL, PV_NONE,
533#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000534 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000535 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
536#if defined(FEAT_MBYTE)
537 (char_u *)&p_ambw, PV_NONE,
538 {(char_u *)"single", (char_u *)0L}
539#else
540 (char_u *)NULL, PV_NONE,
541 {(char_u *)0L, (char_u *)0L}
542#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000543 SCRIPTID_INIT},
Bram Moolenaar8dff8182006-04-06 20:18:50 +0000544#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +0000545 {"autochdir", "acd", P_BOOL|P_VI_DEF,
546 (char_u *)&p_acd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000547 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000548#endif
549 {"autoindent", "ai", P_BOOL|P_VI_DEF,
550 (char_u *)&p_ai, PV_AI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000551 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000552 {"autoprint", "ap", P_BOOL|P_VI_DEF,
553 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000554 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000555 {"autoread", "ar", P_BOOL|P_VI_DEF,
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000556 (char_u *)&p_ar, PV_AR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000557 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000558 {"autowrite", "aw", P_BOOL|P_VI_DEF,
559 (char_u *)&p_aw, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000560 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000561 {"autowriteall","awa", P_BOOL|P_VI_DEF,
562 (char_u *)&p_awa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000563 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000564 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
565 (char_u *)&p_bg, PV_NONE,
566 {
567#if (defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI)
568 (char_u *)"dark",
569#else
570 (char_u *)"light",
571#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000572 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000573 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_COMMA|P_NODUP,
574 (char_u *)&p_bs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000575 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000576 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
577 (char_u *)&p_bk, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000578 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000579 {"backupcopy", "bkc", P_STRING|P_VIM|P_COMMA|P_NODUP,
580 (char_u *)&p_bkc, PV_NONE,
581#ifdef UNIX
582 {(char_u *)"yes", (char_u *)"auto"}
583#else
584 {(char_u *)"auto", (char_u *)"auto"}
585#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000586 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000587 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE,
588 (char_u *)&p_bdir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000589 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000590 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000591 (char_u *)&p_bex, PV_NONE,
592 {
593#ifdef VMS
594 (char_u *)"_",
595#else
596 (char_u *)"~",
597#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000598 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000599 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_COMMA,
600#ifdef FEAT_WILDIGN
601 (char_u *)&p_bsk, PV_NONE,
602 {(char_u *)"", (char_u *)0L}
603#else
604 (char_u *)NULL, PV_NONE,
605 {(char_u *)0L, (char_u *)0L}
606#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000607 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000608#ifdef FEAT_BEVAL
609 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
610 (char_u *)&p_bdlay, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000611 {(char_u *)600L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000612 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
613 (char_u *)&p_beval, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000614 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000615# ifdef FEAT_EVAL
Bram Moolenaar39f05632006-03-19 22:15:26 +0000616 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000617 (char_u *)&p_bexpr, PV_BEXPR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000618 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000619# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000620#endif
621 {"beautify", "bf", P_BOOL|P_VI_DEF,
622 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000623 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000624 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
625 (char_u *)&p_bin, PV_BIN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000626 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000627 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
628#ifdef MSDOS
629 (char_u *)&p_biosk, PV_NONE,
630#else
631 (char_u *)NULL, PV_NONE,
632#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000633 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000634 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
635#ifdef FEAT_MBYTE
636 (char_u *)&p_bomb, PV_BOMB,
637#else
638 (char_u *)NULL, PV_NONE,
639#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000640 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000641 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
642#ifdef FEAT_LINEBREAK
643 (char_u *)&p_breakat, PV_NONE,
644 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
645#else
646 (char_u *)NULL, PV_NONE,
647 {(char_u *)0L, (char_u *)0L}
648#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000649 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000650 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
651#ifdef FEAT_BROWSE
652 (char_u *)&p_bsdir, PV_NONE,
653 {(char_u *)"last", (char_u *)0L}
654#else
655 (char_u *)NULL, PV_NONE,
656 {(char_u *)0L, (char_u *)0L}
657#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000658 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000659 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
660#if defined(FEAT_QUICKFIX)
661 (char_u *)&p_bh, PV_BH,
662 {(char_u *)"", (char_u *)0L}
663#else
664 (char_u *)NULL, PV_NONE,
665 {(char_u *)0L, (char_u *)0L}
666#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000667 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000668 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
669 (char_u *)&p_bl, PV_BL,
670 {(char_u *)1L, (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000671 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000672 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
673#if defined(FEAT_QUICKFIX)
674 (char_u *)&p_bt, PV_BT,
675 {(char_u *)"", (char_u *)0L}
676#else
677 (char_u *)NULL, PV_NONE,
678 {(char_u *)0L, (char_u *)0L}
679#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000680 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000681 {"casemap", "cmp", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000682#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000683 (char_u *)&p_cmp, PV_NONE,
684 {(char_u *)"internal,keepascii", (char_u *)0L}
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000685#else
686 (char_u *)NULL, PV_NONE,
687 {(char_u *)0L, (char_u *)0L}
688#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000689 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000690 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
691#ifdef FEAT_SEARCHPATH
692 (char_u *)&p_cdpath, PV_NONE,
693 {(char_u *)",,", (char_u *)0L}
694#else
695 (char_u *)NULL, PV_NONE,
696 {(char_u *)0L, (char_u *)0L}
697#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000698 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000699 {"cedit", NULL, P_STRING,
700#ifdef FEAT_CMDWIN
701 (char_u *)&p_cedit, PV_NONE,
702 {(char_u *)"", (char_u *)CTRL_F_STR}
703#else
704 (char_u *)NULL, PV_NONE,
705 {(char_u *)0L, (char_u *)0L}
706#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000707 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000708 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
709#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
710 (char_u *)&p_ccv, PV_NONE,
711 {(char_u *)"", (char_u *)0L}
712#else
713 (char_u *)NULL, PV_NONE,
714 {(char_u *)0L, (char_u *)0L}
715#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000716 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000717 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
718#ifdef FEAT_CINDENT
719 (char_u *)&p_cin, PV_CIN,
720#else
721 (char_u *)NULL, PV_NONE,
722#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000723 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000724 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
725#ifdef FEAT_CINDENT
726 (char_u *)&p_cink, PV_CINK,
727 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
728#else
729 (char_u *)NULL, PV_NONE,
730 {(char_u *)0L, (char_u *)0L}
731#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000732 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000733 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
734#ifdef FEAT_CINDENT
735 (char_u *)&p_cino, PV_CINO,
736#else
737 (char_u *)NULL, PV_NONE,
738#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000739 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000740 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
741#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
742 (char_u *)&p_cinw, PV_CINW,
743 {(char_u *)"if,else,while,do,for,switch",
744 (char_u *)0L}
745#else
746 (char_u *)NULL, PV_NONE,
747 {(char_u *)0L, (char_u *)0L}
748#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000749 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000750 {"clipboard", "cb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
751#ifdef FEAT_CLIPBOARD
752 (char_u *)&p_cb, PV_NONE,
753# ifdef FEAT_XCLIPBOARD
754 {(char_u *)"autoselect,exclude:cons\\|linux",
755 (char_u *)0L}
756# else
757 {(char_u *)"", (char_u *)0L}
758# endif
759#else
760 (char_u *)NULL, PV_NONE,
761 {(char_u *)"", (char_u *)0L}
762#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000763 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000764 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
765 (char_u *)&p_ch, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000766 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000767 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
768#ifdef FEAT_CMDWIN
769 (char_u *)&p_cwh, PV_NONE,
770#else
771 (char_u *)NULL, PV_NONE,
772#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000773 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +0200774 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_RWIN,
775#ifdef FEAT_SYN_HL
776 (char_u *)VAR_WIN, PV_CC,
777#else
778 (char_u *)NULL, PV_NONE,
779#endif
780 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000781 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
782 (char_u *)&Columns, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000783 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200784 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000785#ifdef FEAT_COMMENTS
786 (char_u *)&p_com, PV_COM,
787 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
788 (char_u *)0L}
789#else
790 (char_u *)NULL, PV_NONE,
791 {(char_u *)0L, (char_u *)0L}
792#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000793 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200794 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000795#ifdef FEAT_FOLDING
796 (char_u *)&p_cms, PV_CMS,
797 {(char_u *)"/*%s*/", (char_u *)0L}
798#else
799 (char_u *)NULL, PV_NONE,
800 {(char_u *)0L, (char_u *)0L}
801#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000802 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000803 /* P_PRI_MKRC isn't needed here, optval_default()
804 * always returns TRUE for 'compatible' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000805 {"compatible", "cp", P_BOOL|P_RALL,
806 (char_u *)&p_cp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000807 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000808 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
809#ifdef FEAT_INS_EXPAND
810 (char_u *)&p_cpt, PV_CPT,
811 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
812#else
813 (char_u *)NULL, PV_NONE,
814 {(char_u *)0L, (char_u *)0L}
815#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000816 SCRIPTID_INIT},
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200817 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200818#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200819 (char_u *)VAR_WIN, PV_COCU,
820 {(char_u *)"", (char_u *)NULL}
821#else
822 (char_u *)NULL, PV_NONE,
823 {(char_u *)NULL, (char_u *)0L}
824#endif
825 SCRIPTID_INIT},
826 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
827#ifdef FEAT_CONCEAL
828 (char_u *)VAR_WIN, PV_COLE,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200829#else
830 (char_u *)NULL, PV_NONE,
831#endif
832 {(char_u *)0L, (char_u *)0L}
833 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000834 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
835#ifdef FEAT_COMPL_FUNC
836 (char_u *)&p_cfu, PV_CFU,
837 {(char_u *)"", (char_u *)0L}
838#else
839 (char_u *)NULL, PV_NONE,
840 {(char_u *)0L, (char_u *)0L}
841#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000842 SCRIPTID_INIT},
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000843 {"completeopt", "cot", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
844#ifdef FEAT_INS_EXPAND
845 (char_u *)&p_cot, PV_NONE,
Bram Moolenaarc270d802006-03-11 21:29:41 +0000846 {(char_u *)"menu,preview", (char_u *)0L}
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000847#else
848 (char_u *)NULL, PV_NONE,
849 {(char_u *)0L, (char_u *)0L}
850#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000851 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000852 {"confirm", "cf", P_BOOL|P_VI_DEF,
853#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
854 (char_u *)&p_confirm, PV_NONE,
855#else
856 (char_u *)NULL, PV_NONE,
857#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000858 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000859 {"conskey", "consk",P_BOOL|P_VI_DEF,
860#ifdef MSDOS
861 (char_u *)&p_consk, PV_NONE,
862#else
863 (char_u *)NULL, PV_NONE,
864#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000865 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000866 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
867 (char_u *)&p_ci, PV_CI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000868 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000869 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
870 (char_u *)&p_cpo, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000871 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
872 SCRIPTID_INIT},
Bram Moolenaar49771f42010-07-20 17:32:38 +0200873 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200874#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200875 (char_u *)&p_cm, PV_CM,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200876 {(char_u *)"zip", (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200877#else
878 (char_u *)NULL, PV_NONE,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200879 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200880#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +0200881 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000882 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
883#ifdef FEAT_CSCOPE
884 (char_u *)&p_cspc, PV_NONE,
885#else
886 (char_u *)NULL, PV_NONE,
887#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000888 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000889 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
890#ifdef FEAT_CSCOPE
891 (char_u *)&p_csprg, PV_NONE,
892 {(char_u *)"cscope", (char_u *)0L}
893#else
894 (char_u *)NULL, PV_NONE,
895 {(char_u *)0L, (char_u *)0L}
896#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000897 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000898 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
899#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
900 (char_u *)&p_csqf, PV_NONE,
901 {(char_u *)"", (char_u *)0L}
902#else
903 (char_u *)NULL, PV_NONE,
904 {(char_u *)0L, (char_u *)0L}
905#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000906 SCRIPTID_INIT},
Bram Moolenaarf7befa92011-06-12 22:13:40 +0200907 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM,
908#ifdef FEAT_CSCOPE
909 (char_u *)&p_csre, PV_NONE,
910#else
911 (char_u *)NULL, PV_NONE,
912#endif
913 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000914 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
915#ifdef FEAT_CSCOPE
916 (char_u *)&p_cst, PV_NONE,
917#else
918 (char_u *)NULL, PV_NONE,
919#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000920 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000921 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
922#ifdef FEAT_CSCOPE
923 (char_u *)&p_csto, PV_NONE,
924#else
925 (char_u *)NULL, PV_NONE,
926#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000927 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000928 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
929#ifdef FEAT_CSCOPE
930 (char_u *)&p_csverbose, PV_NONE,
931#else
932 (char_u *)NULL, PV_NONE,
933#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000934 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200935 {"cursorbind", "crb", P_BOOL|P_VI_DEF,
936#ifdef FEAT_CURSORBIND
937 (char_u *)VAR_WIN, PV_CRBIND,
938#else
939 (char_u *)NULL, PV_NONE,
940#endif
941 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000942 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
943#ifdef FEAT_SYN_HL
944 (char_u *)VAR_WIN, PV_CUC,
945#else
946 (char_u *)NULL, PV_NONE,
947#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000948 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000949 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWIN,
950#ifdef FEAT_SYN_HL
951 (char_u *)VAR_WIN, PV_CUL,
952#else
953 (char_u *)NULL, PV_NONE,
954#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000955 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000956 {"debug", NULL, P_STRING|P_VI_DEF,
957 (char_u *)&p_debug, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000958 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200959 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000960#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000961 (char_u *)&p_def, PV_DEF,
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000962 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000963#else
964 (char_u *)NULL, PV_NONE,
965 {(char_u *)NULL, (char_u *)0L}
966#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000967 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000968 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
969#ifdef FEAT_MBYTE
970 (char_u *)&p_deco, PV_NONE,
971#else
972 (char_u *)NULL, PV_NONE,
973#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000974 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000975 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
976#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000977 (char_u *)&p_dict, PV_DICT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000978#else
979 (char_u *)NULL, PV_NONE,
980#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000981 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000982 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
983#ifdef FEAT_DIFF
984 (char_u *)VAR_WIN, PV_DIFF,
985#else
986 (char_u *)NULL, PV_NONE,
987#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000988 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200989 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000990#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
991 (char_u *)&p_dex, PV_NONE,
992 {(char_u *)"", (char_u *)0L}
993#else
994 (char_u *)NULL, PV_NONE,
995 {(char_u *)0L, (char_u *)0L}
996#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000997 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000998 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_COMMA|P_NODUP,
999#ifdef FEAT_DIFF
1000 (char_u *)&p_dip, PV_NONE,
1001 {(char_u *)"filler", (char_u *)NULL}
1002#else
1003 (char_u *)NULL, PV_NONE,
1004 {(char_u *)"", (char_u *)NULL}
1005#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001006 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001007 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
1008#ifdef FEAT_DIGRAPHS
1009 (char_u *)&p_dg, PV_NONE,
1010#else
1011 (char_u *)NULL, PV_NONE,
1012#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001013 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001014 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE,
1015 (char_u *)&p_dir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001016 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001017 {"display", "dy", P_STRING|P_VI_DEF|P_COMMA|P_RALL|P_NODUP,
1018 (char_u *)&p_dy, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001019 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001020 {"eadirection", "ead", P_STRING|P_VI_DEF,
1021#ifdef FEAT_VERTSPLIT
1022 (char_u *)&p_ead, PV_NONE,
1023 {(char_u *)"both", (char_u *)0L}
1024#else
1025 (char_u *)NULL, PV_NONE,
1026 {(char_u *)NULL, (char_u *)0L}
1027#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001028 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001029 {"edcompatible","ed", P_BOOL|P_VI_DEF,
1030 (char_u *)&p_ed, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001031 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar865242e2010-07-14 21:12:05 +02001032 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001033#ifdef FEAT_MBYTE
1034 (char_u *)&p_enc, PV_NONE,
1035 {(char_u *)ENC_DFLT, (char_u *)0L}
1036#else
1037 (char_u *)NULL, PV_NONE,
1038 {(char_u *)0L, (char_u *)0L}
1039#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001040 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001041 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1042 (char_u *)&p_eol, PV_EOL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001043 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001044 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1045 (char_u *)&p_ea, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001046 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001047 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001048 (char_u *)&p_ep, PV_EP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001049 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001050 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1051 (char_u *)&p_eb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001052 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001053 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1054#ifdef FEAT_QUICKFIX
1055 (char_u *)&p_ef, PV_NONE,
1056 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1057#else
1058 (char_u *)NULL, PV_NONE,
1059 {(char_u *)NULL, (char_u *)0L}
1060#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001061 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001062 {"errorformat", "efm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1063#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001064 (char_u *)&p_efm, PV_EFM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001065 {(char_u *)DFLT_EFM, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001066#else
1067 (char_u *)NULL, PV_NONE,
1068 {(char_u *)NULL, (char_u *)0L}
1069#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001070 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001071 {"esckeys", "ek", P_BOOL|P_VIM,
1072 (char_u *)&p_ek, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001073 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001074 {"eventignore", "ei", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1075#ifdef FEAT_AUTOCMD
1076 (char_u *)&p_ei, PV_NONE,
1077#else
1078 (char_u *)NULL, PV_NONE,
1079#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001080 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001081 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1082 (char_u *)&p_et, PV_ET,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001083 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001084 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1085 (char_u *)&p_exrc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001086 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001087 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF|P_NO_MKRC,
1088#ifdef FEAT_MBYTE
1089 (char_u *)&p_fenc, PV_FENC,
1090 {(char_u *)"", (char_u *)0L}
1091#else
1092 (char_u *)NULL, PV_NONE,
1093 {(char_u *)0L, (char_u *)0L}
1094#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001095 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001096 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_COMMA,
1097#ifdef FEAT_MBYTE
1098 (char_u *)&p_fencs, PV_NONE,
1099 {(char_u *)"ucs-bom", (char_u *)0L}
1100#else
1101 (char_u *)NULL, PV_NONE,
1102 {(char_u *)0L, (char_u *)0L}
1103#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001104 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001105 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001106 (char_u *)&p_ff, PV_FF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001107 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001108 {"fileformats", "ffs", P_STRING|P_VIM|P_COMMA|P_NODUP,
1109 (char_u *)&p_ffs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001110 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1111 SCRIPTID_INIT},
Bram Moolenaar71afbfe2013-03-19 16:49:16 +01001112 {"fileignorecase", "fic", P_BOOL|P_VI_DEF,
1113 (char_u *)&p_fic, PV_NONE,
1114 {
1115#ifdef CASE_INSENSITIVE_FILENAME
1116 (char_u *)TRUE,
1117#else
1118 (char_u *)FALSE,
1119#endif
1120 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001121 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001122#ifdef FEAT_AUTOCMD
1123 (char_u *)&p_ft, PV_FT,
1124 {(char_u *)"", (char_u *)0L}
1125#else
1126 (char_u *)NULL, PV_NONE,
1127 {(char_u *)0L, (char_u *)0L}
1128#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001129 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001130 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1131#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1132 (char_u *)&p_fcs, PV_NONE,
1133 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1134#else
1135 (char_u *)NULL, PV_NONE,
1136 {(char_u *)"", (char_u *)0L}
1137#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001138 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001139 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1140#ifdef FEAT_FKMAP
1141 (char_u *)&p_fkmap, PV_NONE,
1142#else
1143 (char_u *)NULL, PV_NONE,
1144#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001145 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001146 {"flash", "fl", P_BOOL|P_VI_DEF,
1147 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001148 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001149#ifdef FEAT_FOLDING
1150 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_RWIN,
1151 (char_u *)&p_fcl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001152 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001153 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1154 (char_u *)VAR_WIN, PV_FDC,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001155 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001156 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1157 (char_u *)VAR_WIN, PV_FEN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001158 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001159 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1160# ifdef FEAT_EVAL
1161 (char_u *)VAR_WIN, PV_FDE,
1162 {(char_u *)"0", (char_u *)NULL}
1163# else
1164 (char_u *)NULL, PV_NONE,
1165 {(char_u *)NULL, (char_u *)0L}
1166# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001167 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001168 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1169 (char_u *)VAR_WIN, PV_FDI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001170 {(char_u *)"#", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001171 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
1172 (char_u *)VAR_WIN, PV_FDL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001173 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001174 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001175 (char_u *)&p_fdls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001176 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001177 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
1178 P_RWIN|P_COMMA|P_NODUP,
1179 (char_u *)VAR_WIN, PV_FMR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001180 {(char_u *)"{{{,}}}", (char_u *)NULL}
1181 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001182 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1183 (char_u *)VAR_WIN, PV_FDM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001184 {(char_u *)"manual", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001185 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1186 (char_u *)VAR_WIN, PV_FML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001187 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001188 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1189 (char_u *)VAR_WIN, PV_FDN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001190 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001191 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001192 (char_u *)&p_fdo, PV_NONE,
1193 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001194 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001195 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1196# ifdef FEAT_EVAL
1197 (char_u *)VAR_WIN, PV_FDT,
1198 {(char_u *)"foldtext()", (char_u *)NULL}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001199# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001200 (char_u *)NULL, PV_NONE,
1201 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001202# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001203 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001204#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001205 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001206#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001207 (char_u *)&p_fex, PV_FEX,
1208 {(char_u *)"", (char_u *)0L}
1209#else
1210 (char_u *)NULL, PV_NONE,
1211 {(char_u *)0L, (char_u *)0L}
1212#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001213 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001214 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1215 (char_u *)&p_fo, PV_FO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001216 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1217 SCRIPTID_INIT},
Bram Moolenaar86b68352004-12-27 21:59:20 +00001218 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1219 (char_u *)&p_flp, PV_FLP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001220 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1221 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001222 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1223 (char_u *)&p_fp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001224 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001225 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1226#ifdef HAVE_FSYNC
1227 (char_u *)&p_fs, PV_NONE,
1228 {(char_u *)TRUE, (char_u *)0L}
1229#else
1230 (char_u *)NULL, PV_NONE,
1231 {(char_u *)FALSE, (char_u *)0L}
1232#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001233 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001234 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1235 (char_u *)&p_gd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001236 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001237 {"graphic", "gr", P_BOOL|P_VI_DEF,
1238 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001239 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001240 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1241#ifdef FEAT_QUICKFIX
1242 (char_u *)&p_gefm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001243 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001244#else
1245 (char_u *)NULL, PV_NONE,
1246 {(char_u *)NULL, (char_u *)0L}
1247#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001248 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001249 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1250#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001251 (char_u *)&p_gp, PV_GP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001252 {
1253# ifdef WIN3264
1254 /* may be changed to "grep -n" in os_win32.c */
1255 (char_u *)"findstr /n",
1256# else
1257# ifdef UNIX
1258 /* Add an extra file name so that grep will always
1259 * insert a file name in the match line. */
1260 (char_u *)"grep -n $* /dev/null",
1261# else
1262# ifdef VMS
1263 (char_u *)"SEARCH/NUMBERS ",
1264# else
1265 (char_u *)"grep -n ",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001266# endif
1267# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001268# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001269 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001270#else
1271 (char_u *)NULL, PV_NONE,
1272 {(char_u *)NULL, (char_u *)0L}
1273#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001274 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001275 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1276#ifdef CURSOR_SHAPE
1277 (char_u *)&p_guicursor, PV_NONE,
1278 {
1279# ifdef FEAT_GUI
1280 (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",
1281# else /* MSDOS or Win32 console */
1282 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1283# endif
1284 (char_u *)0L}
1285#else
1286 (char_u *)NULL, PV_NONE,
1287 {(char_u *)NULL, (char_u *)0L}
1288#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001289 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001290 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
1291#ifdef FEAT_GUI
1292 (char_u *)&p_guifont, PV_NONE,
1293 {(char_u *)"", (char_u *)0L}
1294#else
1295 (char_u *)NULL, PV_NONE,
1296 {(char_u *)NULL, (char_u *)0L}
1297#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001298 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001299 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_COMMA,
1300#if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1301 (char_u *)&p_guifontset, PV_NONE,
1302 {(char_u *)"", (char_u *)0L}
1303#else
1304 (char_u *)NULL, PV_NONE,
1305 {(char_u *)NULL, (char_u *)0L}
1306#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001307 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001308 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
1309#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1310 (char_u *)&p_guifontwide, PV_NONE,
1311 {(char_u *)"", (char_u *)0L}
1312#else
1313 (char_u *)NULL, PV_NONE,
1314 {(char_u *)NULL, (char_u *)0L}
1315#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001316 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001317 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001318#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001319 (char_u *)&p_ghr, PV_NONE,
1320#else
1321 (char_u *)NULL, PV_NONE,
1322#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001323 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001324 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001325#if defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001326 (char_u *)&p_go, PV_NONE,
1327# if defined(UNIX) && !defined(MACOS)
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001328 {(char_u *)"aegimrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001329# else
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001330 {(char_u *)"egmrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001331# endif
1332#else
1333 (char_u *)NULL, PV_NONE,
1334 {(char_u *)NULL, (char_u *)0L}
1335#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001336 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001337 {"guipty", NULL, P_BOOL|P_VI_DEF,
1338#if defined(FEAT_GUI)
1339 (char_u *)&p_guipty, PV_NONE,
1340#else
1341 (char_u *)NULL, PV_NONE,
1342#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001343 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar18144c82006-04-12 21:52:12 +00001344 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00001345#if defined(FEAT_GUI_TABLINE)
1346 (char_u *)&p_gtl, PV_NONE,
1347 {(char_u *)"", (char_u *)0L}
1348#else
1349 (char_u *)NULL, PV_NONE,
1350 {(char_u *)NULL, (char_u *)0L}
1351#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001352 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001353 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar57657d82006-04-21 22:12:41 +00001354#if defined(FEAT_GUI_TABLINE)
1355 (char_u *)&p_gtt, PV_NONE,
1356 {(char_u *)"", (char_u *)0L}
1357#else
1358 (char_u *)NULL, PV_NONE,
1359 {(char_u *)NULL, (char_u *)0L}
1360#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001361 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001362 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1363 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001364 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001365 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1366 (char_u *)&p_hf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001367 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1368 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001369 {"helpheight", "hh", P_NUM|P_VI_DEF,
1370#ifdef FEAT_WINDOWS
1371 (char_u *)&p_hh, PV_NONE,
1372#else
1373 (char_u *)NULL, PV_NONE,
1374#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001375 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001376 {"helplang", "hlg", P_STRING|P_VI_DEF|P_COMMA,
1377#ifdef FEAT_MULTI_LANG
1378 (char_u *)&p_hlg, PV_NONE,
1379 {(char_u *)"", (char_u *)0L}
1380#else
1381 (char_u *)NULL, PV_NONE,
1382 {(char_u *)0L, (char_u *)0L}
1383#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001384 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001385 {"hidden", "hid", P_BOOL|P_VI_DEF,
1386 (char_u *)&p_hid, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001387 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001388 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
1389 (char_u *)&p_hl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001390 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1391 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001392 {"history", "hi", P_NUM|P_VIM,
1393 (char_u *)&p_hi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001394 {(char_u *)0L, (char_u *)20L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001395 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1396#ifdef FEAT_RIGHTLEFT
1397 (char_u *)&p_hkmap, PV_NONE,
1398#else
1399 (char_u *)NULL, PV_NONE,
1400#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001401 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001402 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1403#ifdef FEAT_RIGHTLEFT
1404 (char_u *)&p_hkmapp, PV_NONE,
1405#else
1406 (char_u *)NULL, PV_NONE,
1407#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001408 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001409 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1410 (char_u *)&p_hls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001411 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001412 {"icon", NULL, P_BOOL|P_VI_DEF,
1413#ifdef FEAT_TITLE
1414 (char_u *)&p_icon, PV_NONE,
1415#else
1416 (char_u *)NULL, PV_NONE,
1417#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001418 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001419 {"iconstring", NULL, P_STRING|P_VI_DEF,
1420#ifdef FEAT_TITLE
1421 (char_u *)&p_iconstring, PV_NONE,
1422#else
1423 (char_u *)NULL, PV_NONE,
1424#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001425 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001426 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1427 (char_u *)&p_ic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001428 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001429 {"imactivatefunc","imaf",P_STRING|P_VI_DEF|P_SECURE,
1430# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1431 (char_u *)&p_imaf, PV_NONE,
1432 {(char_u *)"", (char_u *)NULL}
1433# else
1434 (char_u *)NULL, PV_NONE,
1435 {(char_u *)NULL, (char_u *)0L}
1436# endif
1437 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001438 {"imactivatekey","imak",P_STRING|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001439#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001440 (char_u *)&p_imak, PV_NONE,
1441#else
1442 (char_u *)NULL, PV_NONE,
1443#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001444 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001445 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1446#ifdef USE_IM_CONTROL
1447 (char_u *)&p_imcmdline, PV_NONE,
1448#else
1449 (char_u *)NULL, PV_NONE,
1450#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001451 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001452 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1453#ifdef USE_IM_CONTROL
1454 (char_u *)&p_imdisable, PV_NONE,
1455#else
1456 (char_u *)NULL, PV_NONE,
1457#endif
1458#ifdef __sgi
1459 {(char_u *)TRUE, (char_u *)0L}
1460#else
1461 {(char_u *)FALSE, (char_u *)0L}
1462#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001463 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001464 {"iminsert", "imi", P_NUM|P_VI_DEF,
1465 (char_u *)&p_iminsert, PV_IMI,
1466#ifdef B_IMODE_IM
1467 {(char_u *)B_IMODE_IM, (char_u *)0L}
1468#else
1469 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1470#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001471 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001472 {"imsearch", "ims", P_NUM|P_VI_DEF,
1473 (char_u *)&p_imsearch, PV_IMS,
1474#ifdef B_IMODE_IM
1475 {(char_u *)B_IMODE_IM, (char_u *)0L}
1476#else
1477 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1478#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001479 SCRIPTID_INIT},
Bram Moolenaar4a460702013-06-29 14:42:26 +02001480 {"imstatusfunc","imsf",P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaarabab85a2013-06-26 19:18:05 +02001481# if defined(FEAT_EVAL) && defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
1482 (char_u *)&p_imsf, PV_NONE,
1483 {(char_u *)"", (char_u *)NULL}
1484# else
1485 (char_u *)NULL, PV_NONE,
1486 {(char_u *)NULL, (char_u *)0L}
1487# endif
1488 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001489 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1490#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001491 (char_u *)&p_inc, PV_INC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001492 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1493#else
1494 (char_u *)NULL, PV_NONE,
1495 {(char_u *)0L, (char_u *)0L}
1496#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001497 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001498 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1499#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1500 (char_u *)&p_inex, PV_INEX,
1501 {(char_u *)"", (char_u *)0L}
1502#else
1503 (char_u *)NULL, PV_NONE,
1504 {(char_u *)0L, (char_u *)0L}
1505#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001506 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001507 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1508 (char_u *)&p_is, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001509 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001510 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1511#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1512 (char_u *)&p_inde, PV_INDE,
1513 {(char_u *)"", (char_u *)0L}
1514#else
1515 (char_u *)NULL, PV_NONE,
1516 {(char_u *)0L, (char_u *)0L}
1517#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001518 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001519 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
1520#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1521 (char_u *)&p_indk, PV_INDK,
1522 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1523#else
1524 (char_u *)NULL, PV_NONE,
1525 {(char_u *)0L, (char_u *)0L}
1526#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001527 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001528 {"infercase", "inf", P_BOOL|P_VI_DEF,
1529 (char_u *)&p_inf, PV_INF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001530 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001531 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1532 (char_u *)&p_im, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001533 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001534 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1535 (char_u *)&p_isf, PV_NONE,
1536 {
1537#ifdef BACKSLASH_IN_FILENAME
1538 /* Excluded are: & and ^ are special in cmd.exe
1539 * ( and ) are used in text separating fnames */
1540 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1541#else
1542# ifdef AMIGA
1543 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1544# else
1545# ifdef VMS
1546 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1547# else /* UNIX et al. */
1548# ifdef EBCDIC
1549 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1550# else
1551 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1552# endif
1553# endif
1554# endif
1555#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001556 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001557 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1558 (char_u *)&p_isi, PV_NONE,
1559 {
1560#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1561 (char_u *)"@,48-57,_,128-167,224-235",
1562#else
1563# ifdef EBCDIC
1564 /* TODO: EBCDIC Check this! @ == isalpha()*/
1565 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1566 "112-120,128,140-142,156,158,172,"
1567 "174,186,191,203-207,219-225,235-239,"
1568 "251-254",
1569# else
1570 (char_u *)"@,48-57,_,192-255",
1571# endif
1572#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001573 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001574 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1575 (char_u *)&p_isk, PV_ISK,
1576 {
1577#ifdef EBCDIC
1578 (char_u *)"@,240-249,_",
1579 /* TODO: EBCDIC Check this! @ == isalpha()*/
1580 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1581 "112-120,128,140-142,156,158,172,"
1582 "174,186,191,203-207,219-225,235-239,"
1583 "251-254",
1584#else
1585 (char_u *)"@,48-57,_",
1586# if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1587 (char_u *)"@,48-57,_,128-167,224-235"
1588# else
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001589 ISK_LATIN1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001590# endif
1591#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001592 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001593 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1594 (char_u *)&p_isp, PV_NONE,
1595 {
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001596#if defined(MSDOS) || defined(MSWIN) || defined(OS2) \
1597 || (defined(MACOS) && !defined(MACOS_X)) \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001598 || defined(VMS)
1599 (char_u *)"@,~-255",
1600#else
1601# ifdef EBCDIC
1602 /* all chars above 63 are printable */
1603 (char_u *)"63-255",
1604# else
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00001605 ISP_LATIN1,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001606# endif
1607#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001608 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001609 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1610 (char_u *)&p_js, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001611 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001612 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1613#ifdef FEAT_CRYPT
1614 (char_u *)&p_key, PV_KEY,
1615 {(char_u *)"", (char_u *)0L}
1616#else
1617 (char_u *)NULL, PV_NONE,
1618 {(char_u *)0L, (char_u *)0L}
1619#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001620 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001621 {"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 +00001622#ifdef FEAT_KEYMAP
1623 (char_u *)&p_keymap, PV_KMAP,
1624 {(char_u *)"", (char_u *)0L}
1625#else
1626 (char_u *)NULL, PV_NONE,
1627 {(char_u *)"", (char_u *)0L}
1628#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001629 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001630 {"keymodel", "km", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1631#ifdef FEAT_VISUAL
1632 (char_u *)&p_km, PV_NONE,
1633#else
1634 (char_u *)NULL, PV_NONE,
1635#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001636 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001637 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001638 (char_u *)&p_kp, PV_KP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001639 {
1640#if defined(MSDOS) || defined(MSWIN)
1641 (char_u *)":help",
1642#else
1643#ifdef VMS
1644 (char_u *)"help",
1645#else
1646# if defined(OS2)
1647 (char_u *)"view /",
1648# else
1649# ifdef USEMAN_S
1650 (char_u *)"man -s",
1651# else
1652 (char_u *)"man",
1653# endif
1654# endif
1655#endif
1656#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001657 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001658 {"langmap", "lmap", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1659#ifdef FEAT_LANGMAP
1660 (char_u *)&p_langmap, PV_NONE,
1661 {(char_u *)"", /* unmatched } */
1662#else
1663 (char_u *)NULL, PV_NONE,
1664 {(char_u *)NULL,
1665#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001666 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001667 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001668#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1669 (char_u *)&p_lm, PV_NONE,
1670#else
1671 (char_u *)NULL, PV_NONE,
1672#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001673 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001674 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1675#ifdef FEAT_WINDOWS
1676 (char_u *)&p_ls, PV_NONE,
1677#else
1678 (char_u *)NULL, PV_NONE,
1679#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001680 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001681 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1682 (char_u *)&p_lz, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001683 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001684 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1685#ifdef FEAT_LINEBREAK
1686 (char_u *)VAR_WIN, PV_LBR,
1687#else
1688 (char_u *)NULL, PV_NONE,
1689#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001690 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001691 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1692 (char_u *)&Rows, PV_NONE,
1693 {
1694#if defined(MSDOS) || defined(WIN3264) || defined(OS2)
1695 (char_u *)25L,
1696#else
1697 (char_u *)24L,
1698#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001699 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001700 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1701#ifdef FEAT_GUI
1702 (char_u *)&p_linespace, PV_NONE,
1703#else
1704 (char_u *)NULL, PV_NONE,
1705#endif
1706#ifdef FEAT_GUI_W32
1707 {(char_u *)1L, (char_u *)0L}
1708#else
1709 {(char_u *)0L, (char_u *)0L}
1710#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001711 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001712 {"lisp", NULL, P_BOOL|P_VI_DEF,
1713#ifdef FEAT_LISP
1714 (char_u *)&p_lisp, PV_LISP,
1715#else
1716 (char_u *)NULL, PV_NONE,
1717#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001718 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001719 {"lispwords", "lw", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1720#ifdef FEAT_LISP
1721 (char_u *)&p_lispwords, PV_NONE,
1722 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1723#else
1724 (char_u *)NULL, PV_NONE,
1725 {(char_u *)"", (char_u *)0L}
1726#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001727 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001728 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1729 (char_u *)VAR_WIN, PV_LIST,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001730 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001731 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1732 (char_u *)&p_lcs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001733 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001734 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1735 (char_u *)&p_lpl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001736 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001737#ifdef FEAT_GUI_MAC
1738 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
1739 (char_u *)&p_macatsui, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001740 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001741#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001742 {"magic", NULL, P_BOOL|P_VI_DEF,
1743 (char_u *)&p_magic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001744 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00001745 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001746#ifdef FEAT_QUICKFIX
1747 (char_u *)&p_mef, PV_NONE,
1748 {(char_u *)"", (char_u *)0L}
1749#else
1750 (char_u *)NULL, PV_NONE,
1751 {(char_u *)NULL, (char_u *)0L}
1752#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001753 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001754 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1755#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001756 (char_u *)&p_mp, PV_MP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001757# ifdef VMS
1758 {(char_u *)"MMS", (char_u *)0L}
1759# else
1760 {(char_u *)"make", (char_u *)0L}
1761# endif
1762#else
1763 (char_u *)NULL, PV_NONE,
1764 {(char_u *)NULL, (char_u *)0L}
1765#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001766 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001767 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
1768 (char_u *)&p_mps, PV_MPS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001769 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1770 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001771 {"matchtime", "mat", P_NUM|P_VI_DEF,
1772 (char_u *)&p_mat, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001773 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001774 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001775#ifdef FEAT_MBYTE
1776 (char_u *)&p_mco, PV_NONE,
1777#else
1778 (char_u *)NULL, PV_NONE,
1779#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001780 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001781 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1782#ifdef FEAT_EVAL
1783 (char_u *)&p_mfd, PV_NONE,
1784#else
1785 (char_u *)NULL, PV_NONE,
1786#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001787 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001788 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1789 (char_u *)&p_mmd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001790 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001791 {"maxmem", "mm", P_NUM|P_VI_DEF,
1792 (char_u *)&p_mm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001793 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1794 SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00001795 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1796 (char_u *)&p_mmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001797 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001798 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1799 (char_u *)&p_mmt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001800 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1801 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001802 {"menuitems", "mis", P_NUM|P_VI_DEF,
1803#ifdef FEAT_MENU
1804 (char_u *)&p_mis, PV_NONE,
1805#else
1806 (char_u *)NULL, PV_NONE,
1807#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001808 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001809 {"mesg", NULL, P_BOOL|P_VI_DEF,
1810 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001811 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001812 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001813#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001814 (char_u *)&p_msm, PV_NONE,
1815 {(char_u *)"460000,2000,500", (char_u *)0L}
1816#else
1817 (char_u *)NULL, PV_NONE,
1818 {(char_u *)0L, (char_u *)0L}
1819#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001820 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001821 {"modeline", "ml", P_BOOL|P_VIM,
1822 (char_u *)&p_ml, PV_ML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001823 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001824 {"modelines", "mls", P_NUM|P_VI_DEF,
1825 (char_u *)&p_mls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001826 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001827 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1828 (char_u *)&p_ma, PV_MA,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001829 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001830 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1831 (char_u *)&p_mod, PV_MOD,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001832 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001833 {"more", NULL, P_BOOL|P_VIM,
1834 (char_u *)&p_more, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001835 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001836 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
1837 (char_u *)&p_mouse, PV_NONE,
1838 {
1839#if defined(MSDOS) || defined(WIN3264)
1840 (char_u *)"a",
1841#else
1842 (char_u *)"",
1843#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001844 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001845 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
1846#ifdef FEAT_GUI
1847 (char_u *)&p_mousef, PV_NONE,
1848#else
1849 (char_u *)NULL, PV_NONE,
1850#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001851 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001852 {"mousehide", "mh", P_BOOL|P_VI_DEF,
1853#ifdef FEAT_GUI
1854 (char_u *)&p_mh, PV_NONE,
1855#else
1856 (char_u *)NULL, PV_NONE,
1857#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001858 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001859 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
1860 (char_u *)&p_mousem, PV_NONE,
1861 {
1862#if defined(MSDOS) || defined(MSWIN)
1863 (char_u *)"popup",
1864#else
1865# if defined(MACOS)
1866 (char_u *)"popup_setpos",
1867# else
1868 (char_u *)"extend",
1869# endif
1870#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001871 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001872 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1873#ifdef FEAT_MOUSESHAPE
1874 (char_u *)&p_mouseshape, PV_NONE,
1875 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
1876#else
1877 (char_u *)NULL, PV_NONE,
1878 {(char_u *)NULL, (char_u *)0L}
1879#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001880 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001881 {"mousetime", "mouset", P_NUM|P_VI_DEF,
1882 (char_u *)&p_mouset, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001883 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001884 {"mzquantum", "mzq", P_NUM,
1885#ifdef FEAT_MZSCHEME
1886 (char_u *)&p_mzq, PV_NONE,
1887#else
1888 (char_u *)NULL, PV_NONE,
1889#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001890 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001891 {"novice", NULL, P_BOOL|P_VI_DEF,
1892 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001893 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001894 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
1895 (char_u *)&p_nf, PV_NF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001896 {(char_u *)"octal,hex", (char_u *)0L}
1897 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001898 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
1899 (char_u *)VAR_WIN, PV_NU,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001900 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00001901 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
1902#ifdef FEAT_LINEBREAK
1903 (char_u *)VAR_WIN, PV_NUW,
1904#else
1905 (char_u *)NULL, PV_NONE,
1906#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001907 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
Bram Moolenaarf75a9632005-09-13 21:20:47 +00001908 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
Bram Moolenaare344bea2005-09-01 20:46:49 +00001909#ifdef FEAT_COMPL_FUNC
1910 (char_u *)&p_ofu, PV_OFU,
1911 {(char_u *)"", (char_u *)0L}
1912#else
1913 (char_u *)NULL, PV_NONE,
1914 {(char_u *)0L, (char_u *)0L}
1915#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001916 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001917 {"open", NULL, P_BOOL|P_VI_DEF,
1918 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001919 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar043545e2006-10-10 16:44:07 +00001920 {"opendevice", "odev", P_BOOL|P_VI_DEF,
1921#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1922 (char_u *)&p_odev, PV_NONE,
1923#else
1924 (char_u *)NULL, PV_NONE,
1925#endif
1926 {(char_u *)FALSE, (char_u *)FALSE}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001927 SCRIPTID_INIT},
Bram Moolenaar2c7a29c2005-12-12 22:02:31 +00001928 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
1929 (char_u *)&p_opfunc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001930 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001931 {"optimize", "opt", P_BOOL|P_VI_DEF,
1932 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001933 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001934 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001935 (char_u *)NULL, PV_NONE,
Bram Moolenaarb07269a2011-05-19 13:41:14 +02001936 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001937 {"paragraphs", "para", P_STRING|P_VI_DEF,
1938 (char_u *)&p_para, PV_NONE,
Bram Moolenaar57e48462008-03-12 16:38:55 +00001939 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001940 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001941 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001942 (char_u *)&p_paste, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001943 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001944 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
1945 (char_u *)&p_pt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001946 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001947 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
1948#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1949 (char_u *)&p_pex, PV_NONE,
1950 {(char_u *)"", (char_u *)0L}
1951#else
1952 (char_u *)NULL, PV_NONE,
1953 {(char_u *)0L, (char_u *)0L}
1954#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001955 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001956 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001957 (char_u *)&p_pm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001958 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001959 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001960 (char_u *)&p_path, PV_PATH,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001961 {
1962#if defined AMIGA || defined MSDOS || defined MSWIN
1963 (char_u *)".,,",
1964#else
1965# if defined(__EMX__)
1966 (char_u *)".,/emx/include,,",
1967# else /* Unix, probably */
1968 (char_u *)".,/usr/include,,",
1969# endif
1970#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001971 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001972 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
1973 (char_u *)&p_pi, PV_PI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001974 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00001975 {"previewheight", "pvh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001976#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
1977 (char_u *)&p_pvh, PV_NONE,
1978#else
1979 (char_u *)NULL, PV_NONE,
1980#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001981 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001982 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
1983#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
1984 (char_u *)VAR_WIN, PV_PVW,
1985#else
1986 (char_u *)NULL, PV_NONE,
1987#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001988 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001989 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001990#ifdef FEAT_PRINTER
1991 (char_u *)&p_pdev, PV_NONE,
1992 {(char_u *)"", (char_u *)0L}
1993#else
1994 (char_u *)NULL, PV_NONE,
1995 {(char_u *)NULL, (char_u *)0L}
1996#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001997 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001998 {"printencoding", "penc", P_STRING|P_VI_DEF,
1999#ifdef FEAT_POSTSCRIPT
2000 (char_u *)&p_penc, PV_NONE,
2001 {(char_u *)"", (char_u *)0L}
2002#else
2003 (char_u *)NULL, PV_NONE,
2004 {(char_u *)NULL, (char_u *)0L}
2005#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002006 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002007 {"printexpr", "pexpr", P_STRING|P_VI_DEF,
2008#ifdef FEAT_POSTSCRIPT
2009 (char_u *)&p_pexpr, PV_NONE,
2010 {(char_u *)"", (char_u *)0L}
2011#else
2012 (char_u *)NULL, PV_NONE,
2013 {(char_u *)NULL, (char_u *)0L}
2014#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002015 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002016 {"printfont", "pfn", P_STRING|P_VI_DEF,
2017#ifdef FEAT_PRINTER
2018 (char_u *)&p_pfn, PV_NONE,
2019 {
2020# ifdef MSWIN
2021 (char_u *)"Courier_New:h10",
2022# else
2023 (char_u *)"courier",
2024# endif
2025 (char_u *)0L}
2026#else
2027 (char_u *)NULL, PV_NONE,
2028 {(char_u *)NULL, (char_u *)0L}
2029#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002030 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002031 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
2032#ifdef FEAT_PRINTER
2033 (char_u *)&p_header, PV_NONE,
2034 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
2035#else
2036 (char_u *)NULL, PV_NONE,
2037 {(char_u *)NULL, (char_u *)0L}
2038#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002039 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002040 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
2041#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2042 (char_u *)&p_pmcs, PV_NONE,
2043 {(char_u *)"", (char_u *)0L}
2044#else
2045 (char_u *)NULL, PV_NONE,
2046 {(char_u *)NULL, (char_u *)0L}
2047#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002048 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002049 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2050#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2051 (char_u *)&p_pmfn, PV_NONE,
2052 {(char_u *)"", (char_u *)0L}
2053#else
2054 (char_u *)NULL, PV_NONE,
2055 {(char_u *)NULL, (char_u *)0L}
2056#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002057 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002058 {"printoptions", "popt", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2059#ifdef FEAT_PRINTER
2060 (char_u *)&p_popt, PV_NONE,
2061 {(char_u *)"", (char_u *)0L}
2062#else
2063 (char_u *)NULL, PV_NONE,
2064 {(char_u *)NULL, (char_u *)0L}
2065#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002066 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002067 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002068 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002069 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002070 {"pumheight", "ph", P_NUM|P_VI_DEF,
2071#ifdef FEAT_INS_EXPAND
2072 (char_u *)&p_ph, PV_NONE,
2073#else
2074 (char_u *)NULL, PV_NONE,
2075#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002076 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002077 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2078#ifdef FEAT_TEXTOBJ
2079 (char_u *)&p_qe, PV_QE,
2080 {(char_u *)"\\", (char_u *)0L}
2081#else
2082 (char_u *)NULL, PV_NONE,
2083 {(char_u *)NULL, (char_u *)0L}
2084#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002085 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002086 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2087 (char_u *)&p_ro, PV_RO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002088 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002089 {"redraw", NULL, P_BOOL|P_VI_DEF,
2090 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002091 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002092 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2093#ifdef FEAT_RELTIME
2094 (char_u *)&p_rdt, PV_NONE,
2095#else
2096 (char_u *)NULL, PV_NONE,
2097#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002098 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02002099 {"regexpengine", "re", P_NUM|P_VI_DEF,
2100 (char_u *)&p_re, PV_NONE,
2101 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002102 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2103 (char_u *)VAR_WIN, PV_RNU,
2104 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002105 {"remap", NULL, P_BOOL|P_VI_DEF,
2106 (char_u *)&p_remap, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002107 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002108 {"report", NULL, P_NUM|P_VI_DEF,
2109 (char_u *)&p_report, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002110 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002111 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2112#ifdef WIN3264
2113 (char_u *)&p_rs, PV_NONE,
2114#else
2115 (char_u *)NULL, PV_NONE,
2116#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002117 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002118 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2119#ifdef FEAT_RIGHTLEFT
2120 (char_u *)&p_ri, PV_NONE,
2121#else
2122 (char_u *)NULL, PV_NONE,
2123#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002124 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002125 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2126#ifdef FEAT_RIGHTLEFT
2127 (char_u *)VAR_WIN, PV_RL,
2128#else
2129 (char_u *)NULL, PV_NONE,
2130#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002131 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002132 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2133#ifdef FEAT_RIGHTLEFT
2134 (char_u *)VAR_WIN, PV_RLC,
2135 {(char_u *)"search", (char_u *)NULL}
2136#else
2137 (char_u *)NULL, PV_NONE,
2138 {(char_u *)NULL, (char_u *)0L}
2139#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002140 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002141 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2142#ifdef FEAT_CMDL_INFO
2143 (char_u *)&p_ru, PV_NONE,
2144#else
2145 (char_u *)NULL, PV_NONE,
2146#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002147 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002148 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2149#ifdef FEAT_STL_OPT
2150 (char_u *)&p_ruf, PV_NONE,
2151#else
2152 (char_u *)NULL, PV_NONE,
2153#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002154 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002155 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_COMMA|P_NODUP|P_SECURE,
2156 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002157 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2158 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002159 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2160 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002161 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002162 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2163#ifdef FEAT_SCROLLBIND
2164 (char_u *)VAR_WIN, PV_SCBIND,
2165#else
2166 (char_u *)NULL, PV_NONE,
2167#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002168 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002169 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2170 (char_u *)&p_sj, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002171 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002172 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2173 (char_u *)&p_so, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002174 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002175 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2176#ifdef FEAT_SCROLLBIND
2177 (char_u *)&p_sbo, PV_NONE,
2178 {(char_u *)"ver,jump", (char_u *)0L}
2179#else
2180 (char_u *)NULL, PV_NONE,
2181 {(char_u *)0L, (char_u *)0L}
2182#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002183 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002184 {"sections", "sect", P_STRING|P_VI_DEF,
2185 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002186 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2187 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002188 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2189 (char_u *)&p_secure, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002190 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002191 {"selection", "sel", P_STRING|P_VI_DEF,
2192#ifdef FEAT_VISUAL
2193 (char_u *)&p_sel, PV_NONE,
2194#else
2195 (char_u *)NULL, PV_NONE,
2196#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002197 {(char_u *)"inclusive", (char_u *)0L}
2198 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002199 {"selectmode", "slm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2200#ifdef FEAT_VISUAL
2201 (char_u *)&p_slm, PV_NONE,
2202#else
2203 (char_u *)NULL, PV_NONE,
2204#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002205 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002206 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2207#ifdef FEAT_SESSION
2208 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002209 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002210 (char_u *)0L}
2211#else
2212 (char_u *)NULL, PV_NONE,
2213 {(char_u *)0L, (char_u *)0L}
2214#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002215 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002216 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2217 (char_u *)&p_sh, PV_NONE,
2218 {
2219#ifdef VMS
2220 (char_u *)"-",
2221#else
2222# if defined(MSDOS)
2223 (char_u *)"command",
2224# else
2225# if defined(WIN16)
2226 (char_u *)"command.com",
2227# else
2228# if defined(WIN3264)
2229 (char_u *)"", /* set in set_init_1() */
2230# else
2231# if defined(OS2)
2232 (char_u *)"cmd.exe",
2233# else
2234# if defined(ARCHIE)
2235 (char_u *)"gos",
2236# else
2237 (char_u *)"sh",
2238# endif
2239# endif
2240# endif
2241# endif
2242# endif
2243#endif /* VMS */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002244 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002245 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2246 (char_u *)&p_shcf, PV_NONE,
2247 {
2248#if defined(MSDOS) || defined(MSWIN)
2249 (char_u *)"/c",
2250#else
2251# if defined(OS2)
2252 (char_u *)"/c",
2253# else
2254 (char_u *)"-c",
2255# endif
2256#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002257 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002258 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2259#ifdef FEAT_QUICKFIX
2260 (char_u *)&p_sp, PV_NONE,
2261 {
2262#if defined(UNIX) || defined(OS2)
2263# ifdef ARCHIE
2264 (char_u *)"2>",
2265# else
2266 (char_u *)"| tee",
2267# endif
2268#else
2269 (char_u *)">",
2270#endif
2271 (char_u *)0L}
2272#else
2273 (char_u *)NULL, PV_NONE,
2274 {(char_u *)0L, (char_u *)0L}
2275#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002276 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002277 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2278 (char_u *)&p_shq, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002279 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002280 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2281 (char_u *)&p_srr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002282 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002283 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2284#ifdef BACKSLASH_IN_FILENAME
2285 (char_u *)&p_ssl, PV_NONE,
2286#else
2287 (char_u *)NULL, PV_NONE,
2288#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002289 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002290 {"shelltemp", "stmp", P_BOOL,
2291 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002292 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002293 {"shelltype", "st", P_NUM|P_VI_DEF,
2294#ifdef AMIGA
2295 (char_u *)&p_st, PV_NONE,
2296#else
2297 (char_u *)NULL, PV_NONE,
2298#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002299 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002300 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2301 (char_u *)&p_sxq, PV_NONE,
2302 {
2303#if defined(UNIX) && defined(USE_SYSTEM) && !defined(__EMX__)
2304 (char_u *)"\"",
2305#else
2306 (char_u *)"",
2307#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002308 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002309 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
2310 (char_u *)&p_sxe, PV_NONE,
2311 {
2312#if defined(MSDOS) || defined(WIN16) || defined(WIN3264)
2313 (char_u *)"\"&|<>()@^",
2314#else
2315 (char_u *)"",
2316#endif
2317 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002318 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2319 (char_u *)&p_sr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002320 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002321 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2322 (char_u *)&p_sw, PV_SW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002323 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002324 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2325 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002326 {(char_u *)"", (char_u *)"filnxtToO"}
2327 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002328 {"shortname", "sn", P_BOOL|P_VI_DEF,
2329#ifdef SHORT_FNAME
2330 (char_u *)NULL, PV_NONE,
2331#else
2332 (char_u *)&p_sn, PV_SN,
2333#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002334 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002335 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2336#ifdef FEAT_LINEBREAK
2337 (char_u *)&p_sbr, PV_NONE,
2338#else
2339 (char_u *)NULL, PV_NONE,
2340#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002341 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002342 {"showcmd", "sc", P_BOOL|P_VIM,
2343#ifdef FEAT_CMDL_INFO
2344 (char_u *)&p_sc, PV_NONE,
2345#else
2346 (char_u *)NULL, PV_NONE,
2347#endif
2348 {(char_u *)FALSE,
2349#ifdef UNIX
2350 (char_u *)FALSE
2351#else
2352 (char_u *)TRUE
2353#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002354 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002355 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2356 (char_u *)&p_sft, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002357 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002358 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2359 (char_u *)&p_sm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002360 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002361 {"showmode", "smd", P_BOOL|P_VIM,
2362 (char_u *)&p_smd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002363 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002364 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2365#ifdef FEAT_WINDOWS
2366 (char_u *)&p_stal, PV_NONE,
2367#else
2368 (char_u *)NULL, PV_NONE,
2369#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002370 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002371 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2372 (char_u *)&p_ss, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002373 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002374 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2375 (char_u *)&p_siso, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002376 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002377 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2378 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002379 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002380 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2381 (char_u *)&p_scs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002382 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002383 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2384#ifdef FEAT_SMARTINDENT
2385 (char_u *)&p_si, PV_SI,
2386#else
2387 (char_u *)NULL, PV_NONE,
2388#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002389 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002390 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2391 (char_u *)&p_sta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002392 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002393 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2394 (char_u *)&p_sts, PV_STS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002395 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002396 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2397 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002398 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002399 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002400#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002401 (char_u *)VAR_WIN, PV_SPELL,
2402#else
2403 (char_u *)NULL, PV_NONE,
2404#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002405 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002406 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002407#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002408 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002409 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002410#else
2411 (char_u *)NULL, PV_NONE,
2412 {(char_u *)0L, (char_u *)0L}
2413#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002414 SCRIPTID_INIT},
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002415 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE|P_COMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002416#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002417 (char_u *)&p_spf, PV_SPF,
2418 {(char_u *)"", (char_u *)0L}
2419#else
2420 (char_u *)NULL, PV_NONE,
2421 {(char_u *)0L, (char_u *)0L}
2422#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002423 SCRIPTID_INIT},
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00002424 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002425#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002426 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002427 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002428#else
2429 (char_u *)NULL, PV_NONE,
2430 {(char_u *)0L, (char_u *)0L}
2431#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002432 SCRIPTID_INIT},
Bram Moolenaar28e4c8d2006-05-09 16:15:42 +00002433 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_COMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002434#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002435 (char_u *)&p_sps, PV_NONE,
2436 {(char_u *)"best", (char_u *)0L}
2437#else
2438 (char_u *)NULL, PV_NONE,
2439 {(char_u *)0L, (char_u *)0L}
2440#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002441 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002442 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2443#ifdef FEAT_WINDOWS
2444 (char_u *)&p_sb, PV_NONE,
2445#else
2446 (char_u *)NULL, PV_NONE,
2447#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002448 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002449 {"splitright", "spr", P_BOOL|P_VI_DEF,
2450#ifdef FEAT_VERTSPLIT
2451 (char_u *)&p_spr, PV_NONE,
2452#else
2453 (char_u *)NULL, PV_NONE,
2454#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002455 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002456 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2457 (char_u *)&p_sol, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002458 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002459 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2460#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002461 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002462#else
2463 (char_u *)NULL, PV_NONE,
2464#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002465 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002466 {"suffixes", "su", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2467 (char_u *)&p_su, PV_NONE,
2468 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002469 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002470 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002471#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002472 (char_u *)&p_sua, PV_SUA,
2473 {(char_u *)"", (char_u *)0L}
2474#else
2475 (char_u *)NULL, PV_NONE,
2476 {(char_u *)0L, (char_u *)0L}
2477#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002478 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002479 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2480 (char_u *)&p_swf, PV_SWF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002481 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002482 {"swapsync", "sws", P_STRING|P_VI_DEF,
2483 (char_u *)&p_sws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002484 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002485 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2486 (char_u *)&p_swb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002487 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002488 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2489#ifdef FEAT_SYN_HL
2490 (char_u *)&p_smc, PV_SMC,
2491 {(char_u *)3000L, (char_u *)0L}
2492#else
2493 (char_u *)NULL, PV_NONE,
2494 {(char_u *)0L, (char_u *)0L}
2495#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002496 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002497 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002498#ifdef FEAT_SYN_HL
2499 (char_u *)&p_syn, PV_SYN,
2500 {(char_u *)"", (char_u *)0L}
2501#else
2502 (char_u *)NULL, PV_NONE,
2503 {(char_u *)0L, (char_u *)0L}
2504#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002505 SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002506 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2507#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002508 (char_u *)&p_tal, PV_NONE,
2509#else
2510 (char_u *)NULL, PV_NONE,
2511#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002512 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002513 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2514#ifdef FEAT_WINDOWS
2515 (char_u *)&p_tpm, PV_NONE,
2516#else
2517 (char_u *)NULL, PV_NONE,
2518#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002519 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002520 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2521 (char_u *)&p_ts, PV_TS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002522 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002523 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2524 (char_u *)&p_tbs, PV_NONE,
2525#ifdef VMS /* binary searching doesn't appear to work on VMS */
2526 {(char_u *)0L, (char_u *)0L}
2527#else
2528 {(char_u *)TRUE, (char_u *)0L}
2529#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002530 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002531 {"taglength", "tl", P_NUM|P_VI_DEF,
2532 (char_u *)&p_tl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002533 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002534 {"tagrelative", "tr", P_BOOL|P_VIM,
2535 (char_u *)&p_tr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002536 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002537 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002538 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002539 {
2540#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2541 (char_u *)"./tags,./TAGS,tags,TAGS",
2542#else
2543 (char_u *)"./tags,tags",
2544#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002545 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002546 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2547 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002548 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002549 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2550 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002551 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002552 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2553#ifdef FEAT_ARABIC
2554 (char_u *)&p_tbidi, PV_NONE,
2555#else
2556 (char_u *)NULL, PV_NONE,
2557#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002558 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002559 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2560#ifdef FEAT_MBYTE
2561 (char_u *)&p_tenc, PV_NONE,
2562 {(char_u *)"", (char_u *)0L}
2563#else
2564 (char_u *)NULL, PV_NONE,
2565 {(char_u *)0L, (char_u *)0L}
2566#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002567 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002568 {"terse", NULL, P_BOOL|P_VI_DEF,
2569 (char_u *)&p_terse, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002570 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002571 {"textauto", "ta", P_BOOL|P_VIM,
2572 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002573 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2574 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002575 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2576 (char_u *)&p_tx, PV_TX,
2577 {
2578#ifdef USE_CRNL
2579 (char_u *)TRUE,
2580#else
2581 (char_u *)FALSE,
2582#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002583 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +02002584 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002585 (char_u *)&p_tw, PV_TW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002586 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002587 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
2588#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002589 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002590#else
2591 (char_u *)NULL, PV_NONE,
2592#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002593 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002594 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2595 (char_u *)&p_to, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002596 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002597 {"timeout", "to", P_BOOL|P_VI_DEF,
2598 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002599 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002600 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2601 (char_u *)&p_tm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002602 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002603 {"title", NULL, P_BOOL|P_VI_DEF,
2604#ifdef FEAT_TITLE
2605 (char_u *)&p_title, PV_NONE,
2606#else
2607 (char_u *)NULL, PV_NONE,
2608#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002609 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002610 {"titlelen", NULL, P_NUM|P_VI_DEF,
2611#ifdef FEAT_TITLE
2612 (char_u *)&p_titlelen, PV_NONE,
2613#else
2614 (char_u *)NULL, PV_NONE,
2615#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002616 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002617 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002618#ifdef FEAT_TITLE
2619 (char_u *)&p_titleold, PV_NONE,
2620 {(char_u *)N_("Thanks for flying Vim"),
2621 (char_u *)0L}
2622#else
2623 (char_u *)NULL, PV_NONE,
2624 {(char_u *)0L, (char_u *)0L}
2625#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002626 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002627 {"titlestring", NULL, P_STRING|P_VI_DEF,
2628#ifdef FEAT_TITLE
2629 (char_u *)&p_titlestring, PV_NONE,
2630#else
2631 (char_u *)NULL, PV_NONE,
2632#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002633 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002634#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
2635 {"toolbar", "tb", P_STRING|P_COMMA|P_VI_DEF|P_NODUP,
2636 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002637 {(char_u *)"icons,tooltips", (char_u *)0L}
2638 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002639#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002640#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002641 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
2642 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002643 {(char_u *)"small", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002644#endif
2645 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2646 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002647 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002648 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2649 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002650 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002651 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2652 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002653 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002654 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2655 (char_u *)&p_tf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002656 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002657 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2658#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2659 (char_u *)&p_ttym, PV_NONE,
2660#else
2661 (char_u *)NULL, PV_NONE,
2662#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002663 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002664 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2665 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002666 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002667 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2668 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002669 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002670 {"undodir", "udir", P_STRING|P_EXPAND|P_COMMA|P_NODUP|P_SECURE|P_VI_DEF,
2671#ifdef FEAT_PERSISTENT_UNDO
2672 (char_u *)&p_udir, PV_NONE,
2673 {(char_u *)".", (char_u *)0L}
2674#else
2675 (char_u *)NULL, PV_NONE,
2676 {(char_u *)0L, (char_u *)0L}
2677#endif
2678 SCRIPTID_INIT},
2679 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2680#ifdef FEAT_PERSISTENT_UNDO
2681 (char_u *)&p_udf, PV_UDF,
2682#else
2683 (char_u *)NULL, PV_NONE,
2684#endif
2685 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002686 {"undolevels", "ul", P_NUM|P_VI_DEF,
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01002687 (char_u *)&p_ul, PV_UL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002688 {
2689#if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS)
2690 (char_u *)1000L,
2691#else
2692 (char_u *)100L,
2693#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002694 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar59f931e2010-07-24 20:27:03 +02002695 {"undoreload", "ur", P_NUM|P_VI_DEF,
2696 (char_u *)&p_ur, PV_NONE,
2697 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002698 {"updatecount", "uc", P_NUM|P_VI_DEF,
2699 (char_u *)&p_uc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002700 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002701 {"updatetime", "ut", P_NUM|P_VI_DEF,
2702 (char_u *)&p_ut, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002703 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002704 {"verbose", "vbs", P_NUM|P_VI_DEF,
2705 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002706 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002707 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2708 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002709 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002710 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2711#ifdef FEAT_SESSION
2712 (char_u *)&p_vdir, PV_NONE,
2713 {(char_u *)DFLT_VDIR, (char_u *)0L}
2714#else
2715 (char_u *)NULL, PV_NONE,
2716 {(char_u *)0L, (char_u *)0L}
2717#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002718 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002719 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2720#ifdef FEAT_SESSION
2721 (char_u *)&p_vop, PV_NONE,
2722 {(char_u *)"folds,options,cursor", (char_u *)0L}
2723#else
2724 (char_u *)NULL, PV_NONE,
2725 {(char_u *)0L, (char_u *)0L}
2726#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002727 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002728 {"viminfo", "vi", P_STRING|P_COMMA|P_NODUP|P_SECURE,
2729#ifdef FEAT_VIMINFO
2730 (char_u *)&p_viminfo, PV_NONE,
2731#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
Bram Moolenaard812df62008-11-09 12:46:09 +00002732 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002733#else
2734# ifdef AMIGA
2735 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002736 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002737# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002738 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002739# endif
2740#endif
2741#else
2742 (char_u *)NULL, PV_NONE,
2743 {(char_u *)0L, (char_u *)0L}
2744#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002745 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02002746 {"virtualedit", "ve", P_STRING|P_COMMA|P_NODUP|P_VI_DEF|P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002747#ifdef FEAT_VIRTUALEDIT
2748 (char_u *)&p_ve, PV_NONE,
2749 {(char_u *)"", (char_u *)""}
2750#else
2751 (char_u *)NULL, PV_NONE,
2752 {(char_u *)0L, (char_u *)0L}
2753#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002754 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002755 {"visualbell", "vb", P_BOOL|P_VI_DEF,
2756 (char_u *)&p_vb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002757 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002758 {"w300", NULL, P_NUM|P_VI_DEF,
2759 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002760 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002761 {"w1200", NULL, P_NUM|P_VI_DEF,
2762 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002763 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002764 {"w9600", NULL, P_NUM|P_VI_DEF,
2765 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002766 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002767 {"warn", NULL, P_BOOL|P_VI_DEF,
2768 (char_u *)&p_warn, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002769 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002770 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
2771 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002772 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002773 {"whichwrap", "ww", P_STRING|P_VIM|P_COMMA|P_FLAGLIST,
2774 (char_u *)&p_ww, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002775 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002776 {"wildchar", "wc", P_NUM|P_VIM,
2777 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002778 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
2779 SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002780 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002781 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002782 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002783 {"wildignore", "wig", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2784#ifdef FEAT_WILDIGN
2785 (char_u *)&p_wig, PV_NONE,
2786#else
2787 (char_u *)NULL, PV_NONE,
2788#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002789 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002790 {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
2791 (char_u *)&p_wic, PV_NONE,
2792 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002793 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
2794#ifdef FEAT_WILDMENU
2795 (char_u *)&p_wmnu, PV_NONE,
2796#else
2797 (char_u *)NULL, PV_NONE,
2798#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002799 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002800 {"wildmode", "wim", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2801 (char_u *)&p_wim, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002802 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00002803 {"wildoptions", "wop", P_STRING|P_VI_DEF,
2804#ifdef FEAT_CMDL_COMPL
2805 (char_u *)&p_wop, PV_NONE,
2806 {(char_u *)"", (char_u *)0L}
2807#else
2808 (char_u *)NULL, PV_NONE,
2809 {(char_u *)NULL, (char_u *)0L}
2810#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002811 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002812 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
2813#ifdef FEAT_WAK
2814 (char_u *)&p_wak, PV_NONE,
2815 {(char_u *)"menu", (char_u *)0L}
2816#else
2817 (char_u *)NULL, PV_NONE,
2818 {(char_u *)NULL, (char_u *)0L}
2819#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002820 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002821 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00002822 (char_u *)&p_window, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002823 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002824 {"winheight", "wh", P_NUM|P_VI_DEF,
2825#ifdef FEAT_WINDOWS
2826 (char_u *)&p_wh, PV_NONE,
2827#else
2828 (char_u *)NULL, PV_NONE,
2829#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002830 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002831 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002832#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002833 (char_u *)VAR_WIN, PV_WFH,
2834#else
2835 (char_u *)NULL, PV_NONE,
2836#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002837 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002838 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
2839#ifdef FEAT_VERTSPLIT
2840 (char_u *)VAR_WIN, PV_WFW,
2841#else
2842 (char_u *)NULL, PV_NONE,
2843#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002844 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002845 {"winminheight", "wmh", P_NUM|P_VI_DEF,
2846#ifdef FEAT_WINDOWS
2847 (char_u *)&p_wmh, PV_NONE,
2848#else
2849 (char_u *)NULL, PV_NONE,
2850#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002851 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002852 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
2853#ifdef FEAT_VERTSPLIT
2854 (char_u *)&p_wmw, PV_NONE,
2855#else
2856 (char_u *)NULL, PV_NONE,
2857#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002858 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002859 {"winwidth", "wiw", P_NUM|P_VI_DEF,
2860#ifdef FEAT_VERTSPLIT
2861 (char_u *)&p_wiw, PV_NONE,
2862#else
2863 (char_u *)NULL, PV_NONE,
2864#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002865 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002866 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
2867 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002868 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002869 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
2870 (char_u *)&p_wm, PV_WM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002871 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002872 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
2873 (char_u *)&p_ws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002874 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002875 {"write", NULL, P_BOOL|P_VI_DEF,
2876 (char_u *)&p_write, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002877 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002878 {"writeany", "wa", P_BOOL|P_VI_DEF,
2879 (char_u *)&p_wa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002880 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002881 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
2882 (char_u *)&p_wb, PV_NONE,
2883 {
2884#ifdef FEAT_WRITEBACKUP
2885 (char_u *)TRUE,
2886#else
2887 (char_u *)FALSE,
2888#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002889 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002890 {"writedelay", "wd", P_NUM|P_VI_DEF,
2891 (char_u *)&p_wd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002892 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002893
2894/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002895#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00002896 (char_u *)&vvv, PV_NONE, \
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002897 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002898
2899 p_term("t_AB", T_CAB)
2900 p_term("t_AF", T_CAF)
2901 p_term("t_AL", T_CAL)
2902 p_term("t_al", T_AL)
2903 p_term("t_bc", T_BC)
2904 p_term("t_cd", T_CD)
2905 p_term("t_ce", T_CE)
2906 p_term("t_cl", T_CL)
2907 p_term("t_cm", T_CM)
2908 p_term("t_Co", T_CCO)
2909 p_term("t_CS", T_CCS)
2910 p_term("t_cs", T_CS)
2911#ifdef FEAT_VERTSPLIT
2912 p_term("t_CV", T_CSV)
2913#endif
2914 p_term("t_ut", T_UT)
2915 p_term("t_da", T_DA)
2916 p_term("t_db", T_DB)
2917 p_term("t_DL", T_CDL)
2918 p_term("t_dl", T_DL)
2919 p_term("t_fs", T_FS)
2920 p_term("t_IE", T_CIE)
2921 p_term("t_IS", T_CIS)
2922 p_term("t_ke", T_KE)
2923 p_term("t_ks", T_KS)
2924 p_term("t_le", T_LE)
2925 p_term("t_mb", T_MB)
2926 p_term("t_md", T_MD)
2927 p_term("t_me", T_ME)
2928 p_term("t_mr", T_MR)
2929 p_term("t_ms", T_MS)
2930 p_term("t_nd", T_ND)
2931 p_term("t_op", T_OP)
2932 p_term("t_RI", T_CRI)
2933 p_term("t_RV", T_CRV)
Bram Moolenaar9584b312013-03-13 19:29:28 +01002934 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002935 p_term("t_Sb", T_CSB)
2936 p_term("t_Sf", T_CSF)
2937 p_term("t_se", T_SE)
2938 p_term("t_so", T_SO)
2939 p_term("t_sr", T_SR)
2940 p_term("t_ts", T_TS)
2941 p_term("t_te", T_TE)
2942 p_term("t_ti", T_TI)
2943 p_term("t_ue", T_UE)
2944 p_term("t_us", T_US)
2945 p_term("t_vb", T_VB)
2946 p_term("t_ve", T_VE)
2947 p_term("t_vi", T_VI)
2948 p_term("t_vs", T_VS)
2949 p_term("t_WP", T_CWP)
2950 p_term("t_WS", T_CWS)
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002951 p_term("t_SI", T_CSI)
2952 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002953 p_term("t_xs", T_XS)
2954 p_term("t_ZH", T_CZH)
2955 p_term("t_ZR", T_CZR)
2956
2957/* terminal key codes are not in here */
2958
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002959 /* end marker */
2960 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002961};
2962
2963#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
2964
2965#ifdef FEAT_MBYTE
2966static char *(p_ambw_values[]) = {"single", "double", NULL};
2967#endif
2968static char *(p_bg_values[]) = {"light", "dark", NULL};
2969static char *(p_nf_values[]) = {"octal", "hex", "alpha", NULL};
2970static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02002971#ifdef FEAT_CRYPT
2972static char *(p_cm_values[]) = {"zip", "blowfish", NULL};
2973#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00002974#ifdef FEAT_CMDL_COMPL
2975static char *(p_wop_values[]) = {"tagfile", NULL};
2976#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002977#ifdef FEAT_WAK
2978static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
2979#endif
2980static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
2981#ifdef FEAT_VISUAL
2982static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
2983static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
2984#endif
2985#ifdef FEAT_VISUAL
2986static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
2987#endif
2988#ifdef FEAT_BROWSE
2989static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
2990#endif
2991#ifdef FEAT_SCROLLBIND
2992static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
2993#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00002994static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00002995#ifdef FEAT_VERTSPLIT
2996static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
2997#endif
2998#if defined(FEAT_QUICKFIX)
Bram Moolenaar21cf8232004-07-16 20:18:37 +00002999# ifdef FEAT_AUTOCMD
3000static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
3001# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00003002static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
Bram Moolenaar21cf8232004-07-16 20:18:37 +00003003# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003004static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
3005#endif
3006static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
3007#ifdef FEAT_FOLDING
3008static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003009# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00003010 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003011# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003012 NULL};
3013static char *(p_fcl_values[]) = {"all", NULL};
3014#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003015#ifdef FEAT_INS_EXPAND
Bram Moolenaarc270d802006-03-11 21:29:41 +00003016static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00003017#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003018
3019static void set_option_default __ARGS((int, int opt_flags, int compatible));
3020static void set_options_default __ARGS((int opt_flags));
Bram Moolenaarf740b292006-02-16 22:11:02 +00003021static char_u *term_bg_default __ARGS((void));
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003022static void did_set_option __ARGS((int opt_idx, int opt_flags, int new_value));
Bram Moolenaar071d4272004-06-13 20:20:40 +00003023static char_u *illegal_char __ARGS((char_u *, int));
3024static int string_to_key __ARGS((char_u *arg));
3025#ifdef FEAT_CMDWIN
3026static char_u *check_cedit __ARGS((void));
3027#endif
3028#ifdef FEAT_TITLE
3029static void did_set_title __ARGS((int icon));
3030#endif
3031static char_u *option_expand __ARGS((int opt_idx, char_u *val));
3032static void didset_options __ARGS((void));
3033static void check_string_option __ARGS((char_u **pp));
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003034#if defined(FEAT_EVAL) || defined(PROTO)
3035static long_u *insecure_flag __ARGS((int opt_idx, int opt_flags));
3036#else
3037# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3038#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003039static void set_string_option_global __ARGS((int opt_idx, char_u **varp));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02003040static char_u *set_string_option __ARGS((int opt_idx, char_u *value, int opt_flags));
Bram Moolenaar071d4272004-06-13 20:20:40 +00003041static 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));
3042static char_u *set_chars_option __ARGS((char_u **varp));
Bram Moolenaar1a384422010-07-14 19:53:30 +02003043#ifdef FEAT_SYN_HL
3044static int int_cmp __ARGS((const void *a, const void *b));
3045#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003046#ifdef FEAT_CLIPBOARD
3047static char_u *check_clipboard_option __ARGS((void));
3048#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003049#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02003050static char_u *compile_cap_prog __ARGS((synblock_T *synblock));
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003051#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003052#ifdef FEAT_EVAL
3053static void set_option_scriptID_idx __ARGS((int opt_idx, int opt_flags, int id));
3054#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003055static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value, int opt_flags));
Bram Moolenaar555b2802005-05-19 21:08:39 +00003056static 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 +00003057static void check_redraw __ARGS((long_u flags));
3058static int findoption __ARGS((char_u *));
3059static int find_key_option __ARGS((char_u *));
3060static void showoptions __ARGS((int all, int opt_flags));
3061static int optval_default __ARGS((struct vimoption *, char_u *varp));
3062static void showoneopt __ARGS((struct vimoption *, int opt_flags));
3063static int put_setstring __ARGS((FILE *fd, char *cmd, char *name, char_u **valuep, int expand));
3064static int put_setnum __ARGS((FILE *fd, char *cmd, char *name, long *valuep));
3065static int put_setbool __ARGS((FILE *fd, char *cmd, char *name, int value));
3066static int istermoption __ARGS((struct vimoption *));
3067static char_u *get_varp_scope __ARGS((struct vimoption *p, int opt_flags));
3068static char_u *get_varp __ARGS((struct vimoption *));
3069static void option_value2string __ARGS((struct vimoption *, int opt_flags));
3070static int wc_use_keyname __ARGS((char_u *varp, long *wcp));
3071#ifdef FEAT_LANGMAP
3072static void langmap_init __ARGS((void));
3073static void langmap_set __ARGS((void));
3074#endif
3075static void paste_option_changed __ARGS((void));
3076static void compatible_set __ARGS((void));
3077#ifdef FEAT_LINEBREAK
3078static void fill_breakat_flags __ARGS((void));
3079#endif
3080static int opt_strings_flags __ARGS((char_u *val, char **values, unsigned *flagp, int list));
3081static int check_opt_strings __ARGS((char_u *val, char **values, int));
3082static int check_opt_wim __ARGS((void));
3083
3084/*
3085 * Initialize the options, first part.
3086 *
3087 * Called only once from main(), just after creating the first buffer.
3088 */
3089 void
3090set_init_1()
3091{
3092 char_u *p;
3093 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003094 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003095
3096#ifdef FEAT_LANGMAP
3097 langmap_init();
3098#endif
3099
3100 /* Be Vi compatible by default */
3101 p_cp = TRUE;
3102
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003103 /* Use POSIX compatibility when $VIM_POSIX is set. */
3104 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003105 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003106 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003107 set_string_default("shm", (char_u *)"A");
3108 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003109
Bram Moolenaar071d4272004-06-13 20:20:40 +00003110 /*
3111 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003112 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003113 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003114 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003115#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
3116# ifdef __EMX__
Bram Moolenaar7c626922005-02-07 22:01:03 +00003117 || ((p = mch_getenv((char_u *)"EMXSHELL")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003118# endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003119 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003120# ifdef WIN3264
Bram Moolenaar7c626922005-02-07 22:01:03 +00003121 || ((p = default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003122# endif
3123#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003124 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003125 set_string_default("sh", p);
3126
3127#ifdef FEAT_WILDIGN
3128 /*
3129 * Set the default for 'backupskip' to include environment variables for
3130 * temp files.
3131 */
3132 {
3133# ifdef UNIX
3134 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3135# else
3136 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3137# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003138 int len;
3139 garray_T ga;
3140 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003141
3142 ga_init2(&ga, 1, 100);
3143 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3144 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003145 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003146# ifdef UNIX
3147 if (*names[n] == NUL)
3148 p = (char_u *)"/tmp";
3149 else
3150# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003151 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003152 if (p != NULL && *p != NUL)
3153 {
3154 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003155 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003156 if (ga_grow(&ga, len) == OK)
3157 {
3158 if (ga.ga_len > 0)
3159 STRCAT(ga.ga_data, ",");
3160 STRCAT(ga.ga_data, p);
3161 add_pathsep(ga.ga_data);
3162 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003163 ga.ga_len += len;
3164 }
3165 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003166 if (mustfree)
3167 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003168 }
3169 if (ga.ga_data != NULL)
3170 {
3171 set_string_default("bsk", ga.ga_data);
3172 vim_free(ga.ga_data);
3173 }
3174 }
3175#endif
3176
3177 /*
3178 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3179 */
3180 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003181 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003182 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003183#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3184 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3185#endif
3186 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003187#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003188 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003189 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003190#else
3191# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003192 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003193 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003194# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003195 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003196# endif
3197#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003198 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003199 opt_idx = findoption((char_u *)"maxmem");
3200 if (opt_idx >= 0)
3201 {
3202#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
Bram Moolenaar427d51c2013-06-16 16:01:25 +02003203 if ((long)options[opt_idx].def_val[VI_DEFAULT] > (long)n
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003204 || (long)options[opt_idx].def_val[VI_DEFAULT] == 0L)
3205#endif
3206 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3207 }
3208 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003209 }
3210
3211#ifdef FEAT_GUI_W32
3212 /* force 'shortname' for Win32s */
3213 if (gui_is_win32s())
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003214 {
3215 opt_idx = findoption((char_u *)"shortname");
3216 if (opt_idx >= 0)
3217 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)TRUE;
3218 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003219#endif
3220
3221#ifdef FEAT_SEARCHPATH
3222 {
3223 char_u *cdpath;
3224 char_u *buf;
3225 int i;
3226 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003227 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003228
3229 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003230 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003231 if (cdpath != NULL)
3232 {
3233 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3234 if (buf != NULL)
3235 {
3236 buf[0] = ','; /* start with ",", current dir first */
3237 j = 1;
3238 for (i = 0; cdpath[i] != NUL; ++i)
3239 {
3240 if (vim_ispathlistsep(cdpath[i]))
3241 buf[j++] = ',';
3242 else
3243 {
3244 if (cdpath[i] == ' ' || cdpath[i] == ',')
3245 buf[j++] = '\\';
3246 buf[j++] = cdpath[i];
3247 }
3248 }
3249 buf[j] = NUL;
3250 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003251 if (opt_idx >= 0)
3252 {
3253 options[opt_idx].def_val[VI_DEFAULT] = buf;
3254 options[opt_idx].flags |= P_DEF_ALLOCED;
3255 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003256 else
3257 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003258 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003259 if (mustfree)
3260 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003261 }
3262 }
3263#endif
3264
3265#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(OS2) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
3266 /* Set print encoding on platforms that don't default to latin1 */
3267 set_string_default("penc",
3268# if defined(MSWIN) || defined(OS2)
3269 (char_u *)"cp1252"
3270# else
3271# ifdef VMS
3272 (char_u *)"dec-mcs"
3273# else
3274# ifdef EBCDIC
3275 (char_u *)"ebcdic-uk"
3276# else
3277# ifdef MAC
3278 (char_u *)"mac-roman"
3279# else /* HPUX */
3280 (char_u *)"hp-roman8"
3281# endif
3282# endif
3283# endif
3284# endif
3285 );
3286#endif
3287
3288#ifdef FEAT_POSTSCRIPT
3289 /* 'printexpr' must be allocated to be able to evaluate it. */
3290 set_string_default("pexpr",
Bram Moolenaared203462004-06-16 11:19:22 +00003291# if defined(MSWIN) || defined(MSDOS) || defined(OS2)
3292 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003293# else
3294# ifdef VMS
3295 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3296
3297# else
3298 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3299# endif
3300# endif
3301 );
3302#endif
3303
3304 /*
3305 * Set all the options (except the terminal options) to their default
3306 * value. Also set the global value for local options.
3307 */
3308 set_options_default(0);
3309
3310#ifdef FEAT_GUI
3311 if (found_reverse_arg)
3312 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3313#endif
3314
3315 curbuf->b_p_initialized = TRUE;
3316 curbuf->b_p_ar = -1; /* no local 'autoread' value */
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01003317 curbuf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003318 check_buf_options(curbuf);
3319 check_win_options(curwin);
3320 check_options();
3321
3322 /* Must be before option_expand(), because that one needs vim_isIDc() */
3323 didset_options();
3324
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003325#ifdef FEAT_SPELL
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003326 /* Use the current chartab for the generic chartab. */
3327 init_spell_chartab();
3328#endif
3329
Bram Moolenaar071d4272004-06-13 20:20:40 +00003330#ifdef FEAT_LINEBREAK
3331 /*
3332 * initialize the table for 'breakat'.
3333 */
3334 fill_breakat_flags();
3335#endif
3336
3337 /*
3338 * Expand environment variables and things like "~" for the defaults.
3339 * If option_expand() returns non-NULL the variable is expanded. This can
3340 * only happen for non-indirect options.
3341 * Also set the default to the expanded value, so ":set" does not list
3342 * them.
3343 * Don't set the P_ALLOCED flag, because we don't want to free the
3344 * default.
3345 */
3346 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3347 {
3348 if ((options[opt_idx].flags & P_GETTEXT)
3349 && options[opt_idx].var != NULL)
3350 p = (char_u *)_(*(char **)options[opt_idx].var);
3351 else
3352 p = option_expand(opt_idx, NULL);
3353 if (p != NULL && (p = vim_strsave(p)) != NULL)
3354 {
3355 *(char_u **)options[opt_idx].var = p;
3356 /* VIMEXP
3357 * Defaults for all expanded options are currently the same for Vi
3358 * and Vim. When this changes, add some code here! Also need to
3359 * split P_DEF_ALLOCED in two.
3360 */
3361 if (options[opt_idx].flags & P_DEF_ALLOCED)
3362 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3363 options[opt_idx].def_val[VI_DEFAULT] = p;
3364 options[opt_idx].flags |= P_DEF_ALLOCED;
3365 }
3366 }
3367
3368 /* Initialize the highlight_attr[] table. */
3369 highlight_changed();
3370
3371 save_file_ff(curbuf); /* Buffer is unchanged */
3372
3373 /* Parse default for 'wildmode' */
3374 check_opt_wim();
3375
3376#if defined(FEAT_ARABIC)
3377 /* Detect use of mlterm.
3378 * Mlterm is a terminal emulator akin to xterm that has some special
3379 * abilities (bidi namely).
3380 * NOTE: mlterm's author is being asked to 'set' a variable
3381 * instead of an environment variable due to inheritance.
3382 */
3383 if (mch_getenv((char_u *)"MLTERM") != NULL)
3384 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3385#endif
3386
3387#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
3388 /* Parse default for 'fillchars'. */
3389 (void)set_chars_option(&p_fcs);
3390#endif
3391
3392#ifdef FEAT_CLIPBOARD
3393 /* Parse default for 'clipboard' */
3394 (void)check_clipboard_option();
3395#endif
3396
3397#ifdef FEAT_MBYTE
3398# if defined(WIN3264) && defined(FEAT_GETTEXT)
3399 /*
3400 * If $LANG isn't set, try to get a good value for it. This makes the
3401 * right language be used automatically. Don't do this for English.
3402 */
3403 if (mch_getenv((char_u *)"LANG") == NULL)
3404 {
3405 char buf[20];
3406
3407 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3408 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3409 * only the first two. */
3410 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3411 (LPTSTR)buf, 20);
3412 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3413 {
3414 /* There are a few exceptions (probably more) */
3415 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3416 STRCPY(buf, "zh_TW");
3417 else if (STRNICMP(buf, "chs", 3) == 0
3418 || STRNICMP(buf, "zhc", 3) == 0)
3419 STRCPY(buf, "zh_CN");
3420 else if (STRNICMP(buf, "jp", 2) == 0)
3421 STRCPY(buf, "ja");
3422 else
3423 buf[2] = NUL; /* truncate to two-letter code */
3424 vim_setenv("LANG", buf);
3425 }
3426 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003427# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003428# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003429 /* Moved to os_mac_conv.c to avoid dependency problems. */
3430 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003431# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003432# endif
3433
3434 /* enc_locale() will try to find the encoding of the current locale. */
3435 p = enc_locale();
3436 if (p != NULL)
3437 {
3438 char_u *save_enc;
3439
3440 /* Try setting 'encoding' and check if the value is valid.
3441 * If not, go back to the default "latin1". */
3442 save_enc = p_enc;
3443 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003444 if (STRCMP(p_enc, "gb18030") == 0)
3445 {
3446 /* We don't support "gb18030", but "cp936" is a good substitute
3447 * for practical purposes, thus use that. It's not an alias to
3448 * still support conversion between gb18030 and utf-8. */
3449 p_enc = vim_strsave((char_u *)"cp936");
3450 vim_free(p);
3451 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003452 if (mb_init() == NULL)
3453 {
3454 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003455 if (opt_idx >= 0)
3456 {
3457 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3458 options[opt_idx].flags |= P_DEF_ALLOCED;
3459 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003460
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003461#if defined(MSDOS) || defined(MSWIN) || defined(OS2) || defined(MACOS) \
3462 || defined(VMS)
3463 if (STRCMP(p_enc, "latin1") == 0
3464# ifdef FEAT_MBYTE
3465 || enc_utf8
3466# endif
3467 )
3468 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003469 /* Adjust the default for 'isprint' and 'iskeyword' to match
3470 * latin1. Also set the defaults for when 'nocompatible' is
3471 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003472 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003473 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003474 set_string_option_direct((char_u *)"isk", -1,
3475 ISK_LATIN1, OPT_FREE, SID_NONE);
3476 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003477 if (opt_idx >= 0)
3478 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003479 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003480 if (opt_idx >= 0)
3481 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003482 (void)init_chartab();
3483 }
3484#endif
3485
Bram Moolenaar071d4272004-06-13 20:20:40 +00003486# if defined(WIN3264) && !defined(FEAT_GUI)
3487 /* Win32 console: When GetACP() returns a different value from
3488 * GetConsoleCP() set 'termencoding'. */
3489 if (GetACP() != GetConsoleCP())
3490 {
3491 char buf[50];
3492
3493 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3494 p_tenc = vim_strsave((char_u *)buf);
3495 if (p_tenc != NULL)
3496 {
3497 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003498 if (opt_idx >= 0)
3499 {
3500 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3501 options[opt_idx].flags |= P_DEF_ALLOCED;
3502 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003503 convert_setup(&input_conv, p_tenc, p_enc);
3504 convert_setup(&output_conv, p_enc, p_tenc);
3505 }
3506 else
3507 p_tenc = empty_option;
3508 }
3509# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003510# if defined(WIN3264) && defined(FEAT_MBYTE)
3511 /* $HOME may have characters in active code page. */
3512 init_homedir();
3513# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003514 }
3515 else
3516 {
3517 vim_free(p_enc);
3518 p_enc = save_enc;
3519 }
3520 }
3521#endif
3522
3523#ifdef FEAT_MULTI_LANG
3524 /* Set the default for 'helplang'. */
3525 set_helplang_default(get_mess_lang());
3526#endif
3527}
3528
3529/*
3530 * Set an option to its default value.
3531 * This does not take care of side effects!
3532 */
3533 static void
3534set_option_default(opt_idx, opt_flags, compatible)
3535 int opt_idx;
3536 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3537 int compatible; /* use Vi default value */
3538{
3539 char_u *varp; /* pointer to variable for current option */
3540 int dvi; /* index in def_val[] */
3541 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003542 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003543 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3544
3545 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3546 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003547 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003548 {
3549 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3550 if (flags & P_STRING)
3551 {
3552 /* Use set_string_option_direct() for local options to handle
3553 * freeing and allocating the value. */
3554 if (options[opt_idx].indir != PV_NONE)
3555 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003556 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003557 else
3558 {
3559 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3560 free_string_option(*(char_u **)(varp));
3561 *(char_u **)varp = options[opt_idx].def_val[dvi];
3562 options[opt_idx].flags &= ~P_ALLOCED;
3563 }
3564 }
3565 else if (flags & P_NUM)
3566 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003567 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003568 win_comp_scroll(curwin);
3569 else
3570 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003571 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003572 /* May also set global value for local option. */
3573 if (both)
3574 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3575 *(long *)varp;
3576 }
3577 }
3578 else /* P_BOOL */
3579 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003580 /* the cast to long is required for Manx C, long_i is needed for
3581 * MSVC */
3582 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003583#ifdef UNIX
3584 /* 'modeline' defaults to off for root */
3585 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3586 *(int *)varp = FALSE;
3587#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003588 /* May also set global value for local option. */
3589 if (both)
3590 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3591 *(int *)varp;
3592 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003593
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003594 /* The default value is not insecure. */
3595 flagsp = insecure_flag(opt_idx, opt_flags);
3596 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003597 }
3598
3599#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003600 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003601#endif
3602}
3603
3604/*
3605 * Set all options (except terminal options) to their default value.
3606 */
3607 static void
3608set_options_default(opt_flags)
3609 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3610{
3611 int i;
3612#ifdef FEAT_WINDOWS
3613 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003614 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003615#endif
3616
3617 for (i = 0; !istermoption(&options[i]); i++)
3618 if (!(options[i].flags & P_NODEFAULT))
3619 set_option_default(i, opt_flags, p_cp);
3620
3621#ifdef FEAT_WINDOWS
3622 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003623 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003624 win_comp_scroll(wp);
3625#else
3626 win_comp_scroll(curwin);
3627#endif
3628}
3629
3630/*
3631 * Set the Vi-default value of a string option.
3632 * Used for 'sh', 'backupskip' and 'term'.
3633 */
3634 void
3635set_string_default(name, val)
3636 char *name;
3637 char_u *val;
3638{
3639 char_u *p;
3640 int opt_idx;
3641
3642 p = vim_strsave(val);
3643 if (p != NULL) /* we don't want a NULL */
3644 {
3645 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003646 if (opt_idx >= 0)
3647 {
3648 if (options[opt_idx].flags & P_DEF_ALLOCED)
3649 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3650 options[opt_idx].def_val[VI_DEFAULT] = p;
3651 options[opt_idx].flags |= P_DEF_ALLOCED;
3652 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003653 }
3654}
3655
3656/*
3657 * Set the Vi-default value of a number option.
3658 * Used for 'lines' and 'columns'.
3659 */
3660 void
3661set_number_default(name, val)
3662 char *name;
3663 long val;
3664{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003665 int opt_idx;
3666
3667 opt_idx = findoption((char_u *)name);
3668 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003669 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003670}
3671
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003672#if defined(EXITFREE) || defined(PROTO)
3673/*
3674 * Free all options.
3675 */
3676 void
3677free_all_options()
3678{
3679 int i;
3680
3681 for (i = 0; !istermoption(&options[i]); i++)
3682 {
3683 if (options[i].indir == PV_NONE)
3684 {
3685 /* global option: free value and default value. */
3686 if (options[i].flags & P_ALLOCED && options[i].var != NULL)
3687 free_string_option(*(char_u **)options[i].var);
3688 if (options[i].flags & P_DEF_ALLOCED)
3689 free_string_option(options[i].def_val[VI_DEFAULT]);
3690 }
3691 else if (options[i].var != VAR_WIN
3692 && (options[i].flags & P_STRING))
3693 /* buffer-local option: free global value */
3694 free_string_option(*(char_u **)options[i].var);
3695 }
3696}
3697#endif
3698
3699
Bram Moolenaar071d4272004-06-13 20:20:40 +00003700/*
3701 * Initialize the options, part two: After getting Rows and Columns and
3702 * setting 'term'.
3703 */
3704 void
3705set_init_2()
3706{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003707 int idx;
3708
Bram Moolenaar071d4272004-06-13 20:20:40 +00003709 /*
3710 * 'scroll' defaults to half the window height. Note that this default is
3711 * wrong when the window height changes.
3712 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003713 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003714 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003715 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003716 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003717 comp_col();
3718
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003719 /*
3720 * 'window' is only for backwards compatibility with Vi.
3721 * Default is Rows - 1.
3722 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003723 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003724 p_window = Rows - 1;
3725 set_number_default("window", Rows - 1);
3726
Bram Moolenaarf740b292006-02-16 22:11:02 +00003727 /* For DOS console the default is always black. */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003728#if !((defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003729 /*
3730 * If 'background' wasn't set by the user, try guessing the value,
3731 * depending on the terminal name. Only need to check for terminals
3732 * with a dark background, that can handle color.
3733 */
3734 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003735 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3736 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003737 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003738 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003739 /* don't mark it as set, when starting the GUI it may be
3740 * changed again */
3741 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003742 }
3743#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003744
3745#ifdef CURSOR_SHAPE
3746 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3747#endif
3748#ifdef FEAT_MOUSESHAPE
3749 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3750#endif
3751#ifdef FEAT_PRINTER
3752 (void)parse_printoptions(); /* parse 'printoptions' default value */
3753#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003754}
3755
3756/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00003757 * Return "dark" or "light" depending on the kind of terminal.
3758 * This is just guessing! Recognized are:
3759 * "linux" Linux console
3760 * "screen.linux" Linux console with screen
3761 * "cygwin" Cygwin shell
3762 * "putty" Putty program
3763 * We also check the COLORFGBG environment variable, which is set by
3764 * rxvt and derivatives. This variable contains either two or three
3765 * values separated by semicolons; we want the last value in either
3766 * case. If this value is 0-6 or 8, our background is dark.
3767 */
3768 static char_u *
3769term_bg_default()
3770{
Bram Moolenaarf740b292006-02-16 22:11:02 +00003771#if defined(MSDOS) || defined(OS2) || defined(WIN3264)
3772 /* DOS console nearly always black */
3773 return (char_u *)"dark";
3774#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00003775 char_u *p;
3776
Bram Moolenaarf740b292006-02-16 22:11:02 +00003777 if (STRCMP(T_NAME, "linux") == 0
3778 || STRCMP(T_NAME, "screen.linux") == 0
3779 || STRCMP(T_NAME, "cygwin") == 0
3780 || STRCMP(T_NAME, "putty") == 0
3781 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
3782 && (p = vim_strrchr(p, ';')) != NULL
3783 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
3784 && p[2] == NUL))
3785 return (char_u *)"dark";
3786 return (char_u *)"light";
3787#endif
3788}
3789
3790/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00003791 * Initialize the options, part three: After reading the .vimrc
3792 */
3793 void
3794set_init_3()
3795{
3796#if defined(UNIX) || defined(OS2) || defined(WIN3264)
3797/*
3798 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
3799 * This is done after other initializations, where 'shell' might have been
3800 * set, but only if they have not been set before.
3801 */
3802 char_u *p;
3803 int idx_srr;
3804 int do_srr;
3805#ifdef FEAT_QUICKFIX
3806 int idx_sp;
3807 int do_sp;
3808#endif
3809
3810 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003811 if (idx_srr < 0)
3812 do_srr = FALSE;
3813 else
3814 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003815#ifdef FEAT_QUICKFIX
3816 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003817 if (idx_sp < 0)
3818 do_sp = FALSE;
3819 else
3820 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003821#endif
3822
3823 /*
3824 * Isolate the name of the shell:
3825 * - Skip beyond any path. E.g., "/usr/bin/csh -f" -> "csh -f".
3826 * - Remove any argument. E.g., "csh -f" -> "csh".
Bram Moolenaarae61bcf2010-05-13 13:12:06 +02003827 * But don't allow a space in the path, so that this works:
3828 * "/usr/bin/csh --rcfile ~/.cshrc"
3829 * But don't do that for Windows, it's common to have a space in the path.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003830 */
Bram Moolenaarae61bcf2010-05-13 13:12:06 +02003831#ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003832 p = gettail(p_sh);
3833 p = vim_strnsave(p, (int)(skiptowhite(p) - p));
Bram Moolenaarae61bcf2010-05-13 13:12:06 +02003834#else
3835 p = skiptowhite(p_sh);
3836 if (*p == NUL)
3837 {
3838 /* No white space, use the tail. */
3839 p = vim_strsave(gettail(p_sh));
3840 }
3841 else
3842 {
3843 char_u *p1, *p2;
3844
3845 /* Find the last path separator before the space. */
3846 p1 = p_sh;
3847 for (p2 = p_sh; p2 < p; mb_ptr_adv(p2))
3848 if (vim_ispathsep(*p2))
3849 p1 = p2 + 1;
3850 p = vim_strnsave(p1, (int)(p - p1));
3851 }
3852#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003853 if (p != NULL)
3854 {
3855 /*
3856 * Default for p_sp is "| tee", for p_srr is ">".
3857 * For known shells it is changed here to include stderr.
3858 */
3859 if ( fnamecmp(p, "csh") == 0
3860 || fnamecmp(p, "tcsh") == 0
3861# if defined(OS2) || defined(WIN3264) /* also check with .exe extension */
3862 || fnamecmp(p, "csh.exe") == 0
3863 || fnamecmp(p, "tcsh.exe") == 0
3864# endif
3865 )
3866 {
3867#if defined(FEAT_QUICKFIX)
3868 if (do_sp)
3869 {
3870# ifdef WIN3264
3871 p_sp = (char_u *)">&";
3872# else
3873 p_sp = (char_u *)"|& tee";
3874# endif
3875 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3876 }
3877#endif
3878 if (do_srr)
3879 {
3880 p_srr = (char_u *)">&";
3881 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3882 }
3883 }
3884 else
3885# ifndef OS2 /* Always use bourne shell style redirection if we reach this */
3886 if ( fnamecmp(p, "sh") == 0
3887 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003888 || fnamecmp(p, "mksh") == 0
3889 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003890 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003891 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003892 || fnamecmp(p, "bash") == 0
3893# ifdef WIN3264
3894 || fnamecmp(p, "cmd") == 0
3895 || fnamecmp(p, "sh.exe") == 0
3896 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003897 || fnamecmp(p, "mksh.exe") == 0
3898 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003899 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003900 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003901 || fnamecmp(p, "bash.exe") == 0
3902 || fnamecmp(p, "cmd.exe") == 0
3903# endif
3904 )
3905# endif
3906 {
3907#if defined(FEAT_QUICKFIX)
3908 if (do_sp)
3909 {
3910# ifdef WIN3264
3911 p_sp = (char_u *)">%s 2>&1";
3912# else
3913 p_sp = (char_u *)"2>&1| tee";
3914# endif
3915 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3916 }
3917#endif
3918 if (do_srr)
3919 {
3920 p_srr = (char_u *)">%s 2>&1";
3921 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3922 }
3923 }
3924 vim_free(p);
3925 }
3926#endif
3927
3928#if defined(MSDOS) || defined(WIN3264) || defined(OS2)
3929 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01003930 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
3931 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003932 * This is done after other initializations, where 'shell' might have been
3933 * set, but only if they have not been set before. Default for p_shcf is
3934 * "/c", for p_shq is "". For "sh" like shells it is changed here to
3935 * "-c" and "\"", but not for DJGPP, because it starts the shell without
3936 * command.com. And for Win32 we need to set p_sxq instead.
3937 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00003938 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003939 {
3940 int idx3;
3941
3942 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003943 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003944 {
3945 p_shcf = (char_u *)"-c";
3946 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3947 }
3948
3949# ifndef DJGPP
3950# ifdef WIN3264
3951 /* Somehow Win32 requires the quotes around the redirection too */
3952 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003953 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003954 {
3955 p_sxq = (char_u *)"\"";
3956 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3957 }
3958# else
3959 idx3 = findoption((char_u *)"shq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003960 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003961 {
3962 p_shq = (char_u *)"\"";
3963 options[idx3].def_val[VI_DEFAULT] = p_shq;
3964 }
3965# endif
3966# endif
3967 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01003968 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
3969 {
3970 int idx3;
3971
3972 /*
3973 * cmd.exe on Windows will strip the first and last double quote given
3974 * on the command line, e.g. most of the time things like:
3975 * cmd /c "my path/to/echo" "my args to echo"
3976 * become:
3977 * my path/to/echo" "my args to echo
3978 * when executed.
3979 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01003980 * To avoid this, set shellxquote to surround the command in
3981 * parenthesis. This appears to make most commands work, without
3982 * breaking commands that worked previously, such as
3983 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01003984 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01003985 idx3 = findoption((char_u *)"sxq");
3986 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
3987 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01003988 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01003989 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3990 }
3991
Bram Moolenaara64ba222012-02-12 23:23:31 +01003992 idx3 = findoption((char_u *)"shcf");
3993 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
3994 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01003995 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01003996 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3997 }
3998 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003999#endif
4000
4001#ifdef FEAT_TITLE
4002 set_title_defaults();
4003#endif
4004}
4005
4006#if defined(FEAT_MULTI_LANG) || defined(PROTO)
4007/*
4008 * When 'helplang' is still at its default value, set it to "lang".
4009 * Only the first two characters of "lang" are used.
4010 */
4011 void
4012set_helplang_default(lang)
4013 char_u *lang;
4014{
4015 int idx;
4016
4017 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
4018 return;
4019 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004020 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004021 {
4022 if (options[idx].flags & P_ALLOCED)
4023 free_string_option(p_hlg);
4024 p_hlg = vim_strsave(lang);
4025 if (p_hlg == NULL)
4026 p_hlg = empty_option;
4027 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004028 {
4029 /* zh_CN becomes "cn", zh_TW becomes "tw". */
4030 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
4031 {
4032 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4033 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4034 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004035 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004036 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004037 options[idx].flags |= P_ALLOCED;
4038 }
4039}
4040#endif
4041
4042#ifdef FEAT_GUI
4043static char_u *gui_bg_default __ARGS((void));
4044
4045 static char_u *
4046gui_bg_default()
4047{
4048 if (gui_get_lightness(gui.back_pixel) < 127)
4049 return (char_u *)"dark";
4050 return (char_u *)"light";
4051}
4052
4053/*
4054 * Option initializations that can only be done after opening the GUI window.
4055 */
4056 void
4057init_gui_options()
4058{
4059 /* Set the 'background' option according to the lightness of the
4060 * background color, unless the user has set it already. */
4061 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4062 {
4063 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4064 highlight_changed();
4065 }
4066}
4067#endif
4068
4069#ifdef FEAT_TITLE
4070/*
4071 * 'title' and 'icon' only default to true if they have not been set or reset
4072 * in .vimrc and we can read the old value.
4073 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4074 * they can be reset. This reduces startup time when using X on a remote
4075 * machine.
4076 */
4077 void
4078set_title_defaults()
4079{
4080 int idx1;
4081 long val;
4082
4083 /*
4084 * If GUI is (going to be) used, we can always set the window title and
4085 * icon name. Saves a bit of time, because the X11 display server does
4086 * not need to be contacted.
4087 */
4088 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004089 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004090 {
4091#ifdef FEAT_GUI
4092 if (gui.starting || gui.in_use)
4093 val = TRUE;
4094 else
4095#endif
4096 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004097 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004098 p_title = val;
4099 }
4100 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004101 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004102 {
4103#ifdef FEAT_GUI
4104 if (gui.starting || gui.in_use)
4105 val = TRUE;
4106 else
4107#endif
4108 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004109 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004110 p_icon = val;
4111 }
4112}
4113#endif
4114
4115/*
4116 * Parse 'arg' for option settings.
4117 *
4118 * 'arg' may be IObuff, but only when no errors can be present and option
4119 * does not need to be expanded with option_expand().
4120 * "opt_flags":
4121 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004122 * OPT_GLOBAL for ":setglobal"
4123 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004124 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004125 * OPT_WINONLY to only set window-local options
4126 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004127 *
4128 * returns FAIL if an error is detected, OK otherwise
4129 */
4130 int
4131do_set(arg, opt_flags)
4132 char_u *arg; /* option string (may be written to!) */
4133 int opt_flags;
4134{
4135 int opt_idx;
4136 char_u *errmsg;
4137 char_u errbuf[80];
4138 char_u *startarg;
4139 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4140 int nextchar; /* next non-white char after option name */
4141 int afterchar; /* character just after option name */
4142 int len;
4143 int i;
4144 long value;
4145 int key;
4146 long_u flags; /* flags for current option */
4147 char_u *varp = NULL; /* pointer to variable for current option */
4148 int did_show = FALSE; /* already showed one value */
4149 int adding; /* "opt+=arg" */
4150 int prepending; /* "opt^=arg" */
4151 int removing; /* "opt-=arg" */
4152 int cp_val = 0;
4153 char_u key_name[2];
4154
4155 if (*arg == NUL)
4156 {
4157 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004158 did_show = TRUE;
4159 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004160 }
4161
4162 while (*arg != NUL) /* loop to process all options */
4163 {
4164 errmsg = NULL;
4165 startarg = arg; /* remember for error message */
4166
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004167 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4168 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004169 {
4170 /*
4171 * ":set all" show all options.
4172 * ":set all&" set all options to their default value.
4173 */
4174 arg += 3;
4175 if (*arg == '&')
4176 {
4177 ++arg;
4178 /* Only for :set command set global value of local options. */
4179 set_options_default(OPT_FREE | opt_flags);
4180 }
4181 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004182 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004183 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004184 did_show = TRUE;
4185 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004186 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004187 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004188 {
4189 showoptions(2, opt_flags);
4190 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004191 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004192 arg += 7;
4193 }
4194 else
4195 {
4196 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004197 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004198 {
4199 prefix = 0;
4200 arg += 2;
4201 }
4202 else if (STRNCMP(arg, "inv", 3) == 0)
4203 {
4204 prefix = 2;
4205 arg += 3;
4206 }
4207
4208 /* find end of name */
4209 key = 0;
4210 if (*arg == '<')
4211 {
4212 nextchar = 0;
4213 opt_idx = -1;
4214 /* look out for <t_>;> */
4215 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4216 len = 5;
4217 else
4218 {
4219 len = 1;
4220 while (arg[len] != NUL && arg[len] != '>')
4221 ++len;
4222 }
4223 if (arg[len] != '>')
4224 {
4225 errmsg = e_invarg;
4226 goto skip;
4227 }
4228 arg[len] = NUL; /* put NUL after name */
4229 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4230 opt_idx = findoption(arg + 1);
4231 arg[len++] = '>'; /* restore '>' */
4232 if (opt_idx == -1)
4233 key = find_key_option(arg + 1);
4234 }
4235 else
4236 {
4237 len = 0;
4238 /*
4239 * The two characters after "t_" may not be alphanumeric.
4240 */
4241 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4242 len = 4;
4243 else
4244 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4245 ++len;
4246 nextchar = arg[len];
4247 arg[len] = NUL; /* put NUL after name */
4248 opt_idx = findoption(arg);
4249 arg[len] = nextchar; /* restore nextchar */
4250 if (opt_idx == -1)
4251 key = find_key_option(arg);
4252 }
4253
4254 /* remember character after option name */
4255 afterchar = arg[len];
4256
4257 /* skip white space, allow ":set ai ?" */
4258 while (vim_iswhite(arg[len]))
4259 ++len;
4260
4261 adding = FALSE;
4262 prepending = FALSE;
4263 removing = FALSE;
4264 if (arg[len] != NUL && arg[len + 1] == '=')
4265 {
4266 if (arg[len] == '+')
4267 {
4268 adding = TRUE; /* "+=" */
4269 ++len;
4270 }
4271 else if (arg[len] == '^')
4272 {
4273 prepending = TRUE; /* "^=" */
4274 ++len;
4275 }
4276 else if (arg[len] == '-')
4277 {
4278 removing = TRUE; /* "-=" */
4279 ++len;
4280 }
4281 }
4282 nextchar = arg[len];
4283
4284 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4285 {
4286 errmsg = (char_u *)N_("E518: Unknown option");
4287 goto skip;
4288 }
4289
4290 if (opt_idx >= 0)
4291 {
4292 if (options[opt_idx].var == NULL) /* hidden option: skip */
4293 {
4294 /* Only give an error message when requesting the value of
4295 * a hidden option, ignore setting it. */
4296 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4297 && (!(options[opt_idx].flags & P_BOOL)
4298 || nextchar == '?'))
4299 errmsg = (char_u *)N_("E519: Option not supported");
4300 goto skip;
4301 }
4302
4303 flags = options[opt_idx].flags;
4304 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4305 }
4306 else
4307 {
4308 flags = P_STRING;
4309 if (key < 0)
4310 {
4311 key_name[0] = KEY2TERMCAP0(key);
4312 key_name[1] = KEY2TERMCAP1(key);
4313 }
4314 else
4315 {
4316 key_name[0] = KS_KEY;
4317 key_name[1] = (key & 0xff);
4318 }
4319 }
4320
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004321 /* Skip all options that are not window-local (used when showing
4322 * an already loaded buffer in a window). */
4323 if ((opt_flags & OPT_WINONLY)
4324 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4325 goto skip;
4326
Bram Moolenaara3227e22006-03-08 21:32:40 +00004327 /* Skip all options that are window-local (used for :vimgrep). */
4328 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4329 && options[opt_idx].var == VAR_WIN)
4330 goto skip;
4331
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004332 /* Disallow changing some options from modelines. */
4333 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004334 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004335 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004336 {
4337 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4338 goto skip;
4339 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004340#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004341 /* In diff mode some options are overruled. This avoids that
4342 * 'foldmethod' becomes "marker" instead of "diff" and that
4343 * "wrap" gets set. */
4344 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004345 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004346 && (options[opt_idx].indir == PV_FDM
4347 || options[opt_idx].indir == PV_WRAP))
4348 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004349#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004350 }
4351
4352#ifdef HAVE_SANDBOX
4353 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004354 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004355 {
4356 errmsg = (char_u *)_(e_sandbox);
4357 goto skip;
4358 }
4359#endif
4360
4361 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4362 {
4363 arg += len;
4364 cp_val = p_cp;
4365 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4366 {
4367 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4368 {
4369 cp_val = FALSE;
4370 arg += 3;
4371 }
4372 else /* "opt&vi": set to Vi default */
4373 {
4374 cp_val = TRUE;
4375 arg += 2;
4376 }
4377 }
4378 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
4379 && arg[1] != NUL && !vim_iswhite(arg[1]))
4380 {
4381 errmsg = e_trailing;
4382 goto skip;
4383 }
4384 }
4385
4386 /*
4387 * allow '=' and ':' as MSDOS command.com allows only one
4388 * '=' character per "set" command line. grrr. (jw)
4389 */
4390 if (nextchar == '?'
4391 || (prefix == 1
4392 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4393 && !(flags & P_BOOL)))
4394 {
4395 /*
4396 * print value
4397 */
4398 if (did_show)
4399 msg_putchar('\n'); /* cursor below last one */
4400 else
4401 {
4402 gotocmdline(TRUE); /* cursor at status line */
4403 did_show = TRUE; /* remember that we did a line */
4404 }
4405 if (opt_idx >= 0)
4406 {
4407 showoneopt(&options[opt_idx], opt_flags);
4408#ifdef FEAT_EVAL
4409 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004410 {
4411 /* Mention where the option was last set. */
4412 if (varp == options[opt_idx].var)
4413 last_set_msg(options[opt_idx].scriptID);
4414 else if ((int)options[opt_idx].indir & PV_WIN)
4415 last_set_msg(curwin->w_p_scriptID[
4416 (int)options[opt_idx].indir & PV_MASK]);
4417 else if ((int)options[opt_idx].indir & PV_BUF)
4418 last_set_msg(curbuf->b_p_scriptID[
4419 (int)options[opt_idx].indir & PV_MASK]);
4420 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004421#endif
4422 }
4423 else
4424 {
4425 char_u *p;
4426
4427 p = find_termcode(key_name);
4428 if (p == NULL)
4429 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004430 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004431 goto skip;
4432 }
4433 else
4434 (void)show_one_termcode(key_name, p, TRUE);
4435 }
4436 if (nextchar != '?'
4437 && nextchar != NUL && !vim_iswhite(afterchar))
4438 errmsg = e_trailing;
4439 }
4440 else
4441 {
4442 if (flags & P_BOOL) /* boolean */
4443 {
4444 if (nextchar == '=' || nextchar == ':')
4445 {
4446 errmsg = e_invarg;
4447 goto skip;
4448 }
4449
4450 /*
4451 * ":set opt!": invert
4452 * ":set opt&": reset to default value
4453 * ":set opt<": reset to global value
4454 */
4455 if (nextchar == '!')
4456 value = *(int *)(varp) ^ 1;
4457 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004458 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004459 ((flags & P_VI_DEF) || cp_val)
4460 ? VI_DEFAULT : VIM_DEFAULT];
4461 else if (nextchar == '<')
4462 {
4463 /* For 'autoread' -1 means to use global value. */
4464 if ((int *)varp == &curbuf->b_p_ar
4465 && opt_flags == OPT_LOCAL)
4466 value = -1;
4467 else
4468 value = *(int *)get_varp_scope(&(options[opt_idx]),
4469 OPT_GLOBAL);
4470 }
4471 else
4472 {
4473 /*
4474 * ":set invopt": invert
4475 * ":set opt" or ":set noopt": set or reset
4476 */
4477 if (nextchar != NUL && !vim_iswhite(afterchar))
4478 {
4479 errmsg = e_trailing;
4480 goto skip;
4481 }
4482 if (prefix == 2) /* inv */
4483 value = *(int *)(varp) ^ 1;
4484 else
4485 value = prefix;
4486 }
4487
4488 errmsg = set_bool_option(opt_idx, varp, (int)value,
4489 opt_flags);
4490 }
4491 else /* numeric or string */
4492 {
4493 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4494 || prefix != 1)
4495 {
4496 errmsg = e_invarg;
4497 goto skip;
4498 }
4499
4500 if (flags & P_NUM) /* numeric */
4501 {
4502 /*
4503 * Different ways to set a number option:
4504 * & set to default value
4505 * < set to global value
4506 * <xx> accept special key codes for 'wildchar'
4507 * c accept any non-digit for 'wildchar'
4508 * [-]0-9 set number
4509 * other error
4510 */
4511 ++arg;
4512 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004513 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004514 ((flags & P_VI_DEF) || cp_val)
4515 ? VI_DEFAULT : VIM_DEFAULT];
4516 else if (nextchar == '<')
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01004517 {
4518 /* For 'undolevels' NO_LOCAL_UNDOLEVEL means to
4519 * use the global value. */
4520 if ((long *)varp == &curbuf->b_p_ul
4521 && opt_flags == OPT_LOCAL)
4522 value = NO_LOCAL_UNDOLEVEL;
4523 else
4524 value = *(long *)get_varp_scope(
4525 &(options[opt_idx]), OPT_GLOBAL);
4526 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004527 else if (((long *)varp == &p_wc
4528 || (long *)varp == &p_wcm)
4529 && (*arg == '<'
4530 || *arg == '^'
4531 || ((!arg[1] || vim_iswhite(arg[1]))
4532 && !VIM_ISDIGIT(*arg))))
4533 {
4534 value = string_to_key(arg);
4535 if (value == 0 && (long *)varp != &p_wcm)
4536 {
4537 errmsg = e_invarg;
4538 goto skip;
4539 }
4540 }
4541 /* allow negative numbers (for 'undolevels') */
4542 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4543 {
4544 i = 0;
4545 if (*arg == '-')
4546 i = 1;
4547#ifdef HAVE_STRTOL
4548 value = strtol((char *)arg, NULL, 0);
4549 if (arg[i] == '0' && TOLOWER_ASC(arg[i + 1]) == 'x')
4550 i += 2;
4551#else
4552 value = atol((char *)arg);
4553#endif
4554 while (VIM_ISDIGIT(arg[i]))
4555 ++i;
4556 if (arg[i] != NUL && !vim_iswhite(arg[i]))
4557 {
4558 errmsg = e_invarg;
4559 goto skip;
4560 }
4561 }
4562 else
4563 {
4564 errmsg = (char_u *)N_("E521: Number required after =");
4565 goto skip;
4566 }
4567
4568 if (adding)
4569 value = *(long *)varp + value;
4570 if (prepending)
4571 value = *(long *)varp * value;
4572 if (removing)
4573 value = *(long *)varp - value;
4574 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004575 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004576 }
4577 else if (opt_idx >= 0) /* string */
4578 {
4579 char_u *save_arg = NULL;
4580 char_u *s = NULL;
4581 char_u *oldval; /* previous value if *varp */
4582 char_u *newval;
4583 char_u *origval;
4584 unsigned newlen;
4585 int comma;
4586 int bs;
4587 int new_value_alloced; /* new string option
4588 was allocated */
4589
4590 /* When using ":set opt=val" for a global option
4591 * with a local value the local value will be
4592 * reset, use the global value here. */
4593 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004594 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004595 varp = options[opt_idx].var;
4596
4597 /* The old value is kept until we are sure that the
4598 * new value is valid. */
4599 oldval = *(char_u **)varp;
4600 if (nextchar == '&') /* set to default val */
4601 {
4602 newval = options[opt_idx].def_val[
4603 ((flags & P_VI_DEF) || cp_val)
4604 ? VI_DEFAULT : VIM_DEFAULT];
4605 if ((char_u **)varp == &p_bg)
4606 {
4607 /* guess the value of 'background' */
4608#ifdef FEAT_GUI
4609 if (gui.in_use)
4610 newval = gui_bg_default();
4611 else
4612#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004613 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004614 }
4615
4616 /* expand environment variables and ~ (since the
4617 * default value was already expanded, only
4618 * required when an environment variable was set
4619 * later */
4620 if (newval == NULL)
4621 newval = empty_option;
4622 else
4623 {
4624 s = option_expand(opt_idx, newval);
4625 if (s == NULL)
4626 s = newval;
4627 newval = vim_strsave(s);
4628 }
4629 new_value_alloced = TRUE;
4630 }
4631 else if (nextchar == '<') /* set to global val */
4632 {
4633 newval = vim_strsave(*(char_u **)get_varp_scope(
4634 &(options[opt_idx]), OPT_GLOBAL));
4635 new_value_alloced = TRUE;
4636 }
4637 else
4638 {
4639 ++arg; /* jump to after the '=' or ':' */
4640
4641 /*
4642 * Set 'keywordprg' to ":help" if an empty
4643 * value was passed to :set by the user.
4644 * Misuse errbuf[] for the resulting string.
4645 */
4646 if (varp == (char_u *)&p_kp
4647 && (*arg == NUL || *arg == ' '))
4648 {
4649 STRCPY(errbuf, ":help");
4650 save_arg = arg;
4651 arg = errbuf;
4652 }
4653 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004654 * Convert 'backspace' number to string, for
4655 * adding, prepending and removing string.
4656 */
4657 else if (varp == (char_u *)&p_bs
4658 && VIM_ISDIGIT(**(char_u **)varp))
4659 {
4660 i = getdigits((char_u **)varp);
4661 switch (i)
4662 {
4663 case 0:
4664 *(char_u **)varp = empty_option;
4665 break;
4666 case 1:
4667 *(char_u **)varp = vim_strsave(
4668 (char_u *)"indent,eol");
4669 break;
4670 case 2:
4671 *(char_u **)varp = vim_strsave(
4672 (char_u *)"indent,eol,start");
4673 break;
4674 }
4675 vim_free(oldval);
4676 oldval = *(char_u **)varp;
4677 }
4678 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004679 * Convert 'whichwrap' number to string, for
4680 * backwards compatibility with Vim 3.0.
4681 * Misuse errbuf[] for the resulting string.
4682 */
4683 else if (varp == (char_u *)&p_ww
4684 && VIM_ISDIGIT(*arg))
4685 {
4686 *errbuf = NUL;
4687 i = getdigits(&arg);
4688 if (i & 1)
4689 STRCAT(errbuf, "b,");
4690 if (i & 2)
4691 STRCAT(errbuf, "s,");
4692 if (i & 4)
4693 STRCAT(errbuf, "h,l,");
4694 if (i & 8)
4695 STRCAT(errbuf, "<,>,");
4696 if (i & 16)
4697 STRCAT(errbuf, "[,],");
4698 if (*errbuf != NUL) /* remove trailing , */
4699 errbuf[STRLEN(errbuf) - 1] = NUL;
4700 save_arg = arg;
4701 arg = errbuf;
4702 }
4703 /*
4704 * Remove '>' before 'dir' and 'bdir', for
4705 * backwards compatibility with version 3.0
4706 */
4707 else if ( *arg == '>'
4708 && (varp == (char_u *)&p_dir
4709 || varp == (char_u *)&p_bdir))
4710 {
4711 ++arg;
4712 }
4713
4714 /* When setting the local value of a global
4715 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004716 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004717 && (opt_flags & OPT_LOCAL))
4718 origval = *(char_u **)get_varp(
4719 &options[opt_idx]);
4720 else
4721 origval = oldval;
4722
4723 /*
4724 * Copy the new string into allocated memory.
4725 * Can't use set_string_option_direct(), because
4726 * we need to remove the backslashes.
4727 */
4728 /* get a bit too much */
4729 newlen = (unsigned)STRLEN(arg) + 1;
4730 if (adding || prepending || removing)
4731 newlen += (unsigned)STRLEN(origval) + 1;
4732 newval = alloc(newlen);
4733 if (newval == NULL) /* out of mem, don't change */
4734 break;
4735 s = newval;
4736
4737 /*
4738 * Copy the string, skip over escaped chars.
4739 * For MS-DOS and WIN32 backslashes before normal
4740 * file name characters are not removed, and keep
4741 * backslash at start, for "\\machine\path", but
4742 * do remove it for "\\\\machine\\path".
4743 * The reverse is found in ExpandOldSetting().
4744 */
4745 while (*arg && !vim_iswhite(*arg))
4746 {
4747 if (*arg == '\\' && arg[1] != NUL
4748#ifdef BACKSLASH_IN_FILENAME
4749 && !((flags & P_EXPAND)
4750 && vim_isfilec(arg[1])
4751 && (arg[1] != '\\'
4752 || (s == newval
4753 && arg[2] != '\\')))
4754#endif
4755 )
4756 ++arg; /* remove backslash */
4757#ifdef FEAT_MBYTE
4758 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00004759 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004760 {
4761 /* copy multibyte char */
4762 mch_memmove(s, arg, (size_t)i);
4763 arg += i;
4764 s += i;
4765 }
4766 else
4767#endif
4768 *s++ = *arg++;
4769 }
4770 *s = NUL;
4771
4772 /*
4773 * Expand environment variables and ~.
4774 * Don't do it when adding without inserting a
4775 * comma.
4776 */
4777 if (!(adding || prepending || removing)
4778 || (flags & P_COMMA))
4779 {
4780 s = option_expand(opt_idx, newval);
4781 if (s != NULL)
4782 {
4783 vim_free(newval);
4784 newlen = (unsigned)STRLEN(s) + 1;
4785 if (adding || prepending || removing)
4786 newlen += (unsigned)STRLEN(origval) + 1;
4787 newval = alloc(newlen);
4788 if (newval == NULL)
4789 break;
4790 STRCPY(newval, s);
4791 }
4792 }
4793
4794 /* locate newval[] in origval[] when removing it
4795 * and when adding to avoid duplicates */
4796 i = 0; /* init for GCC */
4797 if (removing || (flags & P_NODUP))
4798 {
4799 i = (int)STRLEN(newval);
4800 bs = 0;
4801 for (s = origval; *s; ++s)
4802 {
4803 if ((!(flags & P_COMMA)
4804 || s == origval
4805 || (s[-1] == ',' && !(bs & 1)))
4806 && STRNCMP(s, newval, i) == 0
4807 && (!(flags & P_COMMA)
4808 || s[i] == ','
4809 || s[i] == NUL))
4810 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004811 /* Count backslashes. Only a comma with an
4812 * even number of backslashes before it is
Bram Moolenaar071d4272004-06-13 20:20:40 +00004813 * recognized as a separator */
4814 if (s > origval && s[-1] == '\\')
4815 ++bs;
4816 else
4817 bs = 0;
4818 }
4819
4820 /* do not add if already there */
4821 if ((adding || prepending) && *s)
4822 {
4823 prepending = FALSE;
4824 adding = FALSE;
4825 STRCPY(newval, origval);
4826 }
4827 }
4828
4829 /* concatenate the two strings; add a ',' if
4830 * needed */
4831 if (adding || prepending)
4832 {
4833 comma = ((flags & P_COMMA) && *origval != NUL
4834 && *newval != NUL);
4835 if (adding)
4836 {
4837 i = (int)STRLEN(origval);
4838 mch_memmove(newval + i + comma, newval,
4839 STRLEN(newval) + 1);
4840 mch_memmove(newval, origval, (size_t)i);
4841 }
4842 else
4843 {
4844 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004845 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004846 }
4847 if (comma)
4848 newval[i] = ',';
4849 }
4850
4851 /* Remove newval[] from origval[]. (Note: "i" has
4852 * been set above and is used here). */
4853 if (removing)
4854 {
4855 STRCPY(newval, origval);
4856 if (*s)
4857 {
4858 /* may need to remove a comma */
4859 if (flags & P_COMMA)
4860 {
4861 if (s == origval)
4862 {
4863 /* include comma after string */
4864 if (s[i] == ',')
4865 ++i;
4866 }
4867 else
4868 {
4869 /* include comma before string */
4870 --s;
4871 ++i;
4872 }
4873 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004874 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004875 }
4876 }
4877
4878 if (flags & P_FLAGLIST)
4879 {
4880 /* Remove flags that appear twice. */
4881 for (s = newval; *s; ++s)
4882 if ((!(flags & P_COMMA) || *s != ',')
4883 && vim_strchr(s + 1, *s) != NULL)
4884 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004885 STRMOVE(s, s + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004886 --s;
4887 }
4888 }
4889
4890 if (save_arg != NULL) /* number for 'whichwrap' */
4891 arg = save_arg;
4892 new_value_alloced = TRUE;
4893 }
4894
4895 /* Set the new value. */
4896 *(char_u **)(varp) = newval;
4897
4898 /* Handle side effects, and set the global value for
4899 * ":set" on local options. */
4900 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
4901 new_value_alloced, oldval, errbuf, opt_flags);
4902
4903 /* If error detected, print the error message. */
4904 if (errmsg != NULL)
4905 goto skip;
4906 }
4907 else /* key code option */
4908 {
4909 char_u *p;
4910
4911 if (nextchar == '&')
4912 {
4913 if (add_termcap_entry(key_name, TRUE) == FAIL)
4914 errmsg = (char_u *)N_("E522: Not found in termcap");
4915 }
4916 else
4917 {
4918 ++arg; /* jump to after the '=' or ':' */
4919 for (p = arg; *p && !vim_iswhite(*p); ++p)
4920 if (*p == '\\' && p[1] != NUL)
4921 ++p;
4922 nextchar = *p;
4923 *p = NUL;
4924 add_termcode(key_name, arg, FALSE);
4925 *p = nextchar;
4926 }
4927 if (full_screen)
4928 ttest(FALSE);
4929 redraw_all_later(CLEAR);
4930 }
4931 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004932
Bram Moolenaar071d4272004-06-13 20:20:40 +00004933 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004934 did_set_option(opt_idx, opt_flags,
4935 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004936 }
4937
4938skip:
4939 /*
4940 * Advance to next argument.
4941 * - skip until a blank found, taking care of backslashes
4942 * - skip blanks
4943 * - skip one "=val" argument (for hidden options ":set gfn =xx")
4944 */
4945 for (i = 0; i < 2 ; ++i)
4946 {
4947 while (*arg != NUL && !vim_iswhite(*arg))
4948 if (*arg++ == '\\' && *arg != NUL)
4949 ++arg;
4950 arg = skipwhite(arg);
4951 if (*arg != '=')
4952 break;
4953 }
4954 }
4955
4956 if (errmsg != NULL)
4957 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00004958 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00004959 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004960 if (i + (arg - startarg) < IOSIZE)
4961 {
4962 /* append the argument with the error */
4963 STRCAT(IObuff, ": ");
4964 mch_memmove(IObuff + i, startarg, (arg - startarg));
4965 IObuff[i + (arg - startarg)] = NUL;
4966 }
4967 /* make sure all characters are printable */
4968 trans_characters(IObuff, IOSIZE);
4969
4970 ++no_wait_return; /* wait_return done later */
4971 emsg(IObuff); /* show error highlighted */
4972 --no_wait_return;
4973
4974 return FAIL;
4975 }
4976
4977 arg = skipwhite(arg);
4978 }
4979
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004980theend:
4981 if (silent_mode && did_show)
4982 {
4983 /* After displaying option values in silent mode. */
4984 silent_mode = FALSE;
4985 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
4986 msg_putchar('\n');
4987 cursor_on(); /* msg_start() switches it off */
4988 out_flush();
4989 silent_mode = TRUE;
4990 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
4991 }
4992
Bram Moolenaar071d4272004-06-13 20:20:40 +00004993 return OK;
4994}
4995
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004996/*
4997 * Call this when an option has been given a new value through a user command.
4998 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
4999 */
5000 static void
5001did_set_option(opt_idx, opt_flags, new_value)
5002 int opt_idx;
5003 int opt_flags; /* possibly with OPT_MODELINE */
5004 int new_value; /* value was replaced completely */
5005{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005006 long_u *p;
5007
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005008 options[opt_idx].flags |= P_WAS_SET;
5009
5010 /* When an option is set in the sandbox, from a modeline or in secure mode
5011 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005012 * flag. */
5013 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005014 if (secure
5015#ifdef HAVE_SANDBOX
5016 || sandbox != 0
5017#endif
5018 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005019 *p = *p | P_INSECURE;
5020 else if (new_value)
5021 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005022}
5023
Bram Moolenaar071d4272004-06-13 20:20:40 +00005024 static char_u *
5025illegal_char(errbuf, c)
5026 char_u *errbuf;
5027 int c;
5028{
5029 if (errbuf == NULL)
5030 return (char_u *)"";
5031 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00005032 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00005033 return errbuf;
5034}
5035
5036/*
5037 * Convert a key name or string into a key value.
5038 * Used for 'wildchar' and 'cedit' options.
5039 */
5040 static int
5041string_to_key(arg)
5042 char_u *arg;
5043{
5044 if (*arg == '<')
5045 return find_key_option(arg + 1);
5046 if (*arg == '^')
5047 return Ctrl_chr(arg[1]);
5048 return *arg;
5049}
5050
5051#ifdef FEAT_CMDWIN
5052/*
5053 * Check value of 'cedit' and set cedit_key.
5054 * Returns NULL if value is OK, error message otherwise.
5055 */
5056 static char_u *
5057check_cedit()
5058{
5059 int n;
5060
5061 if (*p_cedit == NUL)
5062 cedit_key = -1;
5063 else
5064 {
5065 n = string_to_key(p_cedit);
5066 if (vim_isprintc(n))
5067 return e_invarg;
5068 cedit_key = n;
5069 }
5070 return NULL;
5071}
5072#endif
5073
5074#ifdef FEAT_TITLE
5075/*
5076 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5077 * maketitle() to create and display it.
5078 * When switching the title or icon off, call mch_restore_title() to get
5079 * the old value back.
5080 */
5081 static void
5082did_set_title(icon)
5083 int icon; /* Did set icon instead of title */
5084{
5085 if (starting != NO_SCREEN
5086#ifdef FEAT_GUI
5087 && !gui.starting
5088#endif
5089 )
5090 {
5091 maketitle();
5092 if (icon)
5093 {
5094 if (!p_icon)
5095 mch_restore_title(2);
5096 }
5097 else
5098 {
5099 if (!p_title)
5100 mch_restore_title(1);
5101 }
5102 }
5103}
5104#endif
5105
5106/*
5107 * set_options_bin - called when 'bin' changes value.
5108 */
5109 void
5110set_options_bin(oldval, newval, opt_flags)
5111 int oldval;
5112 int newval;
5113 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5114{
5115 /*
5116 * The option values that are changed when 'bin' changes are
5117 * copied when 'bin is set and restored when 'bin' is reset.
5118 */
5119 if (newval)
5120 {
5121 if (!oldval) /* switched on */
5122 {
5123 if (!(opt_flags & OPT_GLOBAL))
5124 {
5125 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5126 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5127 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5128 curbuf->b_p_et_nobin = curbuf->b_p_et;
5129 }
5130 if (!(opt_flags & OPT_LOCAL))
5131 {
5132 p_tw_nobin = p_tw;
5133 p_wm_nobin = p_wm;
5134 p_ml_nobin = p_ml;
5135 p_et_nobin = p_et;
5136 }
5137 }
5138
5139 if (!(opt_flags & OPT_GLOBAL))
5140 {
5141 curbuf->b_p_tw = 0; /* no automatic line wrap */
5142 curbuf->b_p_wm = 0; /* no automatic line wrap */
5143 curbuf->b_p_ml = 0; /* no modelines */
5144 curbuf->b_p_et = 0; /* no expandtab */
5145 }
5146 if (!(opt_flags & OPT_LOCAL))
5147 {
5148 p_tw = 0;
5149 p_wm = 0;
5150 p_ml = FALSE;
5151 p_et = FALSE;
5152 p_bin = TRUE; /* needed when called for the "-b" argument */
5153 }
5154 }
5155 else if (oldval) /* switched off */
5156 {
5157 if (!(opt_flags & OPT_GLOBAL))
5158 {
5159 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5160 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5161 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5162 curbuf->b_p_et = curbuf->b_p_et_nobin;
5163 }
5164 if (!(opt_flags & OPT_LOCAL))
5165 {
5166 p_tw = p_tw_nobin;
5167 p_wm = p_wm_nobin;
5168 p_ml = p_ml_nobin;
5169 p_et = p_et_nobin;
5170 }
5171 }
5172}
5173
5174#ifdef FEAT_VIMINFO
5175/*
5176 * Find the parameter represented by the given character (eg ', :, ", or /),
5177 * and return its associated value in the 'viminfo' string.
5178 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005179 * If the parameter is not specified in the string or there is no following
5180 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005181 */
5182 int
5183get_viminfo_parameter(type)
5184 int type;
5185{
5186 char_u *p;
5187
5188 p = find_viminfo_parameter(type);
5189 if (p != NULL && VIM_ISDIGIT(*p))
5190 return atoi((char *)p);
5191 return -1;
5192}
5193
5194/*
5195 * Find the parameter represented by the given character (eg ''', ':', '"', or
5196 * '/') in the 'viminfo' option and return a pointer to the string after it.
5197 * Return NULL if the parameter is not specified in the string.
5198 */
5199 char_u *
5200find_viminfo_parameter(type)
5201 int type;
5202{
5203 char_u *p;
5204
5205 for (p = p_viminfo; *p; ++p)
5206 {
5207 if (*p == type)
5208 return p + 1;
5209 if (*p == 'n') /* 'n' is always the last one */
5210 break;
5211 p = vim_strchr(p, ','); /* skip until next ',' */
5212 if (p == NULL) /* hit the end without finding parameter */
5213 break;
5214 }
5215 return NULL;
5216}
5217#endif
5218
5219/*
5220 * Expand environment variables for some string options.
5221 * These string options cannot be indirect!
5222 * If "val" is NULL expand the current value of the option.
5223 * Return pointer to NameBuff, or NULL when not expanded.
5224 */
5225 static char_u *
5226option_expand(opt_idx, val)
5227 int opt_idx;
5228 char_u *val;
5229{
5230 /* if option doesn't need expansion nothing to do */
5231 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5232 return NULL;
5233
5234 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5235 * expand_env() would truncate the string. */
5236 if (val != NULL && STRLEN(val) > MAXPATHL)
5237 return NULL;
5238
5239 if (val == NULL)
5240 val = *(char_u **)options[opt_idx].var;
5241
5242 /*
5243 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5244 * Escape spaces when expanding 'tags', they are used to separate file
5245 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005246 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005247 */
5248 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005249 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005250#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005251 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5252#endif
5253 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005254 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5255 return NULL;
5256
5257 return NameBuff;
5258}
5259
5260/*
5261 * After setting various option values: recompute variables that depend on
5262 * option values.
5263 */
5264 static void
5265didset_options()
5266{
5267 /* initialize the table for 'iskeyword' et.al. */
5268 (void)init_chartab();
5269
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005270#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005271 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005272#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005273 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
5274#ifdef FEAT_SESSION
5275 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5276 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5277#endif
5278#ifdef FEAT_FOLDING
5279 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5280#endif
5281 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
5282#ifdef FEAT_VIRTUALEDIT
5283 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5284#endif
5285#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5286 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5287#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005288#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005289 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005290 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005291 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005292#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005293#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5294 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5295#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005296#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005297 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5298#endif
5299#ifdef FEAT_CMDWIN
5300 /* set cedit_key */
5301 (void)check_cedit();
5302#endif
5303}
5304
5305/*
5306 * Check for string options that are NULL (normally only termcap options).
5307 */
5308 void
5309check_options()
5310{
5311 int opt_idx;
5312
5313 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5314 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5315 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5316}
5317
5318/*
5319 * Check string options in a buffer for NULL value.
5320 */
5321 void
5322check_buf_options(buf)
5323 buf_T *buf;
5324{
5325#if defined(FEAT_QUICKFIX)
5326 check_string_option(&buf->b_p_bh);
5327 check_string_option(&buf->b_p_bt);
5328#endif
5329#ifdef FEAT_MBYTE
5330 check_string_option(&buf->b_p_fenc);
5331#endif
5332 check_string_option(&buf->b_p_ff);
5333#ifdef FEAT_FIND_ID
5334 check_string_option(&buf->b_p_def);
5335 check_string_option(&buf->b_p_inc);
5336# ifdef FEAT_EVAL
5337 check_string_option(&buf->b_p_inex);
5338# endif
5339#endif
5340#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5341 check_string_option(&buf->b_p_inde);
5342 check_string_option(&buf->b_p_indk);
5343#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005344#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5345 check_string_option(&buf->b_p_bexpr);
5346#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005347#if defined(FEAT_CRYPT)
5348 check_string_option(&buf->b_p_cm);
5349#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005350#if defined(FEAT_EVAL)
5351 check_string_option(&buf->b_p_fex);
5352#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005353#ifdef FEAT_CRYPT
5354 check_string_option(&buf->b_p_key);
5355#endif
5356 check_string_option(&buf->b_p_kp);
5357 check_string_option(&buf->b_p_mps);
5358 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005359 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005360 check_string_option(&buf->b_p_isk);
5361#ifdef FEAT_COMMENTS
5362 check_string_option(&buf->b_p_com);
5363#endif
5364#ifdef FEAT_FOLDING
5365 check_string_option(&buf->b_p_cms);
5366#endif
5367 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005368#ifdef FEAT_TEXTOBJ
5369 check_string_option(&buf->b_p_qe);
5370#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005371#ifdef FEAT_SYN_HL
5372 check_string_option(&buf->b_p_syn);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005373#endif
5374#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005375 check_string_option(&buf->b_s.b_p_spc);
5376 check_string_option(&buf->b_s.b_p_spf);
5377 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005378#endif
5379#ifdef FEAT_SEARCHPATH
5380 check_string_option(&buf->b_p_sua);
5381#endif
5382#ifdef FEAT_CINDENT
5383 check_string_option(&buf->b_p_cink);
5384 check_string_option(&buf->b_p_cino);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01005385 parse_cino(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005386#endif
5387#ifdef FEAT_AUTOCMD
5388 check_string_option(&buf->b_p_ft);
5389#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005390#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5391 check_string_option(&buf->b_p_cinw);
5392#endif
5393#ifdef FEAT_INS_EXPAND
5394 check_string_option(&buf->b_p_cpt);
5395#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005396#ifdef FEAT_COMPL_FUNC
5397 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005398 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005399#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005400#ifdef FEAT_KEYMAP
5401 check_string_option(&buf->b_p_keymap);
5402#endif
5403#ifdef FEAT_QUICKFIX
5404 check_string_option(&buf->b_p_gp);
5405 check_string_option(&buf->b_p_mp);
5406 check_string_option(&buf->b_p_efm);
5407#endif
5408 check_string_option(&buf->b_p_ep);
5409 check_string_option(&buf->b_p_path);
5410 check_string_option(&buf->b_p_tags);
5411#ifdef FEAT_INS_EXPAND
5412 check_string_option(&buf->b_p_dict);
5413 check_string_option(&buf->b_p_tsr);
5414#endif
5415}
5416
5417/*
5418 * Free the string allocated for an option.
5419 * Checks for the string being empty_option. This may happen if we're out of
5420 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5421 * check_options().
5422 * Does NOT check for P_ALLOCED flag!
5423 */
5424 void
5425free_string_option(p)
5426 char_u *p;
5427{
5428 if (p != empty_option)
5429 vim_free(p);
5430}
5431
5432 void
5433clear_string_option(pp)
5434 char_u **pp;
5435{
5436 if (*pp != empty_option)
5437 vim_free(*pp);
5438 *pp = empty_option;
5439}
5440
5441 static void
5442check_string_option(pp)
5443 char_u **pp;
5444{
5445 if (*pp == NULL)
5446 *pp = empty_option;
5447}
5448
5449/*
5450 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5451 */
5452 void
5453set_term_option_alloced(p)
5454 char_u **p;
5455{
5456 int opt_idx;
5457
5458 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5459 if (options[opt_idx].var == (char_u *)p)
5460 {
5461 options[opt_idx].flags |= P_ALLOCED;
5462 return;
5463 }
5464 return; /* cannot happen: didn't find it! */
5465}
5466
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005467#if defined(FEAT_EVAL) || defined(PROTO)
5468/*
5469 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5470 * Return FALSE when it wasn't.
5471 * Return -1 for an unknown option.
5472 */
5473 int
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005474was_set_insecurely(opt, opt_flags)
5475 char_u *opt;
5476 int opt_flags;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005477{
5478 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005479 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005480
5481 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005482 {
5483 flagp = insecure_flag(idx, opt_flags);
5484 return (*flagp & P_INSECURE) != 0;
5485 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005486 EMSG2(_(e_intern2), "was_set_insecurely()");
5487 return -1;
5488}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005489
5490/*
5491 * Get a pointer to the flags used for the P_INSECURE flag of option
5492 * "opt_idx". For some local options a local flags field is used.
5493 */
5494 static long_u *
5495insecure_flag(opt_idx, opt_flags)
5496 int opt_idx;
5497 int opt_flags;
5498{
5499 if (opt_flags & OPT_LOCAL)
5500 switch ((int)options[opt_idx].indir)
5501 {
5502#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005503 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005504#endif
5505#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005506# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005507 case PV_FDE: return &curwin->w_p_fde_flags;
5508 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005509# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005510# ifdef FEAT_BEVAL
5511 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5512# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005513# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005514 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005515# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005516 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005517# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005518 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005519# endif
5520#endif
5521 }
5522
5523 /* Nothing special, return global flags field. */
5524 return &options[opt_idx].flags;
5525}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005526#endif
5527
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005528#ifdef FEAT_TITLE
5529static void redraw_titles __ARGS((void));
5530
5531/*
5532 * Redraw the window title and/or tab page text later.
5533 */
5534static void redraw_titles()
5535{
5536 need_maketitle = TRUE;
5537# ifdef FEAT_WINDOWS
5538 redraw_tabline = TRUE;
5539# endif
5540}
5541#endif
5542
Bram Moolenaar071d4272004-06-13 20:20:40 +00005543/*
5544 * Set a string option to a new value (without checking the effect).
5545 * The string is copied into allocated memory.
5546 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005547 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005548 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005549 */
5550 void
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005551set_string_option_direct(name, opt_idx, val, opt_flags, set_sid)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005552 char_u *name;
5553 int opt_idx;
5554 char_u *val;
5555 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar78a15312009-05-15 19:33:18 +00005556 int set_sid UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005557{
5558 char_u *s;
5559 char_u **varp;
5560 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005561 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005562
Bram Moolenaar89d40322006-08-29 15:30:07 +00005563 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005564 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005565 idx = findoption(name);
5566 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005567 {
5568 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar071d4272004-06-13 20:20:40 +00005569 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005570 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005571 }
5572
Bram Moolenaar89d40322006-08-29 15:30:07 +00005573 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005574 return;
5575
5576 s = vim_strsave(val);
5577 if (s != NULL)
5578 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005579 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005580 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005581 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005582 free_string_option(*varp);
5583 *varp = s;
5584
5585 /* For buffer/window local option may also set the global value. */
5586 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005587 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005588
Bram Moolenaar89d40322006-08-29 15:30:07 +00005589 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005590
5591 /* When setting both values of a global option with a local value,
5592 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005593 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005594 {
5595 free_string_option(*varp);
5596 *varp = empty_option;
5597 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005598# ifdef FEAT_EVAL
5599 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005600 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005601 set_sid == 0 ? current_SID : set_sid);
5602# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005603 }
5604}
5605
5606/*
5607 * Set global value for string option when it's a local option.
5608 */
5609 static void
5610set_string_option_global(opt_idx, varp)
5611 int opt_idx; /* option index */
5612 char_u **varp; /* pointer to option variable */
5613{
5614 char_u **p, *s;
5615
5616 /* the global value is always allocated */
5617 if (options[opt_idx].var == VAR_WIN)
5618 p = (char_u **)GLOBAL_WO(varp);
5619 else
5620 p = (char_u **)options[opt_idx].var;
5621 if (options[opt_idx].indir != PV_NONE
5622 && p != varp
5623 && (s = vim_strsave(*varp)) != NULL)
5624 {
5625 free_string_option(*p);
5626 *p = s;
5627 }
5628}
5629
5630/*
5631 * Set a string option to a new value, and handle the effects.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005632 *
5633 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005634 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005635 static char_u *
Bram Moolenaar071d4272004-06-13 20:20:40 +00005636set_string_option(opt_idx, value, opt_flags)
5637 int opt_idx;
5638 char_u *value;
5639 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5640{
5641 char_u *s;
5642 char_u **varp;
5643 char_u *oldval;
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005644 char_u *r = NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005645
5646 if (options[opt_idx].var == NULL) /* don't set hidden option */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005647 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005648
5649 s = vim_strsave(value);
5650 if (s != NULL)
5651 {
5652 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5653 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005654 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005655 ? OPT_GLOBAL : OPT_LOCAL)
5656 : opt_flags);
5657 oldval = *varp;
5658 *varp = s;
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005659 if ((r = did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5660 opt_flags)) == NULL)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005661 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005662 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02005663 return r;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005664}
5665
5666/*
5667 * Handle string options that need some action to perform when changed.
5668 * Returns NULL for success, or an error message for an error.
5669 */
5670 static char_u *
5671did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
5672 opt_flags)
5673 int opt_idx; /* index in options[] table */
5674 char_u **varp; /* pointer to the option variable */
5675 int new_value_alloced; /* new value was allocated */
5676 char_u *oldval; /* previous value of the option */
5677 char_u *errbuf; /* buffer for errors, or NULL */
5678 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5679{
5680 char_u *errmsg = NULL;
5681 char_u *s, *p;
5682 int did_chartab = FALSE;
5683 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005684 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00005685#ifdef FEAT_GUI
5686 /* set when changing an option that only requires a redraw in the GUI */
5687 int redraw_gui_only = FALSE;
5688#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005689
5690 /* Get the global option to compare with, otherwise we would have to check
5691 * two values for all local options. */
5692 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
5693
5694 /* Disallow changing some options from secure mode */
5695 if ((secure
5696#ifdef HAVE_SANDBOX
5697 || sandbox != 0
5698#endif
5699 ) && (options[opt_idx].flags & P_SECURE))
5700 {
5701 errmsg = e_secure;
5702 }
5703
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005704 /* Check for a "normal" file name in some options. Disallow a path
5705 * separator (slash and/or backslash), wildcards and characters that are
5706 * often illegal in a file name. */
5707 else if ((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005708 && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL)
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005709 {
5710 errmsg = e_invarg;
5711 }
5712
Bram Moolenaar071d4272004-06-13 20:20:40 +00005713 /* 'term' */
5714 else if (varp == &T_NAME)
5715 {
5716 if (T_NAME[0] == NUL)
5717 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
5718#ifdef FEAT_GUI
5719 if (gui.in_use)
5720 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
5721 else if (term_is_gui(T_NAME))
5722 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
5723#endif
5724 else if (set_termname(T_NAME) == FAIL)
5725 errmsg = (char_u *)N_("E522: Not found in termcap");
5726 else
5727 /* Screen colors may have changed. */
5728 redraw_later_clear();
5729 }
5730
5731 /* 'backupcopy' */
5732 else if (varp == &p_bkc)
5733 {
5734 if (opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE) != OK)
5735 errmsg = e_invarg;
5736 if (((bkc_flags & BKC_AUTO) != 0)
5737 + ((bkc_flags & BKC_YES) != 0)
5738 + ((bkc_flags & BKC_NO) != 0) != 1)
5739 {
5740 /* Must have exactly one of "auto", "yes" and "no". */
5741 (void)opt_strings_flags(oldval, p_bkc_values, &bkc_flags, TRUE);
5742 errmsg = e_invarg;
5743 }
5744 }
5745
5746 /* 'backupext' and 'patchmode' */
5747 else if (varp == &p_bex || varp == &p_pm)
5748 {
5749 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
5750 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
5751 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
5752 }
5753
5754 /*
5755 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[]
5756 * If the new option is invalid, use old value. 'lisp' option: refill
5757 * chartab[] for '-' char
5758 */
5759 else if ( varp == &p_isi
5760 || varp == &(curbuf->b_p_isk)
5761 || varp == &p_isp
5762 || varp == &p_isf)
5763 {
5764 if (init_chartab() == FAIL)
5765 {
5766 did_chartab = TRUE; /* need to restore it below */
5767 errmsg = e_invarg; /* error in value */
5768 }
5769 }
5770
5771 /* 'helpfile' */
5772 else if (varp == &p_hf)
5773 {
5774 /* May compute new values for $VIM and $VIMRUNTIME */
5775 if (didset_vim)
5776 {
5777 vim_setenv((char_u *)"VIM", (char_u *)"");
5778 didset_vim = FALSE;
5779 }
5780 if (didset_vimruntime)
5781 {
5782 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
5783 didset_vimruntime = FALSE;
5784 }
5785 }
5786
Bram Moolenaar1a384422010-07-14 19:53:30 +02005787#ifdef FEAT_SYN_HL
5788 /* 'colorcolumn' */
5789 else if (varp == &curwin->w_p_cc)
5790 errmsg = check_colorcolumn(curwin);
5791#endif
5792
Bram Moolenaar071d4272004-06-13 20:20:40 +00005793#ifdef FEAT_MULTI_LANG
5794 /* 'helplang' */
5795 else if (varp == &p_hlg)
5796 {
5797 /* Check for "", "ab", "ab,cd", etc. */
5798 for (s = p_hlg; *s != NUL; s += 3)
5799 {
5800 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
5801 {
5802 errmsg = e_invarg;
5803 break;
5804 }
5805 if (s[2] == NUL)
5806 break;
5807 }
5808 }
5809#endif
5810
5811 /* 'highlight' */
5812 else if (varp == &p_hl)
5813 {
5814 if (highlight_changed() == FAIL)
5815 errmsg = e_invarg; /* invalid flags */
5816 }
5817
5818 /* 'nrformats' */
5819 else if (gvarp == &p_nf)
5820 {
5821 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
5822 errmsg = e_invarg;
5823 }
5824
5825#ifdef FEAT_SESSION
5826 /* 'sessionoptions' */
5827 else if (varp == &p_ssop)
5828 {
5829 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
5830 errmsg = e_invarg;
5831 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
5832 {
5833 /* Don't allow both "sesdir" and "curdir". */
5834 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
5835 errmsg = e_invarg;
5836 }
5837 }
5838 /* 'viewoptions' */
5839 else if (varp == &p_vop)
5840 {
5841 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
5842 errmsg = e_invarg;
5843 }
5844#endif
5845
5846 /* 'scrollopt' */
5847#ifdef FEAT_SCROLLBIND
5848 else if (varp == &p_sbo)
5849 {
5850 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
5851 errmsg = e_invarg;
5852 }
5853#endif
5854
5855 /* 'ambiwidth' */
5856#ifdef FEAT_MBYTE
5857 else if (varp == &p_ambw)
5858 {
5859 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
5860 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02005861 else if (set_chars_option(&p_lcs) != NULL)
5862 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
5863# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5864 else if (set_chars_option(&p_fcs) != NULL)
5865 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
5866# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005867 }
5868#endif
5869
5870 /* 'background' */
5871 else if (varp == &p_bg)
5872 {
5873 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
5874 {
5875#ifdef FEAT_EVAL
5876 int dark = (*p_bg == 'd');
5877#endif
5878
5879 init_highlight(FALSE, FALSE);
5880
5881#ifdef FEAT_EVAL
5882 if (dark != (*p_bg == 'd')
5883 && get_var_value((char_u *)"g:colors_name") != NULL)
5884 {
5885 /* The color scheme must have set 'background' back to another
5886 * value, that's not what we want here. Disable the color
5887 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00005888 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005889 free_string_option(p_bg);
5890 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
5891 check_string_option(&p_bg);
5892 init_highlight(FALSE, FALSE);
5893 }
5894#endif
5895 }
5896 else
5897 errmsg = e_invarg;
5898 }
5899
5900 /* 'wildmode' */
5901 else if (varp == &p_wim)
5902 {
5903 if (check_opt_wim() == FAIL)
5904 errmsg = e_invarg;
5905 }
5906
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00005907#ifdef FEAT_CMDL_COMPL
5908 /* 'wildoptions' */
5909 else if (varp == &p_wop)
5910 {
5911 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
5912 errmsg = e_invarg;
5913 }
5914#endif
5915
Bram Moolenaar071d4272004-06-13 20:20:40 +00005916#ifdef FEAT_WAK
5917 /* 'winaltkeys' */
5918 else if (varp == &p_wak)
5919 {
5920 if (*p_wak == NUL
5921 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
5922 errmsg = e_invarg;
5923# ifdef FEAT_MENU
5924# ifdef FEAT_GUI_MOTIF
5925 else if (gui.in_use)
5926 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
5927# else
5928# ifdef FEAT_GUI_GTK
5929 else if (gui.in_use)
5930 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
5931# endif
5932# endif
5933# endif
5934 }
5935#endif
5936
5937#ifdef FEAT_AUTOCMD
5938 /* 'eventignore' */
5939 else if (varp == &p_ei)
5940 {
5941 if (check_ei() == FAIL)
5942 errmsg = e_invarg;
5943 }
5944#endif
5945
5946#ifdef FEAT_MBYTE
5947 /* 'encoding' and 'fileencoding' */
5948 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc)
5949 {
5950 if (gvarp == &p_fenc)
5951 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00005952 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005953 errmsg = e_modifiable;
5954 else if (vim_strchr(*varp, ',') != NULL)
5955 /* No comma allowed in 'fileencoding'; catches confusing it
5956 * with 'fileencodings'. */
5957 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005958 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005959 {
5960# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005961 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005962 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00005963# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005964 /* Add 'fileencoding' to the swap file. */
5965 ml_setflags(curbuf);
5966 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005967 }
5968 if (errmsg == NULL)
5969 {
5970 /* canonize the value, so that STRCMP() can be used on it */
5971 p = enc_canonize(*varp);
5972 if (p != NULL)
5973 {
5974 vim_free(*varp);
5975 *varp = p;
5976 }
5977 if (varp == &p_enc)
5978 {
5979 errmsg = mb_init();
5980# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005981 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00005982# endif
5983 }
5984 }
5985
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005986# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005987 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
5988 {
5989 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
5990 if (STRCMP(p_tenc, "utf-8") != 0)
5991 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
5992 }
5993# endif
5994
5995 if (errmsg == NULL)
5996 {
5997# ifdef FEAT_KEYMAP
5998 /* When 'keymap' is used and 'encoding' changes, reload the keymap
5999 * (with another encoding). */
6000 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
6001 (void)keymap_init();
6002# endif
6003
6004 /* When 'termencoding' is not empty and 'encoding' changes or when
6005 * 'termencoding' changes, need to setup for keyboard input and
6006 * display output conversion. */
6007 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
6008 {
6009 convert_setup(&input_conv, p_tenc, p_enc);
6010 convert_setup(&output_conv, p_enc, p_tenc);
6011 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00006012
6013# if defined(WIN3264) && defined(FEAT_MBYTE)
6014 /* $HOME may have characters in active code page. */
6015 if (varp == &p_enc)
6016 init_homedir();
6017# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006018 }
6019 }
6020#endif
6021
6022#if defined(FEAT_POSTSCRIPT)
6023 else if (varp == &p_penc)
6024 {
6025 /* Canonize printencoding if VIM standard one */
6026 p = enc_canonize(p_penc);
6027 if (p != NULL)
6028 {
6029 vim_free(p_penc);
6030 p_penc = p;
6031 }
6032 else
6033 {
6034 /* Ensure lower case and '-' for '_' */
6035 for (s = p_penc; *s != NUL; s++)
6036 {
6037 if (*s == '_')
6038 *s = '-';
6039 else
6040 *s = TOLOWER_ASC(*s);
6041 }
6042 }
6043 }
6044#endif
6045
Bram Moolenaar9372a112005-12-06 19:59:18 +00006046#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006047 else if (varp == &p_imak)
6048 {
6049 if (gui.in_use && !im_xim_isvalid_imactivate())
6050 errmsg = e_invarg;
6051 }
6052#endif
6053
6054#ifdef FEAT_KEYMAP
6055 else if (varp == &curbuf->b_p_keymap)
6056 {
6057 /* load or unload key mapping tables */
6058 errmsg = keymap_init();
6059
Bram Moolenaarfab06232009-03-04 03:13:35 +00006060 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006061 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006062 if (*curbuf->b_p_keymap != NUL)
6063 {
6064 /* Installed a new keymap, switch on using it. */
6065 curbuf->b_p_iminsert = B_IMODE_LMAP;
6066 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6067 curbuf->b_p_imsearch = B_IMODE_LMAP;
6068 }
6069 else
6070 {
6071 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6072 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6073 curbuf->b_p_iminsert = B_IMODE_NONE;
6074 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6075 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6076 }
6077 if ((opt_flags & OPT_LOCAL) == 0)
6078 {
6079 set_iminsert_global();
6080 set_imsearch_global();
6081 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006082# ifdef FEAT_WINDOWS
6083 status_redraw_curbuf();
6084# endif
6085 }
6086 }
6087#endif
6088
6089 /* 'fileformat' */
6090 else if (gvarp == &p_ff)
6091 {
6092 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6093 errmsg = e_modifiable;
6094 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6095 errmsg = e_invarg;
6096 else
6097 {
6098 /* may also change 'textmode' */
6099 if (get_fileformat(curbuf) == EOL_DOS)
6100 curbuf->b_p_tx = TRUE;
6101 else
6102 curbuf->b_p_tx = FALSE;
6103#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006104 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006105#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006106 /* update flag in swap file */
6107 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006108 /* Redraw needed when switching to/from "mac": a CR in the text
6109 * will be displayed differently. */
6110 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6111 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006112 }
6113 }
6114
6115 /* 'fileformats' */
6116 else if (varp == &p_ffs)
6117 {
6118 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6119 errmsg = e_invarg;
6120 else
6121 {
6122 /* also change 'textauto' */
6123 if (*p_ffs == NUL)
6124 p_ta = FALSE;
6125 else
6126 p_ta = TRUE;
6127 }
6128 }
6129
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006130#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006131 /* 'cryptkey' */
6132 else if (gvarp == &p_key)
6133 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006134# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006135 /* Make sure the ":set" command doesn't show the new value in the
6136 * history. */
6137 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006138# endif
6139 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6140 /* Need to update the swapfile. */
Bram Moolenaar49771f42010-07-20 17:32:38 +02006141 ml_set_crypt_key(curbuf, oldval, get_crypt_method(curbuf));
6142 }
6143
6144 else if (gvarp == &p_cm)
6145 {
6146 if (opt_flags & OPT_LOCAL)
6147 p = curbuf->b_p_cm;
6148 else
6149 p = p_cm;
6150 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6151 errmsg = e_invarg;
6152 else if (get_crypt_method(curbuf) > 0 && blowfish_self_test() == FAIL)
6153 errmsg = e_invarg;
6154 else
6155 {
6156 /* When setting the global value to empty, make it "zip". */
6157 if (*p_cm == NUL)
6158 {
6159 if (new_value_alloced)
6160 free_string_option(p_cm);
6161 p_cm = vim_strsave((char_u *)"zip");
6162 new_value_alloced = TRUE;
6163 }
6164
6165 /* Need to update the swapfile when the effective method changed.
6166 * Set "s" to the effective old value, "p" to the effective new
6167 * method and compare. */
6168 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6169 s = p_cm; /* was previously using the global value */
6170 else
6171 s = oldval;
6172 if (*curbuf->b_p_cm == NUL)
6173 p = p_cm; /* is now using the global value */
6174 else
6175 p = curbuf->b_p_cm;
6176 if (STRCMP(s, p) != 0)
6177 ml_set_crypt_key(curbuf, curbuf->b_p_key,
6178 crypt_method_from_string(s));
6179
6180 /* If the global value changes need to update the swapfile for all
6181 * buffers using that value. */
6182 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6183 {
6184 buf_T *buf;
6185
6186 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
6187 if (buf != curbuf && *buf->b_p_cm == NUL)
6188 ml_set_crypt_key(buf, buf->b_p_key,
6189 crypt_method_from_string(oldval));
6190 }
6191 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006192 }
6193#endif
6194
6195 /* 'matchpairs' */
6196 else if (gvarp == &p_mps)
6197 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006198#ifdef FEAT_MBYTE
6199 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006200 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006201 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006202 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006203 int x2 = -1;
6204 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006205
6206 if (*p != NUL)
6207 p += mb_ptr2len(p);
6208 if (*p != NUL)
6209 x2 = *p++;
6210 if (*p != NUL)
6211 {
6212 x3 = mb_ptr2char(p);
6213 p += mb_ptr2len(p);
6214 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006215 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006216 {
6217 errmsg = e_invarg;
6218 break;
6219 }
6220 if (*p == NUL)
6221 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006222 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006223 }
6224 else
6225#endif
6226 {
6227 /* Check for "x:y,x:y" */
6228 for (p = *varp; *p != NUL; p += 4)
6229 {
6230 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6231 {
6232 errmsg = e_invarg;
6233 break;
6234 }
6235 if (p[3] == NUL)
6236 break;
6237 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006238 }
6239 }
6240
6241#ifdef FEAT_COMMENTS
6242 /* 'comments' */
6243 else if (gvarp == &p_com)
6244 {
6245 for (s = *varp; *s; )
6246 {
6247 while (*s && *s != ':')
6248 {
6249 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6250 && !VIM_ISDIGIT(*s) && *s != '-')
6251 {
6252 errmsg = illegal_char(errbuf, *s);
6253 break;
6254 }
6255 ++s;
6256 }
6257 if (*s++ == NUL)
6258 errmsg = (char_u *)N_("E524: Missing colon");
6259 else if (*s == ',' || *s == NUL)
6260 errmsg = (char_u *)N_("E525: Zero length string");
6261 if (errmsg != NULL)
6262 break;
6263 while (*s && *s != ',')
6264 {
6265 if (*s == '\\' && s[1] != NUL)
6266 ++s;
6267 ++s;
6268 }
6269 s = skip_to_option_part(s);
6270 }
6271 }
6272#endif
6273
6274 /* 'listchars' */
6275 else if (varp == &p_lcs)
6276 {
6277 errmsg = set_chars_option(varp);
6278 }
6279
6280#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6281 /* 'fillchars' */
6282 else if (varp == &p_fcs)
6283 {
6284 errmsg = set_chars_option(varp);
6285 }
6286#endif
6287
6288#ifdef FEAT_CMDWIN
6289 /* 'cedit' */
6290 else if (varp == &p_cedit)
6291 {
6292 errmsg = check_cedit();
6293 }
6294#endif
6295
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006296 /* 'verbosefile' */
6297 else if (varp == &p_vfile)
6298 {
6299 verbose_stop();
6300 if (*p_vfile != NUL && verbose_open() == FAIL)
6301 errmsg = e_invarg;
6302 }
6303
Bram Moolenaar071d4272004-06-13 20:20:40 +00006304#ifdef FEAT_VIMINFO
6305 /* 'viminfo' */
6306 else if (varp == &p_viminfo)
6307 {
6308 for (s = p_viminfo; *s;)
6309 {
6310 /* Check it's a valid character */
6311 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6312 {
6313 errmsg = illegal_char(errbuf, *s);
6314 break;
6315 }
6316 if (*s == 'n') /* name is always last one */
6317 {
6318 break;
6319 }
6320 else if (*s == 'r') /* skip until next ',' */
6321 {
6322 while (*++s && *s != ',')
6323 ;
6324 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006325 else if (*s == '%')
6326 {
6327 /* optional number */
6328 while (vim_isdigit(*++s))
6329 ;
6330 }
6331 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006332 ++s; /* no extra chars */
6333 else /* must have a number */
6334 {
6335 while (vim_isdigit(*++s))
6336 ;
6337
6338 if (!VIM_ISDIGIT(*(s - 1)))
6339 {
6340 if (errbuf != NULL)
6341 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006342 sprintf((char *)errbuf,
6343 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006344 transchar_byte(*(s - 1)));
6345 errmsg = errbuf;
6346 }
6347 else
6348 errmsg = (char_u *)"";
6349 break;
6350 }
6351 }
6352 if (*s == ',')
6353 ++s;
6354 else if (*s)
6355 {
6356 if (errbuf != NULL)
6357 errmsg = (char_u *)N_("E527: Missing comma");
6358 else
6359 errmsg = (char_u *)"";
6360 break;
6361 }
6362 }
6363 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6364 errmsg = (char_u *)N_("E528: Must specify a ' value");
6365 }
6366#endif /* FEAT_VIMINFO */
6367
6368 /* terminal options */
6369 else if (istermoption(&options[opt_idx]) && full_screen)
6370 {
6371 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6372 if (varp == &T_CCO)
6373 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006374 int colors = atoi((char *)T_CCO);
6375
6376 /* Only reinitialize colors if t_Co value has really changed to
6377 * avoid expensive reload of colorscheme if t_Co is set to the
6378 * same value multiple times. */
6379 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006380 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006381 t_colors = colors;
6382 if (t_colors <= 1)
6383 {
6384 if (new_value_alloced)
6385 vim_free(T_CCO);
6386 T_CCO = empty_option;
6387 }
6388 /* We now have a different color setup, initialize it again. */
6389 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006390 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006391 }
6392 ttest(FALSE);
6393 if (varp == &T_ME)
6394 {
6395 out_str(T_ME);
6396 redraw_later(CLEAR);
6397#if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32))
6398 /* Since t_me has been set, this probably means that the user
6399 * wants to use this as default colors. Need to reset default
6400 * background/foreground colors. */
6401 mch_set_normal_colors();
6402#endif
6403 }
6404 }
6405
6406#ifdef FEAT_LINEBREAK
6407 /* 'showbreak' */
6408 else if (varp == &p_sbr)
6409 {
6410 for (s = p_sbr; *s; )
6411 {
6412 if (ptr2cells(s) != 1)
6413 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006414 mb_ptr_adv(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006415 }
6416 }
6417#endif
6418
6419#ifdef FEAT_GUI
6420 /* 'guifont' */
6421 else if (varp == &p_guifont)
6422 {
6423 if (gui.in_use)
6424 {
6425 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006426# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006427 /*
6428 * Put up a font dialog and let the user select a new value.
6429 * If this is cancelled go back to the old value but don't
6430 * give an error message.
6431 */
6432 if (STRCMP(p, "*") == 0)
6433 {
6434 p = gui_mch_font_dialog(oldval);
6435
6436 if (new_value_alloced)
6437 free_string_option(p_guifont);
6438
6439 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6440 new_value_alloced = TRUE;
6441 }
6442# endif
6443 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6444 {
6445# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6446 if (STRCMP(p_guifont, "*") == 0)
6447 {
6448 /* Dialog was cancelled: Keep the old value without giving
6449 * an error message. */
6450 if (new_value_alloced)
6451 free_string_option(p_guifont);
6452 p_guifont = vim_strsave(oldval);
6453 new_value_alloced = TRUE;
6454 }
6455 else
6456# endif
6457 errmsg = (char_u *)N_("E596: Invalid font(s)");
6458 }
6459 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006460 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006461 }
6462# ifdef FEAT_XFONTSET
6463 else if (varp == &p_guifontset)
6464 {
6465 if (STRCMP(p_guifontset, "*") == 0)
6466 errmsg = (char_u *)N_("E597: can't select fontset");
6467 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6468 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006469 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006470 }
6471# endif
6472# ifdef FEAT_MBYTE
6473 else if (varp == &p_guifontwide)
6474 {
6475 if (STRCMP(p_guifontwide, "*") == 0)
6476 errmsg = (char_u *)N_("E533: can't select wide font");
6477 else if (gui_get_wide_font() == FAIL)
6478 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006479 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006480 }
6481# endif
6482#endif
6483
6484#ifdef CURSOR_SHAPE
6485 /* 'guicursor' */
6486 else if (varp == &p_guicursor)
6487 errmsg = parse_shape_opt(SHAPE_CURSOR);
6488#endif
6489
6490#ifdef FEAT_MOUSESHAPE
6491 /* 'mouseshape' */
6492 else if (varp == &p_mouseshape)
6493 {
6494 errmsg = parse_shape_opt(SHAPE_MOUSE);
6495 update_mouseshape(-1);
6496 }
6497#endif
6498
6499#ifdef FEAT_PRINTER
6500 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006501 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006502# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006503 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006504 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006505# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006506#endif
6507
6508#ifdef FEAT_LANGMAP
6509 /* 'langmap' */
6510 else if (varp == &p_langmap)
6511 langmap_set();
6512#endif
6513
6514#ifdef FEAT_LINEBREAK
6515 /* 'breakat' */
6516 else if (varp == &p_breakat)
6517 fill_breakat_flags();
6518#endif
6519
6520#ifdef FEAT_TITLE
6521 /* 'titlestring' and 'iconstring' */
6522 else if (varp == &p_titlestring || varp == &p_iconstring)
6523 {
6524# ifdef FEAT_STL_OPT
6525 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6526
6527 /* NULL => statusline syntax */
6528 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6529 stl_syntax |= flagval;
6530 else
6531 stl_syntax &= ~flagval;
6532# endif
6533 did_set_title(varp == &p_iconstring);
6534
6535 }
6536#endif
6537
6538#ifdef FEAT_GUI
6539 /* 'guioptions' */
6540 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006541 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006542 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006543 redraw_gui_only = TRUE;
6544 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006545#endif
6546
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006547#if defined(FEAT_GUI_TABLINE)
6548 /* 'guitablabel' */
6549 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006550 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006551 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006552 redraw_gui_only = TRUE;
6553 }
6554 /* 'guitabtooltip' */
6555 else if (varp == &p_gtt)
6556 {
6557 redraw_gui_only = TRUE;
6558 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006559#endif
6560
Bram Moolenaar071d4272004-06-13 20:20:40 +00006561#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6562 /* 'ttymouse' */
6563 else if (varp == &p_ttym)
6564 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006565 /* Switch the mouse off before changing the escape sequences used for
6566 * that. */
6567 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006568 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6569 errmsg = e_invarg;
6570 else
6571 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006572 if (termcap_active)
6573 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006574 }
6575#endif
6576
6577#ifdef FEAT_VISUAL
6578 /* 'selection' */
6579 else if (varp == &p_sel)
6580 {
6581 if (*p_sel == NUL
6582 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6583 errmsg = e_invarg;
6584 }
6585
6586 /* 'selectmode' */
6587 else if (varp == &p_slm)
6588 {
6589 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6590 errmsg = e_invarg;
6591 }
6592#endif
6593
6594#ifdef FEAT_BROWSE
6595 /* 'browsedir' */
6596 else if (varp == &p_bsdir)
6597 {
6598 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
6599 && !mch_isdir(p_bsdir))
6600 errmsg = e_invarg;
6601 }
6602#endif
6603
6604#ifdef FEAT_VISUAL
6605 /* 'keymodel' */
6606 else if (varp == &p_km)
6607 {
6608 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
6609 errmsg = e_invarg;
6610 else
6611 {
6612 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
6613 km_startsel = (vim_strchr(p_km, 'a') != NULL);
6614 }
6615 }
6616#endif
6617
6618 /* 'mousemodel' */
6619 else if (varp == &p_mousem)
6620 {
6621 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
6622 errmsg = e_invarg;
6623#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
6624 else if (*p_mousem != *oldval)
6625 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
6626 * to create or delete the popup menus. */
6627 gui_motif_update_mousemodel(root_menu);
6628#endif
6629 }
6630
6631 /* 'switchbuf' */
6632 else if (varp == &p_swb)
6633 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00006634 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006635 errmsg = e_invarg;
6636 }
6637
6638 /* 'debug' */
6639 else if (varp == &p_debug)
6640 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00006641 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006642 errmsg = e_invarg;
6643 }
6644
6645 /* 'display' */
6646 else if (varp == &p_dy)
6647 {
6648 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
6649 errmsg = e_invarg;
6650 else
6651 (void)init_chartab();
6652
6653 }
6654
6655#ifdef FEAT_VERTSPLIT
6656 /* 'eadirection' */
6657 else if (varp == &p_ead)
6658 {
6659 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
6660 errmsg = e_invarg;
6661 }
6662#endif
6663
6664#ifdef FEAT_CLIPBOARD
6665 /* 'clipboard' */
6666 else if (varp == &p_cb)
6667 errmsg = check_clipboard_option();
6668#endif
6669
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00006670#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006671 /* When 'spelllang' or 'spellfile' is set and there is a window for this
6672 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006673 else if (varp == &(curbuf->b_s.b_p_spl) || varp == &(curbuf->b_s.b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00006674 {
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006675 win_T *wp;
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006676 int l;
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006677
Bram Moolenaar860cae12010-06-05 23:22:07 +02006678 if (varp == &(curbuf->b_s.b_p_spf))
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006679 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006680 l = (int)STRLEN(curbuf->b_s.b_p_spf);
6681 if (l > 0 && (l < 4 || STRCMP(curbuf->b_s.b_p_spf + l - 4,
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006682 ".add") != 0))
6683 errmsg = e_invarg;
6684 }
6685
6686 if (errmsg == NULL)
6687 {
6688 FOR_ALL_WINDOWS(wp)
6689 if (wp->w_buffer == curbuf && wp->w_p_spell)
6690 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006691 errmsg = did_set_spelllang(wp);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006692# ifdef FEAT_WINDOWS
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006693 break;
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006694# endif
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006695 }
6696 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006697 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006698 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006699 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006700 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006701 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006702 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006703 /* 'spellsuggest' */
6704 else if (varp == &p_sps)
6705 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00006706 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006707 errmsg = e_invarg;
6708 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00006709 /* 'mkspellmem' */
6710 else if (varp == &p_msm)
6711 {
6712 if (spell_check_msm() != OK)
6713 errmsg = e_invarg;
6714 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006715#endif
6716
Bram Moolenaar071d4272004-06-13 20:20:40 +00006717#ifdef FEAT_QUICKFIX
6718 /* When 'bufhidden' is set, check for valid value. */
6719 else if (gvarp == &p_bh)
6720 {
6721 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
6722 errmsg = e_invarg;
6723 }
6724
6725 /* When 'buftype' is set, check for valid value. */
6726 else if (gvarp == &p_bt)
6727 {
6728 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
6729 errmsg = e_invarg;
6730 else
6731 {
6732# ifdef FEAT_WINDOWS
6733 if (curwin->w_status_height)
6734 {
6735 curwin->w_redr_status = TRUE;
6736 redraw_later(VALID);
6737 }
6738# endif
6739 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar5075aad2010-01-27 15:58:13 +01006740# ifdef FEAT_TITLE
6741 redraw_titles();
6742# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006743 }
6744 }
6745#endif
6746
6747#ifdef FEAT_STL_OPT
6748 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006749 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006750 {
6751 int wid;
6752
6753 if (varp == &p_ruf) /* reset ru_wid first */
6754 ru_wid = 0;
6755 s = *varp;
6756 if (varp == &p_ruf && *s == '%')
6757 {
6758 /* set ru_wid if 'ruf' starts with "%99(" */
6759 if (*++s == '-') /* ignore a '-' */
6760 s++;
6761 wid = getdigits(&s);
6762 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
6763 ru_wid = wid;
6764 else
6765 errmsg = check_stl_option(p_ruf);
6766 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00006767 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00006768 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006769 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006770 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006771 comp_col();
6772 }
6773#endif
6774
6775#ifdef FEAT_INS_EXPAND
6776 /* check if it is a valid value for 'complete' -- Acevedo */
6777 else if (gvarp == &p_cpt)
6778 {
6779 for (s = *varp; *s;)
6780 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02006781 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006782 s++;
6783 if (!*s)
6784 break;
6785 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
6786 {
6787 errmsg = illegal_char(errbuf, *s);
6788 break;
6789 }
6790 if (*++s != NUL && *s != ',' && *s != ' ')
6791 {
6792 if (s[-1] == 'k' || s[-1] == 's')
6793 {
6794 /* skip optional filename after 'k' and 's' */
6795 while (*s && *s != ',' && *s != ' ')
6796 {
6797 if (*s == '\\')
6798 ++s;
6799 ++s;
6800 }
6801 }
6802 else
6803 {
6804 if (errbuf != NULL)
6805 {
6806 sprintf((char *)errbuf,
6807 _("E535: Illegal character after <%c>"),
6808 *--s);
6809 errmsg = errbuf;
6810 }
6811 else
6812 errmsg = (char_u *)"";
6813 break;
6814 }
6815 }
6816 }
6817 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00006818
6819 /* 'completeopt' */
6820 else if (varp == &p_cot)
6821 {
6822 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
6823 errmsg = e_invarg;
6824 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006825#endif /* FEAT_INS_EXPAND */
6826
6827
6828#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
6829 else if (varp == &p_toolbar)
6830 {
6831 if (opt_strings_flags(p_toolbar, p_toolbar_values,
6832 &toolbar_flags, TRUE) != OK)
6833 errmsg = e_invarg;
6834 else
6835 {
6836 out_flush();
6837 gui_mch_show_toolbar((toolbar_flags &
6838 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6839 }
6840 }
6841#endif
6842
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006843#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006844 /* 'toolbariconsize': GTK+ 2 only */
6845 else if (varp == &p_tbis)
6846 {
6847 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
6848 errmsg = e_invarg;
6849 else
6850 {
6851 out_flush();
6852 gui_mch_show_toolbar((toolbar_flags &
6853 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6854 }
6855 }
6856#endif
6857
6858 /* 'pastetoggle': translate key codes like in a mapping */
6859 else if (varp == &p_pt)
6860 {
6861 if (*p_pt)
6862 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00006863 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006864 if (p != NULL)
6865 {
6866 if (new_value_alloced)
6867 free_string_option(p_pt);
6868 p_pt = p;
6869 new_value_alloced = TRUE;
6870 }
6871 }
6872 }
6873
6874 /* 'backspace' */
6875 else if (varp == &p_bs)
6876 {
6877 if (VIM_ISDIGIT(*p_bs))
6878 {
6879 if (*p_bs >'2' || p_bs[1] != NUL)
6880 errmsg = e_invarg;
6881 }
6882 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
6883 errmsg = e_invarg;
6884 }
6885
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00006886#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006887 /* 'casemap' */
6888 else if (varp == &p_cmp)
6889 {
6890 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
6891 errmsg = e_invarg;
6892 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00006893#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006894
6895#ifdef FEAT_DIFF
6896 /* 'diffopt' */
6897 else if (varp == &p_dip)
6898 {
6899 if (diffopt_changed() == FAIL)
6900 errmsg = e_invarg;
6901 }
6902#endif
6903
6904#ifdef FEAT_FOLDING
6905 /* 'foldmethod' */
6906 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
6907 {
6908 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
6909 || *curwin->w_p_fdm == NUL)
6910 errmsg = e_invarg;
6911 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01006912 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006913 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01006914 if (foldmethodIsDiff(curwin))
6915 newFoldLevel();
6916 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006917 }
6918# ifdef FEAT_EVAL
6919 /* 'foldexpr' */
6920 else if (varp == &curwin->w_p_fde)
6921 {
6922 if (foldmethodIsExpr(curwin))
6923 foldUpdateAll(curwin);
6924 }
6925# endif
6926 /* 'foldmarker' */
6927 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
6928 {
6929 p = vim_strchr(*varp, ',');
6930 if (p == NULL)
6931 errmsg = (char_u *)N_("E536: comma required");
6932 else if (p == *varp || p[1] == NUL)
6933 errmsg = e_invarg;
6934 else if (foldmethodIsMarker(curwin))
6935 foldUpdateAll(curwin);
6936 }
6937 /* 'commentstring' */
6938 else if (gvarp == &p_cms)
6939 {
6940 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
6941 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
6942 }
6943 /* 'foldopen' */
6944 else if (varp == &p_fdo)
6945 {
6946 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
6947 errmsg = e_invarg;
6948 }
6949 /* 'foldclose' */
6950 else if (varp == &p_fcl)
6951 {
6952 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
6953 errmsg = e_invarg;
6954 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00006955 /* 'foldignore' */
6956 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
6957 {
6958 if (foldmethodIsIndent(curwin))
6959 foldUpdateAll(curwin);
6960 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006961#endif
6962
6963#ifdef FEAT_VIRTUALEDIT
6964 /* 'virtualedit' */
6965 else if (varp == &p_ve)
6966 {
6967 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
6968 errmsg = e_invarg;
6969 else if (STRCMP(p_ve, oldval) != 0)
6970 {
6971 /* Recompute cursor position in case the new 've' setting
6972 * changes something. */
6973 validate_virtcol();
6974 coladvance(curwin->w_virtcol);
6975 }
6976 }
6977#endif
6978
6979#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
6980 else if (varp == &p_csqf)
6981 {
6982 if (p_csqf != NULL)
6983 {
6984 p = p_csqf;
6985 while (*p != NUL)
6986 {
6987 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
6988 || p[1] == NUL
6989 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
6990 || (p[2] != NUL && p[2] != ','))
6991 {
6992 errmsg = e_invarg;
6993 break;
6994 }
6995 else if (p[2] == NUL)
6996 break;
6997 else
6998 p += 3;
6999 }
7000 }
7001 }
7002#endif
7003
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01007004#ifdef FEAT_CINDENT
7005 /* 'cinoptions' */
7006 else if (gvarp == &p_cino)
7007 {
7008 /* TODO: recognize errors */
7009 parse_cino(curbuf);
7010 }
7011#endif
7012
Bram Moolenaar071d4272004-06-13 20:20:40 +00007013 /* Options that are a list of flags. */
7014 else
7015 {
7016 p = NULL;
7017 if (varp == &p_ww)
7018 p = (char_u *)WW_ALL;
7019 if (varp == &p_shm)
7020 p = (char_u *)SHM_ALL;
7021 else if (varp == &(p_cpo))
7022 p = (char_u *)CPO_ALL;
7023 else if (varp == &(curbuf->b_p_fo))
7024 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02007025#ifdef FEAT_CONCEAL
7026 else if (varp == &curwin->w_p_cocu)
7027 p = (char_u *)COCU_ALL;
7028#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007029 else if (varp == &p_mouse)
7030 {
7031#ifdef FEAT_MOUSE
7032 p = (char_u *)MOUSE_ALL;
7033#else
7034 if (*p_mouse != NUL)
7035 errmsg = (char_u *)N_("E538: No mouse support");
7036#endif
7037 }
7038#if defined(FEAT_GUI)
7039 else if (varp == &p_go)
7040 p = (char_u *)GO_ALL;
7041#endif
7042 if (p != NULL)
7043 {
7044 for (s = *varp; *s; ++s)
7045 if (vim_strchr(p, *s) == NULL)
7046 {
7047 errmsg = illegal_char(errbuf, *s);
7048 break;
7049 }
7050 }
7051 }
7052
7053 /*
7054 * If error detected, restore the previous value.
7055 */
7056 if (errmsg != NULL)
7057 {
7058 if (new_value_alloced)
7059 free_string_option(*varp);
7060 *varp = oldval;
7061 /*
7062 * When resetting some values, need to act on it.
7063 */
7064 if (did_chartab)
7065 (void)init_chartab();
7066 if (varp == &p_hl)
7067 (void)highlight_changed();
7068 }
7069 else
7070 {
7071#ifdef FEAT_EVAL
7072 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007073 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007074#endif
7075 /*
7076 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007077 * Use "free_oldval", because recursiveness may change the flags under
7078 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007079 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007080 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007081 free_string_option(oldval);
7082 if (new_value_alloced)
7083 options[opt_idx].flags |= P_ALLOCED;
7084 else
7085 options[opt_idx].flags &= ~P_ALLOCED;
7086
7087 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007088 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007089 {
7090 /* global option with local value set to use global value; free
7091 * the local value and make it empty */
7092 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7093 free_string_option(*(char_u **)p);
7094 *(char_u **)p = empty_option;
7095 }
7096
7097 /* May set global value for local option. */
7098 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7099 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007100
7101#ifdef FEAT_AUTOCMD
7102 /*
7103 * Trigger the autocommand only after setting the flags.
7104 */
7105# ifdef FEAT_SYN_HL
7106 /* When 'syntax' is set, load the syntax of that name */
7107 if (varp == &(curbuf->b_p_syn))
7108 {
7109 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7110 curbuf->b_fname, TRUE, curbuf);
7111 }
7112# endif
7113 else if (varp == &(curbuf->b_p_ft))
7114 {
7115 /* 'filetype' is set, trigger the FileType autocommand */
7116 did_filetype = TRUE;
7117 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
7118 curbuf->b_fname, TRUE, curbuf);
7119 }
7120#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007121#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007122 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007123 {
7124 char_u fname[200];
7125
7126 /*
7127 * Source the spell/LANG.vim in 'runtimepath'.
7128 * They could set 'spellcapcheck' depending on the language.
7129 * Use the first name in 'spelllang' up to '_region' or
7130 * '.encoding'.
7131 */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007132 for (p = curwin->w_s->b_p_spl; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007133 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7134 break;
7135 vim_snprintf((char *)fname, 200, "spell/%.*s.vim",
Bram Moolenaar860cae12010-06-05 23:22:07 +02007136 (int)(p - curwin->w_s->b_p_spl), curwin->w_s->b_p_spl);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007137 source_runtime(fname, TRUE);
7138 }
7139#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007140 }
7141
7142#ifdef FEAT_MOUSE
7143 if (varp == &p_mouse)
7144 {
7145# ifdef FEAT_MOUSE_TTY
7146 if (*p_mouse == NUL)
7147 mch_setmouse(FALSE); /* switch mouse off */
7148 else
7149# endif
7150 setmouse(); /* in case 'mouse' changed */
7151 }
7152#endif
7153
Bram Moolenaar913077c2012-03-28 19:59:04 +02007154 if (curwin->w_curswant != MAXCOL
7155 && (options[opt_idx].flags & (P_CURSWANT | P_RCLR)) != 0)
7156 curwin->w_set_curswant = TRUE;
7157
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007158#ifdef FEAT_GUI
7159 /* check redraw when it's not a GUI option or the GUI is active. */
7160 if (!redraw_gui_only || gui.in_use)
7161#endif
7162 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007163
7164 return errmsg;
7165}
7166
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007167#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007168/*
7169 * Simple int comparison function for use with qsort()
7170 */
7171 static int
7172int_cmp(a, b)
7173 const void *a;
7174 const void *b;
7175{
7176 return *(const int *)a - *(const int *)b;
7177}
7178
7179/*
7180 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7181 * Returns error message, NULL if it's OK.
7182 */
7183 char_u *
7184check_colorcolumn(wp)
7185 win_T *wp;
7186{
7187 char_u *s;
7188 int col;
7189 int count = 0;
7190 int color_cols[256];
7191 int i;
7192 int j = 0;
7193
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007194 if (wp->w_buffer == NULL)
7195 return NULL; /* buffer was closed */
7196
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007197 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007198 {
7199 if (*s == '-' || *s == '+')
7200 {
7201 /* -N and +N: add to 'textwidth' */
7202 col = (*s == '-') ? -1 : 1;
7203 ++s;
7204 if (!VIM_ISDIGIT(*s))
7205 return e_invarg;
7206 col = col * getdigits(&s);
7207 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007208 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007209 col += wp->w_buffer->b_p_tw;
7210 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007211 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007212 }
7213 else if (VIM_ISDIGIT(*s))
7214 col = getdigits(&s);
7215 else
7216 return e_invarg;
7217 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007218skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007219 if (*s == NUL)
7220 break;
7221 if (*s != ',')
7222 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007223 if (*++s == NUL)
7224 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007225 }
7226
7227 vim_free(wp->w_p_cc_cols);
7228 if (count == 0)
7229 wp->w_p_cc_cols = NULL;
7230 else
7231 {
7232 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7233 if (wp->w_p_cc_cols != NULL)
7234 {
7235 /* sort the columns for faster usage on screen redraw inside
7236 * win_line() */
7237 qsort(color_cols, count, sizeof(int), int_cmp);
7238
7239 for (i = 0; i < count; ++i)
7240 /* skip duplicates */
7241 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7242 wp->w_p_cc_cols[j++] = color_cols[i];
7243 wp->w_p_cc_cols[j] = -1; /* end marker */
7244 }
7245 }
7246
7247 return NULL; /* no error */
7248}
7249#endif
7250
Bram Moolenaar071d4272004-06-13 20:20:40 +00007251/*
7252 * Handle setting 'listchars' or 'fillchars'.
7253 * Returns error message, NULL if it's OK.
7254 */
7255 static char_u *
7256set_chars_option(varp)
7257 char_u **varp;
7258{
7259 int round, i, len, entries;
7260 char_u *p, *s;
7261 int c1, c2 = 0;
7262 struct charstab
7263 {
7264 int *cp;
7265 char *name;
7266 };
7267#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7268 static struct charstab filltab[] =
7269 {
7270 {&fill_stl, "stl"},
7271 {&fill_stlnc, "stlnc"},
7272 {&fill_vert, "vert"},
7273 {&fill_fold, "fold"},
7274 {&fill_diff, "diff"},
7275 };
7276#endif
7277 static struct charstab lcstab[] =
7278 {
7279 {&lcs_eol, "eol"},
7280 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007281 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007282 {&lcs_prec, "precedes"},
7283 {&lcs_tab2, "tab"},
7284 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007285#ifdef FEAT_CONCEAL
7286 {&lcs_conceal, "conceal"},
7287#else
7288 {NULL, "conceal"},
7289#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007290 };
7291 struct charstab *tab;
7292
7293#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7294 if (varp == &p_lcs)
7295#endif
7296 {
7297 tab = lcstab;
7298 entries = sizeof(lcstab) / sizeof(struct charstab);
7299 }
7300#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7301 else
7302 {
7303 tab = filltab;
7304 entries = sizeof(filltab) / sizeof(struct charstab);
7305 }
7306#endif
7307
7308 /* first round: check for valid value, second round: assign values */
7309 for (round = 0; round <= 1; ++round)
7310 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007311 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007312 {
7313 /* After checking that the value is valid: set defaults: space for
7314 * 'fillchars', NUL for 'listchars' */
7315 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007316 if (tab[i].cp != NULL)
7317 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007318 if (varp == &p_lcs)
7319 lcs_tab1 = NUL;
7320#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7321 else
7322 fill_diff = '-';
7323#endif
7324 }
7325 p = *varp;
7326 while (*p)
7327 {
7328 for (i = 0; i < entries; ++i)
7329 {
7330 len = (int)STRLEN(tab[i].name);
7331 if (STRNCMP(p, tab[i].name, len) == 0
7332 && p[len] == ':'
7333 && p[len + 1] != NUL)
7334 {
7335 s = p + len + 1;
7336#ifdef FEAT_MBYTE
7337 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007338 if (mb_char2cells(c1) > 1)
7339 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007340#else
7341 c1 = *s++;
7342#endif
7343 if (tab[i].cp == &lcs_tab2)
7344 {
7345 if (*s == NUL)
7346 continue;
7347#ifdef FEAT_MBYTE
7348 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007349 if (mb_char2cells(c2) > 1)
7350 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007351#else
7352 c2 = *s++;
7353#endif
7354 }
7355 if (*s == ',' || *s == NUL)
7356 {
7357 if (round)
7358 {
7359 if (tab[i].cp == &lcs_tab2)
7360 {
7361 lcs_tab1 = c1;
7362 lcs_tab2 = c2;
7363 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007364 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007365 *(tab[i].cp) = c1;
7366
7367 }
7368 p = s;
7369 break;
7370 }
7371 }
7372 }
7373
7374 if (i == entries)
7375 return e_invarg;
7376 if (*p == ',')
7377 ++p;
7378 }
7379 }
7380
7381 return NULL; /* no error */
7382}
7383
7384#ifdef FEAT_STL_OPT
7385/*
7386 * Check validity of options with the 'statusline' format.
7387 * Return error message or NULL.
7388 */
7389 char_u *
7390check_stl_option(s)
7391 char_u *s;
7392{
7393 int itemcnt = 0;
7394 int groupdepth = 0;
7395 static char_u errbuf[80];
7396
7397 while (*s && itemcnt < STL_MAX_ITEM)
7398 {
7399 /* Check for valid keys after % sequences */
7400 while (*s && *s != '%')
7401 s++;
7402 if (!*s)
7403 break;
7404 s++;
7405 if (*s != '%' && *s != ')')
7406 ++itemcnt;
7407 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7408 {
7409 s++;
7410 continue;
7411 }
7412 if (*s == ')')
7413 {
7414 s++;
7415 if (--groupdepth < 0)
7416 break;
7417 continue;
7418 }
7419 if (*s == '-')
7420 s++;
7421 while (VIM_ISDIGIT(*s))
7422 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007423 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007424 continue;
7425 if (*s == '.')
7426 {
7427 s++;
7428 while (*s && VIM_ISDIGIT(*s))
7429 s++;
7430 }
7431 if (*s == '(')
7432 {
7433 groupdepth++;
7434 continue;
7435 }
7436 if (vim_strchr(STL_ALL, *s) == NULL)
7437 {
7438 return illegal_char(errbuf, *s);
7439 }
7440 if (*s == '{')
7441 {
7442 s++;
7443 while (*s != '}' && *s)
7444 s++;
7445 if (*s != '}')
7446 return (char_u *)N_("E540: Unclosed expression sequence");
7447 }
7448 }
7449 if (itemcnt >= STL_MAX_ITEM)
7450 return (char_u *)N_("E541: too many items");
7451 if (groupdepth != 0)
7452 return (char_u *)N_("E542: unbalanced groups");
7453 return NULL;
7454}
7455#endif
7456
7457#ifdef FEAT_CLIPBOARD
7458/*
7459 * Extract the items in the 'clipboard' option and set global values.
7460 */
7461 static char_u *
7462check_clipboard_option()
7463{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007464 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007465 int new_autoselect_star = FALSE;
7466 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007467 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007468 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007469 regprog_T *new_exclude_prog = NULL;
7470 char_u *errmsg = NULL;
7471 char_u *p;
7472
7473 for (p = p_cb; *p != NUL; )
7474 {
7475 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7476 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007477 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007478 p += 7;
7479 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007480 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007481 && (p[11] == ',' || p[11] == NUL))
7482 {
7483 new_unnamed |= CLIP_UNNAMED_PLUS;
7484 p += 11;
7485 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007486 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007487 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007488 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007489 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007490 p += 10;
7491 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007492 else if (STRNCMP(p, "autoselectplus", 14) == 0
7493 && (p[14] == ',' || p[14] == NUL))
7494 {
7495 new_autoselect_plus = TRUE;
7496 p += 14;
7497 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007498 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007499 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007500 {
7501 new_autoselectml = TRUE;
7502 p += 12;
7503 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007504 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7505 {
7506 new_html = TRUE;
7507 p += 4;
7508 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007509 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7510 {
7511 p += 8;
7512 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7513 if (new_exclude_prog == NULL)
7514 errmsg = e_invarg;
7515 break;
7516 }
7517 else
7518 {
7519 errmsg = e_invarg;
7520 break;
7521 }
7522 if (*p == ',')
7523 ++p;
7524 }
7525 if (errmsg == NULL)
7526 {
7527 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007528 clip_autoselect_star = new_autoselect_star;
7529 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007530 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007531 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02007532 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007533 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02007534#ifdef FEAT_GUI_GTK
7535 if (gui.in_use)
7536 {
7537 gui_gtk_set_selection_targets();
7538 gui_gtk_set_dnd_targets();
7539 }
7540#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007541 }
7542 else
Bram Moolenaar473de612013-06-08 18:19:48 +02007543 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007544
7545 return errmsg;
7546}
7547#endif
7548
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007549#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007550/*
7551 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
7552 * Return error message when failed, NULL when OK.
7553 */
7554 static char_u *
Bram Moolenaar860cae12010-06-05 23:22:07 +02007555compile_cap_prog(synblock)
7556 synblock_T *synblock;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007557{
Bram Moolenaar860cae12010-06-05 23:22:07 +02007558 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007559 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007560
Bram Moolenaar860cae12010-06-05 23:22:07 +02007561 if (*synblock->b_p_spc == NUL)
7562 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007563 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007564 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007565 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007566 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007567 if (re != NULL)
7568 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007569 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02007570 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02007571 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007572 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007573 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007574 return e_invarg;
7575 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007576 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007577 }
7578
Bram Moolenaar473de612013-06-08 18:19:48 +02007579 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007580 return NULL;
7581}
7582#endif
7583
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007584#if defined(FEAT_EVAL) || defined(PROTO)
7585/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007586 * Set the scriptID for an option, taking care of setting the buffer- or
7587 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007588 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007589 static void
7590set_option_scriptID_idx(opt_idx, opt_flags, id)
7591 int opt_idx;
7592 int opt_flags;
7593 int id;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007594{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007595 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
7596 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007597
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007598 /* Remember where the option was set. For local options need to do that
7599 * in the buffer or window structure. */
7600 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007601 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007602 if (both || (opt_flags & OPT_LOCAL))
7603 {
7604 if (indir & PV_BUF)
7605 curbuf->b_p_scriptID[indir & PV_MASK] = id;
7606 else if (indir & PV_WIN)
7607 curwin->w_p_scriptID[indir & PV_MASK] = id;
7608 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007609}
7610#endif
7611
Bram Moolenaar071d4272004-06-13 20:20:40 +00007612/*
7613 * Set the value of a boolean option, and take care of side effects.
7614 * Returns NULL for success, or an error message for an error.
7615 */
7616 static char_u *
7617set_bool_option(opt_idx, varp, value, opt_flags)
7618 int opt_idx; /* index in options[] table */
7619 char_u *varp; /* pointer to the option variable */
7620 int value; /* new value */
7621 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
7622{
7623 int old_value = *(int *)varp;
7624
Bram Moolenaar071d4272004-06-13 20:20:40 +00007625 /* Disallow changing some options from secure mode */
7626 if ((secure
7627#ifdef HAVE_SANDBOX
7628 || sandbox != 0
7629#endif
7630 ) && (options[opt_idx].flags & P_SECURE))
7631 return e_secure;
7632
7633 *(int *)varp = value; /* set the new value */
7634#ifdef FEAT_EVAL
7635 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007636 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007637#endif
7638
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00007639#ifdef FEAT_GUI
7640 need_mouse_correct = TRUE;
7641#endif
7642
Bram Moolenaar071d4272004-06-13 20:20:40 +00007643 /* May set global value for local option. */
7644 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
7645 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
7646
7647 /*
7648 * Handle side effects of changing a bool option.
7649 */
7650
7651 /* 'compatible' */
7652 if ((int *)varp == &p_cp)
7653 {
7654 compatible_set();
7655 }
7656
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007657#ifdef FEAT_PERSISTENT_UNDO
7658 /* 'undofile' */
7659 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
7660 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007661 /* Only take action when the option was set. When reset we do not
7662 * delete the undo file, the option may be set again without making
7663 * any changes in between. */
7664 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007665 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007666 char_u hash[UNDO_HASH_SIZE];
7667 buf_T *save_curbuf = curbuf;
7668
7669 for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007670 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007671 /* When 'undofile' is set globally: for every buffer, otherwise
7672 * only for the current buffer: Try to read in the undofile,
7673 * if one exists, the buffer wasn't changed and the buffer was
7674 * loaded */
7675 if ((curbuf == save_curbuf
7676 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
7677 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
7678 {
7679 u_compute_hash(hash);
7680 u_read_undo(NULL, hash, curbuf->b_fname);
7681 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007682 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007683 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007684 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007685 }
7686#endif
7687
Bram Moolenaar071d4272004-06-13 20:20:40 +00007688 else if ((int *)varp == &curbuf->b_p_ro)
7689 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007690 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007691 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
7692 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007693
7694 /* when 'readonly' is set may give W10 again */
7695 if (curbuf->b_p_ro)
7696 curbuf->b_did_warn = FALSE;
7697
Bram Moolenaar071d4272004-06-13 20:20:40 +00007698#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007699 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007700#endif
7701 }
7702
Bram Moolenaar9c449722010-07-20 18:44:27 +02007703#ifdef FEAT_GUI
7704 else if ((int *)varp == &p_mh)
7705 {
7706 if (!p_mh)
7707 gui_mch_mousehide(FALSE);
7708 }
7709#endif
7710
Bram Moolenaara539df02010-08-01 14:35:05 +02007711#ifdef FEAT_TITLE
7712 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007713 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007714 {
7715 redraw_titles();
7716 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007717 /* when 'endofline' is changed, redraw the window title */
7718 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007719 {
7720 redraw_titles();
7721 }
7722# ifdef FEAT_MBYTE
7723 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00007724 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007725 {
7726 redraw_titles();
7727 }
7728# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007729#endif
7730
7731 /* when 'bin' is set also set some other options */
7732 else if ((int *)varp == &curbuf->b_p_bin)
7733 {
7734 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
7735#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007736 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007737#endif
7738 }
7739
7740#ifdef FEAT_AUTOCMD
7741 /* when 'buflisted' changes, trigger autocommands */
7742 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
7743 {
7744 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
7745 NULL, NULL, TRUE, curbuf);
7746 }
7747#endif
7748
7749 /* when 'swf' is set, create swapfile, when reset remove swapfile */
7750 else if ((int *)varp == &curbuf->b_p_swf)
7751 {
7752 if (curbuf->b_p_swf && p_uc)
7753 ml_open_file(curbuf); /* create the swap file */
7754 else
Bram Moolenaard55de222007-05-06 13:38:48 +00007755 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
7756 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007757 mf_close_file(curbuf, TRUE); /* remove the swap file */
7758 }
7759
7760 /* when 'terse' is set change 'shortmess' */
7761 else if ((int *)varp == &p_terse)
7762 {
7763 char_u *p;
7764
7765 p = vim_strchr(p_shm, SHM_SEARCH);
7766
7767 /* insert 's' in p_shm */
7768 if (p_terse && p == NULL)
7769 {
7770 STRCPY(IObuff, p_shm);
7771 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007772 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007773 }
7774 /* remove 's' from p_shm */
7775 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007776 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007777 }
7778
7779 /* when 'paste' is set or reset also change other options */
7780 else if ((int *)varp == &p_paste)
7781 {
7782 paste_option_changed();
7783 }
7784
7785 /* when 'insertmode' is set from an autocommand need to do work here */
7786 else if ((int *)varp == &p_im)
7787 {
7788 if (p_im)
7789 {
7790 if ((State & INSERT) == 0)
7791 need_start_insertmode = TRUE;
7792 stop_insert_mode = FALSE;
7793 }
7794 else
7795 {
7796 need_start_insertmode = FALSE;
7797 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00007798 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007799 clear_cmdline = TRUE; /* remove "(insert)" */
7800 restart_edit = 0;
7801 }
7802 }
7803
7804 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
7805 else if ((int *)varp == &p_ic && p_hls)
7806 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007807 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007808 }
7809
7810#ifdef FEAT_SEARCH_EXTRA
7811 /* when 'hlsearch' is set or reset: reset no_hlsearch */
7812 else if ((int *)varp == &p_hls)
7813 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01007814 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007815 }
7816#endif
7817
7818#ifdef FEAT_SCROLLBIND
7819 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
7820 * at the end of normal_cmd() */
7821 else if ((int *)varp == &curwin->w_p_scb)
7822 {
7823 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02007824 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007825 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02007826 curwin->w_scbind_pos = curwin->w_topline;
7827 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007828 }
7829#endif
7830
7831#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
7832 /* There can be only one window with 'previewwindow' set. */
7833 else if ((int *)varp == &curwin->w_p_pvw)
7834 {
7835 if (curwin->w_p_pvw)
7836 {
7837 win_T *win;
7838
7839 for (win = firstwin; win != NULL; win = win->w_next)
7840 if (win->w_p_pvw && win != curwin)
7841 {
7842 curwin->w_p_pvw = FALSE;
7843 return (char_u *)N_("E590: A preview window already exists");
7844 }
7845 }
7846 }
7847#endif
7848
7849 /* when 'textmode' is set or reset also change 'fileformat' */
7850 else if ((int *)varp == &curbuf->b_p_tx)
7851 {
7852 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
7853 }
7854
7855 /* when 'textauto' is set or reset also change 'fileformats' */
7856 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007857 set_string_option_direct((char_u *)"ffs", -1,
7858 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007859 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007860
7861 /*
7862 * When 'lisp' option changes include/exclude '-' in
7863 * keyword characters.
7864 */
7865#ifdef FEAT_LISP
7866 else if (varp == (char_u *)&(curbuf->b_p_lisp))
7867 {
7868 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
7869 }
7870#endif
7871
7872#ifdef FEAT_TITLE
7873 /* when 'title' changed, may need to change the title; same for 'icon' */
7874 else if ((int *)varp == &p_title)
7875 {
7876 did_set_title(FALSE);
7877 }
7878
7879 else if ((int *)varp == &p_icon)
7880 {
7881 did_set_title(TRUE);
7882 }
7883#endif
7884
7885 else if ((int *)varp == &curbuf->b_changed)
7886 {
7887 if (!value)
7888 save_file_ff(curbuf); /* Buffer is unchanged */
7889#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007890 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007891#endif
7892#ifdef FEAT_AUTOCMD
7893 modified_was_set = value;
7894#endif
7895 }
7896
7897#ifdef BACKSLASH_IN_FILENAME
7898 else if ((int *)varp == &p_ssl)
7899 {
7900 if (p_ssl)
7901 {
7902 psepc = '/';
7903 psepcN = '\\';
7904 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00007905 }
7906 else
7907 {
7908 psepc = '\\';
7909 psepcN = '/';
7910 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00007911 }
7912
7913 /* need to adjust the file name arguments and buffer names. */
7914 buflist_slash_adjust();
7915 alist_slash_adjust();
7916# ifdef FEAT_EVAL
7917 scriptnames_slash_adjust();
7918# endif
7919 }
7920#endif
7921
7922 /* If 'wrap' is set, set w_leftcol to zero. */
7923 else if ((int *)varp == &curwin->w_p_wrap)
7924 {
7925 if (curwin->w_p_wrap)
7926 curwin->w_leftcol = 0;
7927 }
7928
7929#ifdef FEAT_WINDOWS
7930 else if ((int *)varp == &p_ea)
7931 {
7932 if (p_ea && !old_value)
7933 win_equal(curwin, FALSE, 0);
7934 }
7935#endif
7936
7937 else if ((int *)varp == &p_wiv)
7938 {
7939 /*
7940 * When 'weirdinvert' changed, set/reset 't_xs'.
7941 * Then set 'weirdinvert' according to value of 't_xs'.
7942 */
7943 if (p_wiv && !old_value)
7944 T_XS = (char_u *)"y";
7945 else if (!p_wiv && old_value)
7946 T_XS = empty_option;
7947 p_wiv = (*T_XS != NUL);
7948 }
7949
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00007950#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00007951 else if ((int *)varp == &p_beval)
7952 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01007953 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007954 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01007955 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007956 gui_mch_disable_beval_area(balloonEval);
7957 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00007958#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007959
Bram Moolenaar8dff8182006-04-06 20:18:50 +00007960#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00007961 else if ((int *)varp == &p_acd)
7962 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00007963 /* Change directories when the 'acd' option is set now. */
7964 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00007965 }
7966#endif
7967
7968#ifdef FEAT_DIFF
7969 /* 'diff' */
7970 else if ((int *)varp == &curwin->w_p_diff)
7971 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00007972 /* May add or remove the buffer from the list of diff buffers. */
7973 diff_buf_adjust(curwin);
7974# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00007975 if (foldmethodIsDiff(curwin))
7976 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00007977# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007978 }
7979#endif
7980
7981#ifdef USE_IM_CONTROL
7982 /* 'imdisable' */
7983 else if ((int *)varp == &p_imdisable)
7984 {
7985 /* Only de-activate it here, it will be enabled when changing mode. */
7986 if (p_imdisable)
7987 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02007988 else if (State & INSERT)
7989 /* When the option is set from an autocommand, it may need to take
7990 * effect right away. */
7991 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007992 }
7993#endif
7994
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007995#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00007996 /* 'spell' */
7997 else if ((int *)varp == &curwin->w_p_spell)
7998 {
7999 if (curwin->w_p_spell)
8000 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008001 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008002 if (errmsg != NULL)
8003 EMSG(_(errmsg));
8004 }
8005 }
8006#endif
8007
Bram Moolenaar071d4272004-06-13 20:20:40 +00008008#ifdef FEAT_FKMAP
8009 else if ((int *)varp == &p_altkeymap)
8010 {
8011 if (old_value != p_altkeymap)
8012 {
8013 if (!p_altkeymap)
8014 {
8015 p_hkmap = p_fkmap;
8016 p_fkmap = 0;
8017 }
8018 else
8019 {
8020 p_fkmap = p_hkmap;
8021 p_hkmap = 0;
8022 }
8023 (void)init_chartab();
8024 }
8025 }
8026
8027 /*
8028 * In case some second language keymapping options have changed, check
8029 * and correct the setting in a consistent way.
8030 */
8031
8032 /*
8033 * If hkmap or fkmap are set, reset Arabic keymapping.
8034 */
8035 if ((p_hkmap || p_fkmap) && p_altkeymap)
8036 {
8037 p_altkeymap = p_fkmap;
8038# ifdef FEAT_ARABIC
8039 curwin->w_p_arab = FALSE;
8040# endif
8041 (void)init_chartab();
8042 }
8043
8044 /*
8045 * If hkmap set, reset Farsi keymapping.
8046 */
8047 if (p_hkmap && p_altkeymap)
8048 {
8049 p_altkeymap = 0;
8050 p_fkmap = 0;
8051# ifdef FEAT_ARABIC
8052 curwin->w_p_arab = FALSE;
8053# endif
8054 (void)init_chartab();
8055 }
8056
8057 /*
8058 * If fkmap set, reset Hebrew keymapping.
8059 */
8060 if (p_fkmap && !p_altkeymap)
8061 {
8062 p_altkeymap = 1;
8063 p_hkmap = 0;
8064# ifdef FEAT_ARABIC
8065 curwin->w_p_arab = FALSE;
8066# endif
8067 (void)init_chartab();
8068 }
8069#endif
8070
8071#ifdef FEAT_ARABIC
8072 if ((int *)varp == &curwin->w_p_arab)
8073 {
8074 if (curwin->w_p_arab)
8075 {
8076 /*
8077 * 'arabic' is set, handle various sub-settings.
8078 */
8079 if (!p_tbidi)
8080 {
8081 /* set rightleft mode */
8082 if (!curwin->w_p_rl)
8083 {
8084 curwin->w_p_rl = TRUE;
8085 changed_window_setting();
8086 }
8087
8088 /* Enable Arabic shaping (major part of what Arabic requires) */
8089 if (!p_arshape)
8090 {
8091 p_arshape = TRUE;
8092 redraw_later_clear();
8093 }
8094 }
8095
8096 /* Arabic requires a utf-8 encoding, inform the user if its not
8097 * set. */
8098 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008099 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008100 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8101
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008102 msg_source(hl_attr(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008103 MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
8104#ifdef FEAT_EVAL
8105 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8106#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008107 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008108
8109# ifdef FEAT_MBYTE
8110 /* set 'delcombine' */
8111 p_deco = TRUE;
8112# endif
8113
8114# ifdef FEAT_KEYMAP
8115 /* Force-set the necessary keymap for arabic */
8116 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8117 OPT_LOCAL);
8118# endif
8119# ifdef FEAT_FKMAP
8120 p_altkeymap = 0;
8121 p_hkmap = 0;
8122 p_fkmap = 0;
8123 (void)init_chartab();
8124# endif
8125 }
8126 else
8127 {
8128 /*
8129 * 'arabic' is reset, handle various sub-settings.
8130 */
8131 if (!p_tbidi)
8132 {
8133 /* reset rightleft mode */
8134 if (curwin->w_p_rl)
8135 {
8136 curwin->w_p_rl = FALSE;
8137 changed_window_setting();
8138 }
8139
8140 /* 'arabicshape' isn't reset, it is a global option and
8141 * another window may still need it "on". */
8142 }
8143
8144 /* 'delcombine' isn't reset, it is a global option and another
8145 * window may still want it "on". */
8146
8147# ifdef FEAT_KEYMAP
8148 /* Revert to the default keymap */
8149 curbuf->b_p_iminsert = B_IMODE_NONE;
8150 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8151# endif
8152 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008153 }
8154
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008155#endif
8156
Bram Moolenaar071d4272004-06-13 20:20:40 +00008157 /*
8158 * End of handling side effects for bool options.
8159 */
8160
8161 options[opt_idx].flags |= P_WAS_SET;
8162
8163 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008164 if (curwin->w_curswant != MAXCOL
8165 && (options[opt_idx].flags & (P_CURSWANT | P_RCLR)) != 0)
8166 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008167 check_redraw(options[opt_idx].flags);
8168
8169 return NULL;
8170}
8171
8172/*
8173 * Set the value of a number option, and take care of side effects.
8174 * Returns NULL for success, or an error message for an error.
8175 */
8176 static char_u *
Bram Moolenaar555b2802005-05-19 21:08:39 +00008177set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008178 int opt_idx; /* index in options[] table */
8179 char_u *varp; /* pointer to the option variable */
8180 long value; /* new value */
8181 char_u *errbuf; /* buffer for error messages */
Bram Moolenaar555b2802005-05-19 21:08:39 +00008182 size_t errbuflen; /* length of "errbuf" */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008183 int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and
8184 OPT_MODELINE */
8185{
8186 char_u *errmsg = NULL;
8187 long old_value = *(long *)varp;
8188 long old_Rows = Rows; /* remember old Rows */
8189 long old_Columns = Columns; /* remember old Columns */
8190 long *pp = (long *)varp;
8191
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008192 /* Disallow changing some options from secure mode. */
8193 if ((secure
8194#ifdef HAVE_SANDBOX
8195 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008196#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008197 ) && (options[opt_idx].flags & P_SECURE))
8198 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008199
8200 *pp = value;
8201#ifdef FEAT_EVAL
8202 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008203 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008204#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008205#ifdef FEAT_GUI
8206 need_mouse_correct = TRUE;
8207#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008208
Bram Moolenaar14f24742012-08-08 18:01:05 +02008209 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008210 {
8211 errmsg = e_positive;
8212 curbuf->b_p_sw = curbuf->b_p_ts;
8213 }
8214
8215 /*
8216 * Number options that need some action when changed
8217 */
8218#ifdef FEAT_WINDOWS
8219 if (pp == &p_wh || pp == &p_hh)
8220 {
8221 if (p_wh < 1)
8222 {
8223 errmsg = e_positive;
8224 p_wh = 1;
8225 }
8226 if (p_wmh > p_wh)
8227 {
8228 errmsg = e_winheight;
8229 p_wh = p_wmh;
8230 }
8231 if (p_hh < 0)
8232 {
8233 errmsg = e_positive;
8234 p_hh = 0;
8235 }
8236
8237 /* Change window height NOW */
8238 if (lastwin != firstwin)
8239 {
8240 if (pp == &p_wh && curwin->w_height < p_wh)
8241 win_setheight((int)p_wh);
8242 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8243 win_setheight((int)p_hh);
8244 }
8245 }
8246
8247 /* 'winminheight' */
8248 else if (pp == &p_wmh)
8249 {
8250 if (p_wmh < 0)
8251 {
8252 errmsg = e_positive;
8253 p_wmh = 0;
8254 }
8255 if (p_wmh > p_wh)
8256 {
8257 errmsg = e_winheight;
8258 p_wmh = p_wh;
8259 }
8260 win_setminheight();
8261 }
8262
8263# ifdef FEAT_VERTSPLIT
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008264 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008265 {
8266 if (p_wiw < 1)
8267 {
8268 errmsg = e_positive;
8269 p_wiw = 1;
8270 }
8271 if (p_wmw > p_wiw)
8272 {
8273 errmsg = e_winwidth;
8274 p_wiw = p_wmw;
8275 }
8276
8277 /* Change window width NOW */
8278 if (lastwin != firstwin && curwin->w_width < p_wiw)
8279 win_setwidth((int)p_wiw);
8280 }
8281
8282 /* 'winminwidth' */
8283 else if (pp == &p_wmw)
8284 {
8285 if (p_wmw < 0)
8286 {
8287 errmsg = e_positive;
8288 p_wmw = 0;
8289 }
8290 if (p_wmw > p_wiw)
8291 {
8292 errmsg = e_winwidth;
8293 p_wmw = p_wiw;
8294 }
8295 win_setminheight();
8296 }
8297# endif
8298
8299#endif
8300
8301#ifdef FEAT_WINDOWS
8302 /* (re)set last window status line */
8303 else if (pp == &p_ls)
8304 {
8305 last_status(FALSE);
8306 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008307
8308 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008309 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008310 {
8311 shell_new_rows(); /* recompute window positions and heights */
8312 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008313#endif
8314
8315#ifdef FEAT_GUI
8316 else if (pp == &p_linespace)
8317 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008318 /* Recompute gui.char_height and resize the Vim window to keep the
8319 * same number of lines. */
8320 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008321 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008322 }
8323#endif
8324
8325#ifdef FEAT_FOLDING
8326 /* 'foldlevel' */
8327 else if (pp == &curwin->w_p_fdl)
8328 {
8329 if (curwin->w_p_fdl < 0)
8330 curwin->w_p_fdl = 0;
8331 newFoldLevel();
8332 }
8333
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008334 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008335 else if (pp == &curwin->w_p_fml)
8336 {
8337 foldUpdateAll(curwin);
8338 }
8339
8340 /* 'foldnestmax' */
8341 else if (pp == &curwin->w_p_fdn)
8342 {
8343 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8344 foldUpdateAll(curwin);
8345 }
8346
8347 /* 'foldcolumn' */
8348 else if (pp == &curwin->w_p_fdc)
8349 {
8350 if (curwin->w_p_fdc < 0)
8351 {
8352 errmsg = e_positive;
8353 curwin->w_p_fdc = 0;
8354 }
8355 else if (curwin->w_p_fdc > 12)
8356 {
8357 errmsg = e_invarg;
8358 curwin->w_p_fdc = 12;
8359 }
8360 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008361#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008362
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008363#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008364 /* 'shiftwidth' or 'tabstop' */
8365 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8366 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008367# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008368 if (foldmethodIsIndent(curwin))
8369 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008370# endif
8371# ifdef FEAT_CINDENT
8372 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8373 * parse 'cinoptions'. */
8374 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8375 parse_cino(curbuf);
8376# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008377 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008378#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008379
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008380#ifdef FEAT_MBYTE
8381 /* 'maxcombine' */
8382 else if (pp == &p_mco)
8383 {
8384 if (p_mco > MAX_MCO)
8385 p_mco = MAX_MCO;
8386 else if (p_mco < 0)
8387 p_mco = 0;
8388 screenclear(); /* will re-allocate the screen */
8389 }
8390#endif
8391
Bram Moolenaar071d4272004-06-13 20:20:40 +00008392 else if (pp == &curbuf->b_p_iminsert)
8393 {
8394 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8395 {
8396 errmsg = e_invarg;
8397 curbuf->b_p_iminsert = B_IMODE_NONE;
8398 }
8399 p_iminsert = curbuf->b_p_iminsert;
8400 if (termcap_active) /* don't do this in the alternate screen */
8401 showmode();
8402#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8403 /* Show/unshow value of 'keymap' in status lines. */
8404 status_redraw_curbuf();
8405#endif
8406 }
8407
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008408 else if (pp == &p_window)
8409 {
8410 if (p_window < 1)
8411 p_window = 1;
8412 else if (p_window >= Rows)
8413 p_window = Rows - 1;
8414 }
8415
Bram Moolenaar071d4272004-06-13 20:20:40 +00008416 else if (pp == &curbuf->b_p_imsearch)
8417 {
8418 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8419 {
8420 errmsg = e_invarg;
8421 curbuf->b_p_imsearch = B_IMODE_NONE;
8422 }
8423 p_imsearch = curbuf->b_p_imsearch;
8424 }
8425
8426#ifdef FEAT_TITLE
8427 /* if 'titlelen' has changed, redraw the title */
8428 else if (pp == &p_titlelen)
8429 {
8430 if (p_titlelen < 0)
8431 {
8432 errmsg = e_positive;
8433 p_titlelen = 85;
8434 }
8435 if (starting != NO_SCREEN && old_value != p_titlelen)
8436 need_maketitle = TRUE;
8437 }
8438#endif
8439
8440 /* if p_ch changed value, change the command line height */
8441 else if (pp == &p_ch)
8442 {
8443 if (p_ch < 1)
8444 {
8445 errmsg = e_positive;
8446 p_ch = 1;
8447 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008448 if (p_ch > Rows - min_rows() + 1)
8449 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008450
8451 /* Only compute the new window layout when startup has been
8452 * completed. Otherwise the frame sizes may be wrong. */
8453 if (p_ch != old_value && full_screen
8454#ifdef FEAT_GUI
8455 && !gui.starting
8456#endif
8457 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008458 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008459 }
8460
8461 /* when 'updatecount' changes from zero to non-zero, open swap files */
8462 else if (pp == &p_uc)
8463 {
8464 if (p_uc < 0)
8465 {
8466 errmsg = e_positive;
8467 p_uc = 100;
8468 }
8469 if (p_uc && !old_value)
8470 ml_open_files();
8471 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008472#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008473 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008474 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008475 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008476 {
8477 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008478 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008479 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008480 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008481 {
8482 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008483 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008484 }
8485 }
8486#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008487#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008488 else if (pp == &p_mzq)
8489 mzvim_reset_timer();
8490#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008491
8492 /* sync undo before 'undolevels' changes */
8493 else if (pp == &p_ul)
8494 {
8495 /* use the old value, otherwise u_sync() may not work properly */
8496 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00008497 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008498 p_ul = value;
8499 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01008500 else if (pp == &curbuf->b_p_ul)
8501 {
8502 /* use the old value, otherwise u_sync() may not work properly */
8503 curbuf->b_p_ul = old_value;
8504 u_sync(TRUE);
8505 curbuf->b_p_ul = value;
8506 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008507
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008508#ifdef FEAT_LINEBREAK
8509 /* 'numberwidth' must be positive */
8510 else if (pp == &curwin->w_p_nuw)
8511 {
8512 if (curwin->w_p_nuw < 1)
8513 {
8514 errmsg = e_positive;
8515 curwin->w_p_nuw = 1;
8516 }
8517 if (curwin->w_p_nuw > 10)
8518 {
8519 errmsg = e_invarg;
8520 curwin->w_p_nuw = 10;
8521 }
8522 curwin->w_nrwidth_line_count = 0;
8523 }
8524#endif
8525
Bram Moolenaar1a384422010-07-14 19:53:30 +02008526 else if (pp == &curbuf->b_p_tw)
8527 {
8528 if (curbuf->b_p_tw < 0)
8529 {
8530 errmsg = e_positive;
8531 curbuf->b_p_tw = 0;
8532 }
8533#ifdef FEAT_SYN_HL
8534# ifdef FEAT_WINDOWS
8535 {
8536 win_T *wp;
8537 tabpage_T *tp;
8538
8539 FOR_ALL_TAB_WINDOWS(tp, wp)
8540 check_colorcolumn(wp);
8541 }
8542# else
8543 check_colorcolumn(curwin);
8544# endif
8545#endif
8546 }
8547
Bram Moolenaar071d4272004-06-13 20:20:40 +00008548 /*
8549 * Check the bounds for numeric options here
8550 */
8551 if (Rows < min_rows() && full_screen)
8552 {
8553 if (errbuf != NULL)
8554 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008555 vim_snprintf((char *)errbuf, errbuflen,
8556 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00008557 errmsg = errbuf;
8558 }
8559 Rows = min_rows();
8560 }
8561 if (Columns < MIN_COLUMNS && full_screen)
8562 {
8563 if (errbuf != NULL)
8564 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008565 vim_snprintf((char *)errbuf, errbuflen,
8566 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008567 errmsg = errbuf;
8568 }
8569 Columns = MIN_COLUMNS;
8570 }
Bram Moolenaare057d402013-06-30 17:51:51 +02008571 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008572
8573#ifdef DJGPP
8574 /* avoid a crash by checking for a too large value of 'columns' */
8575 if (old_Columns != Columns && full_screen && term_console)
8576 mch_check_columns();
8577#endif
8578
8579 /*
8580 * If the screen (shell) height has been changed, assume it is the
8581 * physical screenheight.
8582 */
8583 if (old_Rows != Rows || old_Columns != Columns)
8584 {
8585 /* Changing the screen size is not allowed while updating the screen. */
8586 if (updating_screen)
8587 *pp = old_value;
8588 else if (full_screen
8589#ifdef FEAT_GUI
8590 && !gui.starting
8591#endif
8592 )
8593 set_shellsize((int)Columns, (int)Rows, TRUE);
8594 else
8595 {
8596 /* Postpone the resizing; check the size and cmdline position for
8597 * messages. */
8598 check_shellsize();
8599 if (cmdline_row > Rows - p_ch && Rows > p_ch)
8600 cmdline_row = Rows - p_ch;
8601 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00008602 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008603 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008604 }
8605
Bram Moolenaar071d4272004-06-13 20:20:40 +00008606 if (curbuf->b_p_ts <= 0)
8607 {
8608 errmsg = e_positive;
8609 curbuf->b_p_ts = 8;
8610 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008611 if (p_tm < 0)
8612 {
8613 errmsg = e_positive;
8614 p_tm = 0;
8615 }
8616 if ((curwin->w_p_scr <= 0
8617 || (curwin->w_p_scr > curwin->w_height
8618 && curwin->w_height > 0))
8619 && full_screen)
8620 {
8621 if (pp == &(curwin->w_p_scr))
8622 {
8623 if (curwin->w_p_scr != 0)
8624 errmsg = e_scroll;
8625 win_comp_scroll(curwin);
8626 }
8627 /* If 'scroll' became invalid because of a side effect silently adjust
8628 * it. */
8629 else if (curwin->w_p_scr <= 0)
8630 curwin->w_p_scr = 1;
8631 else /* curwin->w_p_scr > curwin->w_height */
8632 curwin->w_p_scr = curwin->w_height;
8633 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00008634 if (p_hi < 0)
8635 {
8636 errmsg = e_positive;
8637 p_hi = 0;
8638 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02008639 if (p_re < 0 || p_re > 2)
8640 {
8641 errmsg = e_invarg;
8642 p_re = 0;
8643 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008644 if (p_report < 0)
8645 {
8646 errmsg = e_positive;
8647 p_report = 1;
8648 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00008649 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008650 {
8651 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
8652 p_sj = Rows / 2;
8653 else
8654 {
8655 errmsg = e_scroll;
8656 p_sj = 1;
8657 }
8658 }
8659 if (p_so < 0 && full_screen)
8660 {
8661 errmsg = e_scroll;
8662 p_so = 0;
8663 }
8664 if (p_siso < 0 && full_screen)
8665 {
8666 errmsg = e_positive;
8667 p_siso = 0;
8668 }
8669#ifdef FEAT_CMDWIN
8670 if (p_cwh < 1)
8671 {
8672 errmsg = e_positive;
8673 p_cwh = 1;
8674 }
8675#endif
8676 if (p_ut < 0)
8677 {
8678 errmsg = e_positive;
8679 p_ut = 2000;
8680 }
8681 if (p_ss < 0)
8682 {
8683 errmsg = e_positive;
8684 p_ss = 0;
8685 }
8686
8687 /* May set global value for local option. */
8688 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8689 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
8690
8691 options[opt_idx].flags |= P_WAS_SET;
8692
8693 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008694 if (curwin->w_curswant != MAXCOL
8695 && (options[opt_idx].flags & (P_CURSWANT | P_RCLR)) != 0)
8696 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008697 check_redraw(options[opt_idx].flags);
8698
8699 return errmsg;
8700}
8701
8702/*
8703 * Called after an option changed: check if something needs to be redrawn.
8704 */
8705 static void
8706check_redraw(flags)
8707 long_u flags;
8708{
8709 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008710 int doclear = (flags & P_RCLR) == P_RCLR;
8711 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008712
8713#ifdef FEAT_WINDOWS
8714 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
8715 status_redraw_all();
8716#endif
8717
8718 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
8719 changed_window_setting();
8720 if (flags & P_RBUF)
8721 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008722 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008723 redraw_all_later(CLEAR);
8724 else if (all)
8725 redraw_all_later(NOT_VALID);
8726}
8727
8728/*
8729 * Find index for option 'arg'.
8730 * Return -1 if not found.
8731 */
8732 static int
8733findoption(arg)
8734 char_u *arg;
8735{
8736 int opt_idx;
8737 char *s, *p;
8738 static short quick_tab[27] = {0, 0}; /* quick access table */
8739 int is_term_opt;
8740
8741 /*
8742 * For first call: Initialize the quick-access table.
8743 * It contains the index for the first option that starts with a certain
8744 * letter. There are 26 letters, plus the first "t_" option.
8745 */
8746 if (quick_tab[1] == 0)
8747 {
8748 p = options[0].fullname;
8749 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8750 {
8751 if (s[0] != p[0])
8752 {
8753 if (s[0] == 't' && s[1] == '_')
8754 quick_tab[26] = opt_idx;
8755 else
8756 quick_tab[CharOrdLow(s[0])] = opt_idx;
8757 }
8758 p = s;
8759 }
8760 }
8761
8762 /*
8763 * Check for name starting with an illegal character.
8764 */
8765#ifdef EBCDIC
8766 if (!islower(arg[0]))
8767#else
8768 if (arg[0] < 'a' || arg[0] > 'z')
8769#endif
8770 return -1;
8771
8772 is_term_opt = (arg[0] == 't' && arg[1] == '_');
8773 if (is_term_opt)
8774 opt_idx = quick_tab[26];
8775 else
8776 opt_idx = quick_tab[CharOrdLow(arg[0])];
8777 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8778 {
8779 if (STRCMP(arg, s) == 0) /* match full name */
8780 break;
8781 }
8782 if (s == NULL && !is_term_opt)
8783 {
8784 opt_idx = quick_tab[CharOrdLow(arg[0])];
8785 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
8786 {
8787 s = options[opt_idx].shortname;
8788 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
8789 break;
8790 s = NULL;
8791 }
8792 }
8793 if (s == NULL)
8794 opt_idx = -1;
8795 return opt_idx;
8796}
8797
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008798#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008799/*
8800 * Get the value for an option.
8801 *
8802 * Returns:
8803 * Number or Toggle option: 1, *numval gets value.
8804 * String option: 0, *stringval gets allocated string.
8805 * Hidden Number or Toggle option: -1.
8806 * hidden String option: -2.
8807 * unknown option: -3.
8808 */
8809 int
8810get_option_value(name, numval, stringval, opt_flags)
8811 char_u *name;
8812 long *numval;
Bram Moolenaar370df582010-06-22 05:16:38 +02008813 char_u **stringval; /* NULL when only checking existence */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008814 int opt_flags;
8815{
8816 int opt_idx;
8817 char_u *varp;
8818
8819 opt_idx = findoption(name);
8820 if (opt_idx < 0) /* unknown option */
8821 return -3;
8822
8823 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
8824
8825 if (options[opt_idx].flags & P_STRING)
8826 {
8827 if (varp == NULL) /* hidden option */
8828 return -2;
8829 if (stringval != NULL)
8830 {
8831#ifdef FEAT_CRYPT
8832 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00008833 if ((char_u **)varp == &curbuf->b_p_key
8834 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008835 *stringval = vim_strsave((char_u *)"*****");
8836 else
8837#endif
8838 *stringval = vim_strsave(*(char_u **)(varp));
8839 }
8840 return 0;
8841 }
8842
8843 if (varp == NULL) /* hidden option */
8844 return -1;
8845 if (options[opt_idx].flags & P_NUM)
8846 *numval = *(long *)varp;
8847 else
8848 {
8849 /* Special case: 'modified' is b_changed, but we also want to consider
8850 * it set when 'ff' or 'fenc' changed. */
8851 if ((int *)varp == &curbuf->b_changed)
8852 *numval = curbufIsChanged();
8853 else
8854 *numval = *(int *)varp;
8855 }
8856 return 1;
8857}
8858#endif
8859
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02008860#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3)
8861/*
8862 * Returns the option attributes and its value. Unlike the above function it
8863 * will return either global value or local value of the option depending on
8864 * what was requested, but it will never return global value if it was
8865 * requested to return local one and vice versa. Neither it will return
8866 * buffer-local value if it was requested to return window-local one.
8867 *
8868 * Pretends that option is absent if it is not present in the requested scope
8869 * (i.e. has no global, window-local or buffer-local value depending on
8870 * opt_type). Uses
8871 *
8872 * Returned flags:
8873 * 0 hidden or unknown option
8874 * see SOPT_* in vim.h for other flags
8875 *
8876 * Possible opt_type values: see SREQ_* in vim.h
8877 */
8878 int
8879get_option_value_strict(name, numval, stringval, opt_type, from)
8880 char_u *name;
8881 long *numval;
8882 char_u **stringval; /* NULL when only obtaining attributes */
8883 int opt_type;
8884 void *from;
8885{
8886 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02008887 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02008888 struct vimoption *p;
8889 int r = 0;
8890
8891 opt_idx = findoption(name);
8892 if (opt_idx < 0)
8893 return 0;
8894
8895 p = &(options[opt_idx]);
8896
8897 /* Hidden option */
8898 if (p->var == NULL)
8899 return 0;
8900
8901 if (p->flags & P_BOOL)
8902 r |= SOPT_BOOL;
8903 else if (p->flags & P_NUM)
8904 r |= SOPT_NUM;
8905 else if (p->flags & P_STRING)
8906 r |= SOPT_STRING;
8907
8908 if (p->indir == PV_NONE)
8909 {
8910 if (opt_type == SREQ_GLOBAL)
8911 r |= SOPT_GLOBAL;
8912 else
8913 return 0; /* Did not request global-only option */
8914 }
8915 else
8916 {
8917 if (p->indir & PV_BOTH)
8918 r |= SOPT_GLOBAL;
8919 else if (opt_type == SREQ_GLOBAL)
8920 return 0; /* Requested global option */
8921
8922 if (p->indir & PV_WIN)
8923 {
8924 if (opt_type == SREQ_BUF)
8925 return 0; /* Did not request window-local option */
8926 else
8927 r |= SOPT_WIN;
8928 }
8929 else if (p->indir & PV_BUF)
8930 {
8931 if (opt_type == SREQ_WIN)
8932 return 0; /* Did not request buffer-local option */
8933 else
8934 r |= SOPT_BUF;
8935 }
8936 }
8937
8938 if (stringval == NULL)
8939 return r;
8940
8941 if (opt_type == SREQ_GLOBAL)
8942 varp = p->var;
8943 else
8944 {
8945 if (opt_type == SREQ_BUF)
8946 {
8947 /* Special case: 'modified' is b_changed, but we also want to
8948 * consider it set when 'ff' or 'fenc' changed. */
8949 if (p->indir == PV_MOD)
8950 {
8951 *numval = bufIsChanged((buf_T *) from);
8952 varp = NULL;
8953 }
8954#ifdef FEAT_CRYPT
8955 else if (p->indir == PV_KEY)
8956 {
8957 /* never return the value of the crypt key */
8958 *stringval = NULL;
8959 varp = NULL;
8960 }
8961#endif
8962 else
8963 {
8964 aco_save_T aco;
8965 aucmd_prepbuf(&aco, (buf_T *) from);
8966 varp = get_varp(p);
8967 aucmd_restbuf(&aco);
8968 }
8969 }
8970 else if (opt_type == SREQ_WIN)
8971 {
8972 win_T *save_curwin;
8973 save_curwin = curwin;
8974 curwin = (win_T *) from;
8975 curbuf = curwin->w_buffer;
8976 varp = get_varp(p);
8977 curwin = save_curwin;
8978 curbuf = curwin->w_buffer;
8979 }
8980 if (varp == p->var)
8981 return (r | SOPT_UNSET);
8982 }
8983
8984 if (varp != NULL)
8985 {
8986 if (p->flags & P_STRING)
8987 *stringval = vim_strsave(*(char_u **)(varp));
8988 else if (p->flags & P_NUM)
8989 *numval = *(long *) varp;
8990 else
8991 *numval = *(int *)varp;
8992 }
8993
8994 return r;
8995}
8996#endif
8997
Bram Moolenaar071d4272004-06-13 20:20:40 +00008998/*
8999 * Set the value of option "name".
9000 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009001 *
9002 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009003 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009004 char_u *
Bram Moolenaar071d4272004-06-13 20:20:40 +00009005set_option_value(name, number, string, opt_flags)
9006 char_u *name;
9007 long number;
9008 char_u *string;
9009 int opt_flags; /* OPT_LOCAL or 0 (both) */
9010{
9011 int opt_idx;
9012 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009013 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009014
9015 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009016 if (opt_idx < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009017 EMSG2(_("E355: Unknown option: %s"), name);
9018 else
9019 {
9020 flags = options[opt_idx].flags;
9021#ifdef HAVE_SANDBOX
9022 /* Disallow changing some options in the sandbox */
9023 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009024 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009025 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009026 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009027 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009028#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009029 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009030 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009031 else
9032 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009033 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009034 if (varp != NULL) /* hidden option is not changed */
9035 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009036 if (number == 0 && string != NULL)
9037 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009038 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009039
9040 /* Either we are given a string or we are setting option
9041 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009042 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009043 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009044 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009045 {
9046 /* There's another character after zeros or the string
9047 * is empty. In both cases, we are trying to set a
9048 * num option using a string. */
9049 EMSG3(_("E521: Number required: &%s = '%s'"),
9050 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009051 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009052
9053 }
9054 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009055 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009056 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009057 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009058 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009059 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009060 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009061 }
9062 }
9063 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009064 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009065}
9066
9067/*
9068 * Get the terminal code for a terminal option.
9069 * Returns NULL when not found.
9070 */
9071 char_u *
9072get_term_code(tname)
9073 char_u *tname;
9074{
9075 int opt_idx;
9076 char_u *varp;
9077
9078 if (tname[0] != 't' || tname[1] != '_' ||
9079 tname[2] == NUL || tname[3] == NUL)
9080 return NULL;
9081 if ((opt_idx = findoption(tname)) >= 0)
9082 {
9083 varp = get_varp(&(options[opt_idx]));
9084 if (varp != NULL)
9085 varp = *(char_u **)(varp);
9086 return varp;
9087 }
9088 return find_termcode(tname + 2);
9089}
9090
9091 char_u *
9092get_highlight_default()
9093{
9094 int i;
9095
9096 i = findoption((char_u *)"hl");
9097 if (i >= 0)
9098 return options[i].def_val[VI_DEFAULT];
9099 return (char_u *)NULL;
9100}
9101
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009102#if defined(FEAT_MBYTE) || defined(PROTO)
9103 char_u *
9104get_encoding_default()
9105{
9106 int i;
9107
9108 i = findoption((char_u *)"enc");
9109 if (i >= 0)
9110 return options[i].def_val[VI_DEFAULT];
9111 return (char_u *)NULL;
9112}
9113#endif
9114
Bram Moolenaar071d4272004-06-13 20:20:40 +00009115/*
9116 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9117 */
9118 static int
9119find_key_option(arg)
9120 char_u *arg;
9121{
9122 int key;
9123 int modifiers;
9124
9125 /*
9126 * Don't use get_special_key_code() for t_xx, we don't want it to call
9127 * add_termcap_entry().
9128 */
9129 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9130 key = TERMCAP2KEY(arg[2], arg[3]);
9131 else
9132 {
9133 --arg; /* put arg at the '<' */
9134 modifiers = 0;
Bram Moolenaar2a8ced02008-12-24 11:54:31 +00009135 key = find_special_key(&arg, &modifiers, TRUE, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009136 if (modifiers) /* can't handle modifiers here */
9137 key = 0;
9138 }
9139 return key;
9140}
9141
9142/*
9143 * if 'all' == 0: show changed options
9144 * if 'all' == 1: show all normal options
9145 * if 'all' == 2: show all terminal options
9146 */
9147 static void
9148showoptions(all, opt_flags)
9149 int all;
9150 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
9151{
9152 struct vimoption *p;
9153 int col;
9154 int isterm;
9155 char_u *varp;
9156 struct vimoption **items;
9157 int item_count;
9158 int run;
9159 int row, rows;
9160 int cols;
9161 int i;
9162 int len;
9163
9164#define INC 20
9165#define GAP 3
9166
9167 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9168 PARAM_COUNT));
9169 if (items == NULL)
9170 return;
9171
9172 /* Highlight title */
9173 if (all == 2)
9174 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9175 else if (opt_flags & OPT_GLOBAL)
9176 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9177 else if (opt_flags & OPT_LOCAL)
9178 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9179 else
9180 MSG_PUTS_TITLE(_("\n--- Options ---"));
9181
9182 /*
9183 * do the loop two times:
9184 * 1. display the short items
9185 * 2. display the long items (only strings and numbers)
9186 */
9187 for (run = 1; run <= 2 && !got_int; ++run)
9188 {
9189 /*
9190 * collect the items in items[]
9191 */
9192 item_count = 0;
9193 for (p = &options[0]; p->fullname != NULL; p++)
9194 {
9195 varp = NULL;
9196 isterm = istermoption(p);
9197 if (opt_flags != 0)
9198 {
9199 if (p->indir != PV_NONE && !isterm)
9200 varp = get_varp_scope(p, opt_flags);
9201 }
9202 else
9203 varp = get_varp(p);
9204 if (varp != NULL
9205 && ((all == 2 && isterm)
9206 || (all == 1 && !isterm)
9207 || (all == 0 && !optval_default(p, varp))))
9208 {
9209 if (p->flags & P_BOOL)
9210 len = 1; /* a toggle option fits always */
9211 else
9212 {
9213 option_value2string(p, opt_flags);
9214 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9215 }
9216 if ((len <= INC - GAP && run == 1) ||
9217 (len > INC - GAP && run == 2))
9218 items[item_count++] = p;
9219 }
9220 }
9221
9222 /*
9223 * display the items
9224 */
9225 if (run == 1)
9226 {
9227 cols = (Columns + GAP - 3) / INC;
9228 if (cols == 0)
9229 cols = 1;
9230 rows = (item_count + cols - 1) / cols;
9231 }
9232 else /* run == 2 */
9233 rows = item_count;
9234 for (row = 0; row < rows && !got_int; ++row)
9235 {
9236 msg_putchar('\n'); /* go to next line */
9237 if (got_int) /* 'q' typed in more */
9238 break;
9239 col = 0;
9240 for (i = row; i < item_count; i += rows)
9241 {
9242 msg_col = col; /* make columns */
9243 showoneopt(items[i], opt_flags);
9244 col += INC;
9245 }
9246 out_flush();
9247 ui_breakcheck();
9248 }
9249 }
9250 vim_free(items);
9251}
9252
9253/*
9254 * Return TRUE if option "p" has its default value.
9255 */
9256 static int
9257optval_default(p, varp)
9258 struct vimoption *p;
9259 char_u *varp;
9260{
9261 int dvi;
9262
9263 if (varp == NULL)
9264 return TRUE; /* hidden option is always at default */
9265 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9266 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009267 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009268 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009269 /* the cast to long is required for Manx C, long_i is
9270 * needed for MSVC */
9271 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009272 /* P_STRING */
9273 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9274}
9275
9276/*
9277 * showoneopt: show the value of one option
9278 * must not be called with a hidden option!
9279 */
9280 static void
9281showoneopt(p, opt_flags)
9282 struct vimoption *p;
9283 int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */
9284{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009285 char_u *varp;
9286 int save_silent = silent_mode;
9287
9288 silent_mode = FALSE;
9289 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009290
9291 varp = get_varp_scope(p, opt_flags);
9292
9293 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9294 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9295 ? !curbufIsChanged() : !*(int *)varp))
9296 MSG_PUTS("no");
9297 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9298 MSG_PUTS("--");
9299 else
9300 MSG_PUTS(" ");
9301 MSG_PUTS(p->fullname);
9302 if (!(p->flags & P_BOOL))
9303 {
9304 msg_putchar('=');
9305 /* put value string in NameBuff */
9306 option_value2string(p, opt_flags);
9307 msg_outtrans(NameBuff);
9308 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009309
9310 silent_mode = save_silent;
9311 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009312}
9313
9314/*
9315 * Write modified options as ":set" commands to a file.
9316 *
9317 * There are three values for "opt_flags":
9318 * OPT_GLOBAL: Write global option values and fresh values of
9319 * buffer-local options (used for start of a session
9320 * file).
9321 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
9322 * curwin (used for a vimrc file).
9323 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
9324 * and local values for window-local options of
9325 * curwin. Local values are also written when at the
9326 * default value, because a modeline or autocommand
9327 * may have set them when doing ":edit file" and the
9328 * user has set them back at the default or fresh
9329 * value.
9330 * When "local_only" is TRUE, don't write fresh
9331 * values, only local values (for ":mkview").
9332 * (fresh value = value used for a new buffer or window for a local option).
9333 *
9334 * Return FAIL on error, OK otherwise.
9335 */
9336 int
9337makeset(fd, opt_flags, local_only)
9338 FILE *fd;
9339 int opt_flags;
9340 int local_only;
9341{
9342 struct vimoption *p;
9343 char_u *varp; /* currently used value */
9344 char_u *varp_fresh; /* local value */
9345 char_u *varp_local = NULL; /* fresh value */
9346 char *cmd;
9347 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009348 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009349
9350 /*
9351 * The options that don't have a default (terminal name, columns, lines)
9352 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009353 * Do the loop over "options[]" twice: once for options with the
9354 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009355 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009356 for (pri = 1; pri >= 0; --pri)
9357 {
9358 for (p = &options[0]; !istermoption(p); p++)
9359 if (!(p->flags & P_NO_MKRC)
9360 && !istermoption(p)
9361 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009362 {
9363 /* skip global option when only doing locals */
9364 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
9365 continue;
9366
9367 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
9368 * file, they are always buffer-specific. */
9369 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
9370 continue;
9371
9372 /* Global values are only written when not at the default value. */
9373 varp = get_varp_scope(p, opt_flags);
9374 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
9375 continue;
9376
9377 round = 2;
9378 if (p->indir != PV_NONE)
9379 {
9380 if (p->var == VAR_WIN)
9381 {
9382 /* skip window-local option when only doing globals */
9383 if (!(opt_flags & OPT_LOCAL))
9384 continue;
9385 /* When fresh value of window-local option is not at the
9386 * default, need to write it too. */
9387 if (!(opt_flags & OPT_GLOBAL) && !local_only)
9388 {
9389 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
9390 if (!optval_default(p, varp_fresh))
9391 {
9392 round = 1;
9393 varp_local = varp;
9394 varp = varp_fresh;
9395 }
9396 }
9397 }
9398 }
9399
9400 /* Round 1: fresh value for window-local options.
9401 * Round 2: other values */
9402 for ( ; round <= 2; varp = varp_local, ++round)
9403 {
9404 if (round == 1 || (opt_flags & OPT_GLOBAL))
9405 cmd = "set";
9406 else
9407 cmd = "setlocal";
9408
9409 if (p->flags & P_BOOL)
9410 {
9411 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
9412 return FAIL;
9413 }
9414 else if (p->flags & P_NUM)
9415 {
9416 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
9417 return FAIL;
9418 }
9419 else /* P_STRING */
9420 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009421#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9422 int do_endif = FALSE;
9423
Bram Moolenaar071d4272004-06-13 20:20:40 +00009424 /* Don't set 'syntax' and 'filetype' again if the value is
9425 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009426 if (
9427# if defined(FEAT_SYN_HL)
9428 p->indir == PV_SYN
9429# if defined(FEAT_AUTOCMD)
9430 ||
9431# endif
9432# endif
9433# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009434 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009435# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009436 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00009437 {
9438 if (fprintf(fd, "if &%s != '%s'", p->fullname,
9439 *(char_u **)(varp)) < 0
9440 || put_eol(fd) < 0)
9441 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009442 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009443 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009444#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009445 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
9446 (p->flags & P_EXPAND) != 0) == FAIL)
9447 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009448#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9449 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009450 {
9451 if (put_line(fd, "endif") == FAIL)
9452 return FAIL;
9453 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009454#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009455 }
9456 }
9457 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009458 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009459 return OK;
9460}
9461
9462#if defined(FEAT_FOLDING) || defined(PROTO)
9463/*
9464 * Generate set commands for the local fold options only. Used when
9465 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
9466 */
9467 int
9468makefoldset(fd)
9469 FILE *fd;
9470{
9471 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
9472# ifdef FEAT_EVAL
9473 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
9474 == FAIL
9475# endif
9476 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
9477 == FAIL
9478 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
9479 == FAIL
9480 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
9481 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
9482 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
9483 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
9484 )
9485 return FAIL;
9486
9487 return OK;
9488}
9489#endif
9490
9491 static int
9492put_setstring(fd, cmd, name, valuep, expand)
9493 FILE *fd;
9494 char *cmd;
9495 char *name;
9496 char_u **valuep;
9497 int expand;
9498{
9499 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009500 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009501
9502 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9503 return FAIL;
9504 if (*valuep != NULL)
9505 {
9506 /* Output 'pastetoggle' as key names. For other
9507 * options some characters have to be escaped with
9508 * CTRL-V or backslash */
9509 if (valuep == &p_pt)
9510 {
9511 s = *valuep;
9512 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +00009513 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009514 return FAIL;
9515 }
9516 else if (expand)
9517 {
Bram Moolenaarf8441472011-04-28 17:24:58 +02009518 buf = alloc(MAXPATHL);
9519 if (buf == NULL)
9520 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009521 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
9522 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +02009523 {
9524 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009525 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009526 }
9527 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009528 }
9529 else if (put_escstr(fd, *valuep, 2) == FAIL)
9530 return FAIL;
9531 }
9532 if (put_eol(fd) < 0)
9533 return FAIL;
9534 return OK;
9535}
9536
9537 static int
9538put_setnum(fd, cmd, name, valuep)
9539 FILE *fd;
9540 char *cmd;
9541 char *name;
9542 long *valuep;
9543{
9544 long wc;
9545
9546 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9547 return FAIL;
9548 if (wc_use_keyname((char_u *)valuep, &wc))
9549 {
9550 /* print 'wildchar' and 'wildcharm' as a key name */
9551 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
9552 return FAIL;
9553 }
9554 else if (fprintf(fd, "%ld", *valuep) < 0)
9555 return FAIL;
9556 if (put_eol(fd) < 0)
9557 return FAIL;
9558 return OK;
9559}
9560
9561 static int
9562put_setbool(fd, cmd, name, value)
9563 FILE *fd;
9564 char *cmd;
9565 char *name;
9566 int value;
9567{
Bram Moolenaar893de922007-10-02 18:40:57 +00009568 if (value < 0) /* global/local option using global value */
9569 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009570 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
9571 || put_eol(fd) < 0)
9572 return FAIL;
9573 return OK;
9574}
9575
9576/*
9577 * Clear all the terminal options.
9578 * If the option has been allocated, free the memory.
9579 * Terminal options are never hidden or indirect.
9580 */
9581 void
9582clear_termoptions()
9583{
Bram Moolenaar071d4272004-06-13 20:20:40 +00009584 /*
9585 * Reset a few things before clearing the old options. This may cause
9586 * outputting a few things that the terminal doesn't understand, but the
9587 * screen will be cleared later, so this is OK.
9588 */
9589#ifdef FEAT_MOUSE_TTY
9590 mch_setmouse(FALSE); /* switch mouse off */
9591#endif
9592#ifdef FEAT_TITLE
9593 mch_restore_title(3); /* restore window titles */
9594#endif
9595#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
9596 /* When starting the GUI close the display opened for the clipboard.
9597 * After restoring the title, because that will need the display. */
9598 if (gui.starting)
9599 clear_xterm_clip();
9600#endif
9601#ifdef WIN3264
9602 /*
9603 * Check if this is allowed now.
9604 */
9605 if (can_end_termcap_mode(FALSE) == TRUE)
9606#endif
9607 stoptermcap(); /* stop termcap mode */
9608
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00009609 free_termoptions();
9610}
9611
9612 void
9613free_termoptions()
9614{
9615 struct vimoption *p;
9616
Bram Moolenaar071d4272004-06-13 20:20:40 +00009617 for (p = &options[0]; p->fullname != NULL; p++)
9618 if (istermoption(p))
9619 {
9620 if (p->flags & P_ALLOCED)
9621 free_string_option(*(char_u **)(p->var));
9622 if (p->flags & P_DEF_ALLOCED)
9623 free_string_option(p->def_val[VI_DEFAULT]);
9624 *(char_u **)(p->var) = empty_option;
9625 p->def_val[VI_DEFAULT] = empty_option;
9626 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
9627 }
9628 clear_termcodes();
9629}
9630
9631/*
Bram Moolenaar363cb672009-07-22 12:28:17 +00009632 * Free the string for one term option, if it was allocated.
9633 * Set the string to empty_option and clear allocated flag.
9634 * "var" points to the option value.
9635 */
9636 void
9637free_one_termoption(var)
9638 char_u *var;
9639{
9640 struct vimoption *p;
9641
9642 for (p = &options[0]; p->fullname != NULL; p++)
9643 if (p->var == var)
9644 {
9645 if (p->flags & P_ALLOCED)
9646 free_string_option(*(char_u **)(p->var));
9647 *(char_u **)(p->var) = empty_option;
9648 p->flags &= ~P_ALLOCED;
9649 break;
9650 }
9651}
9652
9653/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00009654 * Set the terminal option defaults to the current value.
9655 * Used after setting the terminal name.
9656 */
9657 void
9658set_term_defaults()
9659{
9660 struct vimoption *p;
9661
9662 for (p = &options[0]; p->fullname != NULL; p++)
9663 {
9664 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
9665 {
9666 if (p->flags & P_DEF_ALLOCED)
9667 {
9668 free_string_option(p->def_val[VI_DEFAULT]);
9669 p->flags &= ~P_DEF_ALLOCED;
9670 }
9671 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
9672 if (p->flags & P_ALLOCED)
9673 {
9674 p->flags |= P_DEF_ALLOCED;
9675 p->flags &= ~P_ALLOCED; /* don't free the value now */
9676 }
9677 }
9678 }
9679}
9680
9681/*
9682 * return TRUE if 'p' starts with 't_'
9683 */
9684 static int
9685istermoption(p)
9686 struct vimoption *p;
9687{
9688 return (p->fullname[0] == 't' && p->fullname[1] == '_');
9689}
9690
9691/*
9692 * Compute columns for ruler and shown command. 'sc_col' is also used to
9693 * decide what the maximum length of a message on the status line can be.
9694 * If there is a status line for the last window, 'sc_col' is independent
9695 * of 'ru_col'.
9696 */
9697
9698#define COL_RULER 17 /* columns needed by standard ruler */
9699
9700 void
9701comp_col()
9702{
9703#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
9704 int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin));
9705
9706 sc_col = 0;
9707 ru_col = 0;
9708 if (p_ru)
9709 {
9710#ifdef FEAT_STL_OPT
9711 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
9712#else
9713 ru_col = COL_RULER + 1;
9714#endif
9715 /* no last status line, adjust sc_col */
9716 if (!last_has_status)
9717 sc_col = ru_col;
9718 }
9719 if (p_sc)
9720 {
9721 sc_col += SHOWCMD_COLS;
9722 if (!p_ru || last_has_status) /* no need for separating space */
9723 ++sc_col;
9724 }
9725 sc_col = Columns - sc_col;
9726 ru_col = Columns - ru_col;
9727 if (sc_col <= 0) /* screen too narrow, will become a mess */
9728 sc_col = 1;
9729 if (ru_col <= 0)
9730 ru_col = 1;
9731#else
9732 sc_col = Columns;
9733 ru_col = Columns;
9734#endif
9735}
9736
9737/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009738 * Unset local option value, similar to ":set opt<".
9739 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009740 void
9741unset_global_local_option(name, from)
9742 char_u *name;
9743 void *from;
9744{
9745 struct vimoption *p;
9746 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009747 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009748
9749 opt_idx = findoption(name);
9750 p = &(options[opt_idx]);
9751
9752 switch ((int)p->indir)
9753 {
9754 /* global option with local value: use local value if it's been set */
9755 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009756 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009757 break;
9758 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009759 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009760 break;
9761 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009762 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009763 break;
9764 case PV_AR:
9765 buf->b_p_ar = -1;
9766 break;
9767 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009768 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009769 break;
9770#ifdef FEAT_FIND_ID
9771 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009772 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009773 break;
9774 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009775 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009776 break;
9777#endif
9778#ifdef FEAT_INS_EXPAND
9779 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009780 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009781 break;
9782 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009783 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009784 break;
9785#endif
9786#ifdef FEAT_QUICKFIX
9787 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009788 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009789 break;
9790 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009791 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009792 break;
9793 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009794 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009795 break;
9796#endif
9797#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9798 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009799 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009800 break;
9801#endif
9802#if defined(FEAT_CRYPT)
9803 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009804 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009805 break;
9806#endif
9807#ifdef FEAT_STL_OPT
9808 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009809 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009810 break;
9811#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01009812 case PV_UL:
9813 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
9814 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009815 }
9816}
9817
9818/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00009819 * Get pointer to option variable, depending on local or global scope.
9820 */
9821 static char_u *
9822get_varp_scope(p, opt_flags)
9823 struct vimoption *p;
9824 int opt_flags;
9825{
9826 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
9827 {
9828 if (p->var == VAR_WIN)
9829 return (char_u *)GLOBAL_WO(get_varp(p));
9830 return p->var;
9831 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +00009832 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009833 {
9834 switch ((int)p->indir)
9835 {
9836#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009837 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
9838 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
9839 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009840#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009841 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
9842 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
9843 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +00009844 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009845 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009846#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009847 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
9848 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009849#endif
9850#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009851 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
9852 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009853#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00009854#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9855 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
9856#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02009857#if defined(FEAT_CRYPT)
9858 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
9859#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009860#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009861 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009862#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01009863 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009864 }
9865 return NULL; /* "cannot happen" */
9866 }
9867 return get_varp(p);
9868}
9869
9870/*
9871 * Get pointer to option variable.
9872 */
9873 static char_u *
9874get_varp(p)
9875 struct vimoption *p;
9876{
9877 /* hidden option, always return NULL */
9878 if (p->var == NULL)
9879 return NULL;
9880
9881 switch ((int)p->indir)
9882 {
9883 case PV_NONE: return p->var;
9884
9885 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009886 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009887 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009888 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009889 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009890 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009891 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +00009892 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00009893 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009894 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009895 ? (char_u *)&(curbuf->b_p_tags) : p->var;
9896#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009897 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009898 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009899 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009900 ? (char_u *)&(curbuf->b_p_inc) : p->var;
9901#endif
9902#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009903 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009904 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009905 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009906 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
9907#endif
9908#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009909 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009910 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009911 case PV_GP: return *curbuf->b_p_gp != NUL
9912 ? (char_u *)&(curbuf->b_p_gp) : p->var;
9913 case PV_MP: return *curbuf->b_p_mp != NUL
9914 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009915#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00009916#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9917 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
9918 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
9919#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02009920#if defined(FEAT_CRYPT)
9921 case PV_CM: return *curbuf->b_p_cm != NUL
9922 ? (char_u *)&(curbuf->b_p_cm) : p->var;
9923#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009924#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009925 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009926 ? (char_u *)&(curwin->w_p_stl) : p->var;
9927#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01009928 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
9929 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009930
9931#ifdef FEAT_ARABIC
9932 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
9933#endif
9934 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00009935#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00009936 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
9937#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00009938#ifdef FEAT_SYN_HL
9939 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
9940 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +02009941 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00009942#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009943#ifdef FEAT_DIFF
9944 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
9945#endif
9946#ifdef FEAT_FOLDING
9947 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
9948 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
9949 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
9950 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
9951 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
9952 case PV_FML: return (char_u *)&(curwin->w_p_fml);
9953 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
9954# ifdef FEAT_EVAL
9955 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
9956 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
9957# endif
9958 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
9959#endif
9960 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +02009961 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009962#ifdef FEAT_LINEBREAK
9963 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
9964#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009965#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00009966 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
9967#endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00009968#ifdef FEAT_VERTSPLIT
9969 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
9970#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009971#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
9972 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
9973#endif
9974#ifdef FEAT_RIGHTLEFT
9975 case PV_RL: return (char_u *)&(curwin->w_p_rl);
9976 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
9977#endif
9978 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
9979 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
9980#ifdef FEAT_LINEBREAK
9981 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
9982#endif
9983#ifdef FEAT_SCROLLBIND
9984 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
9985#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +02009986#ifdef FEAT_CURSORBIND
9987 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
9988#endif
9989#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009990 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
9991 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
Bram Moolenaar860cae12010-06-05 23:22:07 +02009992#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009993
9994 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
9995 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
9996#ifdef FEAT_MBYTE
9997 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
9998#endif
9999#if defined(FEAT_QUICKFIX)
10000 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10001 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
10002#endif
10003 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10004 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10005#ifdef FEAT_CINDENT
10006 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10007 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10008 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10009#endif
10010#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10011 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10012#endif
10013#ifdef FEAT_COMMENTS
10014 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10015#endif
10016#ifdef FEAT_FOLDING
10017 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10018#endif
10019#ifdef FEAT_INS_EXPAND
10020 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10021#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010022#ifdef FEAT_COMPL_FUNC
10023 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010024 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010025#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010026 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
10027 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10028#ifdef FEAT_MBYTE
10029 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10030#endif
10031 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10032#ifdef FEAT_AUTOCMD
10033 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10034#endif
10035 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010036 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010037 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10038 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10039 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10040 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10041#ifdef FEAT_FIND_ID
10042# ifdef FEAT_EVAL
10043 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10044# endif
10045#endif
10046#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10047 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10048 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10049#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010050#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010051 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10052#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010053#ifdef FEAT_CRYPT
10054 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10055#endif
10056#ifdef FEAT_LISP
10057 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10058#endif
10059 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10060 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10061 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10062 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10063 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010064 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010065#ifdef FEAT_TEXTOBJ
10066 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10067#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010068 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10069#ifdef FEAT_SMARTINDENT
10070 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10071#endif
10072#ifndef SHORT_FNAME
10073 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
10074#endif
10075 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10076#ifdef FEAT_SEARCHPATH
10077 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10078#endif
10079 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10080#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010081 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010082 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10083#endif
10084#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010085 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10086 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10087 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010088#endif
10089 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10090 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10091 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10092 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010093#ifdef FEAT_PERSISTENT_UNDO
10094 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10095#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010096 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10097#ifdef FEAT_KEYMAP
10098 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10099#endif
10100 default: EMSG(_("E356: get_varp ERROR"));
10101 }
10102 /* always return a valid pointer to avoid a crash! */
10103 return (char_u *)&(curbuf->b_p_wm);
10104}
10105
10106/*
10107 * Get the value of 'equalprg', either the buffer-local one or the global one.
10108 */
10109 char_u *
10110get_equalprg()
10111{
10112 if (*curbuf->b_p_ep == NUL)
10113 return p_ep;
10114 return curbuf->b_p_ep;
10115}
10116
10117#if defined(FEAT_WINDOWS) || defined(PROTO)
10118/*
10119 * Copy options from one window to another.
10120 * Used when splitting a window.
10121 */
10122 void
10123win_copy_options(wp_from, wp_to)
10124 win_T *wp_from;
10125 win_T *wp_to;
10126{
10127 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10128 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10129# ifdef FEAT_RIGHTLEFT
10130# ifdef FEAT_FKMAP
10131 /* Is this right? */
10132 wp_to->w_farsi = wp_from->w_farsi;
10133# endif
10134# endif
10135}
10136#endif
10137
10138/*
10139 * Copy the options from one winopt_T to another.
10140 * Doesn't free the old option values in "to", use clear_winopt() for that.
10141 * The 'scroll' option is not copied, because it depends on the window height.
10142 * The 'previewwindow' option is reset, there can be only one preview window.
10143 */
10144 void
10145copy_winopt(from, to)
10146 winopt_T *from;
10147 winopt_T *to;
10148{
10149#ifdef FEAT_ARABIC
10150 to->wo_arab = from->wo_arab;
10151#endif
10152 to->wo_list = from->wo_list;
10153 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010154 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010155#ifdef FEAT_LINEBREAK
10156 to->wo_nuw = from->wo_nuw;
10157#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010158#ifdef FEAT_RIGHTLEFT
10159 to->wo_rl = from->wo_rl;
10160 to->wo_rlc = vim_strsave(from->wo_rlc);
10161#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010162#ifdef FEAT_STL_OPT
10163 to->wo_stl = vim_strsave(from->wo_stl);
10164#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010165 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010166#ifdef FEAT_DIFF
10167 to->wo_wrap_save = from->wo_wrap_save;
10168#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010169#ifdef FEAT_LINEBREAK
10170 to->wo_lbr = from->wo_lbr;
10171#endif
10172#ifdef FEAT_SCROLLBIND
10173 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010174 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010175#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010176#ifdef FEAT_CURSORBIND
10177 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010178 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010179#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010180#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010181 to->wo_spell = from->wo_spell;
10182#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010183#ifdef FEAT_SYN_HL
10184 to->wo_cuc = from->wo_cuc;
10185 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010186 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010187#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010188#ifdef FEAT_DIFF
10189 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010190 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010191#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010192#ifdef FEAT_CONCEAL
10193 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010194 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010195#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010196#ifdef FEAT_FOLDING
10197 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010198 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010199 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010200 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010201 to->wo_fdi = vim_strsave(from->wo_fdi);
10202 to->wo_fml = from->wo_fml;
10203 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010204 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010205 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010206 to->wo_fdm_save = from->wo_diff_saved
10207 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010208 to->wo_fdn = from->wo_fdn;
10209# ifdef FEAT_EVAL
10210 to->wo_fde = vim_strsave(from->wo_fde);
10211 to->wo_fdt = vim_strsave(from->wo_fdt);
10212# endif
10213 to->wo_fmr = vim_strsave(from->wo_fmr);
10214#endif
10215 check_winopt(to); /* don't want NULL pointers */
10216}
10217
10218/*
10219 * Check string options in a window for a NULL value.
10220 */
10221 void
10222check_win_options(win)
10223 win_T *win;
10224{
10225 check_winopt(&win->w_onebuf_opt);
10226 check_winopt(&win->w_allbuf_opt);
10227}
10228
10229/*
10230 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10231 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010232 void
10233check_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010234 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010235{
10236#ifdef FEAT_FOLDING
10237 check_string_option(&wop->wo_fdi);
10238 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010239 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010240# ifdef FEAT_EVAL
10241 check_string_option(&wop->wo_fde);
10242 check_string_option(&wop->wo_fdt);
10243# endif
10244 check_string_option(&wop->wo_fmr);
10245#endif
10246#ifdef FEAT_RIGHTLEFT
10247 check_string_option(&wop->wo_rlc);
10248#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010249#ifdef FEAT_STL_OPT
10250 check_string_option(&wop->wo_stl);
10251#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010252#ifdef FEAT_SYN_HL
10253 check_string_option(&wop->wo_cc);
10254#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010255#ifdef FEAT_CONCEAL
10256 check_string_option(&wop->wo_cocu);
10257#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010258}
10259
10260/*
10261 * Free the allocated memory inside a winopt_T.
10262 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010263 void
10264clear_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010265 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010266{
10267#ifdef FEAT_FOLDING
10268 clear_string_option(&wop->wo_fdi);
10269 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010270 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010271# ifdef FEAT_EVAL
10272 clear_string_option(&wop->wo_fde);
10273 clear_string_option(&wop->wo_fdt);
10274# endif
10275 clear_string_option(&wop->wo_fmr);
10276#endif
10277#ifdef FEAT_RIGHTLEFT
10278 clear_string_option(&wop->wo_rlc);
10279#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010280#ifdef FEAT_STL_OPT
10281 clear_string_option(&wop->wo_stl);
10282#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010283#ifdef FEAT_SYN_HL
10284 clear_string_option(&wop->wo_cc);
10285#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010286#ifdef FEAT_CONCEAL
10287 clear_string_option(&wop->wo_cocu);
10288#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010289}
10290
10291/*
10292 * Copy global option values to local options for one buffer.
10293 * Used when creating a new buffer and sometimes when entering a buffer.
10294 * flags:
10295 * BCO_ENTER We will enter the buf buffer.
10296 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
10297 * appropriate.
10298 * BCO_NOHELP Don't copy the values to a help buffer.
10299 */
10300 void
10301buf_copy_options(buf, flags)
10302 buf_T *buf;
10303 int flags;
10304{
10305 int should_copy = TRUE;
10306 char_u *save_p_isk = NULL; /* init for GCC */
10307 int dont_do_help;
10308 int did_isk = FALSE;
10309
10310 /*
Bram Moolenaar1a384422010-07-14 19:53:30 +020010311 * Don't do anything if the buffer is invalid.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010312 */
10313 if (buf == NULL || !buf_valid(buf))
10314 return;
10315
10316 /*
10317 * Skip this when the option defaults have not been set yet. Happens when
10318 * main() allocates the first buffer.
10319 */
10320 if (p_cpo != NULL)
10321 {
10322 /*
10323 * Always copy when entering and 'cpo' contains 'S'.
10324 * Don't copy when already initialized.
10325 * Don't copy when 'cpo' contains 's' and not entering.
10326 * 'S' BCO_ENTER initialized 's' should_copy
10327 * yes yes X X TRUE
10328 * yes no yes X FALSE
10329 * no X yes X FALSE
10330 * X no no yes FALSE
10331 * X no no no TRUE
10332 * no yes no X TRUE
10333 */
10334 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
10335 && (buf->b_p_initialized
10336 || (!(flags & BCO_ENTER)
10337 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
10338 should_copy = FALSE;
10339
10340 if (should_copy || (flags & BCO_ALWAYS))
10341 {
10342 /* Don't copy the options specific to a help buffer when
10343 * BCO_NOHELP is given or the options were initialized already
10344 * (jumping back to a help file with CTRL-T or CTRL-O) */
10345 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
10346 || buf->b_p_initialized;
10347 if (dont_do_help) /* don't free b_p_isk */
10348 {
10349 save_p_isk = buf->b_p_isk;
10350 buf->b_p_isk = NULL;
10351 }
10352 /*
10353 * Always free the allocated strings.
10354 * If not already initialized, set 'readonly' and copy 'fileformat'.
10355 */
10356 if (!buf->b_p_initialized)
10357 {
10358 free_buf_options(buf, TRUE);
10359 buf->b_p_ro = FALSE; /* don't copy readonly */
10360 buf->b_p_tx = p_tx;
10361#ifdef FEAT_MBYTE
10362 buf->b_p_fenc = vim_strsave(p_fenc);
10363#endif
10364 buf->b_p_ff = vim_strsave(p_ff);
10365#if defined(FEAT_QUICKFIX)
10366 buf->b_p_bh = empty_option;
10367 buf->b_p_bt = empty_option;
10368#endif
10369 }
10370 else
10371 free_buf_options(buf, FALSE);
10372
10373 buf->b_p_ai = p_ai;
10374 buf->b_p_ai_nopaste = p_ai_nopaste;
10375 buf->b_p_sw = p_sw;
10376 buf->b_p_tw = p_tw;
10377 buf->b_p_tw_nopaste = p_tw_nopaste;
10378 buf->b_p_tw_nobin = p_tw_nobin;
10379 buf->b_p_wm = p_wm;
10380 buf->b_p_wm_nopaste = p_wm_nopaste;
10381 buf->b_p_wm_nobin = p_wm_nobin;
10382 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000010383#ifdef FEAT_MBYTE
10384 buf->b_p_bomb = p_bomb;
10385#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010386 buf->b_p_et = p_et;
10387 buf->b_p_et_nobin = p_et_nobin;
10388 buf->b_p_ml = p_ml;
10389 buf->b_p_ml_nobin = p_ml_nobin;
10390 buf->b_p_inf = p_inf;
10391 buf->b_p_swf = p_swf;
10392#ifdef FEAT_INS_EXPAND
10393 buf->b_p_cpt = vim_strsave(p_cpt);
10394#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010395#ifdef FEAT_COMPL_FUNC
10396 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010397 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010398#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010399 buf->b_p_sts = p_sts;
10400 buf->b_p_sts_nopaste = p_sts_nopaste;
10401#ifndef SHORT_FNAME
10402 buf->b_p_sn = p_sn;
10403#endif
10404#ifdef FEAT_COMMENTS
10405 buf->b_p_com = vim_strsave(p_com);
10406#endif
10407#ifdef FEAT_FOLDING
10408 buf->b_p_cms = vim_strsave(p_cms);
10409#endif
10410 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010411 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010412 buf->b_p_nf = vim_strsave(p_nf);
10413 buf->b_p_mps = vim_strsave(p_mps);
10414#ifdef FEAT_SMARTINDENT
10415 buf->b_p_si = p_si;
10416#endif
10417 buf->b_p_ci = p_ci;
10418#ifdef FEAT_CINDENT
10419 buf->b_p_cin = p_cin;
10420 buf->b_p_cink = vim_strsave(p_cink);
10421 buf->b_p_cino = vim_strsave(p_cino);
10422#endif
10423#ifdef FEAT_AUTOCMD
10424 /* Don't copy 'filetype', it must be detected */
10425 buf->b_p_ft = empty_option;
10426#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010427 buf->b_p_pi = p_pi;
10428#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10429 buf->b_p_cinw = vim_strsave(p_cinw);
10430#endif
10431#ifdef FEAT_LISP
10432 buf->b_p_lisp = p_lisp;
10433#endif
10434#ifdef FEAT_SYN_HL
10435 /* Don't copy 'syntax', it must be set */
10436 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010437 buf->b_p_smc = p_smc;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010438#endif
10439#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020010440 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010441 (void)compile_cap_prog(&buf->b_s);
10442 buf->b_s.b_p_spf = vim_strsave(p_spf);
10443 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010444#endif
10445#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10446 buf->b_p_inde = vim_strsave(p_inde);
10447 buf->b_p_indk = vim_strsave(p_indk);
10448#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010449#if defined(FEAT_EVAL)
10450 buf->b_p_fex = vim_strsave(p_fex);
10451#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010452#ifdef FEAT_CRYPT
10453 buf->b_p_key = vim_strsave(p_key);
10454#endif
10455#ifdef FEAT_SEARCHPATH
10456 buf->b_p_sua = vim_strsave(p_sua);
10457#endif
10458#ifdef FEAT_KEYMAP
10459 buf->b_p_keymap = vim_strsave(p_keymap);
10460 buf->b_kmap_state |= KEYMAP_INIT;
10461#endif
10462 /* This isn't really an option, but copying the langmap and IME
10463 * state from the current buffer is better than resetting it. */
10464 buf->b_p_iminsert = p_iminsert;
10465 buf->b_p_imsearch = p_imsearch;
10466
10467 /* options that are normally global but also have a local value
10468 * are not copied, start using the global value */
10469 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010470 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010471#ifdef FEAT_QUICKFIX
10472 buf->b_p_gp = empty_option;
10473 buf->b_p_mp = empty_option;
10474 buf->b_p_efm = empty_option;
10475#endif
10476 buf->b_p_ep = empty_option;
10477 buf->b_p_kp = empty_option;
10478 buf->b_p_path = empty_option;
10479 buf->b_p_tags = empty_option;
10480#ifdef FEAT_FIND_ID
10481 buf->b_p_def = empty_option;
10482 buf->b_p_inc = empty_option;
10483# ifdef FEAT_EVAL
10484 buf->b_p_inex = vim_strsave(p_inex);
10485# endif
10486#endif
10487#ifdef FEAT_INS_EXPAND
10488 buf->b_p_dict = empty_option;
10489 buf->b_p_tsr = empty_option;
10490#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010491#ifdef FEAT_TEXTOBJ
10492 buf->b_p_qe = vim_strsave(p_qe);
10493#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010494#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10495 buf->b_p_bexpr = empty_option;
10496#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010497#if defined(FEAT_CRYPT)
10498 buf->b_p_cm = empty_option;
10499#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010500#ifdef FEAT_PERSISTENT_UNDO
10501 buf->b_p_udf = p_udf;
10502#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010503
10504 /*
10505 * Don't copy the options set by ex_help(), use the saved values,
10506 * when going from a help buffer to a non-help buffer.
10507 * Don't touch these at all when BCO_NOHELP is used and going from
10508 * or to a help buffer.
10509 */
10510 if (dont_do_help)
10511 buf->b_p_isk = save_p_isk;
10512 else
10513 {
10514 buf->b_p_isk = vim_strsave(p_isk);
10515 did_isk = TRUE;
10516 buf->b_p_ts = p_ts;
10517 buf->b_help = FALSE;
10518#ifdef FEAT_QUICKFIX
10519 if (buf->b_p_bt[0] == 'h')
10520 clear_string_option(&buf->b_p_bt);
10521#endif
10522 buf->b_p_ma = p_ma;
10523 }
10524 }
10525
10526 /*
10527 * When the options should be copied (ignoring BCO_ALWAYS), set the
10528 * flag that indicates that the options have been initialized.
10529 */
10530 if (should_copy)
10531 buf->b_p_initialized = TRUE;
10532 }
10533
10534 check_buf_options(buf); /* make sure we don't have NULLs */
10535 if (did_isk)
10536 (void)buf_init_chartab(buf, FALSE);
10537}
10538
10539/*
10540 * Reset the 'modifiable' option and its default value.
10541 */
10542 void
10543reset_modifiable()
10544{
10545 int opt_idx;
10546
10547 curbuf->b_p_ma = FALSE;
10548 p_ma = FALSE;
10549 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000010550 if (opt_idx >= 0)
10551 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010552}
10553
10554/*
10555 * Set the global value for 'iminsert' to the local value.
10556 */
10557 void
10558set_iminsert_global()
10559{
10560 p_iminsert = curbuf->b_p_iminsert;
10561}
10562
10563/*
10564 * Set the global value for 'imsearch' to the local value.
10565 */
10566 void
10567set_imsearch_global()
10568{
10569 p_imsearch = curbuf->b_p_imsearch;
10570}
10571
10572#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
10573static int expand_option_idx = -1;
10574static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
10575static int expand_option_flags = 0;
10576
10577 void
10578set_context_in_set_cmd(xp, arg, opt_flags)
10579 expand_T *xp;
10580 char_u *arg;
10581 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
10582{
10583 int nextchar;
10584 long_u flags = 0; /* init for GCC */
10585 int opt_idx = 0; /* init for GCC */
10586 char_u *p;
10587 char_u *s;
10588 int is_term_option = FALSE;
10589 int key;
10590
10591 expand_option_flags = opt_flags;
10592
10593 xp->xp_context = EXPAND_SETTINGS;
10594 if (*arg == NUL)
10595 {
10596 xp->xp_pattern = arg;
10597 return;
10598 }
10599 p = arg + STRLEN(arg) - 1;
10600 if (*p == ' ' && *(p - 1) != '\\')
10601 {
10602 xp->xp_pattern = p + 1;
10603 return;
10604 }
10605 while (p > arg)
10606 {
10607 s = p;
10608 /* count number of backslashes before ' ' or ',' */
10609 if (*p == ' ' || *p == ',')
10610 {
10611 while (s > arg && *(s - 1) == '\\')
10612 --s;
10613 }
10614 /* break at a space with an even number of backslashes */
10615 if (*p == ' ' && ((p - s) & 1) == 0)
10616 {
10617 ++p;
10618 break;
10619 }
10620 --p;
10621 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000010622 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010623 {
10624 xp->xp_context = EXPAND_BOOL_SETTINGS;
10625 p += 2;
10626 }
10627 if (STRNCMP(p, "inv", 3) == 0)
10628 {
10629 xp->xp_context = EXPAND_BOOL_SETTINGS;
10630 p += 3;
10631 }
10632 xp->xp_pattern = arg = p;
10633 if (*arg == '<')
10634 {
10635 while (*p != '>')
10636 if (*p++ == NUL) /* expand terminal option name */
10637 return;
10638 key = get_special_key_code(arg + 1);
10639 if (key == 0) /* unknown name */
10640 {
10641 xp->xp_context = EXPAND_NOTHING;
10642 return;
10643 }
10644 nextchar = *++p;
10645 is_term_option = TRUE;
10646 expand_option_name[2] = KEY2TERMCAP0(key);
10647 expand_option_name[3] = KEY2TERMCAP1(key);
10648 }
10649 else
10650 {
10651 if (p[0] == 't' && p[1] == '_')
10652 {
10653 p += 2;
10654 if (*p != NUL)
10655 ++p;
10656 if (*p == NUL)
10657 return; /* expand option name */
10658 nextchar = *++p;
10659 is_term_option = TRUE;
10660 expand_option_name[2] = p[-2];
10661 expand_option_name[3] = p[-1];
10662 }
10663 else
10664 {
10665 /* Allow * wildcard */
10666 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
10667 p++;
10668 if (*p == NUL)
10669 return;
10670 nextchar = *p;
10671 *p = NUL;
10672 opt_idx = findoption(arg);
10673 *p = nextchar;
10674 if (opt_idx == -1 || options[opt_idx].var == NULL)
10675 {
10676 xp->xp_context = EXPAND_NOTHING;
10677 return;
10678 }
10679 flags = options[opt_idx].flags;
10680 if (flags & P_BOOL)
10681 {
10682 xp->xp_context = EXPAND_NOTHING;
10683 return;
10684 }
10685 }
10686 }
10687 /* handle "-=" and "+=" */
10688 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
10689 {
10690 ++p;
10691 nextchar = '=';
10692 }
10693 if ((nextchar != '=' && nextchar != ':')
10694 || xp->xp_context == EXPAND_BOOL_SETTINGS)
10695 {
10696 xp->xp_context = EXPAND_UNSUCCESSFUL;
10697 return;
10698 }
10699 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
10700 {
10701 xp->xp_context = EXPAND_OLD_SETTING;
10702 if (is_term_option)
10703 expand_option_idx = -1;
10704 else
10705 expand_option_idx = opt_idx;
10706 xp->xp_pattern = p + 1;
10707 return;
10708 }
10709 xp->xp_context = EXPAND_NOTHING;
10710 if (is_term_option || (flags & P_NUM))
10711 return;
10712
10713 xp->xp_pattern = p + 1;
10714
10715 if (flags & P_EXPAND)
10716 {
10717 p = options[opt_idx].var;
10718 if (p == (char_u *)&p_bdir
10719 || p == (char_u *)&p_dir
10720 || p == (char_u *)&p_path
10721 || p == (char_u *)&p_rtp
10722#ifdef FEAT_SEARCHPATH
10723 || p == (char_u *)&p_cdpath
10724#endif
10725#ifdef FEAT_SESSION
10726 || p == (char_u *)&p_vdir
10727#endif
10728 )
10729 {
10730 xp->xp_context = EXPAND_DIRECTORIES;
10731 if (p == (char_u *)&p_path
10732#ifdef FEAT_SEARCHPATH
10733 || p == (char_u *)&p_cdpath
10734#endif
10735 )
10736 xp->xp_backslash = XP_BS_THREE;
10737 else
10738 xp->xp_backslash = XP_BS_ONE;
10739 }
10740 else
10741 {
10742 xp->xp_context = EXPAND_FILES;
10743 /* for 'tags' need three backslashes for a space */
10744 if (p == (char_u *)&p_tags)
10745 xp->xp_backslash = XP_BS_THREE;
10746 else
10747 xp->xp_backslash = XP_BS_ONE;
10748 }
10749 }
10750
10751 /* For an option that is a list of file names, find the start of the
10752 * last file name. */
10753 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
10754 {
10755 /* count number of backslashes before ' ' or ',' */
10756 if (*p == ' ' || *p == ',')
10757 {
10758 s = p;
10759 while (s > xp->xp_pattern && *(s - 1) == '\\')
10760 --s;
10761 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
10762 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
10763 {
10764 xp->xp_pattern = p + 1;
10765 break;
10766 }
10767 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000010768
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010769#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000010770 /* for 'spellsuggest' start at "file:" */
10771 if (options[opt_idx].var == (char_u *)&p_sps
10772 && STRNCMP(p, "file:", 5) == 0)
10773 {
10774 xp->xp_pattern = p + 5;
10775 break;
10776 }
10777#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010778 }
10779
10780 return;
10781}
10782
10783 int
10784ExpandSettings(xp, regmatch, num_file, file)
10785 expand_T *xp;
10786 regmatch_T *regmatch;
10787 int *num_file;
10788 char_u ***file;
10789{
10790 int num_normal = 0; /* Nr of matching non-term-code settings */
10791 int num_term = 0; /* Nr of matching terminal code settings */
10792 int opt_idx;
10793 int match;
10794 int count = 0;
10795 char_u *str;
10796 int loop;
10797 int is_term_opt;
10798 char_u name_buf[MAX_KEY_NAME_LEN];
10799 static char *(names[]) = {"all", "termcap"};
10800 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
10801
10802 /* do this loop twice:
10803 * loop == 0: count the number of matching options
10804 * loop == 1: copy the matching options into allocated memory
10805 */
10806 for (loop = 0; loop <= 1; ++loop)
10807 {
10808 regmatch->rm_ic = ic;
10809 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
10810 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000010811 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
10812 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010813 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
10814 {
10815 if (loop == 0)
10816 num_normal++;
10817 else
10818 (*file)[count++] = vim_strsave((char_u *)names[match]);
10819 }
10820 }
10821 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
10822 opt_idx++)
10823 {
10824 if (options[opt_idx].var == NULL)
10825 continue;
10826 if (xp->xp_context == EXPAND_BOOL_SETTINGS
10827 && !(options[opt_idx].flags & P_BOOL))
10828 continue;
10829 is_term_opt = istermoption(&options[opt_idx]);
10830 if (is_term_opt && num_normal > 0)
10831 continue;
10832 match = FALSE;
10833 if (vim_regexec(regmatch, str, (colnr_T)0)
10834 || (options[opt_idx].shortname != NULL
10835 && vim_regexec(regmatch,
10836 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
10837 match = TRUE;
10838 else if (is_term_opt)
10839 {
10840 name_buf[0] = '<';
10841 name_buf[1] = 't';
10842 name_buf[2] = '_';
10843 name_buf[3] = str[2];
10844 name_buf[4] = str[3];
10845 name_buf[5] = '>';
10846 name_buf[6] = NUL;
10847 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10848 {
10849 match = TRUE;
10850 str = name_buf;
10851 }
10852 }
10853 if (match)
10854 {
10855 if (loop == 0)
10856 {
10857 if (is_term_opt)
10858 num_term++;
10859 else
10860 num_normal++;
10861 }
10862 else
10863 (*file)[count++] = vim_strsave(str);
10864 }
10865 }
10866 /*
10867 * Check terminal key codes, these are not in the option table
10868 */
10869 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
10870 {
10871 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
10872 {
10873 if (!isprint(str[0]) || !isprint(str[1]))
10874 continue;
10875
10876 name_buf[0] = 't';
10877 name_buf[1] = '_';
10878 name_buf[2] = str[0];
10879 name_buf[3] = str[1];
10880 name_buf[4] = NUL;
10881
10882 match = FALSE;
10883 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10884 match = TRUE;
10885 else
10886 {
10887 name_buf[0] = '<';
10888 name_buf[1] = 't';
10889 name_buf[2] = '_';
10890 name_buf[3] = str[0];
10891 name_buf[4] = str[1];
10892 name_buf[5] = '>';
10893 name_buf[6] = NUL;
10894
10895 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10896 match = TRUE;
10897 }
10898 if (match)
10899 {
10900 if (loop == 0)
10901 num_term++;
10902 else
10903 (*file)[count++] = vim_strsave(name_buf);
10904 }
10905 }
10906
10907 /*
10908 * Check special key names.
10909 */
10910 regmatch->rm_ic = TRUE; /* ignore case here */
10911 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
10912 {
10913 name_buf[0] = '<';
10914 STRCPY(name_buf + 1, str);
10915 STRCAT(name_buf, ">");
10916
10917 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10918 {
10919 if (loop == 0)
10920 num_term++;
10921 else
10922 (*file)[count++] = vim_strsave(name_buf);
10923 }
10924 }
10925 }
10926 if (loop == 0)
10927 {
10928 if (num_normal > 0)
10929 *num_file = num_normal;
10930 else if (num_term > 0)
10931 *num_file = num_term;
10932 else
10933 return OK;
10934 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
10935 if (*file == NULL)
10936 {
10937 *file = (char_u **)"";
10938 return FAIL;
10939 }
10940 }
10941 }
10942 return OK;
10943}
10944
10945 int
10946ExpandOldSetting(num_file, file)
10947 int *num_file;
10948 char_u ***file;
10949{
10950 char_u *var = NULL; /* init for GCC */
10951 char_u *buf;
10952
10953 *num_file = 0;
10954 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
10955 if (*file == NULL)
10956 return FAIL;
10957
10958 /*
10959 * For a terminal key code expand_option_idx is < 0.
10960 */
10961 if (expand_option_idx < 0)
10962 {
10963 var = find_termcode(expand_option_name + 2);
10964 if (var == NULL)
10965 expand_option_idx = findoption(expand_option_name);
10966 }
10967
10968 if (expand_option_idx >= 0)
10969 {
10970 /* put string of option value in NameBuff */
10971 option_value2string(&options[expand_option_idx], expand_option_flags);
10972 var = NameBuff;
10973 }
10974 else if (var == NULL)
10975 var = (char_u *)"";
10976
10977 /* A backslash is required before some characters. This is the reverse of
10978 * what happens in do_set(). */
10979 buf = vim_strsave_escaped(var, escape_chars);
10980
10981 if (buf == NULL)
10982 {
10983 vim_free(*file);
10984 *file = NULL;
10985 return FAIL;
10986 }
10987
10988#ifdef BACKSLASH_IN_FILENAME
10989 /* For MS-Windows et al. we don't double backslashes at the start and
10990 * before a file name character. */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000010991 for (var = buf; *var != NUL; mb_ptr_adv(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010992 if (var[0] == '\\' && var[1] == '\\'
10993 && expand_option_idx >= 0
10994 && (options[expand_option_idx].flags & P_EXPAND)
10995 && vim_isfilec(var[2])
10996 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000010997 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010998#endif
10999
11000 *file[0] = buf;
11001 *num_file = 1;
11002 return OK;
11003}
11004#endif
11005
11006/*
11007 * Get the value for the numeric or string option *opp in a nice format into
11008 * NameBuff[]. Must not be called with a hidden option!
11009 */
11010 static void
11011option_value2string(opp, opt_flags)
11012 struct vimoption *opp;
11013 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
11014{
11015 char_u *varp;
11016
11017 varp = get_varp_scope(opp, opt_flags);
11018
11019 if (opp->flags & P_NUM)
11020 {
11021 long wc = 0;
11022
11023 if (wc_use_keyname(varp, &wc))
11024 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11025 else if (wc != 0)
11026 STRCPY(NameBuff, transchar((int)wc));
11027 else
11028 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11029 }
11030 else /* P_STRING */
11031 {
11032 varp = *(char_u **)(varp);
11033 if (varp == NULL) /* just in case */
11034 NameBuff[0] = NUL;
11035#ifdef FEAT_CRYPT
11036 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011037 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011038 STRCPY(NameBuff, "*****");
11039#endif
11040 else if (opp->flags & P_EXPAND)
11041 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11042 /* Translate 'pastetoggle' into special key names */
11043 else if ((char_u **)opp->var == &p_pt)
11044 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11045 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011046 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011047 }
11048}
11049
11050/*
11051 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11052 * printed as a keyname.
11053 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11054 */
11055 static int
11056wc_use_keyname(varp, wcp)
11057 char_u *varp;
11058 long *wcp;
11059{
11060 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11061 {
11062 *wcp = *(long *)varp;
11063 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11064 return TRUE;
11065 }
11066 return FALSE;
11067}
11068
11069#ifdef FEAT_LANGMAP
11070/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011071 * Any character has an equivalent 'langmap' character. This is used for
11072 * keyboards that have a special language mode that sends characters above
11073 * 128 (although other characters can be translated too). The "to" field is a
11074 * Vim command character. This avoids having to switch the keyboard back to
11075 * ASCII mode when leaving Insert mode.
11076 *
11077 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11078 * commands.
11079 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11080 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11081 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011082 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011083# ifdef FEAT_MBYTE
11084/*
11085 * With multi-byte support use growarray for 'langmap' chars >= 256
11086 */
11087typedef struct
11088{
11089 int from;
11090 int to;
11091} langmap_entry_T;
11092
11093static garray_T langmap_mapga;
11094static void langmap_set_entry __ARGS((int from, int to));
Bram Moolenaar071d4272004-06-13 20:20:40 +000011095
11096/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011097 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11098 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011099 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011100 static void
11101langmap_set_entry(from, to)
11102 int from;
11103 int to;
11104{
11105 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011106 int a = 0;
11107 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011108
11109 /* Do a binary search for an existing entry. */
11110 while (a != b)
11111 {
11112 int i = (a + b) / 2;
11113 int d = entries[i].from - from;
11114
11115 if (d == 0)
11116 {
11117 entries[i].to = to;
11118 return;
11119 }
11120 if (d < 0)
11121 a = i + 1;
11122 else
11123 b = i;
11124 }
11125
11126 if (ga_grow(&langmap_mapga, 1) != OK)
11127 return; /* out of memory */
11128
11129 /* insert new entry at position "a" */
11130 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11131 mch_memmove(entries + 1, entries,
11132 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11133 ++langmap_mapga.ga_len;
11134 entries[0].from = from;
11135 entries[0].to = to;
11136}
11137
11138/*
11139 * Apply 'langmap' to multi-byte character "c" and return the result.
11140 */
11141 int
11142langmap_adjust_mb(c)
11143 int c;
11144{
11145 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11146 int a = 0;
11147 int b = langmap_mapga.ga_len;
11148
11149 while (a != b)
11150 {
11151 int i = (a + b) / 2;
11152 int d = entries[i].from - c;
11153
11154 if (d == 0)
11155 return entries[i].to; /* found matching entry */
11156 if (d < 0)
11157 a = i + 1;
11158 else
11159 b = i;
11160 }
11161 return c; /* no entry found, return "c" unmodified */
11162}
11163# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011164
11165 static void
11166langmap_init()
11167{
11168 int i;
11169
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011170 for (i = 0; i < 256; i++)
11171 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11172# ifdef FEAT_MBYTE
11173 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11174# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011175}
11176
11177/*
11178 * Called when langmap option is set; the language map can be
11179 * changed at any time!
11180 */
11181 static void
11182langmap_set()
11183{
11184 char_u *p;
11185 char_u *p2;
11186 int from, to;
11187
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011188#ifdef FEAT_MBYTE
11189 ga_clear(&langmap_mapga); /* clear the previous map first */
11190#endif
11191 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011192
11193 for (p = p_langmap; p[0] != NUL; )
11194 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011195 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
11196 mb_ptr_adv(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011197 {
11198 if (p2[0] == '\\' && p2[1] != NUL)
11199 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011200 }
11201 if (p2[0] == ';')
11202 ++p2; /* abcd;ABCD form, p2 points to A */
11203 else
11204 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11205 while (p[0])
11206 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011207 if (p[0] == ',')
11208 {
11209 ++p;
11210 break;
11211 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011212 if (p[0] == '\\' && p[1] != NUL)
11213 ++p;
11214#ifdef FEAT_MBYTE
11215 from = (*mb_ptr2char)(p);
11216#else
11217 from = p[0];
11218#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011219 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011220 if (p2 == NULL)
11221 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011222 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011223 if (p[0] != ',')
11224 {
11225 if (p[0] == '\\')
11226 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011227#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011228 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011229#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011230 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011231#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011232 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011233 }
11234 else
11235 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011236 if (p2[0] != ',')
11237 {
11238 if (p2[0] == '\\')
11239 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011240#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011241 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011242#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011243 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011244#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011245 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011246 }
11247 if (to == NUL)
11248 {
11249 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
11250 transchar(from));
11251 return;
11252 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011253
11254#ifdef FEAT_MBYTE
11255 if (from >= 256)
11256 langmap_set_entry(from, to);
11257 else
11258#endif
11259 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011260
11261 /* Advance to next pair */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011262 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011263 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011264 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011265 mb_ptr_adv(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011266 if (*p == ';')
11267 {
11268 p = p2;
11269 if (p[0] != NUL)
11270 {
11271 if (p[0] != ',')
11272 {
11273 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
11274 return;
11275 }
11276 ++p;
11277 }
11278 break;
11279 }
11280 }
11281 }
11282 }
11283}
11284#endif
11285
11286/*
11287 * Return TRUE if format option 'x' is in effect.
11288 * Take care of no formatting when 'paste' is set.
11289 */
11290 int
11291has_format_option(x)
11292 int x;
11293{
11294 if (p_paste)
11295 return FALSE;
11296 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
11297}
11298
11299/*
11300 * Return TRUE if "x" is present in 'shortmess' option, or
11301 * 'shortmess' contains 'a' and "x" is present in SHM_A.
11302 */
11303 int
11304shortmess(x)
11305 int x;
11306{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010011307 return p_shm != NULL &&
11308 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000011309 || (vim_strchr(p_shm, 'a') != NULL
11310 && vim_strchr((char_u *)SHM_A, x) != NULL));
11311}
11312
11313/*
11314 * paste_option_changed() - Called after p_paste was set or reset.
11315 */
11316 static void
11317paste_option_changed()
11318{
11319 static int old_p_paste = FALSE;
11320 static int save_sm = 0;
11321#ifdef FEAT_CMDL_INFO
11322 static int save_ru = 0;
11323#endif
11324#ifdef FEAT_RIGHTLEFT
11325 static int save_ri = 0;
11326 static int save_hkmap = 0;
11327#endif
11328 buf_T *buf;
11329
11330 if (p_paste)
11331 {
11332 /*
11333 * Paste switched from off to on.
11334 * Save the current values, so they can be restored later.
11335 */
11336 if (!old_p_paste)
11337 {
11338 /* save options for each buffer */
11339 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11340 {
11341 buf->b_p_tw_nopaste = buf->b_p_tw;
11342 buf->b_p_wm_nopaste = buf->b_p_wm;
11343 buf->b_p_sts_nopaste = buf->b_p_sts;
11344 buf->b_p_ai_nopaste = buf->b_p_ai;
11345 }
11346
11347 /* save global options */
11348 save_sm = p_sm;
11349#ifdef FEAT_CMDL_INFO
11350 save_ru = p_ru;
11351#endif
11352#ifdef FEAT_RIGHTLEFT
11353 save_ri = p_ri;
11354 save_hkmap = p_hkmap;
11355#endif
11356 /* save global values for local buffer options */
11357 p_tw_nopaste = p_tw;
11358 p_wm_nopaste = p_wm;
11359 p_sts_nopaste = p_sts;
11360 p_ai_nopaste = p_ai;
11361 }
11362
11363 /*
11364 * Always set the option values, also when 'paste' is set when it is
11365 * already on.
11366 */
11367 /* set options for each buffer */
11368 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11369 {
11370 buf->b_p_tw = 0; /* textwidth is 0 */
11371 buf->b_p_wm = 0; /* wrapmargin is 0 */
11372 buf->b_p_sts = 0; /* softtabstop is 0 */
11373 buf->b_p_ai = 0; /* no auto-indent */
11374 }
11375
11376 /* set global options */
11377 p_sm = 0; /* no showmatch */
11378#ifdef FEAT_CMDL_INFO
11379# ifdef FEAT_WINDOWS
11380 if (p_ru)
11381 status_redraw_all(); /* redraw to remove the ruler */
11382# endif
11383 p_ru = 0; /* no ruler */
11384#endif
11385#ifdef FEAT_RIGHTLEFT
11386 p_ri = 0; /* no reverse insert */
11387 p_hkmap = 0; /* no Hebrew keyboard */
11388#endif
11389 /* set global values for local buffer options */
11390 p_tw = 0;
11391 p_wm = 0;
11392 p_sts = 0;
11393 p_ai = 0;
11394 }
11395
11396 /*
11397 * Paste switched from on to off: Restore saved values.
11398 */
11399 else if (old_p_paste)
11400 {
11401 /* restore options for each buffer */
11402 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11403 {
11404 buf->b_p_tw = buf->b_p_tw_nopaste;
11405 buf->b_p_wm = buf->b_p_wm_nopaste;
11406 buf->b_p_sts = buf->b_p_sts_nopaste;
11407 buf->b_p_ai = buf->b_p_ai_nopaste;
11408 }
11409
11410 /* restore global options */
11411 p_sm = save_sm;
11412#ifdef FEAT_CMDL_INFO
11413# ifdef FEAT_WINDOWS
11414 if (p_ru != save_ru)
11415 status_redraw_all(); /* redraw to draw the ruler */
11416# endif
11417 p_ru = save_ru;
11418#endif
11419#ifdef FEAT_RIGHTLEFT
11420 p_ri = save_ri;
11421 p_hkmap = save_hkmap;
11422#endif
11423 /* set global values for local buffer options */
11424 p_tw = p_tw_nopaste;
11425 p_wm = p_wm_nopaste;
11426 p_sts = p_sts_nopaste;
11427 p_ai = p_ai_nopaste;
11428 }
11429
11430 old_p_paste = p_paste;
11431}
11432
11433/*
11434 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
11435 *
11436 * Reset 'compatible' and set the values for options that didn't get set yet
11437 * to the Vim defaults.
11438 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011439 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011440 */
11441 void
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011442vimrc_found(fname, envname)
11443 char_u *fname;
11444 char_u *envname;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011445{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011446 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000011447 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011448 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011449
11450 if (!option_was_set((char_u *)"cp"))
11451 {
11452 p_cp = FALSE;
11453 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11454 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
11455 set_option_default(opt_idx, OPT_FREE, FALSE);
11456 didset_options();
11457 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011458
11459 if (fname != NULL)
11460 {
11461 p = vim_getenv(envname, &dofree);
11462 if (p == NULL)
11463 {
11464 /* Set $MYVIMRC to the first vimrc file found. */
11465 p = FullName_save(fname, FALSE);
11466 if (p != NULL)
11467 {
11468 vim_setenv(envname, p);
11469 vim_free(p);
11470 }
11471 }
11472 else if (dofree)
11473 vim_free(p);
11474 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011475}
11476
11477/*
11478 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
11479 */
11480 void
11481change_compatible(on)
11482 int on;
11483{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011484 int opt_idx;
11485
Bram Moolenaar071d4272004-06-13 20:20:40 +000011486 if (p_cp != on)
11487 {
11488 p_cp = on;
11489 compatible_set();
11490 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011491 opt_idx = findoption((char_u *)"cp");
11492 if (opt_idx >= 0)
11493 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011494}
11495
11496/*
11497 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020011498 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011499 */
11500 int
11501option_was_set(name)
11502 char_u *name;
11503{
11504 int idx;
11505
11506 idx = findoption(name);
11507 if (idx < 0) /* unknown option */
11508 return FALSE;
11509 if (options[idx].flags & P_WAS_SET)
11510 return TRUE;
11511 return FALSE;
11512}
11513
11514/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010011515 * Reset the flag indicating option "name" was set.
11516 */
11517 void
11518reset_option_was_set(name)
11519 char_u *name;
11520{
11521 int idx = findoption(name);
11522
11523 if (idx >= 0)
11524 options[idx].flags &= ~P_WAS_SET;
11525}
11526
11527/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011528 * compatible_set() - Called when 'compatible' has been set or unset.
11529 *
11530 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
11531 * flag) to a Vi compatible value.
11532 * When 'compatible' is unset: Set all options that have a different default
11533 * for Vim (without the P_VI_DEF flag) to that default.
11534 */
11535 static void
11536compatible_set()
11537{
11538 int opt_idx;
11539
11540 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11541 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
11542 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
11543 set_option_default(opt_idx, OPT_FREE, p_cp);
11544 didset_options();
11545}
11546
11547#ifdef FEAT_LINEBREAK
11548
11549# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
11550 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011551 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011552# endif
11553
11554/*
11555 * fill_breakat_flags() -- called when 'breakat' changes value.
11556 */
11557 static void
11558fill_breakat_flags()
11559{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011560 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011561 int i;
11562
11563 for (i = 0; i < 256; i++)
11564 breakat_flags[i] = FALSE;
11565
11566 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011567 for (p = p_breakat; *p; p++)
11568 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011569}
11570
11571# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011572 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011573# endif
11574
11575#endif
11576
11577/*
11578 * Check an option that can be a range of string values.
11579 *
11580 * Return OK for correct value, FAIL otherwise.
11581 * Empty is always OK.
11582 */
11583 static int
11584check_opt_strings(val, values, list)
11585 char_u *val;
11586 char **values;
11587 int list; /* when TRUE: accept a list of values */
11588{
11589 return opt_strings_flags(val, values, NULL, list);
11590}
11591
11592/*
11593 * Handle an option that can be a range of string values.
11594 * Set a flag in "*flagp" for each string present.
11595 *
11596 * Return OK for correct value, FAIL otherwise.
11597 * Empty is always OK.
11598 */
11599 static int
11600opt_strings_flags(val, values, flagp, list)
11601 char_u *val; /* new value */
11602 char **values; /* array of valid string values */
11603 unsigned *flagp;
11604 int list; /* when TRUE: accept a list of values */
11605{
11606 int i;
11607 int len;
11608 unsigned new_flags = 0;
11609
11610 while (*val)
11611 {
11612 for (i = 0; ; ++i)
11613 {
11614 if (values[i] == NULL) /* val not found in values[] */
11615 return FAIL;
11616
11617 len = (int)STRLEN(values[i]);
11618 if (STRNCMP(values[i], val, len) == 0
11619 && ((list && val[len] == ',') || val[len] == NUL))
11620 {
11621 val += len + (val[len] == ',');
11622 new_flags |= (1 << i);
11623 break; /* check next item in val list */
11624 }
11625 }
11626 }
11627 if (flagp != NULL)
11628 *flagp = new_flags;
11629
11630 return OK;
11631}
11632
11633/*
11634 * Read the 'wildmode' option, fill wim_flags[].
11635 */
11636 static int
11637check_opt_wim()
11638{
11639 char_u new_wim_flags[4];
11640 char_u *p;
11641 int i;
11642 int idx = 0;
11643
11644 for (i = 0; i < 4; ++i)
11645 new_wim_flags[i] = 0;
11646
11647 for (p = p_wim; *p; ++p)
11648 {
11649 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
11650 ;
11651 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
11652 return FAIL;
11653 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
11654 new_wim_flags[idx] |= WIM_LONGEST;
11655 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
11656 new_wim_flags[idx] |= WIM_FULL;
11657 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
11658 new_wim_flags[idx] |= WIM_LIST;
11659 else
11660 return FAIL;
11661 p += i;
11662 if (*p == NUL)
11663 break;
11664 if (*p == ',')
11665 {
11666 if (idx == 3)
11667 return FAIL;
11668 ++idx;
11669 }
11670 }
11671
11672 /* fill remaining entries with last flag */
11673 while (idx < 3)
11674 {
11675 new_wim_flags[idx + 1] = new_wim_flags[idx];
11676 ++idx;
11677 }
11678
11679 /* only when there are no errors, wim_flags[] is changed */
11680 for (i = 0; i < 4; ++i)
11681 wim_flags[i] = new_wim_flags[i];
11682 return OK;
11683}
11684
11685/*
11686 * Check if backspacing over something is allowed.
11687 */
11688 int
11689can_bs(what)
11690 int what; /* BS_INDENT, BS_EOL or BS_START */
11691{
11692 switch (*p_bs)
11693 {
11694 case '2': return TRUE;
11695 case '1': return (what != BS_START);
11696 case '0': return FALSE;
11697 }
11698 return vim_strchr(p_bs, what) != NULL;
11699}
11700
11701/*
11702 * Save the current values of 'fileformat' and 'fileencoding', so that we know
11703 * the file must be considered changed when the value is different.
11704 */
11705 void
11706save_file_ff(buf)
11707 buf_T *buf;
11708{
11709 buf->b_start_ffc = *buf->b_p_ff;
11710 buf->b_start_eol = buf->b_p_eol;
11711#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011712 buf->b_start_bomb = buf->b_p_bomb;
11713
Bram Moolenaar071d4272004-06-13 20:20:40 +000011714 /* Only use free/alloc when necessary, they take time. */
11715 if (buf->b_start_fenc == NULL
11716 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
11717 {
11718 vim_free(buf->b_start_fenc);
11719 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
11720 }
11721#endif
11722}
11723
11724/*
11725 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
11726 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011727 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
11728 * changed and 'binary' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010011729 * When "ignore_empty" is true don't consider a new, empty buffer to be
11730 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011731 */
11732 int
Bram Moolenaar164c60f2011-01-22 00:11:50 +010011733file_ff_differs(buf, ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011734 buf_T *buf;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010011735 int ignore_empty;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011736{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000011737 /* In a buffer that was never loaded the options are not valid. */
11738 if (buf->b_flags & BF_NEVERLOADED)
11739 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010011740 if (ignore_empty
11741 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011742 && buf->b_ml.ml_line_count == 1
11743 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
11744 return FALSE;
11745 if (buf->b_start_ffc != *buf->b_p_ff)
11746 return TRUE;
11747 if (buf->b_p_bin && buf->b_start_eol != buf->b_p_eol)
11748 return TRUE;
11749#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011750 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
11751 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011752 if (buf->b_start_fenc == NULL)
11753 return (*buf->b_p_fenc != NUL);
11754 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
11755#else
11756 return FALSE;
11757#endif
11758}
11759
11760/*
11761 * return OK if "p" is a valid fileformat name, FAIL otherwise.
11762 */
11763 int
11764check_ff_value(p)
11765 char_u *p;
11766{
11767 return check_opt_strings(p, p_ff_values, FALSE);
11768}
Bram Moolenaar14f24742012-08-08 18:01:05 +020011769
11770/*
11771 * Return the effective shiftwidth value for current buffer, using the
11772 * 'tabstop' value when 'shiftwidth' is zero.
11773 */
11774 long
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010011775get_sw_value(buf)
11776 buf_T *buf;
Bram Moolenaar14f24742012-08-08 18:01:05 +020011777{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010011778 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020011779}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020011780
11781/*
11782 * Return the effective softtabstop value for the current buffer, using the
11783 * 'tabstop' value when 'softtabstop' is negative.
11784 */
11785 long
11786get_sts_value()
11787{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010011788 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020011789}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010011790
11791/*
11792 * Check matchpairs option for "*initc".
11793 * If there is a match set "*initc" to the matching character and "*findc" to
11794 * the opposite character. Set "*backwards" to the direction.
11795 * When "switchit" is TRUE swap the direction.
11796 */
11797 void
11798find_mps_values(initc, findc, backwards, switchit)
11799 int *initc;
11800 int *findc;
11801 int *backwards;
11802 int switchit;
11803{
11804 char_u *ptr;
11805
11806 ptr = curbuf->b_p_mps;
11807 while (*ptr != NUL)
11808 {
11809#ifdef FEAT_MBYTE
11810 if (has_mbyte)
11811 {
11812 char_u *prev;
11813
11814 if (mb_ptr2char(ptr) == *initc)
11815 {
11816 if (switchit)
11817 {
11818 *findc = *initc;
11819 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
11820 *backwards = TRUE;
11821 }
11822 else
11823 {
11824 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
11825 *backwards = FALSE;
11826 }
11827 return;
11828 }
11829 prev = ptr;
11830 ptr += mb_ptr2len(ptr) + 1;
11831 if (mb_ptr2char(ptr) == *initc)
11832 {
11833 if (switchit)
11834 {
11835 *findc = *initc;
11836 *initc = mb_ptr2char(prev);
11837 *backwards = FALSE;
11838 }
11839 else
11840 {
11841 *findc = mb_ptr2char(prev);
11842 *backwards = TRUE;
11843 }
11844 return;
11845 }
11846 ptr += mb_ptr2len(ptr);
11847 }
11848 else
11849#endif
11850 {
11851 if (*ptr == *initc)
11852 {
11853 if (switchit)
11854 {
11855 *backwards = TRUE;
11856 *findc = *initc;
11857 *initc = ptr[2];
11858 }
11859 else
11860 {
11861 *backwards = FALSE;
11862 *findc = ptr[2];
11863 }
11864 return;
11865 }
11866 ptr += 2;
11867 if (*ptr == *initc)
11868 {
11869 if (switchit)
11870 {
11871 *backwards = FALSE;
11872 *findc = *initc;
11873 *initc = ptr[-2];
11874 }
11875 else
11876 {
11877 *backwards = TRUE;
11878 *findc = ptr[-2];
11879 }
11880 return;
11881 }
11882 ++ptr;
11883 }
11884 if (*ptr == ',')
11885 ++ptr;
11886 }
11887}