blob: 8c72da6391debb5a8c2ea3ad3edd77fd638fd2a0 [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];
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007125 char_u *q = curwin->w_s->b_p_spl;
7126
7127 /* Skip the first name if it is "cjk". */
7128 if (STRNCMP(q, "cjk,", 4) == 0)
7129 q += 4;
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007130
7131 /*
7132 * Source the spell/LANG.vim in 'runtimepath'.
7133 * They could set 'spellcapcheck' depending on the language.
7134 * Use the first name in 'spelllang' up to '_region' or
7135 * '.encoding'.
7136 */
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007137 for (p = q; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007138 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7139 break;
Bram Moolenaarcc63c642013-11-12 04:44:01 +01007140 vim_snprintf((char *)fname, 200, "spell/%.*s.vim", (int)(p - q), q);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007141 source_runtime(fname, TRUE);
7142 }
7143#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007144 }
7145
7146#ifdef FEAT_MOUSE
7147 if (varp == &p_mouse)
7148 {
7149# ifdef FEAT_MOUSE_TTY
7150 if (*p_mouse == NUL)
7151 mch_setmouse(FALSE); /* switch mouse off */
7152 else
7153# endif
7154 setmouse(); /* in case 'mouse' changed */
7155 }
7156#endif
7157
Bram Moolenaar913077c2012-03-28 19:59:04 +02007158 if (curwin->w_curswant != MAXCOL
7159 && (options[opt_idx].flags & (P_CURSWANT | P_RCLR)) != 0)
7160 curwin->w_set_curswant = TRUE;
7161
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007162#ifdef FEAT_GUI
7163 /* check redraw when it's not a GUI option or the GUI is active. */
7164 if (!redraw_gui_only || gui.in_use)
7165#endif
7166 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007167
7168 return errmsg;
7169}
7170
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007171#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007172/*
7173 * Simple int comparison function for use with qsort()
7174 */
7175 static int
7176int_cmp(a, b)
7177 const void *a;
7178 const void *b;
7179{
7180 return *(const int *)a - *(const int *)b;
7181}
7182
7183/*
7184 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7185 * Returns error message, NULL if it's OK.
7186 */
7187 char_u *
7188check_colorcolumn(wp)
7189 win_T *wp;
7190{
7191 char_u *s;
7192 int col;
7193 int count = 0;
7194 int color_cols[256];
7195 int i;
7196 int j = 0;
7197
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007198 if (wp->w_buffer == NULL)
7199 return NULL; /* buffer was closed */
7200
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007201 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007202 {
7203 if (*s == '-' || *s == '+')
7204 {
7205 /* -N and +N: add to 'textwidth' */
7206 col = (*s == '-') ? -1 : 1;
7207 ++s;
7208 if (!VIM_ISDIGIT(*s))
7209 return e_invarg;
7210 col = col * getdigits(&s);
7211 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007212 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007213 col += wp->w_buffer->b_p_tw;
7214 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007215 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007216 }
7217 else if (VIM_ISDIGIT(*s))
7218 col = getdigits(&s);
7219 else
7220 return e_invarg;
7221 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007222skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007223 if (*s == NUL)
7224 break;
7225 if (*s != ',')
7226 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007227 if (*++s == NUL)
7228 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007229 }
7230
7231 vim_free(wp->w_p_cc_cols);
7232 if (count == 0)
7233 wp->w_p_cc_cols = NULL;
7234 else
7235 {
7236 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7237 if (wp->w_p_cc_cols != NULL)
7238 {
7239 /* sort the columns for faster usage on screen redraw inside
7240 * win_line() */
7241 qsort(color_cols, count, sizeof(int), int_cmp);
7242
7243 for (i = 0; i < count; ++i)
7244 /* skip duplicates */
7245 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7246 wp->w_p_cc_cols[j++] = color_cols[i];
7247 wp->w_p_cc_cols[j] = -1; /* end marker */
7248 }
7249 }
7250
7251 return NULL; /* no error */
7252}
7253#endif
7254
Bram Moolenaar071d4272004-06-13 20:20:40 +00007255/*
7256 * Handle setting 'listchars' or 'fillchars'.
7257 * Returns error message, NULL if it's OK.
7258 */
7259 static char_u *
7260set_chars_option(varp)
7261 char_u **varp;
7262{
7263 int round, i, len, entries;
7264 char_u *p, *s;
7265 int c1, c2 = 0;
7266 struct charstab
7267 {
7268 int *cp;
7269 char *name;
7270 };
7271#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7272 static struct charstab filltab[] =
7273 {
7274 {&fill_stl, "stl"},
7275 {&fill_stlnc, "stlnc"},
7276 {&fill_vert, "vert"},
7277 {&fill_fold, "fold"},
7278 {&fill_diff, "diff"},
7279 };
7280#endif
7281 static struct charstab lcstab[] =
7282 {
7283 {&lcs_eol, "eol"},
7284 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007285 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007286 {&lcs_prec, "precedes"},
7287 {&lcs_tab2, "tab"},
7288 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007289#ifdef FEAT_CONCEAL
7290 {&lcs_conceal, "conceal"},
7291#else
7292 {NULL, "conceal"},
7293#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007294 };
7295 struct charstab *tab;
7296
7297#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7298 if (varp == &p_lcs)
7299#endif
7300 {
7301 tab = lcstab;
7302 entries = sizeof(lcstab) / sizeof(struct charstab);
7303 }
7304#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7305 else
7306 {
7307 tab = filltab;
7308 entries = sizeof(filltab) / sizeof(struct charstab);
7309 }
7310#endif
7311
7312 /* first round: check for valid value, second round: assign values */
7313 for (round = 0; round <= 1; ++round)
7314 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007315 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007316 {
7317 /* After checking that the value is valid: set defaults: space for
7318 * 'fillchars', NUL for 'listchars' */
7319 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007320 if (tab[i].cp != NULL)
7321 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007322 if (varp == &p_lcs)
7323 lcs_tab1 = NUL;
7324#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7325 else
7326 fill_diff = '-';
7327#endif
7328 }
7329 p = *varp;
7330 while (*p)
7331 {
7332 for (i = 0; i < entries; ++i)
7333 {
7334 len = (int)STRLEN(tab[i].name);
7335 if (STRNCMP(p, tab[i].name, len) == 0
7336 && p[len] == ':'
7337 && p[len + 1] != NUL)
7338 {
7339 s = p + len + 1;
7340#ifdef FEAT_MBYTE
7341 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007342 if (mb_char2cells(c1) > 1)
7343 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007344#else
7345 c1 = *s++;
7346#endif
7347 if (tab[i].cp == &lcs_tab2)
7348 {
7349 if (*s == NUL)
7350 continue;
7351#ifdef FEAT_MBYTE
7352 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007353 if (mb_char2cells(c2) > 1)
7354 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007355#else
7356 c2 = *s++;
7357#endif
7358 }
7359 if (*s == ',' || *s == NUL)
7360 {
7361 if (round)
7362 {
7363 if (tab[i].cp == &lcs_tab2)
7364 {
7365 lcs_tab1 = c1;
7366 lcs_tab2 = c2;
7367 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007368 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007369 *(tab[i].cp) = c1;
7370
7371 }
7372 p = s;
7373 break;
7374 }
7375 }
7376 }
7377
7378 if (i == entries)
7379 return e_invarg;
7380 if (*p == ',')
7381 ++p;
7382 }
7383 }
7384
7385 return NULL; /* no error */
7386}
7387
7388#ifdef FEAT_STL_OPT
7389/*
7390 * Check validity of options with the 'statusline' format.
7391 * Return error message or NULL.
7392 */
7393 char_u *
7394check_stl_option(s)
7395 char_u *s;
7396{
7397 int itemcnt = 0;
7398 int groupdepth = 0;
7399 static char_u errbuf[80];
7400
7401 while (*s && itemcnt < STL_MAX_ITEM)
7402 {
7403 /* Check for valid keys after % sequences */
7404 while (*s && *s != '%')
7405 s++;
7406 if (!*s)
7407 break;
7408 s++;
7409 if (*s != '%' && *s != ')')
7410 ++itemcnt;
7411 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7412 {
7413 s++;
7414 continue;
7415 }
7416 if (*s == ')')
7417 {
7418 s++;
7419 if (--groupdepth < 0)
7420 break;
7421 continue;
7422 }
7423 if (*s == '-')
7424 s++;
7425 while (VIM_ISDIGIT(*s))
7426 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007427 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007428 continue;
7429 if (*s == '.')
7430 {
7431 s++;
7432 while (*s && VIM_ISDIGIT(*s))
7433 s++;
7434 }
7435 if (*s == '(')
7436 {
7437 groupdepth++;
7438 continue;
7439 }
7440 if (vim_strchr(STL_ALL, *s) == NULL)
7441 {
7442 return illegal_char(errbuf, *s);
7443 }
7444 if (*s == '{')
7445 {
7446 s++;
7447 while (*s != '}' && *s)
7448 s++;
7449 if (*s != '}')
7450 return (char_u *)N_("E540: Unclosed expression sequence");
7451 }
7452 }
7453 if (itemcnt >= STL_MAX_ITEM)
7454 return (char_u *)N_("E541: too many items");
7455 if (groupdepth != 0)
7456 return (char_u *)N_("E542: unbalanced groups");
7457 return NULL;
7458}
7459#endif
7460
7461#ifdef FEAT_CLIPBOARD
7462/*
7463 * Extract the items in the 'clipboard' option and set global values.
7464 */
7465 static char_u *
7466check_clipboard_option()
7467{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007468 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007469 int new_autoselect_star = FALSE;
7470 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007471 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007472 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007473 regprog_T *new_exclude_prog = NULL;
7474 char_u *errmsg = NULL;
7475 char_u *p;
7476
7477 for (p = p_cb; *p != NUL; )
7478 {
7479 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7480 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007481 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007482 p += 7;
7483 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007484 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007485 && (p[11] == ',' || p[11] == NUL))
7486 {
7487 new_unnamed |= CLIP_UNNAMED_PLUS;
7488 p += 11;
7489 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007490 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007491 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007492 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007493 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007494 p += 10;
7495 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007496 else if (STRNCMP(p, "autoselectplus", 14) == 0
7497 && (p[14] == ',' || p[14] == NUL))
7498 {
7499 new_autoselect_plus = TRUE;
7500 p += 14;
7501 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007502 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007503 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007504 {
7505 new_autoselectml = TRUE;
7506 p += 12;
7507 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007508 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7509 {
7510 new_html = TRUE;
7511 p += 4;
7512 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007513 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7514 {
7515 p += 8;
7516 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7517 if (new_exclude_prog == NULL)
7518 errmsg = e_invarg;
7519 break;
7520 }
7521 else
7522 {
7523 errmsg = e_invarg;
7524 break;
7525 }
7526 if (*p == ',')
7527 ++p;
7528 }
7529 if (errmsg == NULL)
7530 {
7531 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007532 clip_autoselect_star = new_autoselect_star;
7533 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007534 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007535 clip_html = new_html;
Bram Moolenaar473de612013-06-08 18:19:48 +02007536 vim_regfree(clip_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007537 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02007538#ifdef FEAT_GUI_GTK
7539 if (gui.in_use)
7540 {
7541 gui_gtk_set_selection_targets();
7542 gui_gtk_set_dnd_targets();
7543 }
7544#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007545 }
7546 else
Bram Moolenaar473de612013-06-08 18:19:48 +02007547 vim_regfree(new_exclude_prog);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007548
7549 return errmsg;
7550}
7551#endif
7552
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007553#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007554/*
7555 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
7556 * Return error message when failed, NULL when OK.
7557 */
7558 static char_u *
Bram Moolenaar860cae12010-06-05 23:22:07 +02007559compile_cap_prog(synblock)
7560 synblock_T *synblock;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007561{
Bram Moolenaar860cae12010-06-05 23:22:07 +02007562 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007563 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007564
Bram Moolenaar860cae12010-06-05 23:22:07 +02007565 if (*synblock->b_p_spc == NUL)
7566 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007567 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007568 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007569 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007570 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007571 if (re != NULL)
7572 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007573 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
Bram Moolenaar473de612013-06-08 18:19:48 +02007574 vim_free(re);
Bram Moolenaar860cae12010-06-05 23:22:07 +02007575 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007576 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007577 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007578 return e_invarg;
7579 }
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007580 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007581 }
7582
Bram Moolenaar473de612013-06-08 18:19:48 +02007583 vim_regfree(rp);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007584 return NULL;
7585}
7586#endif
7587
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007588#if defined(FEAT_EVAL) || defined(PROTO)
7589/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007590 * Set the scriptID for an option, taking care of setting the buffer- or
7591 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007592 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007593 static void
7594set_option_scriptID_idx(opt_idx, opt_flags, id)
7595 int opt_idx;
7596 int opt_flags;
7597 int id;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007598{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007599 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
7600 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007601
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007602 /* Remember where the option was set. For local options need to do that
7603 * in the buffer or window structure. */
7604 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007605 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007606 if (both || (opt_flags & OPT_LOCAL))
7607 {
7608 if (indir & PV_BUF)
7609 curbuf->b_p_scriptID[indir & PV_MASK] = id;
7610 else if (indir & PV_WIN)
7611 curwin->w_p_scriptID[indir & PV_MASK] = id;
7612 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007613}
7614#endif
7615
Bram Moolenaar071d4272004-06-13 20:20:40 +00007616/*
7617 * Set the value of a boolean option, and take care of side effects.
7618 * Returns NULL for success, or an error message for an error.
7619 */
7620 static char_u *
7621set_bool_option(opt_idx, varp, value, opt_flags)
7622 int opt_idx; /* index in options[] table */
7623 char_u *varp; /* pointer to the option variable */
7624 int value; /* new value */
7625 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
7626{
7627 int old_value = *(int *)varp;
7628
Bram Moolenaar071d4272004-06-13 20:20:40 +00007629 /* Disallow changing some options from secure mode */
7630 if ((secure
7631#ifdef HAVE_SANDBOX
7632 || sandbox != 0
7633#endif
7634 ) && (options[opt_idx].flags & P_SECURE))
7635 return e_secure;
7636
7637 *(int *)varp = value; /* set the new value */
7638#ifdef FEAT_EVAL
7639 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007640 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007641#endif
7642
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00007643#ifdef FEAT_GUI
7644 need_mouse_correct = TRUE;
7645#endif
7646
Bram Moolenaar071d4272004-06-13 20:20:40 +00007647 /* May set global value for local option. */
7648 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
7649 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
7650
7651 /*
7652 * Handle side effects of changing a bool option.
7653 */
7654
7655 /* 'compatible' */
7656 if ((int *)varp == &p_cp)
7657 {
7658 compatible_set();
7659 }
7660
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007661#ifdef FEAT_PERSISTENT_UNDO
7662 /* 'undofile' */
7663 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
7664 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007665 /* Only take action when the option was set. When reset we do not
7666 * delete the undo file, the option may be set again without making
7667 * any changes in between. */
7668 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007669 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007670 char_u hash[UNDO_HASH_SIZE];
7671 buf_T *save_curbuf = curbuf;
7672
7673 for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007674 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007675 /* When 'undofile' is set globally: for every buffer, otherwise
7676 * only for the current buffer: Try to read in the undofile,
7677 * if one exists, the buffer wasn't changed and the buffer was
7678 * loaded */
7679 if ((curbuf == save_curbuf
7680 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
7681 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
7682 {
7683 u_compute_hash(hash);
7684 u_read_undo(NULL, hash, curbuf->b_fname);
7685 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007686 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007687 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007688 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007689 }
7690#endif
7691
Bram Moolenaar071d4272004-06-13 20:20:40 +00007692 else if ((int *)varp == &curbuf->b_p_ro)
7693 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007694 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007695 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
7696 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007697
7698 /* when 'readonly' is set may give W10 again */
7699 if (curbuf->b_p_ro)
7700 curbuf->b_did_warn = FALSE;
7701
Bram Moolenaar071d4272004-06-13 20:20:40 +00007702#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007703 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007704#endif
7705 }
7706
Bram Moolenaar9c449722010-07-20 18:44:27 +02007707#ifdef FEAT_GUI
7708 else if ((int *)varp == &p_mh)
7709 {
7710 if (!p_mh)
7711 gui_mch_mousehide(FALSE);
7712 }
7713#endif
7714
Bram Moolenaara539df02010-08-01 14:35:05 +02007715#ifdef FEAT_TITLE
7716 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007717 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007718 {
7719 redraw_titles();
7720 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007721 /* when 'endofline' is changed, redraw the window title */
7722 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007723 {
7724 redraw_titles();
7725 }
7726# ifdef FEAT_MBYTE
7727 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00007728 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007729 {
7730 redraw_titles();
7731 }
7732# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007733#endif
7734
7735 /* when 'bin' is set also set some other options */
7736 else if ((int *)varp == &curbuf->b_p_bin)
7737 {
7738 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
7739#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007740 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007741#endif
7742 }
7743
7744#ifdef FEAT_AUTOCMD
7745 /* when 'buflisted' changes, trigger autocommands */
7746 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
7747 {
7748 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
7749 NULL, NULL, TRUE, curbuf);
7750 }
7751#endif
7752
7753 /* when 'swf' is set, create swapfile, when reset remove swapfile */
7754 else if ((int *)varp == &curbuf->b_p_swf)
7755 {
7756 if (curbuf->b_p_swf && p_uc)
7757 ml_open_file(curbuf); /* create the swap file */
7758 else
Bram Moolenaard55de222007-05-06 13:38:48 +00007759 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
7760 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007761 mf_close_file(curbuf, TRUE); /* remove the swap file */
7762 }
7763
7764 /* when 'terse' is set change 'shortmess' */
7765 else if ((int *)varp == &p_terse)
7766 {
7767 char_u *p;
7768
7769 p = vim_strchr(p_shm, SHM_SEARCH);
7770
7771 /* insert 's' in p_shm */
7772 if (p_terse && p == NULL)
7773 {
7774 STRCPY(IObuff, p_shm);
7775 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007776 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007777 }
7778 /* remove 's' from p_shm */
7779 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007780 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007781 }
7782
7783 /* when 'paste' is set or reset also change other options */
7784 else if ((int *)varp == &p_paste)
7785 {
7786 paste_option_changed();
7787 }
7788
7789 /* when 'insertmode' is set from an autocommand need to do work here */
7790 else if ((int *)varp == &p_im)
7791 {
7792 if (p_im)
7793 {
7794 if ((State & INSERT) == 0)
7795 need_start_insertmode = TRUE;
7796 stop_insert_mode = FALSE;
7797 }
7798 else
7799 {
7800 need_start_insertmode = FALSE;
7801 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00007802 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007803 clear_cmdline = TRUE; /* remove "(insert)" */
7804 restart_edit = 0;
7805 }
7806 }
7807
7808 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
7809 else if ((int *)varp == &p_ic && p_hls)
7810 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007811 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007812 }
7813
7814#ifdef FEAT_SEARCH_EXTRA
7815 /* when 'hlsearch' is set or reset: reset no_hlsearch */
7816 else if ((int *)varp == &p_hls)
7817 {
Bram Moolenaar8050efa2013-11-08 04:30:20 +01007818 SET_NO_HLSEARCH(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007819 }
7820#endif
7821
7822#ifdef FEAT_SCROLLBIND
7823 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
7824 * at the end of normal_cmd() */
7825 else if ((int *)varp == &curwin->w_p_scb)
7826 {
7827 if (curwin->w_p_scb)
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02007828 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00007829 do_check_scrollbind(FALSE);
Bram Moolenaar04c5c9e2013-07-09 13:44:59 +02007830 curwin->w_scbind_pos = curwin->w_topline;
7831 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007832 }
7833#endif
7834
7835#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
7836 /* There can be only one window with 'previewwindow' set. */
7837 else if ((int *)varp == &curwin->w_p_pvw)
7838 {
7839 if (curwin->w_p_pvw)
7840 {
7841 win_T *win;
7842
7843 for (win = firstwin; win != NULL; win = win->w_next)
7844 if (win->w_p_pvw && win != curwin)
7845 {
7846 curwin->w_p_pvw = FALSE;
7847 return (char_u *)N_("E590: A preview window already exists");
7848 }
7849 }
7850 }
7851#endif
7852
7853 /* when 'textmode' is set or reset also change 'fileformat' */
7854 else if ((int *)varp == &curbuf->b_p_tx)
7855 {
7856 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
7857 }
7858
7859 /* when 'textauto' is set or reset also change 'fileformats' */
7860 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007861 set_string_option_direct((char_u *)"ffs", -1,
7862 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007863 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007864
7865 /*
7866 * When 'lisp' option changes include/exclude '-' in
7867 * keyword characters.
7868 */
7869#ifdef FEAT_LISP
7870 else if (varp == (char_u *)&(curbuf->b_p_lisp))
7871 {
7872 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
7873 }
7874#endif
7875
7876#ifdef FEAT_TITLE
7877 /* when 'title' changed, may need to change the title; same for 'icon' */
7878 else if ((int *)varp == &p_title)
7879 {
7880 did_set_title(FALSE);
7881 }
7882
7883 else if ((int *)varp == &p_icon)
7884 {
7885 did_set_title(TRUE);
7886 }
7887#endif
7888
7889 else if ((int *)varp == &curbuf->b_changed)
7890 {
7891 if (!value)
7892 save_file_ff(curbuf); /* Buffer is unchanged */
7893#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007894 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007895#endif
7896#ifdef FEAT_AUTOCMD
7897 modified_was_set = value;
7898#endif
7899 }
7900
7901#ifdef BACKSLASH_IN_FILENAME
7902 else if ((int *)varp == &p_ssl)
7903 {
7904 if (p_ssl)
7905 {
7906 psepc = '/';
7907 psepcN = '\\';
7908 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00007909 }
7910 else
7911 {
7912 psepc = '\\';
7913 psepcN = '/';
7914 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00007915 }
7916
7917 /* need to adjust the file name arguments and buffer names. */
7918 buflist_slash_adjust();
7919 alist_slash_adjust();
7920# ifdef FEAT_EVAL
7921 scriptnames_slash_adjust();
7922# endif
7923 }
7924#endif
7925
7926 /* If 'wrap' is set, set w_leftcol to zero. */
7927 else if ((int *)varp == &curwin->w_p_wrap)
7928 {
7929 if (curwin->w_p_wrap)
7930 curwin->w_leftcol = 0;
7931 }
7932
7933#ifdef FEAT_WINDOWS
7934 else if ((int *)varp == &p_ea)
7935 {
7936 if (p_ea && !old_value)
7937 win_equal(curwin, FALSE, 0);
7938 }
7939#endif
7940
7941 else if ((int *)varp == &p_wiv)
7942 {
7943 /*
7944 * When 'weirdinvert' changed, set/reset 't_xs'.
7945 * Then set 'weirdinvert' according to value of 't_xs'.
7946 */
7947 if (p_wiv && !old_value)
7948 T_XS = (char_u *)"y";
7949 else if (!p_wiv && old_value)
7950 T_XS = empty_option;
7951 p_wiv = (*T_XS != NUL);
7952 }
7953
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00007954#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00007955 else if ((int *)varp == &p_beval)
7956 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01007957 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007958 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01007959 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007960 gui_mch_disable_beval_area(balloonEval);
7961 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00007962#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007963
Bram Moolenaar8dff8182006-04-06 20:18:50 +00007964#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00007965 else if ((int *)varp == &p_acd)
7966 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00007967 /* Change directories when the 'acd' option is set now. */
7968 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00007969 }
7970#endif
7971
7972#ifdef FEAT_DIFF
7973 /* 'diff' */
7974 else if ((int *)varp == &curwin->w_p_diff)
7975 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00007976 /* May add or remove the buffer from the list of diff buffers. */
7977 diff_buf_adjust(curwin);
7978# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00007979 if (foldmethodIsDiff(curwin))
7980 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00007981# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007982 }
7983#endif
7984
7985#ifdef USE_IM_CONTROL
7986 /* 'imdisable' */
7987 else if ((int *)varp == &p_imdisable)
7988 {
7989 /* Only de-activate it here, it will be enabled when changing mode. */
7990 if (p_imdisable)
7991 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02007992 else if (State & INSERT)
7993 /* When the option is set from an autocommand, it may need to take
7994 * effect right away. */
7995 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007996 }
7997#endif
7998
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007999#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008000 /* 'spell' */
8001 else if ((int *)varp == &curwin->w_p_spell)
8002 {
8003 if (curwin->w_p_spell)
8004 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02008005 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00008006 if (errmsg != NULL)
8007 EMSG(_(errmsg));
8008 }
8009 }
8010#endif
8011
Bram Moolenaar071d4272004-06-13 20:20:40 +00008012#ifdef FEAT_FKMAP
8013 else if ((int *)varp == &p_altkeymap)
8014 {
8015 if (old_value != p_altkeymap)
8016 {
8017 if (!p_altkeymap)
8018 {
8019 p_hkmap = p_fkmap;
8020 p_fkmap = 0;
8021 }
8022 else
8023 {
8024 p_fkmap = p_hkmap;
8025 p_hkmap = 0;
8026 }
8027 (void)init_chartab();
8028 }
8029 }
8030
8031 /*
8032 * In case some second language keymapping options have changed, check
8033 * and correct the setting in a consistent way.
8034 */
8035
8036 /*
8037 * If hkmap or fkmap are set, reset Arabic keymapping.
8038 */
8039 if ((p_hkmap || p_fkmap) && p_altkeymap)
8040 {
8041 p_altkeymap = p_fkmap;
8042# ifdef FEAT_ARABIC
8043 curwin->w_p_arab = FALSE;
8044# endif
8045 (void)init_chartab();
8046 }
8047
8048 /*
8049 * If hkmap set, reset Farsi keymapping.
8050 */
8051 if (p_hkmap && p_altkeymap)
8052 {
8053 p_altkeymap = 0;
8054 p_fkmap = 0;
8055# ifdef FEAT_ARABIC
8056 curwin->w_p_arab = FALSE;
8057# endif
8058 (void)init_chartab();
8059 }
8060
8061 /*
8062 * If fkmap set, reset Hebrew keymapping.
8063 */
8064 if (p_fkmap && !p_altkeymap)
8065 {
8066 p_altkeymap = 1;
8067 p_hkmap = 0;
8068# ifdef FEAT_ARABIC
8069 curwin->w_p_arab = FALSE;
8070# endif
8071 (void)init_chartab();
8072 }
8073#endif
8074
8075#ifdef FEAT_ARABIC
8076 if ((int *)varp == &curwin->w_p_arab)
8077 {
8078 if (curwin->w_p_arab)
8079 {
8080 /*
8081 * 'arabic' is set, handle various sub-settings.
8082 */
8083 if (!p_tbidi)
8084 {
8085 /* set rightleft mode */
8086 if (!curwin->w_p_rl)
8087 {
8088 curwin->w_p_rl = TRUE;
8089 changed_window_setting();
8090 }
8091
8092 /* Enable Arabic shaping (major part of what Arabic requires) */
8093 if (!p_arshape)
8094 {
8095 p_arshape = TRUE;
8096 redraw_later_clear();
8097 }
8098 }
8099
8100 /* Arabic requires a utf-8 encoding, inform the user if its not
8101 * set. */
8102 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008103 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008104 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8105
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008106 msg_source(hl_attr(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008107 MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
8108#ifdef FEAT_EVAL
8109 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8110#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008111 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008112
8113# ifdef FEAT_MBYTE
8114 /* set 'delcombine' */
8115 p_deco = TRUE;
8116# endif
8117
8118# ifdef FEAT_KEYMAP
8119 /* Force-set the necessary keymap for arabic */
8120 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8121 OPT_LOCAL);
8122# endif
8123# ifdef FEAT_FKMAP
8124 p_altkeymap = 0;
8125 p_hkmap = 0;
8126 p_fkmap = 0;
8127 (void)init_chartab();
8128# endif
8129 }
8130 else
8131 {
8132 /*
8133 * 'arabic' is reset, handle various sub-settings.
8134 */
8135 if (!p_tbidi)
8136 {
8137 /* reset rightleft mode */
8138 if (curwin->w_p_rl)
8139 {
8140 curwin->w_p_rl = FALSE;
8141 changed_window_setting();
8142 }
8143
8144 /* 'arabicshape' isn't reset, it is a global option and
8145 * another window may still need it "on". */
8146 }
8147
8148 /* 'delcombine' isn't reset, it is a global option and another
8149 * window may still want it "on". */
8150
8151# ifdef FEAT_KEYMAP
8152 /* Revert to the default keymap */
8153 curbuf->b_p_iminsert = B_IMODE_NONE;
8154 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8155# endif
8156 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008157 }
8158
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008159#endif
8160
Bram Moolenaar071d4272004-06-13 20:20:40 +00008161 /*
8162 * End of handling side effects for bool options.
8163 */
8164
8165 options[opt_idx].flags |= P_WAS_SET;
8166
8167 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008168 if (curwin->w_curswant != MAXCOL
8169 && (options[opt_idx].flags & (P_CURSWANT | P_RCLR)) != 0)
8170 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008171 check_redraw(options[opt_idx].flags);
8172
8173 return NULL;
8174}
8175
8176/*
8177 * Set the value of a number option, and take care of side effects.
8178 * Returns NULL for success, or an error message for an error.
8179 */
8180 static char_u *
Bram Moolenaar555b2802005-05-19 21:08:39 +00008181set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008182 int opt_idx; /* index in options[] table */
8183 char_u *varp; /* pointer to the option variable */
8184 long value; /* new value */
8185 char_u *errbuf; /* buffer for error messages */
Bram Moolenaar555b2802005-05-19 21:08:39 +00008186 size_t errbuflen; /* length of "errbuf" */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008187 int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and
8188 OPT_MODELINE */
8189{
8190 char_u *errmsg = NULL;
8191 long old_value = *(long *)varp;
8192 long old_Rows = Rows; /* remember old Rows */
8193 long old_Columns = Columns; /* remember old Columns */
8194 long *pp = (long *)varp;
8195
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008196 /* Disallow changing some options from secure mode. */
8197 if ((secure
8198#ifdef HAVE_SANDBOX
8199 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008200#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008201 ) && (options[opt_idx].flags & P_SECURE))
8202 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008203
8204 *pp = value;
8205#ifdef FEAT_EVAL
8206 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008207 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008208#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008209#ifdef FEAT_GUI
8210 need_mouse_correct = TRUE;
8211#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008212
Bram Moolenaar14f24742012-08-08 18:01:05 +02008213 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008214 {
8215 errmsg = e_positive;
8216 curbuf->b_p_sw = curbuf->b_p_ts;
8217 }
8218
8219 /*
8220 * Number options that need some action when changed
8221 */
8222#ifdef FEAT_WINDOWS
8223 if (pp == &p_wh || pp == &p_hh)
8224 {
8225 if (p_wh < 1)
8226 {
8227 errmsg = e_positive;
8228 p_wh = 1;
8229 }
8230 if (p_wmh > p_wh)
8231 {
8232 errmsg = e_winheight;
8233 p_wh = p_wmh;
8234 }
8235 if (p_hh < 0)
8236 {
8237 errmsg = e_positive;
8238 p_hh = 0;
8239 }
8240
8241 /* Change window height NOW */
8242 if (lastwin != firstwin)
8243 {
8244 if (pp == &p_wh && curwin->w_height < p_wh)
8245 win_setheight((int)p_wh);
8246 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8247 win_setheight((int)p_hh);
8248 }
8249 }
8250
8251 /* 'winminheight' */
8252 else if (pp == &p_wmh)
8253 {
8254 if (p_wmh < 0)
8255 {
8256 errmsg = e_positive;
8257 p_wmh = 0;
8258 }
8259 if (p_wmh > p_wh)
8260 {
8261 errmsg = e_winheight;
8262 p_wmh = p_wh;
8263 }
8264 win_setminheight();
8265 }
8266
8267# ifdef FEAT_VERTSPLIT
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008268 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008269 {
8270 if (p_wiw < 1)
8271 {
8272 errmsg = e_positive;
8273 p_wiw = 1;
8274 }
8275 if (p_wmw > p_wiw)
8276 {
8277 errmsg = e_winwidth;
8278 p_wiw = p_wmw;
8279 }
8280
8281 /* Change window width NOW */
8282 if (lastwin != firstwin && curwin->w_width < p_wiw)
8283 win_setwidth((int)p_wiw);
8284 }
8285
8286 /* 'winminwidth' */
8287 else if (pp == &p_wmw)
8288 {
8289 if (p_wmw < 0)
8290 {
8291 errmsg = e_positive;
8292 p_wmw = 0;
8293 }
8294 if (p_wmw > p_wiw)
8295 {
8296 errmsg = e_winwidth;
8297 p_wmw = p_wiw;
8298 }
8299 win_setminheight();
8300 }
8301# endif
8302
8303#endif
8304
8305#ifdef FEAT_WINDOWS
8306 /* (re)set last window status line */
8307 else if (pp == &p_ls)
8308 {
8309 last_status(FALSE);
8310 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008311
8312 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008313 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008314 {
8315 shell_new_rows(); /* recompute window positions and heights */
8316 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008317#endif
8318
8319#ifdef FEAT_GUI
8320 else if (pp == &p_linespace)
8321 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008322 /* Recompute gui.char_height and resize the Vim window to keep the
8323 * same number of lines. */
8324 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008325 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008326 }
8327#endif
8328
8329#ifdef FEAT_FOLDING
8330 /* 'foldlevel' */
8331 else if (pp == &curwin->w_p_fdl)
8332 {
8333 if (curwin->w_p_fdl < 0)
8334 curwin->w_p_fdl = 0;
8335 newFoldLevel();
8336 }
8337
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008338 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008339 else if (pp == &curwin->w_p_fml)
8340 {
8341 foldUpdateAll(curwin);
8342 }
8343
8344 /* 'foldnestmax' */
8345 else if (pp == &curwin->w_p_fdn)
8346 {
8347 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8348 foldUpdateAll(curwin);
8349 }
8350
8351 /* 'foldcolumn' */
8352 else if (pp == &curwin->w_p_fdc)
8353 {
8354 if (curwin->w_p_fdc < 0)
8355 {
8356 errmsg = e_positive;
8357 curwin->w_p_fdc = 0;
8358 }
8359 else if (curwin->w_p_fdc > 12)
8360 {
8361 errmsg = e_invarg;
8362 curwin->w_p_fdc = 12;
8363 }
8364 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008365#endif /* FEAT_FOLDING */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008366
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008367#if defined(FEAT_FOLDING) || defined(FEAT_CINDENT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008368 /* 'shiftwidth' or 'tabstop' */
8369 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8370 {
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008371# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00008372 if (foldmethodIsIndent(curwin))
8373 foldUpdateAll(curwin);
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008374# endif
8375# ifdef FEAT_CINDENT
8376 /* When 'shiftwidth' changes, or it's zero and 'tabstop' changes:
8377 * parse 'cinoptions'. */
8378 if (pp == &curbuf->b_p_sw || curbuf->b_p_sw == 0)
8379 parse_cino(curbuf);
8380# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008381 }
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +01008382#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008383
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008384#ifdef FEAT_MBYTE
8385 /* 'maxcombine' */
8386 else if (pp == &p_mco)
8387 {
8388 if (p_mco > MAX_MCO)
8389 p_mco = MAX_MCO;
8390 else if (p_mco < 0)
8391 p_mco = 0;
8392 screenclear(); /* will re-allocate the screen */
8393 }
8394#endif
8395
Bram Moolenaar071d4272004-06-13 20:20:40 +00008396 else if (pp == &curbuf->b_p_iminsert)
8397 {
8398 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8399 {
8400 errmsg = e_invarg;
8401 curbuf->b_p_iminsert = B_IMODE_NONE;
8402 }
8403 p_iminsert = curbuf->b_p_iminsert;
8404 if (termcap_active) /* don't do this in the alternate screen */
8405 showmode();
8406#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8407 /* Show/unshow value of 'keymap' in status lines. */
8408 status_redraw_curbuf();
8409#endif
8410 }
8411
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008412 else if (pp == &p_window)
8413 {
8414 if (p_window < 1)
8415 p_window = 1;
8416 else if (p_window >= Rows)
8417 p_window = Rows - 1;
8418 }
8419
Bram Moolenaar071d4272004-06-13 20:20:40 +00008420 else if (pp == &curbuf->b_p_imsearch)
8421 {
8422 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8423 {
8424 errmsg = e_invarg;
8425 curbuf->b_p_imsearch = B_IMODE_NONE;
8426 }
8427 p_imsearch = curbuf->b_p_imsearch;
8428 }
8429
8430#ifdef FEAT_TITLE
8431 /* if 'titlelen' has changed, redraw the title */
8432 else if (pp == &p_titlelen)
8433 {
8434 if (p_titlelen < 0)
8435 {
8436 errmsg = e_positive;
8437 p_titlelen = 85;
8438 }
8439 if (starting != NO_SCREEN && old_value != p_titlelen)
8440 need_maketitle = TRUE;
8441 }
8442#endif
8443
8444 /* if p_ch changed value, change the command line height */
8445 else if (pp == &p_ch)
8446 {
8447 if (p_ch < 1)
8448 {
8449 errmsg = e_positive;
8450 p_ch = 1;
8451 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008452 if (p_ch > Rows - min_rows() + 1)
8453 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008454
8455 /* Only compute the new window layout when startup has been
8456 * completed. Otherwise the frame sizes may be wrong. */
8457 if (p_ch != old_value && full_screen
8458#ifdef FEAT_GUI
8459 && !gui.starting
8460#endif
8461 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008462 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008463 }
8464
8465 /* when 'updatecount' changes from zero to non-zero, open swap files */
8466 else if (pp == &p_uc)
8467 {
8468 if (p_uc < 0)
8469 {
8470 errmsg = e_positive;
8471 p_uc = 100;
8472 }
8473 if (p_uc && !old_value)
8474 ml_open_files();
8475 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008476#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008477 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008478 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008479 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008480 {
8481 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008482 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008483 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008484 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008485 {
8486 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008487 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008488 }
8489 }
8490#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008491#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008492 else if (pp == &p_mzq)
8493 mzvim_reset_timer();
8494#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008495
8496 /* sync undo before 'undolevels' changes */
8497 else if (pp == &p_ul)
8498 {
8499 /* use the old value, otherwise u_sync() may not work properly */
8500 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00008501 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008502 p_ul = value;
8503 }
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01008504 else if (pp == &curbuf->b_p_ul)
8505 {
8506 /* use the old value, otherwise u_sync() may not work properly */
8507 curbuf->b_p_ul = old_value;
8508 u_sync(TRUE);
8509 curbuf->b_p_ul = value;
8510 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008511
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008512#ifdef FEAT_LINEBREAK
8513 /* 'numberwidth' must be positive */
8514 else if (pp == &curwin->w_p_nuw)
8515 {
8516 if (curwin->w_p_nuw < 1)
8517 {
8518 errmsg = e_positive;
8519 curwin->w_p_nuw = 1;
8520 }
8521 if (curwin->w_p_nuw > 10)
8522 {
8523 errmsg = e_invarg;
8524 curwin->w_p_nuw = 10;
8525 }
8526 curwin->w_nrwidth_line_count = 0;
8527 }
8528#endif
8529
Bram Moolenaar1a384422010-07-14 19:53:30 +02008530 else if (pp == &curbuf->b_p_tw)
8531 {
8532 if (curbuf->b_p_tw < 0)
8533 {
8534 errmsg = e_positive;
8535 curbuf->b_p_tw = 0;
8536 }
8537#ifdef FEAT_SYN_HL
8538# ifdef FEAT_WINDOWS
8539 {
8540 win_T *wp;
8541 tabpage_T *tp;
8542
8543 FOR_ALL_TAB_WINDOWS(tp, wp)
8544 check_colorcolumn(wp);
8545 }
8546# else
8547 check_colorcolumn(curwin);
8548# endif
8549#endif
8550 }
8551
Bram Moolenaar071d4272004-06-13 20:20:40 +00008552 /*
8553 * Check the bounds for numeric options here
8554 */
8555 if (Rows < min_rows() && full_screen)
8556 {
8557 if (errbuf != NULL)
8558 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008559 vim_snprintf((char *)errbuf, errbuflen,
8560 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00008561 errmsg = errbuf;
8562 }
8563 Rows = min_rows();
8564 }
8565 if (Columns < MIN_COLUMNS && full_screen)
8566 {
8567 if (errbuf != NULL)
8568 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008569 vim_snprintf((char *)errbuf, errbuflen,
8570 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008571 errmsg = errbuf;
8572 }
8573 Columns = MIN_COLUMNS;
8574 }
Bram Moolenaare057d402013-06-30 17:51:51 +02008575 limit_screen_size();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008576
8577#ifdef DJGPP
8578 /* avoid a crash by checking for a too large value of 'columns' */
8579 if (old_Columns != Columns && full_screen && term_console)
8580 mch_check_columns();
8581#endif
8582
8583 /*
8584 * If the screen (shell) height has been changed, assume it is the
8585 * physical screenheight.
8586 */
8587 if (old_Rows != Rows || old_Columns != Columns)
8588 {
8589 /* Changing the screen size is not allowed while updating the screen. */
8590 if (updating_screen)
8591 *pp = old_value;
8592 else if (full_screen
8593#ifdef FEAT_GUI
8594 && !gui.starting
8595#endif
8596 )
8597 set_shellsize((int)Columns, (int)Rows, TRUE);
8598 else
8599 {
8600 /* Postpone the resizing; check the size and cmdline position for
8601 * messages. */
8602 check_shellsize();
8603 if (cmdline_row > Rows - p_ch && Rows > p_ch)
8604 cmdline_row = Rows - p_ch;
8605 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00008606 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008607 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008608 }
8609
Bram Moolenaar071d4272004-06-13 20:20:40 +00008610 if (curbuf->b_p_ts <= 0)
8611 {
8612 errmsg = e_positive;
8613 curbuf->b_p_ts = 8;
8614 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008615 if (p_tm < 0)
8616 {
8617 errmsg = e_positive;
8618 p_tm = 0;
8619 }
8620 if ((curwin->w_p_scr <= 0
8621 || (curwin->w_p_scr > curwin->w_height
8622 && curwin->w_height > 0))
8623 && full_screen)
8624 {
8625 if (pp == &(curwin->w_p_scr))
8626 {
8627 if (curwin->w_p_scr != 0)
8628 errmsg = e_scroll;
8629 win_comp_scroll(curwin);
8630 }
8631 /* If 'scroll' became invalid because of a side effect silently adjust
8632 * it. */
8633 else if (curwin->w_p_scr <= 0)
8634 curwin->w_p_scr = 1;
8635 else /* curwin->w_p_scr > curwin->w_height */
8636 curwin->w_p_scr = curwin->w_height;
8637 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00008638 if (p_hi < 0)
8639 {
8640 errmsg = e_positive;
8641 p_hi = 0;
8642 }
Bram Moolenaarfbc0d2e2013-05-19 19:40:29 +02008643 if (p_re < 0 || p_re > 2)
8644 {
8645 errmsg = e_invarg;
8646 p_re = 0;
8647 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008648 if (p_report < 0)
8649 {
8650 errmsg = e_positive;
8651 p_report = 1;
8652 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00008653 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008654 {
8655 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
8656 p_sj = Rows / 2;
8657 else
8658 {
8659 errmsg = e_scroll;
8660 p_sj = 1;
8661 }
8662 }
8663 if (p_so < 0 && full_screen)
8664 {
8665 errmsg = e_scroll;
8666 p_so = 0;
8667 }
8668 if (p_siso < 0 && full_screen)
8669 {
8670 errmsg = e_positive;
8671 p_siso = 0;
8672 }
8673#ifdef FEAT_CMDWIN
8674 if (p_cwh < 1)
8675 {
8676 errmsg = e_positive;
8677 p_cwh = 1;
8678 }
8679#endif
8680 if (p_ut < 0)
8681 {
8682 errmsg = e_positive;
8683 p_ut = 2000;
8684 }
8685 if (p_ss < 0)
8686 {
8687 errmsg = e_positive;
8688 p_ss = 0;
8689 }
8690
8691 /* May set global value for local option. */
8692 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8693 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
8694
8695 options[opt_idx].flags |= P_WAS_SET;
8696
8697 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008698 if (curwin->w_curswant != MAXCOL
8699 && (options[opt_idx].flags & (P_CURSWANT | P_RCLR)) != 0)
8700 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008701 check_redraw(options[opt_idx].flags);
8702
8703 return errmsg;
8704}
8705
8706/*
8707 * Called after an option changed: check if something needs to be redrawn.
8708 */
8709 static void
8710check_redraw(flags)
8711 long_u flags;
8712{
8713 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008714 int doclear = (flags & P_RCLR) == P_RCLR;
8715 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008716
8717#ifdef FEAT_WINDOWS
8718 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
8719 status_redraw_all();
8720#endif
8721
8722 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
8723 changed_window_setting();
8724 if (flags & P_RBUF)
8725 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008726 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008727 redraw_all_later(CLEAR);
8728 else if (all)
8729 redraw_all_later(NOT_VALID);
8730}
8731
8732/*
8733 * Find index for option 'arg'.
8734 * Return -1 if not found.
8735 */
8736 static int
8737findoption(arg)
8738 char_u *arg;
8739{
8740 int opt_idx;
8741 char *s, *p;
8742 static short quick_tab[27] = {0, 0}; /* quick access table */
8743 int is_term_opt;
8744
8745 /*
8746 * For first call: Initialize the quick-access table.
8747 * It contains the index for the first option that starts with a certain
8748 * letter. There are 26 letters, plus the first "t_" option.
8749 */
8750 if (quick_tab[1] == 0)
8751 {
8752 p = options[0].fullname;
8753 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8754 {
8755 if (s[0] != p[0])
8756 {
8757 if (s[0] == 't' && s[1] == '_')
8758 quick_tab[26] = opt_idx;
8759 else
8760 quick_tab[CharOrdLow(s[0])] = opt_idx;
8761 }
8762 p = s;
8763 }
8764 }
8765
8766 /*
8767 * Check for name starting with an illegal character.
8768 */
8769#ifdef EBCDIC
8770 if (!islower(arg[0]))
8771#else
8772 if (arg[0] < 'a' || arg[0] > 'z')
8773#endif
8774 return -1;
8775
8776 is_term_opt = (arg[0] == 't' && arg[1] == '_');
8777 if (is_term_opt)
8778 opt_idx = quick_tab[26];
8779 else
8780 opt_idx = quick_tab[CharOrdLow(arg[0])];
8781 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8782 {
8783 if (STRCMP(arg, s) == 0) /* match full name */
8784 break;
8785 }
8786 if (s == NULL && !is_term_opt)
8787 {
8788 opt_idx = quick_tab[CharOrdLow(arg[0])];
8789 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
8790 {
8791 s = options[opt_idx].shortname;
8792 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
8793 break;
8794 s = NULL;
8795 }
8796 }
8797 if (s == NULL)
8798 opt_idx = -1;
8799 return opt_idx;
8800}
8801
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008802#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008803/*
8804 * Get the value for an option.
8805 *
8806 * Returns:
8807 * Number or Toggle option: 1, *numval gets value.
8808 * String option: 0, *stringval gets allocated string.
8809 * Hidden Number or Toggle option: -1.
8810 * hidden String option: -2.
8811 * unknown option: -3.
8812 */
8813 int
8814get_option_value(name, numval, stringval, opt_flags)
8815 char_u *name;
8816 long *numval;
Bram Moolenaar370df582010-06-22 05:16:38 +02008817 char_u **stringval; /* NULL when only checking existence */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008818 int opt_flags;
8819{
8820 int opt_idx;
8821 char_u *varp;
8822
8823 opt_idx = findoption(name);
8824 if (opt_idx < 0) /* unknown option */
8825 return -3;
8826
8827 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
8828
8829 if (options[opt_idx].flags & P_STRING)
8830 {
8831 if (varp == NULL) /* hidden option */
8832 return -2;
8833 if (stringval != NULL)
8834 {
8835#ifdef FEAT_CRYPT
8836 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00008837 if ((char_u **)varp == &curbuf->b_p_key
8838 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008839 *stringval = vim_strsave((char_u *)"*****");
8840 else
8841#endif
8842 *stringval = vim_strsave(*(char_u **)(varp));
8843 }
8844 return 0;
8845 }
8846
8847 if (varp == NULL) /* hidden option */
8848 return -1;
8849 if (options[opt_idx].flags & P_NUM)
8850 *numval = *(long *)varp;
8851 else
8852 {
8853 /* Special case: 'modified' is b_changed, but we also want to consider
8854 * it set when 'ff' or 'fenc' changed. */
8855 if ((int *)varp == &curbuf->b_changed)
8856 *numval = curbufIsChanged();
8857 else
8858 *numval = *(int *)varp;
8859 }
8860 return 1;
8861}
8862#endif
8863
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01008864#if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02008865/*
8866 * Returns the option attributes and its value. Unlike the above function it
8867 * will return either global value or local value of the option depending on
8868 * what was requested, but it will never return global value if it was
8869 * requested to return local one and vice versa. Neither it will return
8870 * buffer-local value if it was requested to return window-local one.
8871 *
8872 * Pretends that option is absent if it is not present in the requested scope
8873 * (i.e. has no global, window-local or buffer-local value depending on
8874 * opt_type). Uses
8875 *
8876 * Returned flags:
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01008877 * 0 hidden or unknown option, also option that does not have requested
8878 * type (see SREQ_* in vim.h)
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02008879 * see SOPT_* in vim.h for other flags
8880 *
8881 * Possible opt_type values: see SREQ_* in vim.h
8882 */
8883 int
8884get_option_value_strict(name, numval, stringval, opt_type, from)
8885 char_u *name;
8886 long *numval;
8887 char_u **stringval; /* NULL when only obtaining attributes */
8888 int opt_type;
8889 void *from;
8890{
8891 int opt_idx;
Bram Moolenaar68001862013-05-11 13:45:05 +02008892 char_u *varp = NULL;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02008893 struct vimoption *p;
8894 int r = 0;
8895
8896 opt_idx = findoption(name);
8897 if (opt_idx < 0)
8898 return 0;
8899
8900 p = &(options[opt_idx]);
8901
8902 /* Hidden option */
8903 if (p->var == NULL)
8904 return 0;
8905
8906 if (p->flags & P_BOOL)
8907 r |= SOPT_BOOL;
8908 else if (p->flags & P_NUM)
8909 r |= SOPT_NUM;
8910 else if (p->flags & P_STRING)
8911 r |= SOPT_STRING;
8912
8913 if (p->indir == PV_NONE)
8914 {
8915 if (opt_type == SREQ_GLOBAL)
8916 r |= SOPT_GLOBAL;
8917 else
8918 return 0; /* Did not request global-only option */
8919 }
8920 else
8921 {
8922 if (p->indir & PV_BOTH)
8923 r |= SOPT_GLOBAL;
8924 else if (opt_type == SREQ_GLOBAL)
8925 return 0; /* Requested global option */
8926
8927 if (p->indir & PV_WIN)
8928 {
8929 if (opt_type == SREQ_BUF)
8930 return 0; /* Did not request window-local option */
8931 else
8932 r |= SOPT_WIN;
8933 }
8934 else if (p->indir & PV_BUF)
8935 {
8936 if (opt_type == SREQ_WIN)
8937 return 0; /* Did not request buffer-local option */
8938 else
8939 r |= SOPT_BUF;
8940 }
8941 }
8942
8943 if (stringval == NULL)
8944 return r;
8945
8946 if (opt_type == SREQ_GLOBAL)
8947 varp = p->var;
8948 else
8949 {
8950 if (opt_type == SREQ_BUF)
8951 {
8952 /* Special case: 'modified' is b_changed, but we also want to
8953 * consider it set when 'ff' or 'fenc' changed. */
8954 if (p->indir == PV_MOD)
8955 {
8956 *numval = bufIsChanged((buf_T *) from);
8957 varp = NULL;
8958 }
8959#ifdef FEAT_CRYPT
8960 else if (p->indir == PV_KEY)
8961 {
8962 /* never return the value of the crypt key */
8963 *stringval = NULL;
8964 varp = NULL;
8965 }
8966#endif
8967 else
8968 {
8969 aco_save_T aco;
8970 aucmd_prepbuf(&aco, (buf_T *) from);
8971 varp = get_varp(p);
8972 aucmd_restbuf(&aco);
8973 }
8974 }
8975 else if (opt_type == SREQ_WIN)
8976 {
8977 win_T *save_curwin;
8978 save_curwin = curwin;
8979 curwin = (win_T *) from;
8980 curbuf = curwin->w_buffer;
8981 varp = get_varp(p);
8982 curwin = save_curwin;
8983 curbuf = curwin->w_buffer;
8984 }
8985 if (varp == p->var)
8986 return (r | SOPT_UNSET);
8987 }
8988
8989 if (varp != NULL)
8990 {
8991 if (p->flags & P_STRING)
8992 *stringval = vim_strsave(*(char_u **)(varp));
8993 else if (p->flags & P_NUM)
8994 *numval = *(long *) varp;
8995 else
8996 *numval = *(int *)varp;
8997 }
8998
8999 return r;
9000}
Bram Moolenaar1028f4d2014-01-14 16:55:00 +01009001
9002/*
9003 * Iterate over options. First argument is a pointer to a pointer to a structure
9004 * inside options[] array, second is option type like in the above function.
9005 *
9006 * If first argument points to NULL it is assumed that iteration just started
9007 * and caller needs the very first value.
9008 * If first argument points to the end marker function returns NULL and sets
9009 * first argument to NULL.
9010 *
9011 * Returns full option name for current option on each call.
9012 */
9013 char_u *
9014option_iter_next(option, opt_type)
9015 void **option;
9016 int opt_type;
9017{
9018 struct vimoption *ret = NULL;
9019 do
9020 {
9021 if (*option == NULL)
9022 *option = (void *) options;
9023 else if (((struct vimoption *) (*option))->fullname == NULL)
9024 {
9025 *option = NULL;
9026 return NULL;
9027 }
9028 else
9029 *option = (void *) (((struct vimoption *) (*option)) + 1);
9030
9031 ret = ((struct vimoption *) (*option));
9032
9033 /* Hidden option */
9034 if (ret->var == NULL)
9035 {
9036 ret = NULL;
9037 continue;
9038 }
9039
9040 switch (opt_type)
9041 {
9042 case SREQ_GLOBAL:
9043 if (!(ret->indir == PV_NONE || ret->indir & PV_BOTH))
9044 ret = NULL;
9045 break;
9046 case SREQ_BUF:
9047 if (!(ret->indir & PV_BUF))
9048 ret = NULL;
9049 break;
9050 case SREQ_WIN:
9051 if (!(ret->indir & PV_WIN))
9052 ret = NULL;
9053 break;
9054 default:
9055 EMSG2(_(e_intern2), "option_iter_next()");
9056 return NULL;
9057 }
9058 }
9059 while (ret == NULL);
9060
9061 return (char_u *)ret->fullname;
9062}
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009063#endif
9064
Bram Moolenaar071d4272004-06-13 20:20:40 +00009065/*
9066 * Set the value of option "name".
9067 * Use "string" for string options, use "number" for other options.
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009068 *
9069 * Returns NULL on success or error message on error.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009070 */
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009071 char_u *
Bram Moolenaar071d4272004-06-13 20:20:40 +00009072set_option_value(name, number, string, opt_flags)
9073 char_u *name;
9074 long number;
9075 char_u *string;
9076 int opt_flags; /* OPT_LOCAL or 0 (both) */
9077{
9078 int opt_idx;
9079 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00009080 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009081
9082 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00009083 if (opt_idx < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009084 EMSG2(_("E355: Unknown option: %s"), name);
9085 else
9086 {
9087 flags = options[opt_idx].flags;
9088#ifdef HAVE_SANDBOX
9089 /* Disallow changing some options in the sandbox */
9090 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009091 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00009092 EMSG(_(e_sandbox));
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009093 return NULL;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009094 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009095#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009096 if (flags & P_STRING)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009097 return set_string_option(opt_idx, string, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009098 else
9099 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00009100 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009101 if (varp != NULL) /* hidden option is not changed */
9102 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009103 if (number == 0 && string != NULL)
9104 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009105 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009106
9107 /* Either we are given a string or we are setting option
9108 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009109 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009110 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00009111 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009112 {
9113 /* There's another character after zeros or the string
9114 * is empty. In both cases, we are trying to set a
9115 * num option using a string. */
9116 EMSG3(_("E521: Number required: &%s = '%s'"),
9117 name, string);
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009118 return NULL; /* do nothing as we hit an error */
Bram Moolenaar96bb6212007-06-19 18:52:53 +00009119
9120 }
9121 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009122 if (flags & P_NUM)
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009123 return set_num_option(opt_idx, varp, number,
Bram Moolenaar555b2802005-05-19 21:08:39 +00009124 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009125 else
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009126 return set_bool_option(opt_idx, varp, (int)number,
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00009127 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009128 }
9129 }
9130 }
Bram Moolenaarc96ebe72013-05-21 22:38:18 +02009131 return NULL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009132}
9133
9134/*
9135 * Get the terminal code for a terminal option.
9136 * Returns NULL when not found.
9137 */
9138 char_u *
9139get_term_code(tname)
9140 char_u *tname;
9141{
9142 int opt_idx;
9143 char_u *varp;
9144
9145 if (tname[0] != 't' || tname[1] != '_' ||
9146 tname[2] == NUL || tname[3] == NUL)
9147 return NULL;
9148 if ((opt_idx = findoption(tname)) >= 0)
9149 {
9150 varp = get_varp(&(options[opt_idx]));
9151 if (varp != NULL)
9152 varp = *(char_u **)(varp);
9153 return varp;
9154 }
9155 return find_termcode(tname + 2);
9156}
9157
9158 char_u *
9159get_highlight_default()
9160{
9161 int i;
9162
9163 i = findoption((char_u *)"hl");
9164 if (i >= 0)
9165 return options[i].def_val[VI_DEFAULT];
9166 return (char_u *)NULL;
9167}
9168
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00009169#if defined(FEAT_MBYTE) || defined(PROTO)
9170 char_u *
9171get_encoding_default()
9172{
9173 int i;
9174
9175 i = findoption((char_u *)"enc");
9176 if (i >= 0)
9177 return options[i].def_val[VI_DEFAULT];
9178 return (char_u *)NULL;
9179}
9180#endif
9181
Bram Moolenaar071d4272004-06-13 20:20:40 +00009182/*
9183 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
9184 */
9185 static int
9186find_key_option(arg)
9187 char_u *arg;
9188{
9189 int key;
9190 int modifiers;
9191
9192 /*
9193 * Don't use get_special_key_code() for t_xx, we don't want it to call
9194 * add_termcap_entry().
9195 */
9196 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
9197 key = TERMCAP2KEY(arg[2], arg[3]);
9198 else
9199 {
9200 --arg; /* put arg at the '<' */
9201 modifiers = 0;
Bram Moolenaar2a8ced02008-12-24 11:54:31 +00009202 key = find_special_key(&arg, &modifiers, TRUE, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009203 if (modifiers) /* can't handle modifiers here */
9204 key = 0;
9205 }
9206 return key;
9207}
9208
9209/*
9210 * if 'all' == 0: show changed options
9211 * if 'all' == 1: show all normal options
9212 * if 'all' == 2: show all terminal options
9213 */
9214 static void
9215showoptions(all, opt_flags)
9216 int all;
9217 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
9218{
9219 struct vimoption *p;
9220 int col;
9221 int isterm;
9222 char_u *varp;
9223 struct vimoption **items;
9224 int item_count;
9225 int run;
9226 int row, rows;
9227 int cols;
9228 int i;
9229 int len;
9230
9231#define INC 20
9232#define GAP 3
9233
9234 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
9235 PARAM_COUNT));
9236 if (items == NULL)
9237 return;
9238
9239 /* Highlight title */
9240 if (all == 2)
9241 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
9242 else if (opt_flags & OPT_GLOBAL)
9243 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
9244 else if (opt_flags & OPT_LOCAL)
9245 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
9246 else
9247 MSG_PUTS_TITLE(_("\n--- Options ---"));
9248
9249 /*
9250 * do the loop two times:
9251 * 1. display the short items
9252 * 2. display the long items (only strings and numbers)
9253 */
9254 for (run = 1; run <= 2 && !got_int; ++run)
9255 {
9256 /*
9257 * collect the items in items[]
9258 */
9259 item_count = 0;
9260 for (p = &options[0]; p->fullname != NULL; p++)
9261 {
9262 varp = NULL;
9263 isterm = istermoption(p);
9264 if (opt_flags != 0)
9265 {
9266 if (p->indir != PV_NONE && !isterm)
9267 varp = get_varp_scope(p, opt_flags);
9268 }
9269 else
9270 varp = get_varp(p);
9271 if (varp != NULL
9272 && ((all == 2 && isterm)
9273 || (all == 1 && !isterm)
9274 || (all == 0 && !optval_default(p, varp))))
9275 {
9276 if (p->flags & P_BOOL)
9277 len = 1; /* a toggle option fits always */
9278 else
9279 {
9280 option_value2string(p, opt_flags);
9281 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9282 }
9283 if ((len <= INC - GAP && run == 1) ||
9284 (len > INC - GAP && run == 2))
9285 items[item_count++] = p;
9286 }
9287 }
9288
9289 /*
9290 * display the items
9291 */
9292 if (run == 1)
9293 {
9294 cols = (Columns + GAP - 3) / INC;
9295 if (cols == 0)
9296 cols = 1;
9297 rows = (item_count + cols - 1) / cols;
9298 }
9299 else /* run == 2 */
9300 rows = item_count;
9301 for (row = 0; row < rows && !got_int; ++row)
9302 {
9303 msg_putchar('\n'); /* go to next line */
9304 if (got_int) /* 'q' typed in more */
9305 break;
9306 col = 0;
9307 for (i = row; i < item_count; i += rows)
9308 {
9309 msg_col = col; /* make columns */
9310 showoneopt(items[i], opt_flags);
9311 col += INC;
9312 }
9313 out_flush();
9314 ui_breakcheck();
9315 }
9316 }
9317 vim_free(items);
9318}
9319
9320/*
9321 * Return TRUE if option "p" has its default value.
9322 */
9323 static int
9324optval_default(p, varp)
9325 struct vimoption *p;
9326 char_u *varp;
9327{
9328 int dvi;
9329
9330 if (varp == NULL)
9331 return TRUE; /* hidden option is always at default */
9332 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9333 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009334 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009335 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009336 /* the cast to long is required for Manx C, long_i is
9337 * needed for MSVC */
9338 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009339 /* P_STRING */
9340 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9341}
9342
9343/*
9344 * showoneopt: show the value of one option
9345 * must not be called with a hidden option!
9346 */
9347 static void
9348showoneopt(p, opt_flags)
9349 struct vimoption *p;
9350 int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */
9351{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009352 char_u *varp;
9353 int save_silent = silent_mode;
9354
9355 silent_mode = FALSE;
9356 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009357
9358 varp = get_varp_scope(p, opt_flags);
9359
9360 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9361 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9362 ? !curbufIsChanged() : !*(int *)varp))
9363 MSG_PUTS("no");
9364 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9365 MSG_PUTS("--");
9366 else
9367 MSG_PUTS(" ");
9368 MSG_PUTS(p->fullname);
9369 if (!(p->flags & P_BOOL))
9370 {
9371 msg_putchar('=');
9372 /* put value string in NameBuff */
9373 option_value2string(p, opt_flags);
9374 msg_outtrans(NameBuff);
9375 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009376
9377 silent_mode = save_silent;
9378 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009379}
9380
9381/*
9382 * Write modified options as ":set" commands to a file.
9383 *
9384 * There are three values for "opt_flags":
9385 * OPT_GLOBAL: Write global option values and fresh values of
9386 * buffer-local options (used for start of a session
9387 * file).
9388 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
9389 * curwin (used for a vimrc file).
9390 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
9391 * and local values for window-local options of
9392 * curwin. Local values are also written when at the
9393 * default value, because a modeline or autocommand
9394 * may have set them when doing ":edit file" and the
9395 * user has set them back at the default or fresh
9396 * value.
9397 * When "local_only" is TRUE, don't write fresh
9398 * values, only local values (for ":mkview").
9399 * (fresh value = value used for a new buffer or window for a local option).
9400 *
9401 * Return FAIL on error, OK otherwise.
9402 */
9403 int
9404makeset(fd, opt_flags, local_only)
9405 FILE *fd;
9406 int opt_flags;
9407 int local_only;
9408{
9409 struct vimoption *p;
9410 char_u *varp; /* currently used value */
9411 char_u *varp_fresh; /* local value */
9412 char_u *varp_local = NULL; /* fresh value */
9413 char *cmd;
9414 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009415 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009416
9417 /*
9418 * The options that don't have a default (terminal name, columns, lines)
9419 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009420 * Do the loop over "options[]" twice: once for options with the
9421 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009422 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009423 for (pri = 1; pri >= 0; --pri)
9424 {
9425 for (p = &options[0]; !istermoption(p); p++)
9426 if (!(p->flags & P_NO_MKRC)
9427 && !istermoption(p)
9428 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009429 {
9430 /* skip global option when only doing locals */
9431 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
9432 continue;
9433
9434 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
9435 * file, they are always buffer-specific. */
9436 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
9437 continue;
9438
9439 /* Global values are only written when not at the default value. */
9440 varp = get_varp_scope(p, opt_flags);
9441 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
9442 continue;
9443
9444 round = 2;
9445 if (p->indir != PV_NONE)
9446 {
9447 if (p->var == VAR_WIN)
9448 {
9449 /* skip window-local option when only doing globals */
9450 if (!(opt_flags & OPT_LOCAL))
9451 continue;
9452 /* When fresh value of window-local option is not at the
9453 * default, need to write it too. */
9454 if (!(opt_flags & OPT_GLOBAL) && !local_only)
9455 {
9456 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
9457 if (!optval_default(p, varp_fresh))
9458 {
9459 round = 1;
9460 varp_local = varp;
9461 varp = varp_fresh;
9462 }
9463 }
9464 }
9465 }
9466
9467 /* Round 1: fresh value for window-local options.
9468 * Round 2: other values */
9469 for ( ; round <= 2; varp = varp_local, ++round)
9470 {
9471 if (round == 1 || (opt_flags & OPT_GLOBAL))
9472 cmd = "set";
9473 else
9474 cmd = "setlocal";
9475
9476 if (p->flags & P_BOOL)
9477 {
9478 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
9479 return FAIL;
9480 }
9481 else if (p->flags & P_NUM)
9482 {
9483 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
9484 return FAIL;
9485 }
9486 else /* P_STRING */
9487 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009488#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9489 int do_endif = FALSE;
9490
Bram Moolenaar071d4272004-06-13 20:20:40 +00009491 /* Don't set 'syntax' and 'filetype' again if the value is
9492 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009493 if (
9494# if defined(FEAT_SYN_HL)
9495 p->indir == PV_SYN
9496# if defined(FEAT_AUTOCMD)
9497 ||
9498# endif
9499# endif
9500# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009501 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009502# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009503 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00009504 {
9505 if (fprintf(fd, "if &%s != '%s'", p->fullname,
9506 *(char_u **)(varp)) < 0
9507 || put_eol(fd) < 0)
9508 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009509 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009510 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009511#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009512 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
9513 (p->flags & P_EXPAND) != 0) == FAIL)
9514 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009515#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9516 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009517 {
9518 if (put_line(fd, "endif") == FAIL)
9519 return FAIL;
9520 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009521#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009522 }
9523 }
9524 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009525 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009526 return OK;
9527}
9528
9529#if defined(FEAT_FOLDING) || defined(PROTO)
9530/*
9531 * Generate set commands for the local fold options only. Used when
9532 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
9533 */
9534 int
9535makefoldset(fd)
9536 FILE *fd;
9537{
9538 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
9539# ifdef FEAT_EVAL
9540 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
9541 == FAIL
9542# endif
9543 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
9544 == FAIL
9545 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
9546 == FAIL
9547 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
9548 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
9549 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
9550 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
9551 )
9552 return FAIL;
9553
9554 return OK;
9555}
9556#endif
9557
9558 static int
9559put_setstring(fd, cmd, name, valuep, expand)
9560 FILE *fd;
9561 char *cmd;
9562 char *name;
9563 char_u **valuep;
9564 int expand;
9565{
9566 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009567 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009568
9569 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9570 return FAIL;
9571 if (*valuep != NULL)
9572 {
9573 /* Output 'pastetoggle' as key names. For other
9574 * options some characters have to be escaped with
9575 * CTRL-V or backslash */
9576 if (valuep == &p_pt)
9577 {
9578 s = *valuep;
9579 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +00009580 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009581 return FAIL;
9582 }
9583 else if (expand)
9584 {
Bram Moolenaarf8441472011-04-28 17:24:58 +02009585 buf = alloc(MAXPATHL);
9586 if (buf == NULL)
9587 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009588 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
9589 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +02009590 {
9591 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009592 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009593 }
9594 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009595 }
9596 else if (put_escstr(fd, *valuep, 2) == FAIL)
9597 return FAIL;
9598 }
9599 if (put_eol(fd) < 0)
9600 return FAIL;
9601 return OK;
9602}
9603
9604 static int
9605put_setnum(fd, cmd, name, valuep)
9606 FILE *fd;
9607 char *cmd;
9608 char *name;
9609 long *valuep;
9610{
9611 long wc;
9612
9613 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9614 return FAIL;
9615 if (wc_use_keyname((char_u *)valuep, &wc))
9616 {
9617 /* print 'wildchar' and 'wildcharm' as a key name */
9618 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
9619 return FAIL;
9620 }
9621 else if (fprintf(fd, "%ld", *valuep) < 0)
9622 return FAIL;
9623 if (put_eol(fd) < 0)
9624 return FAIL;
9625 return OK;
9626}
9627
9628 static int
9629put_setbool(fd, cmd, name, value)
9630 FILE *fd;
9631 char *cmd;
9632 char *name;
9633 int value;
9634{
Bram Moolenaar893de922007-10-02 18:40:57 +00009635 if (value < 0) /* global/local option using global value */
9636 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009637 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
9638 || put_eol(fd) < 0)
9639 return FAIL;
9640 return OK;
9641}
9642
9643/*
9644 * Clear all the terminal options.
9645 * If the option has been allocated, free the memory.
9646 * Terminal options are never hidden or indirect.
9647 */
9648 void
9649clear_termoptions()
9650{
Bram Moolenaar071d4272004-06-13 20:20:40 +00009651 /*
9652 * Reset a few things before clearing the old options. This may cause
9653 * outputting a few things that the terminal doesn't understand, but the
9654 * screen will be cleared later, so this is OK.
9655 */
9656#ifdef FEAT_MOUSE_TTY
9657 mch_setmouse(FALSE); /* switch mouse off */
9658#endif
9659#ifdef FEAT_TITLE
9660 mch_restore_title(3); /* restore window titles */
9661#endif
9662#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
9663 /* When starting the GUI close the display opened for the clipboard.
9664 * After restoring the title, because that will need the display. */
9665 if (gui.starting)
9666 clear_xterm_clip();
9667#endif
9668#ifdef WIN3264
9669 /*
9670 * Check if this is allowed now.
9671 */
9672 if (can_end_termcap_mode(FALSE) == TRUE)
9673#endif
9674 stoptermcap(); /* stop termcap mode */
9675
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00009676 free_termoptions();
9677}
9678
9679 void
9680free_termoptions()
9681{
9682 struct vimoption *p;
9683
Bram Moolenaar071d4272004-06-13 20:20:40 +00009684 for (p = &options[0]; p->fullname != NULL; p++)
9685 if (istermoption(p))
9686 {
9687 if (p->flags & P_ALLOCED)
9688 free_string_option(*(char_u **)(p->var));
9689 if (p->flags & P_DEF_ALLOCED)
9690 free_string_option(p->def_val[VI_DEFAULT]);
9691 *(char_u **)(p->var) = empty_option;
9692 p->def_val[VI_DEFAULT] = empty_option;
9693 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
9694 }
9695 clear_termcodes();
9696}
9697
9698/*
Bram Moolenaar363cb672009-07-22 12:28:17 +00009699 * Free the string for one term option, if it was allocated.
9700 * Set the string to empty_option and clear allocated flag.
9701 * "var" points to the option value.
9702 */
9703 void
9704free_one_termoption(var)
9705 char_u *var;
9706{
9707 struct vimoption *p;
9708
9709 for (p = &options[0]; p->fullname != NULL; p++)
9710 if (p->var == var)
9711 {
9712 if (p->flags & P_ALLOCED)
9713 free_string_option(*(char_u **)(p->var));
9714 *(char_u **)(p->var) = empty_option;
9715 p->flags &= ~P_ALLOCED;
9716 break;
9717 }
9718}
9719
9720/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00009721 * Set the terminal option defaults to the current value.
9722 * Used after setting the terminal name.
9723 */
9724 void
9725set_term_defaults()
9726{
9727 struct vimoption *p;
9728
9729 for (p = &options[0]; p->fullname != NULL; p++)
9730 {
9731 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
9732 {
9733 if (p->flags & P_DEF_ALLOCED)
9734 {
9735 free_string_option(p->def_val[VI_DEFAULT]);
9736 p->flags &= ~P_DEF_ALLOCED;
9737 }
9738 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
9739 if (p->flags & P_ALLOCED)
9740 {
9741 p->flags |= P_DEF_ALLOCED;
9742 p->flags &= ~P_ALLOCED; /* don't free the value now */
9743 }
9744 }
9745 }
9746}
9747
9748/*
9749 * return TRUE if 'p' starts with 't_'
9750 */
9751 static int
9752istermoption(p)
9753 struct vimoption *p;
9754{
9755 return (p->fullname[0] == 't' && p->fullname[1] == '_');
9756}
9757
9758/*
9759 * Compute columns for ruler and shown command. 'sc_col' is also used to
9760 * decide what the maximum length of a message on the status line can be.
9761 * If there is a status line for the last window, 'sc_col' is independent
9762 * of 'ru_col'.
9763 */
9764
9765#define COL_RULER 17 /* columns needed by standard ruler */
9766
9767 void
9768comp_col()
9769{
9770#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
9771 int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin));
9772
9773 sc_col = 0;
9774 ru_col = 0;
9775 if (p_ru)
9776 {
9777#ifdef FEAT_STL_OPT
9778 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
9779#else
9780 ru_col = COL_RULER + 1;
9781#endif
9782 /* no last status line, adjust sc_col */
9783 if (!last_has_status)
9784 sc_col = ru_col;
9785 }
9786 if (p_sc)
9787 {
9788 sc_col += SHOWCMD_COLS;
9789 if (!p_ru || last_has_status) /* no need for separating space */
9790 ++sc_col;
9791 }
9792 sc_col = Columns - sc_col;
9793 ru_col = Columns - ru_col;
9794 if (sc_col <= 0) /* screen too narrow, will become a mess */
9795 sc_col = 1;
9796 if (ru_col <= 0)
9797 ru_col = 1;
9798#else
9799 sc_col = Columns;
9800 ru_col = Columns;
9801#endif
9802}
9803
9804/*
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009805 * Unset local option value, similar to ":set opt<".
9806 */
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009807 void
9808unset_global_local_option(name, from)
9809 char_u *name;
9810 void *from;
9811{
9812 struct vimoption *p;
9813 int opt_idx;
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009814 buf_T *buf = (buf_T *)from;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009815
9816 opt_idx = findoption(name);
9817 p = &(options[opt_idx]);
9818
9819 switch ((int)p->indir)
9820 {
9821 /* global option with local value: use local value if it's been set */
9822 case PV_EP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009823 clear_string_option(&buf->b_p_ep);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009824 break;
9825 case PV_KP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009826 clear_string_option(&buf->b_p_kp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009827 break;
9828 case PV_PATH:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009829 clear_string_option(&buf->b_p_path);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009830 break;
9831 case PV_AR:
9832 buf->b_p_ar = -1;
9833 break;
9834 case PV_TAGS:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009835 clear_string_option(&buf->b_p_tags);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009836 break;
9837#ifdef FEAT_FIND_ID
9838 case PV_DEF:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009839 clear_string_option(&buf->b_p_def);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009840 break;
9841 case PV_INC:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009842 clear_string_option(&buf->b_p_inc);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009843 break;
9844#endif
9845#ifdef FEAT_INS_EXPAND
9846 case PV_DICT:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009847 clear_string_option(&buf->b_p_dict);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009848 break;
9849 case PV_TSR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009850 clear_string_option(&buf->b_p_tsr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009851 break;
9852#endif
9853#ifdef FEAT_QUICKFIX
9854 case PV_EFM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009855 clear_string_option(&buf->b_p_efm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009856 break;
9857 case PV_GP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009858 clear_string_option(&buf->b_p_gp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009859 break;
9860 case PV_MP:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009861 clear_string_option(&buf->b_p_mp);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009862 break;
9863#endif
9864#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9865 case PV_BEXPR:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009866 clear_string_option(&buf->b_p_bexpr);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009867 break;
9868#endif
9869#if defined(FEAT_CRYPT)
9870 case PV_CM:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009871 clear_string_option(&buf->b_p_cm);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009872 break;
9873#endif
9874#ifdef FEAT_STL_OPT
9875 case PV_STL:
Bram Moolenaar51ac8a22013-05-06 06:45:47 +02009876 clear_string_option(&((win_T *)from)->w_p_stl);
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009877 break;
9878#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01009879 case PV_UL:
9880 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
9881 break;
Bram Moolenaar84e0f6c2013-05-06 03:52:55 +02009882 }
9883}
9884
9885/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00009886 * Get pointer to option variable, depending on local or global scope.
9887 */
9888 static char_u *
9889get_varp_scope(p, opt_flags)
9890 struct vimoption *p;
9891 int opt_flags;
9892{
9893 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
9894 {
9895 if (p->var == VAR_WIN)
9896 return (char_u *)GLOBAL_WO(get_varp(p));
9897 return p->var;
9898 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +00009899 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009900 {
9901 switch ((int)p->indir)
9902 {
9903#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009904 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
9905 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
9906 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009907#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009908 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
9909 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
9910 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +00009911 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009912 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009913#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009914 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
9915 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009916#endif
9917#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009918 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
9919 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009920#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00009921#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9922 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
9923#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02009924#if defined(FEAT_CRYPT)
9925 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
9926#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009927#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009928 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009929#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01009930 case PV_UL: return (char_u *)&(curbuf->b_p_ul);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009931 }
9932 return NULL; /* "cannot happen" */
9933 }
9934 return get_varp(p);
9935}
9936
9937/*
9938 * Get pointer to option variable.
9939 */
9940 static char_u *
9941get_varp(p)
9942 struct vimoption *p;
9943{
9944 /* hidden option, always return NULL */
9945 if (p->var == NULL)
9946 return NULL;
9947
9948 switch ((int)p->indir)
9949 {
9950 case PV_NONE: return p->var;
9951
9952 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009953 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009954 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009955 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009956 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009957 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009958 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +00009959 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00009960 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009961 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009962 ? (char_u *)&(curbuf->b_p_tags) : p->var;
9963#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009964 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009965 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009966 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009967 ? (char_u *)&(curbuf->b_p_inc) : p->var;
9968#endif
9969#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009970 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009971 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009972 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009973 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
9974#endif
9975#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009976 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009977 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009978 case PV_GP: return *curbuf->b_p_gp != NUL
9979 ? (char_u *)&(curbuf->b_p_gp) : p->var;
9980 case PV_MP: return *curbuf->b_p_mp != NUL
9981 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009982#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00009983#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9984 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
9985 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
9986#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02009987#if defined(FEAT_CRYPT)
9988 case PV_CM: return *curbuf->b_p_cm != NUL
9989 ? (char_u *)&(curbuf->b_p_cm) : p->var;
9990#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009991#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009992 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009993 ? (char_u *)&(curwin->w_p_stl) : p->var;
9994#endif
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +01009995 case PV_UL: return curbuf->b_p_ul != NO_LOCAL_UNDOLEVEL
9996 ? (char_u *)&(curbuf->b_p_ul) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009997
9998#ifdef FEAT_ARABIC
9999 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
10000#endif
10001 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010002#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010003 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
10004#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010005#ifdef FEAT_SYN_HL
10006 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
10007 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +020010008 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010009#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010010#ifdef FEAT_DIFF
10011 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
10012#endif
10013#ifdef FEAT_FOLDING
10014 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
10015 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
10016 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
10017 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
10018 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
10019 case PV_FML: return (char_u *)&(curwin->w_p_fml);
10020 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
10021# ifdef FEAT_EVAL
10022 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
10023 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
10024# endif
10025 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
10026#endif
10027 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +020010028 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010029#ifdef FEAT_LINEBREAK
10030 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
10031#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010032#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +000010033 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
10034#endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000010035#ifdef FEAT_VERTSPLIT
10036 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
10037#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010038#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
10039 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
10040#endif
10041#ifdef FEAT_RIGHTLEFT
10042 case PV_RL: return (char_u *)&(curwin->w_p_rl);
10043 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
10044#endif
10045 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
10046 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
10047#ifdef FEAT_LINEBREAK
10048 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
10049#endif
10050#ifdef FEAT_SCROLLBIND
10051 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
10052#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +020010053#ifdef FEAT_CURSORBIND
10054 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
10055#endif
10056#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010057 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
10058 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010059#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010060
10061 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
10062 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
10063#ifdef FEAT_MBYTE
10064 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
10065#endif
10066#if defined(FEAT_QUICKFIX)
10067 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
10068 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
10069#endif
10070 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
10071 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
10072#ifdef FEAT_CINDENT
10073 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
10074 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
10075 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
10076#endif
10077#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10078 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
10079#endif
10080#ifdef FEAT_COMMENTS
10081 case PV_COM: return (char_u *)&(curbuf->b_p_com);
10082#endif
10083#ifdef FEAT_FOLDING
10084 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
10085#endif
10086#ifdef FEAT_INS_EXPAND
10087 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
10088#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010089#ifdef FEAT_COMPL_FUNC
10090 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010091 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010092#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010093 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
10094 case PV_ET: return (char_u *)&(curbuf->b_p_et);
10095#ifdef FEAT_MBYTE
10096 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
10097#endif
10098 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
10099#ifdef FEAT_AUTOCMD
10100 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
10101#endif
10102 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010103 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010104 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
10105 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
10106 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
10107 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
10108#ifdef FEAT_FIND_ID
10109# ifdef FEAT_EVAL
10110 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
10111# endif
10112#endif
10113#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10114 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
10115 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
10116#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000010117#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010118 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
10119#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010120#ifdef FEAT_CRYPT
10121 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
10122#endif
10123#ifdef FEAT_LISP
10124 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
10125#endif
10126 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
10127 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
10128 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
10129 case PV_MOD: return (char_u *)&(curbuf->b_changed);
10130 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010131 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010132#ifdef FEAT_TEXTOBJ
10133 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
10134#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010135 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
10136#ifdef FEAT_SMARTINDENT
10137 case PV_SI: return (char_u *)&(curbuf->b_p_si);
10138#endif
10139#ifndef SHORT_FNAME
10140 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
10141#endif
10142 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
10143#ifdef FEAT_SEARCHPATH
10144 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
10145#endif
10146 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
10147#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010148 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010149 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
10150#endif
10151#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +020010152 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
10153 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
10154 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010155#endif
10156 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
10157 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
10158 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
10159 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010160#ifdef FEAT_PERSISTENT_UNDO
10161 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
10162#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010163 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
10164#ifdef FEAT_KEYMAP
10165 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
10166#endif
10167 default: EMSG(_("E356: get_varp ERROR"));
10168 }
10169 /* always return a valid pointer to avoid a crash! */
10170 return (char_u *)&(curbuf->b_p_wm);
10171}
10172
10173/*
10174 * Get the value of 'equalprg', either the buffer-local one or the global one.
10175 */
10176 char_u *
10177get_equalprg()
10178{
10179 if (*curbuf->b_p_ep == NUL)
10180 return p_ep;
10181 return curbuf->b_p_ep;
10182}
10183
10184#if defined(FEAT_WINDOWS) || defined(PROTO)
10185/*
10186 * Copy options from one window to another.
10187 * Used when splitting a window.
10188 */
10189 void
10190win_copy_options(wp_from, wp_to)
10191 win_T *wp_from;
10192 win_T *wp_to;
10193{
10194 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
10195 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
10196# ifdef FEAT_RIGHTLEFT
10197# ifdef FEAT_FKMAP
10198 /* Is this right? */
10199 wp_to->w_farsi = wp_from->w_farsi;
10200# endif
10201# endif
10202}
10203#endif
10204
10205/*
10206 * Copy the options from one winopt_T to another.
10207 * Doesn't free the old option values in "to", use clear_winopt() for that.
10208 * The 'scroll' option is not copied, because it depends on the window height.
10209 * The 'previewwindow' option is reset, there can be only one preview window.
10210 */
10211 void
10212copy_winopt(from, to)
10213 winopt_T *from;
10214 winopt_T *to;
10215{
10216#ifdef FEAT_ARABIC
10217 to->wo_arab = from->wo_arab;
10218#endif
10219 to->wo_list = from->wo_list;
10220 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +020010221 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +000010222#ifdef FEAT_LINEBREAK
10223 to->wo_nuw = from->wo_nuw;
10224#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010225#ifdef FEAT_RIGHTLEFT
10226 to->wo_rl = from->wo_rl;
10227 to->wo_rlc = vim_strsave(from->wo_rlc);
10228#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010229#ifdef FEAT_STL_OPT
10230 to->wo_stl = vim_strsave(from->wo_stl);
10231#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010232 to->wo_wrap = from->wo_wrap;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010233#ifdef FEAT_DIFF
10234 to->wo_wrap_save = from->wo_wrap_save;
10235#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010236#ifdef FEAT_LINEBREAK
10237 to->wo_lbr = from->wo_lbr;
10238#endif
10239#ifdef FEAT_SCROLLBIND
10240 to->wo_scb = from->wo_scb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010241 to->wo_scb_save = from->wo_scb_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010242#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010243#ifdef FEAT_CURSORBIND
10244 to->wo_crb = from->wo_crb;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010245 to->wo_crb_save = from->wo_crb_save;
Bram Moolenaar4161dcc2010-12-02 15:33:21 +010010246#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010247#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +000010248 to->wo_spell = from->wo_spell;
10249#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010250#ifdef FEAT_SYN_HL
10251 to->wo_cuc = from->wo_cuc;
10252 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +020010253 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010254#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010255#ifdef FEAT_DIFF
10256 to->wo_diff = from->wo_diff;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010257 to->wo_diff_saved = from->wo_diff_saved;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010258#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010259#ifdef FEAT_CONCEAL
10260 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +020010261 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010262#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010263#ifdef FEAT_FOLDING
10264 to->wo_fdc = from->wo_fdc;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010265 to->wo_fdc_save = from->wo_fdc_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010266 to->wo_fen = from->wo_fen;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010267 to->wo_fen_save = from->wo_fen_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010268 to->wo_fdi = vim_strsave(from->wo_fdi);
10269 to->wo_fml = from->wo_fml;
10270 to->wo_fdl = from->wo_fdl;
Bram Moolenaara87aa802013-07-03 15:47:03 +020010271 to->wo_fdl_save = from->wo_fdl_save;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010272 to->wo_fdm = vim_strsave(from->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010273 to->wo_fdm_save = from->wo_diff_saved
10274 ? vim_strsave(from->wo_fdm_save) : empty_option;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010275 to->wo_fdn = from->wo_fdn;
10276# ifdef FEAT_EVAL
10277 to->wo_fde = vim_strsave(from->wo_fde);
10278 to->wo_fdt = vim_strsave(from->wo_fdt);
10279# endif
10280 to->wo_fmr = vim_strsave(from->wo_fmr);
10281#endif
10282 check_winopt(to); /* don't want NULL pointers */
10283}
10284
10285/*
10286 * Check string options in a window for a NULL value.
10287 */
10288 void
10289check_win_options(win)
10290 win_T *win;
10291{
10292 check_winopt(&win->w_onebuf_opt);
10293 check_winopt(&win->w_allbuf_opt);
10294}
10295
10296/*
10297 * Check for NULL pointers in a winopt_T and replace them with empty_option.
10298 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010299 void
10300check_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010301 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010302{
10303#ifdef FEAT_FOLDING
10304 check_string_option(&wop->wo_fdi);
10305 check_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010306 check_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010307# ifdef FEAT_EVAL
10308 check_string_option(&wop->wo_fde);
10309 check_string_option(&wop->wo_fdt);
10310# endif
10311 check_string_option(&wop->wo_fmr);
10312#endif
10313#ifdef FEAT_RIGHTLEFT
10314 check_string_option(&wop->wo_rlc);
10315#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010316#ifdef FEAT_STL_OPT
10317 check_string_option(&wop->wo_stl);
10318#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010319#ifdef FEAT_SYN_HL
10320 check_string_option(&wop->wo_cc);
10321#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010322#ifdef FEAT_CONCEAL
10323 check_string_option(&wop->wo_cocu);
10324#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010325}
10326
10327/*
10328 * Free the allocated memory inside a winopt_T.
10329 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010330 void
10331clear_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +000010332 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010333{
10334#ifdef FEAT_FOLDING
10335 clear_string_option(&wop->wo_fdi);
10336 clear_string_option(&wop->wo_fdm);
Bram Moolenaara87aa802013-07-03 15:47:03 +020010337 clear_string_option(&wop->wo_fdm_save);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010338# ifdef FEAT_EVAL
10339 clear_string_option(&wop->wo_fde);
10340 clear_string_option(&wop->wo_fdt);
10341# endif
10342 clear_string_option(&wop->wo_fmr);
10343#endif
10344#ifdef FEAT_RIGHTLEFT
10345 clear_string_option(&wop->wo_rlc);
10346#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +000010347#ifdef FEAT_STL_OPT
10348 clear_string_option(&wop->wo_stl);
10349#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +020010350#ifdef FEAT_SYN_HL
10351 clear_string_option(&wop->wo_cc);
10352#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010353#ifdef FEAT_CONCEAL
10354 clear_string_option(&wop->wo_cocu);
10355#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010356}
10357
10358/*
10359 * Copy global option values to local options for one buffer.
10360 * Used when creating a new buffer and sometimes when entering a buffer.
10361 * flags:
10362 * BCO_ENTER We will enter the buf buffer.
10363 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
10364 * appropriate.
10365 * BCO_NOHELP Don't copy the values to a help buffer.
10366 */
10367 void
10368buf_copy_options(buf, flags)
10369 buf_T *buf;
10370 int flags;
10371{
10372 int should_copy = TRUE;
10373 char_u *save_p_isk = NULL; /* init for GCC */
10374 int dont_do_help;
10375 int did_isk = FALSE;
10376
10377 /*
Bram Moolenaar1a384422010-07-14 19:53:30 +020010378 * Don't do anything if the buffer is invalid.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010379 */
10380 if (buf == NULL || !buf_valid(buf))
10381 return;
10382
10383 /*
10384 * Skip this when the option defaults have not been set yet. Happens when
10385 * main() allocates the first buffer.
10386 */
10387 if (p_cpo != NULL)
10388 {
10389 /*
10390 * Always copy when entering and 'cpo' contains 'S'.
10391 * Don't copy when already initialized.
10392 * Don't copy when 'cpo' contains 's' and not entering.
10393 * 'S' BCO_ENTER initialized 's' should_copy
10394 * yes yes X X TRUE
10395 * yes no yes X FALSE
10396 * no X yes X FALSE
10397 * X no no yes FALSE
10398 * X no no no TRUE
10399 * no yes no X TRUE
10400 */
10401 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
10402 && (buf->b_p_initialized
10403 || (!(flags & BCO_ENTER)
10404 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
10405 should_copy = FALSE;
10406
10407 if (should_copy || (flags & BCO_ALWAYS))
10408 {
10409 /* Don't copy the options specific to a help buffer when
10410 * BCO_NOHELP is given or the options were initialized already
10411 * (jumping back to a help file with CTRL-T or CTRL-O) */
10412 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
10413 || buf->b_p_initialized;
10414 if (dont_do_help) /* don't free b_p_isk */
10415 {
10416 save_p_isk = buf->b_p_isk;
10417 buf->b_p_isk = NULL;
10418 }
10419 /*
10420 * Always free the allocated strings.
10421 * If not already initialized, set 'readonly' and copy 'fileformat'.
10422 */
10423 if (!buf->b_p_initialized)
10424 {
10425 free_buf_options(buf, TRUE);
10426 buf->b_p_ro = FALSE; /* don't copy readonly */
10427 buf->b_p_tx = p_tx;
10428#ifdef FEAT_MBYTE
10429 buf->b_p_fenc = vim_strsave(p_fenc);
10430#endif
10431 buf->b_p_ff = vim_strsave(p_ff);
10432#if defined(FEAT_QUICKFIX)
10433 buf->b_p_bh = empty_option;
10434 buf->b_p_bt = empty_option;
10435#endif
10436 }
10437 else
10438 free_buf_options(buf, FALSE);
10439
10440 buf->b_p_ai = p_ai;
10441 buf->b_p_ai_nopaste = p_ai_nopaste;
10442 buf->b_p_sw = p_sw;
10443 buf->b_p_tw = p_tw;
10444 buf->b_p_tw_nopaste = p_tw_nopaste;
10445 buf->b_p_tw_nobin = p_tw_nobin;
10446 buf->b_p_wm = p_wm;
10447 buf->b_p_wm_nopaste = p_wm_nopaste;
10448 buf->b_p_wm_nobin = p_wm_nobin;
10449 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000010450#ifdef FEAT_MBYTE
10451 buf->b_p_bomb = p_bomb;
10452#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010453 buf->b_p_et = p_et;
10454 buf->b_p_et_nobin = p_et_nobin;
10455 buf->b_p_ml = p_ml;
10456 buf->b_p_ml_nobin = p_ml_nobin;
10457 buf->b_p_inf = p_inf;
10458 buf->b_p_swf = p_swf;
10459#ifdef FEAT_INS_EXPAND
10460 buf->b_p_cpt = vim_strsave(p_cpt);
10461#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010462#ifdef FEAT_COMPL_FUNC
10463 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010464 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010465#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010466 buf->b_p_sts = p_sts;
10467 buf->b_p_sts_nopaste = p_sts_nopaste;
10468#ifndef SHORT_FNAME
10469 buf->b_p_sn = p_sn;
10470#endif
10471#ifdef FEAT_COMMENTS
10472 buf->b_p_com = vim_strsave(p_com);
10473#endif
10474#ifdef FEAT_FOLDING
10475 buf->b_p_cms = vim_strsave(p_cms);
10476#endif
10477 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010478 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010479 buf->b_p_nf = vim_strsave(p_nf);
10480 buf->b_p_mps = vim_strsave(p_mps);
10481#ifdef FEAT_SMARTINDENT
10482 buf->b_p_si = p_si;
10483#endif
10484 buf->b_p_ci = p_ci;
10485#ifdef FEAT_CINDENT
10486 buf->b_p_cin = p_cin;
10487 buf->b_p_cink = vim_strsave(p_cink);
10488 buf->b_p_cino = vim_strsave(p_cino);
10489#endif
10490#ifdef FEAT_AUTOCMD
10491 /* Don't copy 'filetype', it must be detected */
10492 buf->b_p_ft = empty_option;
10493#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010494 buf->b_p_pi = p_pi;
10495#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10496 buf->b_p_cinw = vim_strsave(p_cinw);
10497#endif
10498#ifdef FEAT_LISP
10499 buf->b_p_lisp = p_lisp;
10500#endif
10501#ifdef FEAT_SYN_HL
10502 /* Don't copy 'syntax', it must be set */
10503 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010504 buf->b_p_smc = p_smc;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010505#endif
10506#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020010507 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010508 (void)compile_cap_prog(&buf->b_s);
10509 buf->b_s.b_p_spf = vim_strsave(p_spf);
10510 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010511#endif
10512#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10513 buf->b_p_inde = vim_strsave(p_inde);
10514 buf->b_p_indk = vim_strsave(p_indk);
10515#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010516#if defined(FEAT_EVAL)
10517 buf->b_p_fex = vim_strsave(p_fex);
10518#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010519#ifdef FEAT_CRYPT
10520 buf->b_p_key = vim_strsave(p_key);
10521#endif
10522#ifdef FEAT_SEARCHPATH
10523 buf->b_p_sua = vim_strsave(p_sua);
10524#endif
10525#ifdef FEAT_KEYMAP
10526 buf->b_p_keymap = vim_strsave(p_keymap);
10527 buf->b_kmap_state |= KEYMAP_INIT;
10528#endif
10529 /* This isn't really an option, but copying the langmap and IME
10530 * state from the current buffer is better than resetting it. */
10531 buf->b_p_iminsert = p_iminsert;
10532 buf->b_p_imsearch = p_imsearch;
10533
10534 /* options that are normally global but also have a local value
10535 * are not copied, start using the global value */
10536 buf->b_p_ar = -1;
Bram Moolenaarf5a2fd82013-11-06 05:26:15 +010010537 buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010538#ifdef FEAT_QUICKFIX
10539 buf->b_p_gp = empty_option;
10540 buf->b_p_mp = empty_option;
10541 buf->b_p_efm = empty_option;
10542#endif
10543 buf->b_p_ep = empty_option;
10544 buf->b_p_kp = empty_option;
10545 buf->b_p_path = empty_option;
10546 buf->b_p_tags = empty_option;
10547#ifdef FEAT_FIND_ID
10548 buf->b_p_def = empty_option;
10549 buf->b_p_inc = empty_option;
10550# ifdef FEAT_EVAL
10551 buf->b_p_inex = vim_strsave(p_inex);
10552# endif
10553#endif
10554#ifdef FEAT_INS_EXPAND
10555 buf->b_p_dict = empty_option;
10556 buf->b_p_tsr = empty_option;
10557#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010558#ifdef FEAT_TEXTOBJ
10559 buf->b_p_qe = vim_strsave(p_qe);
10560#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010561#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10562 buf->b_p_bexpr = empty_option;
10563#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010564#if defined(FEAT_CRYPT)
10565 buf->b_p_cm = empty_option;
10566#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010567#ifdef FEAT_PERSISTENT_UNDO
10568 buf->b_p_udf = p_udf;
10569#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010570
10571 /*
10572 * Don't copy the options set by ex_help(), use the saved values,
10573 * when going from a help buffer to a non-help buffer.
10574 * Don't touch these at all when BCO_NOHELP is used and going from
10575 * or to a help buffer.
10576 */
10577 if (dont_do_help)
10578 buf->b_p_isk = save_p_isk;
10579 else
10580 {
10581 buf->b_p_isk = vim_strsave(p_isk);
10582 did_isk = TRUE;
10583 buf->b_p_ts = p_ts;
10584 buf->b_help = FALSE;
10585#ifdef FEAT_QUICKFIX
10586 if (buf->b_p_bt[0] == 'h')
10587 clear_string_option(&buf->b_p_bt);
10588#endif
10589 buf->b_p_ma = p_ma;
10590 }
10591 }
10592
10593 /*
10594 * When the options should be copied (ignoring BCO_ALWAYS), set the
10595 * flag that indicates that the options have been initialized.
10596 */
10597 if (should_copy)
10598 buf->b_p_initialized = TRUE;
10599 }
10600
10601 check_buf_options(buf); /* make sure we don't have NULLs */
10602 if (did_isk)
10603 (void)buf_init_chartab(buf, FALSE);
10604}
10605
10606/*
10607 * Reset the 'modifiable' option and its default value.
10608 */
10609 void
10610reset_modifiable()
10611{
10612 int opt_idx;
10613
10614 curbuf->b_p_ma = FALSE;
10615 p_ma = FALSE;
10616 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000010617 if (opt_idx >= 0)
10618 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010619}
10620
10621/*
10622 * Set the global value for 'iminsert' to the local value.
10623 */
10624 void
10625set_iminsert_global()
10626{
10627 p_iminsert = curbuf->b_p_iminsert;
10628}
10629
10630/*
10631 * Set the global value for 'imsearch' to the local value.
10632 */
10633 void
10634set_imsearch_global()
10635{
10636 p_imsearch = curbuf->b_p_imsearch;
10637}
10638
10639#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
10640static int expand_option_idx = -1;
10641static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
10642static int expand_option_flags = 0;
10643
10644 void
10645set_context_in_set_cmd(xp, arg, opt_flags)
10646 expand_T *xp;
10647 char_u *arg;
10648 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
10649{
10650 int nextchar;
10651 long_u flags = 0; /* init for GCC */
10652 int opt_idx = 0; /* init for GCC */
10653 char_u *p;
10654 char_u *s;
10655 int is_term_option = FALSE;
10656 int key;
10657
10658 expand_option_flags = opt_flags;
10659
10660 xp->xp_context = EXPAND_SETTINGS;
10661 if (*arg == NUL)
10662 {
10663 xp->xp_pattern = arg;
10664 return;
10665 }
10666 p = arg + STRLEN(arg) - 1;
10667 if (*p == ' ' && *(p - 1) != '\\')
10668 {
10669 xp->xp_pattern = p + 1;
10670 return;
10671 }
10672 while (p > arg)
10673 {
10674 s = p;
10675 /* count number of backslashes before ' ' or ',' */
10676 if (*p == ' ' || *p == ',')
10677 {
10678 while (s > arg && *(s - 1) == '\\')
10679 --s;
10680 }
10681 /* break at a space with an even number of backslashes */
10682 if (*p == ' ' && ((p - s) & 1) == 0)
10683 {
10684 ++p;
10685 break;
10686 }
10687 --p;
10688 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000010689 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010690 {
10691 xp->xp_context = EXPAND_BOOL_SETTINGS;
10692 p += 2;
10693 }
10694 if (STRNCMP(p, "inv", 3) == 0)
10695 {
10696 xp->xp_context = EXPAND_BOOL_SETTINGS;
10697 p += 3;
10698 }
10699 xp->xp_pattern = arg = p;
10700 if (*arg == '<')
10701 {
10702 while (*p != '>')
10703 if (*p++ == NUL) /* expand terminal option name */
10704 return;
10705 key = get_special_key_code(arg + 1);
10706 if (key == 0) /* unknown name */
10707 {
10708 xp->xp_context = EXPAND_NOTHING;
10709 return;
10710 }
10711 nextchar = *++p;
10712 is_term_option = TRUE;
10713 expand_option_name[2] = KEY2TERMCAP0(key);
10714 expand_option_name[3] = KEY2TERMCAP1(key);
10715 }
10716 else
10717 {
10718 if (p[0] == 't' && p[1] == '_')
10719 {
10720 p += 2;
10721 if (*p != NUL)
10722 ++p;
10723 if (*p == NUL)
10724 return; /* expand option name */
10725 nextchar = *++p;
10726 is_term_option = TRUE;
10727 expand_option_name[2] = p[-2];
10728 expand_option_name[3] = p[-1];
10729 }
10730 else
10731 {
10732 /* Allow * wildcard */
10733 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
10734 p++;
10735 if (*p == NUL)
10736 return;
10737 nextchar = *p;
10738 *p = NUL;
10739 opt_idx = findoption(arg);
10740 *p = nextchar;
10741 if (opt_idx == -1 || options[opt_idx].var == NULL)
10742 {
10743 xp->xp_context = EXPAND_NOTHING;
10744 return;
10745 }
10746 flags = options[opt_idx].flags;
10747 if (flags & P_BOOL)
10748 {
10749 xp->xp_context = EXPAND_NOTHING;
10750 return;
10751 }
10752 }
10753 }
10754 /* handle "-=" and "+=" */
10755 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
10756 {
10757 ++p;
10758 nextchar = '=';
10759 }
10760 if ((nextchar != '=' && nextchar != ':')
10761 || xp->xp_context == EXPAND_BOOL_SETTINGS)
10762 {
10763 xp->xp_context = EXPAND_UNSUCCESSFUL;
10764 return;
10765 }
10766 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
10767 {
10768 xp->xp_context = EXPAND_OLD_SETTING;
10769 if (is_term_option)
10770 expand_option_idx = -1;
10771 else
10772 expand_option_idx = opt_idx;
10773 xp->xp_pattern = p + 1;
10774 return;
10775 }
10776 xp->xp_context = EXPAND_NOTHING;
10777 if (is_term_option || (flags & P_NUM))
10778 return;
10779
10780 xp->xp_pattern = p + 1;
10781
10782 if (flags & P_EXPAND)
10783 {
10784 p = options[opt_idx].var;
10785 if (p == (char_u *)&p_bdir
10786 || p == (char_u *)&p_dir
10787 || p == (char_u *)&p_path
10788 || p == (char_u *)&p_rtp
10789#ifdef FEAT_SEARCHPATH
10790 || p == (char_u *)&p_cdpath
10791#endif
10792#ifdef FEAT_SESSION
10793 || p == (char_u *)&p_vdir
10794#endif
10795 )
10796 {
10797 xp->xp_context = EXPAND_DIRECTORIES;
10798 if (p == (char_u *)&p_path
10799#ifdef FEAT_SEARCHPATH
10800 || p == (char_u *)&p_cdpath
10801#endif
10802 )
10803 xp->xp_backslash = XP_BS_THREE;
10804 else
10805 xp->xp_backslash = XP_BS_ONE;
10806 }
10807 else
10808 {
10809 xp->xp_context = EXPAND_FILES;
10810 /* for 'tags' need three backslashes for a space */
10811 if (p == (char_u *)&p_tags)
10812 xp->xp_backslash = XP_BS_THREE;
10813 else
10814 xp->xp_backslash = XP_BS_ONE;
10815 }
10816 }
10817
10818 /* For an option that is a list of file names, find the start of the
10819 * last file name. */
10820 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
10821 {
10822 /* count number of backslashes before ' ' or ',' */
10823 if (*p == ' ' || *p == ',')
10824 {
10825 s = p;
10826 while (s > xp->xp_pattern && *(s - 1) == '\\')
10827 --s;
10828 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
10829 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
10830 {
10831 xp->xp_pattern = p + 1;
10832 break;
10833 }
10834 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000010835
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010836#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000010837 /* for 'spellsuggest' start at "file:" */
10838 if (options[opt_idx].var == (char_u *)&p_sps
10839 && STRNCMP(p, "file:", 5) == 0)
10840 {
10841 xp->xp_pattern = p + 5;
10842 break;
10843 }
10844#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010845 }
10846
10847 return;
10848}
10849
10850 int
10851ExpandSettings(xp, regmatch, num_file, file)
10852 expand_T *xp;
10853 regmatch_T *regmatch;
10854 int *num_file;
10855 char_u ***file;
10856{
10857 int num_normal = 0; /* Nr of matching non-term-code settings */
10858 int num_term = 0; /* Nr of matching terminal code settings */
10859 int opt_idx;
10860 int match;
10861 int count = 0;
10862 char_u *str;
10863 int loop;
10864 int is_term_opt;
10865 char_u name_buf[MAX_KEY_NAME_LEN];
10866 static char *(names[]) = {"all", "termcap"};
10867 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
10868
10869 /* do this loop twice:
10870 * loop == 0: count the number of matching options
10871 * loop == 1: copy the matching options into allocated memory
10872 */
10873 for (loop = 0; loop <= 1; ++loop)
10874 {
10875 regmatch->rm_ic = ic;
10876 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
10877 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000010878 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
10879 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010880 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
10881 {
10882 if (loop == 0)
10883 num_normal++;
10884 else
10885 (*file)[count++] = vim_strsave((char_u *)names[match]);
10886 }
10887 }
10888 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
10889 opt_idx++)
10890 {
10891 if (options[opt_idx].var == NULL)
10892 continue;
10893 if (xp->xp_context == EXPAND_BOOL_SETTINGS
10894 && !(options[opt_idx].flags & P_BOOL))
10895 continue;
10896 is_term_opt = istermoption(&options[opt_idx]);
10897 if (is_term_opt && num_normal > 0)
10898 continue;
10899 match = FALSE;
10900 if (vim_regexec(regmatch, str, (colnr_T)0)
10901 || (options[opt_idx].shortname != NULL
10902 && vim_regexec(regmatch,
10903 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
10904 match = TRUE;
10905 else if (is_term_opt)
10906 {
10907 name_buf[0] = '<';
10908 name_buf[1] = 't';
10909 name_buf[2] = '_';
10910 name_buf[3] = str[2];
10911 name_buf[4] = str[3];
10912 name_buf[5] = '>';
10913 name_buf[6] = NUL;
10914 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10915 {
10916 match = TRUE;
10917 str = name_buf;
10918 }
10919 }
10920 if (match)
10921 {
10922 if (loop == 0)
10923 {
10924 if (is_term_opt)
10925 num_term++;
10926 else
10927 num_normal++;
10928 }
10929 else
10930 (*file)[count++] = vim_strsave(str);
10931 }
10932 }
10933 /*
10934 * Check terminal key codes, these are not in the option table
10935 */
10936 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
10937 {
10938 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
10939 {
10940 if (!isprint(str[0]) || !isprint(str[1]))
10941 continue;
10942
10943 name_buf[0] = 't';
10944 name_buf[1] = '_';
10945 name_buf[2] = str[0];
10946 name_buf[3] = str[1];
10947 name_buf[4] = NUL;
10948
10949 match = FALSE;
10950 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10951 match = TRUE;
10952 else
10953 {
10954 name_buf[0] = '<';
10955 name_buf[1] = 't';
10956 name_buf[2] = '_';
10957 name_buf[3] = str[0];
10958 name_buf[4] = str[1];
10959 name_buf[5] = '>';
10960 name_buf[6] = NUL;
10961
10962 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10963 match = TRUE;
10964 }
10965 if (match)
10966 {
10967 if (loop == 0)
10968 num_term++;
10969 else
10970 (*file)[count++] = vim_strsave(name_buf);
10971 }
10972 }
10973
10974 /*
10975 * Check special key names.
10976 */
10977 regmatch->rm_ic = TRUE; /* ignore case here */
10978 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
10979 {
10980 name_buf[0] = '<';
10981 STRCPY(name_buf + 1, str);
10982 STRCAT(name_buf, ">");
10983
10984 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10985 {
10986 if (loop == 0)
10987 num_term++;
10988 else
10989 (*file)[count++] = vim_strsave(name_buf);
10990 }
10991 }
10992 }
10993 if (loop == 0)
10994 {
10995 if (num_normal > 0)
10996 *num_file = num_normal;
10997 else if (num_term > 0)
10998 *num_file = num_term;
10999 else
11000 return OK;
11001 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
11002 if (*file == NULL)
11003 {
11004 *file = (char_u **)"";
11005 return FAIL;
11006 }
11007 }
11008 }
11009 return OK;
11010}
11011
11012 int
11013ExpandOldSetting(num_file, file)
11014 int *num_file;
11015 char_u ***file;
11016{
11017 char_u *var = NULL; /* init for GCC */
11018 char_u *buf;
11019
11020 *num_file = 0;
11021 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
11022 if (*file == NULL)
11023 return FAIL;
11024
11025 /*
11026 * For a terminal key code expand_option_idx is < 0.
11027 */
11028 if (expand_option_idx < 0)
11029 {
11030 var = find_termcode(expand_option_name + 2);
11031 if (var == NULL)
11032 expand_option_idx = findoption(expand_option_name);
11033 }
11034
11035 if (expand_option_idx >= 0)
11036 {
11037 /* put string of option value in NameBuff */
11038 option_value2string(&options[expand_option_idx], expand_option_flags);
11039 var = NameBuff;
11040 }
11041 else if (var == NULL)
11042 var = (char_u *)"";
11043
11044 /* A backslash is required before some characters. This is the reverse of
11045 * what happens in do_set(). */
11046 buf = vim_strsave_escaped(var, escape_chars);
11047
11048 if (buf == NULL)
11049 {
11050 vim_free(*file);
11051 *file = NULL;
11052 return FAIL;
11053 }
11054
11055#ifdef BACKSLASH_IN_FILENAME
11056 /* For MS-Windows et al. we don't double backslashes at the start and
11057 * before a file name character. */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011058 for (var = buf; *var != NUL; mb_ptr_adv(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011059 if (var[0] == '\\' && var[1] == '\\'
11060 && expand_option_idx >= 0
11061 && (options[expand_option_idx].flags & P_EXPAND)
11062 && vim_isfilec(var[2])
11063 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000011064 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011065#endif
11066
11067 *file[0] = buf;
11068 *num_file = 1;
11069 return OK;
11070}
11071#endif
11072
11073/*
11074 * Get the value for the numeric or string option *opp in a nice format into
11075 * NameBuff[]. Must not be called with a hidden option!
11076 */
11077 static void
11078option_value2string(opp, opt_flags)
11079 struct vimoption *opp;
11080 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
11081{
11082 char_u *varp;
11083
11084 varp = get_varp_scope(opp, opt_flags);
11085
11086 if (opp->flags & P_NUM)
11087 {
11088 long wc = 0;
11089
11090 if (wc_use_keyname(varp, &wc))
11091 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
11092 else if (wc != 0)
11093 STRCPY(NameBuff, transchar((int)wc));
11094 else
11095 sprintf((char *)NameBuff, "%ld", *(long *)varp);
11096 }
11097 else /* P_STRING */
11098 {
11099 varp = *(char_u **)(varp);
11100 if (varp == NULL) /* just in case */
11101 NameBuff[0] = NUL;
11102#ifdef FEAT_CRYPT
11103 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000011104 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011105 STRCPY(NameBuff, "*****");
11106#endif
11107 else if (opp->flags & P_EXPAND)
11108 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
11109 /* Translate 'pastetoggle' into special key names */
11110 else if ((char_u **)opp->var == &p_pt)
11111 str2specialbuf(p_pt, NameBuff, MAXPATHL);
11112 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000011113 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011114 }
11115}
11116
11117/*
11118 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
11119 * printed as a keyname.
11120 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
11121 */
11122 static int
11123wc_use_keyname(varp, wcp)
11124 char_u *varp;
11125 long *wcp;
11126{
11127 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
11128 {
11129 *wcp = *(long *)varp;
11130 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
11131 return TRUE;
11132 }
11133 return FALSE;
11134}
11135
11136#ifdef FEAT_LANGMAP
11137/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011138 * Any character has an equivalent 'langmap' character. This is used for
11139 * keyboards that have a special language mode that sends characters above
11140 * 128 (although other characters can be translated too). The "to" field is a
11141 * Vim command character. This avoids having to switch the keyboard back to
11142 * ASCII mode when leaving Insert mode.
11143 *
11144 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
11145 * commands.
11146 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
11147 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
11148 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011149 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011150# ifdef FEAT_MBYTE
11151/*
11152 * With multi-byte support use growarray for 'langmap' chars >= 256
11153 */
11154typedef struct
11155{
11156 int from;
11157 int to;
11158} langmap_entry_T;
11159
11160static garray_T langmap_mapga;
11161static void langmap_set_entry __ARGS((int from, int to));
Bram Moolenaar071d4272004-06-13 20:20:40 +000011162
11163/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011164 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
11165 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011166 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011167 static void
11168langmap_set_entry(from, to)
11169 int from;
11170 int to;
11171{
11172 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020011173 int a = 0;
11174 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011175
11176 /* Do a binary search for an existing entry. */
11177 while (a != b)
11178 {
11179 int i = (a + b) / 2;
11180 int d = entries[i].from - from;
11181
11182 if (d == 0)
11183 {
11184 entries[i].to = to;
11185 return;
11186 }
11187 if (d < 0)
11188 a = i + 1;
11189 else
11190 b = i;
11191 }
11192
11193 if (ga_grow(&langmap_mapga, 1) != OK)
11194 return; /* out of memory */
11195
11196 /* insert new entry at position "a" */
11197 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
11198 mch_memmove(entries + 1, entries,
11199 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
11200 ++langmap_mapga.ga_len;
11201 entries[0].from = from;
11202 entries[0].to = to;
11203}
11204
11205/*
11206 * Apply 'langmap' to multi-byte character "c" and return the result.
11207 */
11208 int
11209langmap_adjust_mb(c)
11210 int c;
11211{
11212 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
11213 int a = 0;
11214 int b = langmap_mapga.ga_len;
11215
11216 while (a != b)
11217 {
11218 int i = (a + b) / 2;
11219 int d = entries[i].from - c;
11220
11221 if (d == 0)
11222 return entries[i].to; /* found matching entry */
11223 if (d < 0)
11224 a = i + 1;
11225 else
11226 b = i;
11227 }
11228 return c; /* no entry found, return "c" unmodified */
11229}
11230# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011231
11232 static void
11233langmap_init()
11234{
11235 int i;
11236
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011237 for (i = 0; i < 256; i++)
11238 langmap_mapchar[i] = i; /* we init with a one-to-one map */
11239# ifdef FEAT_MBYTE
11240 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
11241# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000011242}
11243
11244/*
11245 * Called when langmap option is set; the language map can be
11246 * changed at any time!
11247 */
11248 static void
11249langmap_set()
11250{
11251 char_u *p;
11252 char_u *p2;
11253 int from, to;
11254
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011255#ifdef FEAT_MBYTE
11256 ga_clear(&langmap_mapga); /* clear the previous map first */
11257#endif
11258 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000011259
11260 for (p = p_langmap; p[0] != NUL; )
11261 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011262 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
11263 mb_ptr_adv(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000011264 {
11265 if (p2[0] == '\\' && p2[1] != NUL)
11266 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011267 }
11268 if (p2[0] == ';')
11269 ++p2; /* abcd;ABCD form, p2 points to A */
11270 else
11271 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
11272 while (p[0])
11273 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011274 if (p[0] == ',')
11275 {
11276 ++p;
11277 break;
11278 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011279 if (p[0] == '\\' && p[1] != NUL)
11280 ++p;
11281#ifdef FEAT_MBYTE
11282 from = (*mb_ptr2char)(p);
11283#else
11284 from = p[0];
11285#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011286 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011287 if (p2 == NULL)
11288 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011289 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011290 if (p[0] != ',')
11291 {
11292 if (p[0] == '\\')
11293 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011294#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011295 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011296#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011297 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011298#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011299 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011300 }
11301 else
11302 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020011303 if (p2[0] != ',')
11304 {
11305 if (p2[0] == '\\')
11306 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011307#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020011308 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011309#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020011310 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000011311#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020011312 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011313 }
11314 if (to == NUL)
11315 {
11316 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
11317 transchar(from));
11318 return;
11319 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000011320
11321#ifdef FEAT_MBYTE
11322 if (from >= 256)
11323 langmap_set_entry(from, to);
11324 else
11325#endif
11326 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011327
11328 /* Advance to next pair */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011329 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020011330 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011331 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000011332 mb_ptr_adv(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000011333 if (*p == ';')
11334 {
11335 p = p2;
11336 if (p[0] != NUL)
11337 {
11338 if (p[0] != ',')
11339 {
11340 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
11341 return;
11342 }
11343 ++p;
11344 }
11345 break;
11346 }
11347 }
11348 }
11349 }
11350}
11351#endif
11352
11353/*
11354 * Return TRUE if format option 'x' is in effect.
11355 * Take care of no formatting when 'paste' is set.
11356 */
11357 int
11358has_format_option(x)
11359 int x;
11360{
11361 if (p_paste)
11362 return FALSE;
11363 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
11364}
11365
11366/*
11367 * Return TRUE if "x" is present in 'shortmess' option, or
11368 * 'shortmess' contains 'a' and "x" is present in SHM_A.
11369 */
11370 int
11371shortmess(x)
11372 int x;
11373{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010011374 return p_shm != NULL &&
11375 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000011376 || (vim_strchr(p_shm, 'a') != NULL
11377 && vim_strchr((char_u *)SHM_A, x) != NULL));
11378}
11379
11380/*
11381 * paste_option_changed() - Called after p_paste was set or reset.
11382 */
11383 static void
11384paste_option_changed()
11385{
11386 static int old_p_paste = FALSE;
11387 static int save_sm = 0;
11388#ifdef FEAT_CMDL_INFO
11389 static int save_ru = 0;
11390#endif
11391#ifdef FEAT_RIGHTLEFT
11392 static int save_ri = 0;
11393 static int save_hkmap = 0;
11394#endif
11395 buf_T *buf;
11396
11397 if (p_paste)
11398 {
11399 /*
11400 * Paste switched from off to on.
11401 * Save the current values, so they can be restored later.
11402 */
11403 if (!old_p_paste)
11404 {
11405 /* save options for each buffer */
11406 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11407 {
11408 buf->b_p_tw_nopaste = buf->b_p_tw;
11409 buf->b_p_wm_nopaste = buf->b_p_wm;
11410 buf->b_p_sts_nopaste = buf->b_p_sts;
11411 buf->b_p_ai_nopaste = buf->b_p_ai;
11412 }
11413
11414 /* save global options */
11415 save_sm = p_sm;
11416#ifdef FEAT_CMDL_INFO
11417 save_ru = p_ru;
11418#endif
11419#ifdef FEAT_RIGHTLEFT
11420 save_ri = p_ri;
11421 save_hkmap = p_hkmap;
11422#endif
11423 /* save global values for local buffer options */
11424 p_tw_nopaste = p_tw;
11425 p_wm_nopaste = p_wm;
11426 p_sts_nopaste = p_sts;
11427 p_ai_nopaste = p_ai;
11428 }
11429
11430 /*
11431 * Always set the option values, also when 'paste' is set when it is
11432 * already on.
11433 */
11434 /* set options for each buffer */
11435 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11436 {
11437 buf->b_p_tw = 0; /* textwidth is 0 */
11438 buf->b_p_wm = 0; /* wrapmargin is 0 */
11439 buf->b_p_sts = 0; /* softtabstop is 0 */
11440 buf->b_p_ai = 0; /* no auto-indent */
11441 }
11442
11443 /* set global options */
11444 p_sm = 0; /* no showmatch */
11445#ifdef FEAT_CMDL_INFO
11446# ifdef FEAT_WINDOWS
11447 if (p_ru)
11448 status_redraw_all(); /* redraw to remove the ruler */
11449# endif
11450 p_ru = 0; /* no ruler */
11451#endif
11452#ifdef FEAT_RIGHTLEFT
11453 p_ri = 0; /* no reverse insert */
11454 p_hkmap = 0; /* no Hebrew keyboard */
11455#endif
11456 /* set global values for local buffer options */
11457 p_tw = 0;
11458 p_wm = 0;
11459 p_sts = 0;
11460 p_ai = 0;
11461 }
11462
11463 /*
11464 * Paste switched from on to off: Restore saved values.
11465 */
11466 else if (old_p_paste)
11467 {
11468 /* restore options for each buffer */
11469 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11470 {
11471 buf->b_p_tw = buf->b_p_tw_nopaste;
11472 buf->b_p_wm = buf->b_p_wm_nopaste;
11473 buf->b_p_sts = buf->b_p_sts_nopaste;
11474 buf->b_p_ai = buf->b_p_ai_nopaste;
11475 }
11476
11477 /* restore global options */
11478 p_sm = save_sm;
11479#ifdef FEAT_CMDL_INFO
11480# ifdef FEAT_WINDOWS
11481 if (p_ru != save_ru)
11482 status_redraw_all(); /* redraw to draw the ruler */
11483# endif
11484 p_ru = save_ru;
11485#endif
11486#ifdef FEAT_RIGHTLEFT
11487 p_ri = save_ri;
11488 p_hkmap = save_hkmap;
11489#endif
11490 /* set global values for local buffer options */
11491 p_tw = p_tw_nopaste;
11492 p_wm = p_wm_nopaste;
11493 p_sts = p_sts_nopaste;
11494 p_ai = p_ai_nopaste;
11495 }
11496
11497 old_p_paste = p_paste;
11498}
11499
11500/*
11501 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
11502 *
11503 * Reset 'compatible' and set the values for options that didn't get set yet
11504 * to the Vim defaults.
11505 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011506 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011507 */
11508 void
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011509vimrc_found(fname, envname)
11510 char_u *fname;
11511 char_u *envname;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011512{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011513 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000011514 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011515 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011516
11517 if (!option_was_set((char_u *)"cp"))
11518 {
11519 p_cp = FALSE;
11520 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11521 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
11522 set_option_default(opt_idx, OPT_FREE, FALSE);
11523 didset_options();
11524 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011525
11526 if (fname != NULL)
11527 {
11528 p = vim_getenv(envname, &dofree);
11529 if (p == NULL)
11530 {
11531 /* Set $MYVIMRC to the first vimrc file found. */
11532 p = FullName_save(fname, FALSE);
11533 if (p != NULL)
11534 {
11535 vim_setenv(envname, p);
11536 vim_free(p);
11537 }
11538 }
11539 else if (dofree)
11540 vim_free(p);
11541 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011542}
11543
11544/*
11545 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
11546 */
11547 void
11548change_compatible(on)
11549 int on;
11550{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011551 int opt_idx;
11552
Bram Moolenaar071d4272004-06-13 20:20:40 +000011553 if (p_cp != on)
11554 {
11555 p_cp = on;
11556 compatible_set();
11557 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011558 opt_idx = findoption((char_u *)"cp");
11559 if (opt_idx >= 0)
11560 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011561}
11562
11563/*
11564 * Return TRUE when option "name" has been set.
Bram Moolenaar1a4a75c2013-07-28 16:03:06 +020011565 * Only works correctly for global options.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011566 */
11567 int
11568option_was_set(name)
11569 char_u *name;
11570{
11571 int idx;
11572
11573 idx = findoption(name);
11574 if (idx < 0) /* unknown option */
11575 return FALSE;
11576 if (options[idx].flags & P_WAS_SET)
11577 return TRUE;
11578 return FALSE;
11579}
11580
11581/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010011582 * Reset the flag indicating option "name" was set.
11583 */
11584 void
11585reset_option_was_set(name)
11586 char_u *name;
11587{
11588 int idx = findoption(name);
11589
11590 if (idx >= 0)
11591 options[idx].flags &= ~P_WAS_SET;
11592}
11593
11594/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011595 * compatible_set() - Called when 'compatible' has been set or unset.
11596 *
11597 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
11598 * flag) to a Vi compatible value.
11599 * When 'compatible' is unset: Set all options that have a different default
11600 * for Vim (without the P_VI_DEF flag) to that default.
11601 */
11602 static void
11603compatible_set()
11604{
11605 int opt_idx;
11606
11607 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11608 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
11609 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
11610 set_option_default(opt_idx, OPT_FREE, p_cp);
11611 didset_options();
11612}
11613
11614#ifdef FEAT_LINEBREAK
11615
11616# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
11617 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011618 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011619# endif
11620
11621/*
11622 * fill_breakat_flags() -- called when 'breakat' changes value.
11623 */
11624 static void
11625fill_breakat_flags()
11626{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011627 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011628 int i;
11629
11630 for (i = 0; i < 256; i++)
11631 breakat_flags[i] = FALSE;
11632
11633 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011634 for (p = p_breakat; *p; p++)
11635 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011636}
11637
11638# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011639 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011640# endif
11641
11642#endif
11643
11644/*
11645 * Check an option that can be a range of string values.
11646 *
11647 * Return OK for correct value, FAIL otherwise.
11648 * Empty is always OK.
11649 */
11650 static int
11651check_opt_strings(val, values, list)
11652 char_u *val;
11653 char **values;
11654 int list; /* when TRUE: accept a list of values */
11655{
11656 return opt_strings_flags(val, values, NULL, list);
11657}
11658
11659/*
11660 * Handle an option that can be a range of string values.
11661 * Set a flag in "*flagp" for each string present.
11662 *
11663 * Return OK for correct value, FAIL otherwise.
11664 * Empty is always OK.
11665 */
11666 static int
11667opt_strings_flags(val, values, flagp, list)
11668 char_u *val; /* new value */
11669 char **values; /* array of valid string values */
11670 unsigned *flagp;
11671 int list; /* when TRUE: accept a list of values */
11672{
11673 int i;
11674 int len;
11675 unsigned new_flags = 0;
11676
11677 while (*val)
11678 {
11679 for (i = 0; ; ++i)
11680 {
11681 if (values[i] == NULL) /* val not found in values[] */
11682 return FAIL;
11683
11684 len = (int)STRLEN(values[i]);
11685 if (STRNCMP(values[i], val, len) == 0
11686 && ((list && val[len] == ',') || val[len] == NUL))
11687 {
11688 val += len + (val[len] == ',');
11689 new_flags |= (1 << i);
11690 break; /* check next item in val list */
11691 }
11692 }
11693 }
11694 if (flagp != NULL)
11695 *flagp = new_flags;
11696
11697 return OK;
11698}
11699
11700/*
11701 * Read the 'wildmode' option, fill wim_flags[].
11702 */
11703 static int
11704check_opt_wim()
11705{
11706 char_u new_wim_flags[4];
11707 char_u *p;
11708 int i;
11709 int idx = 0;
11710
11711 for (i = 0; i < 4; ++i)
11712 new_wim_flags[i] = 0;
11713
11714 for (p = p_wim; *p; ++p)
11715 {
11716 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
11717 ;
11718 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
11719 return FAIL;
11720 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
11721 new_wim_flags[idx] |= WIM_LONGEST;
11722 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
11723 new_wim_flags[idx] |= WIM_FULL;
11724 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
11725 new_wim_flags[idx] |= WIM_LIST;
11726 else
11727 return FAIL;
11728 p += i;
11729 if (*p == NUL)
11730 break;
11731 if (*p == ',')
11732 {
11733 if (idx == 3)
11734 return FAIL;
11735 ++idx;
11736 }
11737 }
11738
11739 /* fill remaining entries with last flag */
11740 while (idx < 3)
11741 {
11742 new_wim_flags[idx + 1] = new_wim_flags[idx];
11743 ++idx;
11744 }
11745
11746 /* only when there are no errors, wim_flags[] is changed */
11747 for (i = 0; i < 4; ++i)
11748 wim_flags[i] = new_wim_flags[i];
11749 return OK;
11750}
11751
11752/*
11753 * Check if backspacing over something is allowed.
11754 */
11755 int
11756can_bs(what)
11757 int what; /* BS_INDENT, BS_EOL or BS_START */
11758{
11759 switch (*p_bs)
11760 {
11761 case '2': return TRUE;
11762 case '1': return (what != BS_START);
11763 case '0': return FALSE;
11764 }
11765 return vim_strchr(p_bs, what) != NULL;
11766}
11767
11768/*
11769 * Save the current values of 'fileformat' and 'fileencoding', so that we know
11770 * the file must be considered changed when the value is different.
11771 */
11772 void
11773save_file_ff(buf)
11774 buf_T *buf;
11775{
11776 buf->b_start_ffc = *buf->b_p_ff;
11777 buf->b_start_eol = buf->b_p_eol;
11778#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011779 buf->b_start_bomb = buf->b_p_bomb;
11780
Bram Moolenaar071d4272004-06-13 20:20:40 +000011781 /* Only use free/alloc when necessary, they take time. */
11782 if (buf->b_start_fenc == NULL
11783 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
11784 {
11785 vim_free(buf->b_start_fenc);
11786 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
11787 }
11788#endif
11789}
11790
11791/*
11792 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
11793 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011794 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
11795 * changed and 'binary' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010011796 * When "ignore_empty" is true don't consider a new, empty buffer to be
11797 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011798 */
11799 int
Bram Moolenaar164c60f2011-01-22 00:11:50 +010011800file_ff_differs(buf, ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011801 buf_T *buf;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010011802 int ignore_empty;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011803{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000011804 /* In a buffer that was never loaded the options are not valid. */
11805 if (buf->b_flags & BF_NEVERLOADED)
11806 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010011807 if (ignore_empty
11808 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011809 && buf->b_ml.ml_line_count == 1
11810 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
11811 return FALSE;
11812 if (buf->b_start_ffc != *buf->b_p_ff)
11813 return TRUE;
11814 if (buf->b_p_bin && buf->b_start_eol != buf->b_p_eol)
11815 return TRUE;
11816#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011817 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
11818 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011819 if (buf->b_start_fenc == NULL)
11820 return (*buf->b_p_fenc != NUL);
11821 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
11822#else
11823 return FALSE;
11824#endif
11825}
11826
11827/*
11828 * return OK if "p" is a valid fileformat name, FAIL otherwise.
11829 */
11830 int
11831check_ff_value(p)
11832 char_u *p;
11833{
11834 return check_opt_strings(p, p_ff_values, FALSE);
11835}
Bram Moolenaar14f24742012-08-08 18:01:05 +020011836
11837/*
11838 * Return the effective shiftwidth value for current buffer, using the
11839 * 'tabstop' value when 'shiftwidth' is zero.
11840 */
11841 long
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010011842get_sw_value(buf)
11843 buf_T *buf;
Bram Moolenaar14f24742012-08-08 18:01:05 +020011844{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010011845 return buf->b_p_sw ? buf->b_p_sw : buf->b_p_ts;
Bram Moolenaar14f24742012-08-08 18:01:05 +020011846}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020011847
11848/*
11849 * Return the effective softtabstop value for the current buffer, using the
11850 * 'tabstop' value when 'softtabstop' is negative.
11851 */
11852 long
11853get_sts_value()
11854{
Bram Moolenaar6bcbcc52013-11-05 07:13:41 +010011855 return curbuf->b_p_sts < 0 ? get_sw_value(curbuf) : curbuf->b_p_sts;
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020011856}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010011857
11858/*
11859 * Check matchpairs option for "*initc".
11860 * If there is a match set "*initc" to the matching character and "*findc" to
11861 * the opposite character. Set "*backwards" to the direction.
11862 * When "switchit" is TRUE swap the direction.
11863 */
11864 void
11865find_mps_values(initc, findc, backwards, switchit)
11866 int *initc;
11867 int *findc;
11868 int *backwards;
11869 int switchit;
11870{
11871 char_u *ptr;
11872
11873 ptr = curbuf->b_p_mps;
11874 while (*ptr != NUL)
11875 {
11876#ifdef FEAT_MBYTE
11877 if (has_mbyte)
11878 {
11879 char_u *prev;
11880
11881 if (mb_ptr2char(ptr) == *initc)
11882 {
11883 if (switchit)
11884 {
11885 *findc = *initc;
11886 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
11887 *backwards = TRUE;
11888 }
11889 else
11890 {
11891 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
11892 *backwards = FALSE;
11893 }
11894 return;
11895 }
11896 prev = ptr;
11897 ptr += mb_ptr2len(ptr) + 1;
11898 if (mb_ptr2char(ptr) == *initc)
11899 {
11900 if (switchit)
11901 {
11902 *findc = *initc;
11903 *initc = mb_ptr2char(prev);
11904 *backwards = FALSE;
11905 }
11906 else
11907 {
11908 *findc = mb_ptr2char(prev);
11909 *backwards = TRUE;
11910 }
11911 return;
11912 }
11913 ptr += mb_ptr2len(ptr);
11914 }
11915 else
11916#endif
11917 {
11918 if (*ptr == *initc)
11919 {
11920 if (switchit)
11921 {
11922 *backwards = TRUE;
11923 *findc = *initc;
11924 *initc = ptr[2];
11925 }
11926 else
11927 {
11928 *backwards = FALSE;
11929 *findc = ptr[2];
11930 }
11931 return;
11932 }
11933 ptr += 2;
11934 if (*ptr == *initc)
11935 {
11936 if (switchit)
11937 {
11938 *backwards = FALSE;
11939 *findc = *initc;
11940 *initc = ptr[-2];
11941 }
11942 else
11943 {
11944 *backwards = TRUE;
11945 *findc = ptr[-2];
11946 }
11947 return;
11948 }
11949 ++ptr;
11950 }
11951 if (*ptr == ',')
11952 ++ptr;
11953 }
11954}