blob: 467d578a6fa43e08c0c55f3ee8b5edde716e68b0 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001/* vi:set ts=8 sts=4 sw=4:
2 *
3 * VIM - Vi IMproved by Bram Moolenaar
4 *
5 * Do ":help uganda" in Vim to read copying and usage conditions.
6 * Do ":help credits" in Vim to see a list of people who contributed.
7 * See README.txt for an overview of the Vim source code.
8 */
9
10/*
11 * Code to handle user-settable options. This is all pretty much table-
12 * driven. Checklist for adding a new option:
13 * - Put it in the options array below (copy an existing entry).
14 * - For a global option: Add a variable for it in option.h.
15 * - For a buffer or window local option:
16 * - Add a PV_XX entry to the enum below.
17 * - Add a variable to the window or buffer struct in structs.h.
18 * - For a window option, add some code to copy_winopt().
19 * - For a buffer option, add some code to buf_copy_options().
20 * - For a buffer string option, add code to check_buf_options().
21 * - If it's a numeric option, add any necessary bounds checks to do_set().
22 * - If it's a list of flags, add some code in do_set(), search for WW_ALL.
23 * - When adding an option with expansion (P_EXPAND), but with a different
24 * default for Vi and Vim (no P_VI_DEF), add some code at VIMEXP.
25 * - Add documentation! One line in doc/help.txt, full description in
26 * options.txt, and any other related places.
27 * - Add an entry in runtime/optwin.vim.
28 * When making changes:
29 * - Adjust the help for the option in doc/option.txt.
30 * - When an entry has the P_VIM flag, or is lacking the P_VI_DEF flag, add a
31 * comment at the help for the 'compatible' option.
32 */
33
34#define IN_OPTION_C
35#include "vim.h"
36
37/*
38 * The options that are local to a window or buffer have "indir" set to one of
39 * these values. Special values:
40 * PV_NONE: global option.
Bram Moolenaara23ccb82006-02-27 00:08:02 +000041 * PV_WIN is added: window-local option
42 * PV_BUF is added: buffer-local option
Bram Moolenaar071d4272004-06-13 20:20:40 +000043 * PV_BOTH is added: global option which also has a local value.
44 */
45#define PV_BOTH 0x1000
Bram Moolenaara23ccb82006-02-27 00:08:02 +000046#define PV_WIN 0x2000
47#define PV_BUF 0x4000
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000048#define PV_MASK 0x0fff
Bram Moolenaara23ccb82006-02-27 00:08:02 +000049#define OPT_WIN(x) (idopt_T)(PV_WIN + (int)(x))
50#define OPT_BUF(x) (idopt_T)(PV_BUF + (int)(x))
Bram Moolenaar071d4272004-06-13 20:20:40 +000051#define OPT_BOTH(x) (idopt_T)(PV_BOTH + (int)(x))
52
Bram Moolenaara23ccb82006-02-27 00:08:02 +000053/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000054 * Definition of the PV_ values for buffer-local options.
55 * The BV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +000056 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +000057#define PV_AI OPT_BUF(BV_AI)
58#define PV_AR OPT_BOTH(OPT_BUF(BV_AR))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000059#ifdef FEAT_QUICKFIX
Bram Moolenaara23ccb82006-02-27 00:08:02 +000060# define PV_BH OPT_BUF(BV_BH)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000061# define PV_BT OPT_BUF(BV_BT)
62# define PV_EFM OPT_BOTH(OPT_BUF(BV_EFM))
63# define PV_GP OPT_BOTH(OPT_BUF(BV_GP))
64# define PV_MP OPT_BOTH(OPT_BUF(BV_MP))
Bram Moolenaara23ccb82006-02-27 00:08:02 +000065#endif
66#define PV_BIN OPT_BUF(BV_BIN)
67#define PV_BL OPT_BUF(BV_BL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000068#ifdef FEAT_MBYTE
69# define PV_BOMB OPT_BUF(BV_BOMB)
70#endif
71#define PV_CI OPT_BUF(BV_CI)
72#ifdef FEAT_CINDENT
73# define PV_CIN OPT_BUF(BV_CIN)
74# define PV_CINK OPT_BUF(BV_CINK)
75# define PV_CINO OPT_BUF(BV_CINO)
76#endif
77#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
78# define PV_CINW OPT_BUF(BV_CINW)
79#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020080#define PV_CM OPT_BOTH(OPT_BUF(BV_CM))
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +000081#ifdef FEAT_FOLDING
82# define PV_CMS OPT_BUF(BV_CMS)
83#endif
84#ifdef FEAT_COMMENTS
85# define PV_COM OPT_BUF(BV_COM)
86#endif
87#ifdef FEAT_INS_EXPAND
88# define PV_CPT OPT_BUF(BV_CPT)
89# define PV_DICT OPT_BOTH(OPT_BUF(BV_DICT))
90# define PV_TSR OPT_BOTH(OPT_BUF(BV_TSR))
91#endif
92#ifdef FEAT_COMPL_FUNC
93# define PV_CFU OPT_BUF(BV_CFU)
94#endif
95#ifdef FEAT_FIND_ID
96# define PV_DEF OPT_BOTH(OPT_BUF(BV_DEF))
97# define PV_INC OPT_BOTH(OPT_BUF(BV_INC))
98#endif
99#define PV_EOL OPT_BUF(BV_EOL)
100#define PV_EP OPT_BOTH(OPT_BUF(BV_EP))
101#define PV_ET OPT_BUF(BV_ET)
102#ifdef FEAT_MBYTE
103# define PV_FENC OPT_BUF(BV_FENC)
104#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000105#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
106# define PV_BEXPR OPT_BOTH(OPT_BUF(BV_BEXPR))
107#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000108#ifdef FEAT_EVAL
109# define PV_FEX OPT_BUF(BV_FEX)
110#endif
111#define PV_FF OPT_BUF(BV_FF)
112#define PV_FLP OPT_BUF(BV_FLP)
113#define PV_FO OPT_BUF(BV_FO)
114#ifdef FEAT_AUTOCMD
115# define PV_FT OPT_BUF(BV_FT)
116#endif
117#define PV_IMI OPT_BUF(BV_IMI)
118#define PV_IMS OPT_BUF(BV_IMS)
119#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
120# define PV_INDE OPT_BUF(BV_INDE)
121# define PV_INDK OPT_BUF(BV_INDK)
122#endif
123#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
124# define PV_INEX OPT_BUF(BV_INEX)
125#endif
126#define PV_INF OPT_BUF(BV_INF)
127#define PV_ISK OPT_BUF(BV_ISK)
128#ifdef FEAT_CRYPT
129# define PV_KEY OPT_BUF(BV_KEY)
130#endif
131#ifdef FEAT_KEYMAP
132# define PV_KMAP OPT_BUF(BV_KMAP)
133#endif
134#define PV_KP OPT_BOTH(OPT_BUF(BV_KP))
135#ifdef FEAT_LISP
136# define PV_LISP OPT_BUF(BV_LISP)
137#endif
138#define PV_MA OPT_BUF(BV_MA)
139#define PV_ML OPT_BUF(BV_ML)
140#define PV_MOD OPT_BUF(BV_MOD)
141#define PV_MPS OPT_BUF(BV_MPS)
142#define PV_NF OPT_BUF(BV_NF)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000143#ifdef FEAT_COMPL_FUNC
144# define PV_OFU OPT_BUF(BV_OFU)
145#endif
146#define PV_PATH OPT_BOTH(OPT_BUF(BV_PATH))
147#define PV_PI OPT_BUF(BV_PI)
148#ifdef FEAT_TEXTOBJ
149# define PV_QE OPT_BUF(BV_QE)
150#endif
151#define PV_RO OPT_BUF(BV_RO)
152#ifdef FEAT_SMARTINDENT
153# define PV_SI OPT_BUF(BV_SI)
154#endif
155#ifndef SHORT_FNAME
156# define PV_SN OPT_BUF(BV_SN)
157#endif
158#ifdef FEAT_SYN_HL
159# define PV_SMC OPT_BUF(BV_SMC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000160# define PV_SYN OPT_BUF(BV_SYN)
161#endif
162#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000163# define PV_SPC OPT_BUF(BV_SPC)
164# define PV_SPF OPT_BUF(BV_SPF)
165# define PV_SPL OPT_BUF(BV_SPL)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000166#endif
167#define PV_STS OPT_BUF(BV_STS)
168#ifdef FEAT_SEARCHPATH
169# define PV_SUA OPT_BUF(BV_SUA)
170#endif
171#define PV_SW OPT_BUF(BV_SW)
172#define PV_SWF OPT_BUF(BV_SWF)
173#define PV_TAGS OPT_BOTH(OPT_BUF(BV_TAGS))
174#define PV_TS OPT_BUF(BV_TS)
175#define PV_TW OPT_BUF(BV_TW)
176#define PV_TX OPT_BUF(BV_TX)
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200177#ifdef FEAT_PERSISTENT_UNDO
178# define PV_UDF OPT_BUF(BV_UDF)
179#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000180#define PV_WM OPT_BUF(BV_WM)
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000181
182/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000183 * Definition of the PV_ values for window-local options.
184 * The WV_ values are defined in option.h.
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000185 */
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000186#define PV_LIST OPT_WIN(WV_LIST)
187#ifdef FEAT_ARABIC
188# define PV_ARAB OPT_WIN(WV_ARAB)
189#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000190#ifdef FEAT_DIFF
191# define PV_DIFF OPT_WIN(WV_DIFF)
192#endif
193#ifdef FEAT_FOLDING
194# define PV_FDC OPT_WIN(WV_FDC)
195# define PV_FEN OPT_WIN(WV_FEN)
196# define PV_FDI OPT_WIN(WV_FDI)
197# define PV_FDL OPT_WIN(WV_FDL)
198# define PV_FDM OPT_WIN(WV_FDM)
199# define PV_FML OPT_WIN(WV_FML)
200# define PV_FDN OPT_WIN(WV_FDN)
201# ifdef FEAT_EVAL
202# define PV_FDE OPT_WIN(WV_FDE)
203# define PV_FDT OPT_WIN(WV_FDT)
204# endif
205# define PV_FMR OPT_WIN(WV_FMR)
206#endif
207#ifdef FEAT_LINEBREAK
208# define PV_LBR OPT_WIN(WV_LBR)
209#endif
210#define PV_NU OPT_WIN(WV_NU)
Bram Moolenaar64486672010-05-16 15:46:46 +0200211#define PV_RNU OPT_WIN(WV_RNU)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000212#ifdef FEAT_LINEBREAK
213# define PV_NUW OPT_WIN(WV_NUW)
214#endif
215#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
216# define PV_PVW OPT_WIN(WV_PVW)
217#endif
218#ifdef FEAT_RIGHTLEFT
219# define PV_RL OPT_WIN(WV_RL)
220# define PV_RLC OPT_WIN(WV_RLC)
221#endif
222#ifdef FEAT_SCROLLBIND
223# define PV_SCBIND OPT_WIN(WV_SCBIND)
224#endif
225#define PV_SCROLL OPT_WIN(WV_SCROLL)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000226#ifdef FEAT_SPELL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000227# define PV_SPELL OPT_WIN(WV_SPELL)
228#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000229#ifdef FEAT_SYN_HL
230# define PV_CUC OPT_WIN(WV_CUC)
231# define PV_CUL OPT_WIN(WV_CUL)
Bram Moolenaar1a384422010-07-14 19:53:30 +0200232# define PV_CC OPT_WIN(WV_CC)
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000233#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000234#ifdef FEAT_STL_OPT
235# define PV_STL OPT_BOTH(OPT_WIN(WV_STL))
236#endif
237#ifdef FEAT_WINDOWS
238# define PV_WFH OPT_WIN(WV_WFH)
239#endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +0000240#ifdef FEAT_VERTSPLIT
241# define PV_WFW OPT_WIN(WV_WFW)
242#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000243#define PV_WRAP OPT_WIN(WV_WRAP)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200244#ifdef FEAT_CURSORBIND
245# define PV_CRBIND OPT_WIN(WV_CRBIND)
246#endif
247#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200248# define PV_COCU OPT_WIN(WV_COCU)
249# define PV_COLE OPT_WIN(WV_COLE)
Bram Moolenaar860cae12010-06-05 23:22:07 +0200250#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000251
252/* WV_ and BV_ values get typecasted to this for the "indir" field */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000253typedef enum
254{
Bram Moolenaar7d96acd2008-06-09 15:07:54 +0000255 PV_NONE = 0,
256 PV_MAXVAL = 0xffff /* to avoid warnings for value out of range */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000257} idopt_T;
258
259/*
260 * Options local to a window have a value local to a buffer and global to all
261 * buffers. Indicate this by setting "var" to VAR_WIN.
262 */
263#define VAR_WIN ((char_u *)-1)
264
265/*
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000266 * These are the global values for options which are also local to a buffer.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000267 * Only to be used in option.c!
268 */
269static int p_ai;
270static int p_bin;
271#ifdef FEAT_MBYTE
272static int p_bomb;
273#endif
274#if defined(FEAT_QUICKFIX)
275static char_u *p_bh;
276static char_u *p_bt;
277#endif
278static int p_bl;
279static int p_ci;
280#ifdef FEAT_CINDENT
281static int p_cin;
282static char_u *p_cink;
283static char_u *p_cino;
284#endif
285#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
286static char_u *p_cinw;
287#endif
288#ifdef FEAT_COMMENTS
289static char_u *p_com;
290#endif
291#ifdef FEAT_FOLDING
292static char_u *p_cms;
293#endif
294#ifdef FEAT_INS_EXPAND
295static char_u *p_cpt;
296#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000297#ifdef FEAT_COMPL_FUNC
298static char_u *p_cfu;
Bram Moolenaare344bea2005-09-01 20:46:49 +0000299static char_u *p_ofu;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000300#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000301static int p_eol;
302static int p_et;
303#ifdef FEAT_MBYTE
304static char_u *p_fenc;
305#endif
306static char_u *p_ff;
307static char_u *p_fo;
Bram Moolenaar86b68352004-12-27 21:59:20 +0000308static char_u *p_flp;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000309#ifdef FEAT_AUTOCMD
310static char_u *p_ft;
311#endif
312static long p_iminsert;
313static long p_imsearch;
314#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
315static char_u *p_inex;
316#endif
317#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
318static char_u *p_inde;
319static char_u *p_indk;
320#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +0000321#if defined(FEAT_EVAL)
322static char_u *p_fex;
323#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000324static int p_inf;
325static char_u *p_isk;
326#ifdef FEAT_CRYPT
327static char_u *p_key;
328#endif
329#ifdef FEAT_LISP
330static int p_lisp;
331#endif
332static int p_ml;
333static int p_ma;
334static int p_mod;
335static char_u *p_mps;
336static char_u *p_nf;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000337static int p_pi;
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000338#ifdef FEAT_TEXTOBJ
339static char_u *p_qe;
340#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000341static int p_ro;
342#ifdef FEAT_SMARTINDENT
343static int p_si;
344#endif
345#ifndef SHORT_FNAME
346static int p_sn;
347#endif
348static long p_sts;
349#if defined(FEAT_SEARCHPATH)
350static char_u *p_sua;
351#endif
352static long p_sw;
353static int p_swf;
354#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +0000355static long p_smc;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000356static char_u *p_syn;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000357#endif
358#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +0000359static char_u *p_spc;
Bram Moolenaar82cf9b62005-06-07 21:09:25 +0000360static char_u *p_spf;
Bram Moolenaar217ad922005-03-20 22:37:15 +0000361static char_u *p_spl;
Bram Moolenaar071d4272004-06-13 20:20:40 +0000362#endif
363static long p_ts;
364static long p_tw;
365static int p_tx;
Bram Moolenaar55debbe2010-05-23 23:34:36 +0200366#ifdef FEAT_PERSISTENT_UNDO
367static int p_udf;
368#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000369static long p_wm;
370#ifdef FEAT_KEYMAP
371static char_u *p_keymap;
372#endif
373
374/* Saved values for when 'bin' is set. */
375static int p_et_nobin;
376static int p_ml_nobin;
377static long p_tw_nobin;
378static long p_wm_nobin;
379
380/* Saved values for when 'paste' is set */
381static long p_tw_nopaste;
382static long p_wm_nopaste;
383static long p_sts_nopaste;
384static int p_ai_nopaste;
385
386struct vimoption
387{
388 char *fullname; /* full option name */
389 char *shortname; /* permissible abbreviation */
390 long_u flags; /* see below */
391 char_u *var; /* global option: pointer to variable;
392 * window-local option: VAR_WIN;
393 * buffer-local option: global value */
394 idopt_T indir; /* global option: PV_NONE;
395 * local option: indirect option index */
396 char_u *def_val[2]; /* default values for variable (vi and vim) */
397#ifdef FEAT_EVAL
398 scid_T scriptID; /* script in which the option was last set */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000399# define SCRIPTID_INIT , 0
400#else
401# define SCRIPTID_INIT
Bram Moolenaar071d4272004-06-13 20:20:40 +0000402#endif
403};
404
405#define VI_DEFAULT 0 /* def_val[VI_DEFAULT] is Vi default value */
406#define VIM_DEFAULT 1 /* def_val[VIM_DEFAULT] is Vim default value */
407
408/*
409 * Flags
410 */
411#define P_BOOL 0x01 /* the option is boolean */
412#define P_NUM 0x02 /* the option is numeric */
413#define P_STRING 0x04 /* the option is a string */
414#define P_ALLOCED 0x08 /* the string option is in allocated memory,
Bram Moolenaar363cb672009-07-22 12:28:17 +0000415 must use free_string_option() when
416 assigning new value. Not set if default is
417 the same. */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000418#define P_EXPAND 0x10 /* environment expansion. NOTE: P_EXPAND can
419 never be used for local or hidden options! */
420#define P_NODEFAULT 0x40 /* don't set to default value */
421#define P_DEF_ALLOCED 0x80 /* default value is in allocated memory, must
422 use vim_free() when assigning new value */
423#define P_WAS_SET 0x100 /* option has been set/reset */
424#define P_NO_MKRC 0x200 /* don't include in :mkvimrc output */
425#define P_VI_DEF 0x400 /* Use Vi default for Vim */
426#define P_VIM 0x800 /* Vim option, reset when 'cp' set */
427
428 /* when option changed, what to display: */
429#define P_RSTAT 0x1000 /* redraw status lines */
430#define P_RWIN 0x2000 /* redraw current window */
431#define P_RBUF 0x4000 /* redraw current buffer */
432#define P_RALL 0x6000 /* redraw all windows */
433#define P_RCLR 0x7000 /* clear and redraw all */
434
435#define P_COMMA 0x8000 /* comma separated list */
Bram Moolenaar913077c2012-03-28 19:59:04 +0200436#define P_NODUP 0x10000L /* don't allow duplicate strings */
437#define P_FLAGLIST 0x20000L /* list of single-char flags */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000438
Bram Moolenaar913077c2012-03-28 19:59:04 +0200439#define P_SECURE 0x40000L /* cannot change in modeline or secure mode */
440#define P_GETTEXT 0x80000L /* expand default value with _() */
441#define P_NOGLOB 0x100000L /* do not use local value for global vimrc */
442#define P_NFNAME 0x200000L /* only normal file name chars allowed */
443#define P_INSECURE 0x400000L /* option was set from a modeline */
444#define P_PRI_MKRC 0x800000L /* priority for :mkvimrc (setting option has
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000445 side effects) */
Bram Moolenaar913077c2012-03-28 19:59:04 +0200446#define P_NO_ML 0x1000000L /* not allowed in modeline */
447#define P_CURSWANT 0x2000000L /* update curswant required; not needed when
448 * there is a redraw flag */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000449
Bram Moolenaar362e1a32006-03-06 23:29:24 +0000450#define ISK_LATIN1 (char_u *)"@,48-57,_,192-255"
451
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000452/* 'isprint' for latin1 is also used for MS-Windows cp1252, where 0x80 is used
453 * for the currency sign. */
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000454#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
Bram Moolenaare2f98b92006-03-29 21:18:24 +0000455# define ISP_LATIN1 (char_u *)"@,~-255"
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +0000456#else
457# define ISP_LATIN1 (char_u *)"@,161-255"
458#endif
459
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000460/* The 16 bit MS-DOS version is low on space, make the string as short as
461 * possible when compiling with few features. */
462#if defined(FEAT_DIFF) || defined(FEAT_FOLDING) || defined(FEAT_SPELL) \
463 || defined(FEAT_VERTSPLIT) || defined(FEAT_CLIPBOARD) \
Bram Moolenaar860cae12010-06-05 23:22:07 +0200464 || defined(FEAT_INS_EXPAND) || defined(FEAT_SYN_HL) || defined(FEAT_CONCEAL)
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100465# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,c:VertSplit,t:Title,v:Visual,V:VisualNOS,w:WarningMsg,W:WildMenu,f:Folded,F:FoldColumn,A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal,B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel,x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill,!:CursorColumn,.:CursorLine,o:ColorColumn"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000466#else
Bram Moolenaar06ca5132012-03-23 16:25:17 +0100467# define HIGHLIGHT_INIT "8:SpecialKey,@:NonText,d:Directory,e:ErrorMsg,i:IncSearch,l:Search,m:MoreMsg,M:ModeMsg,n:LineNr,N:CursorLineNr,r:Question,s:StatusLine,S:StatusLineNC,t:Title,v:Visual,w:WarningMsg,W:WildMenu,>:SignColumn,*:TabLine,#:TabLineSel,_:TabLineFill"
Bram Moolenaar3991dab2006-03-27 17:01:56 +0000468#endif
469
Bram Moolenaar071d4272004-06-13 20:20:40 +0000470/*
471 * options[] is initialized here.
472 * The order of the options MUST be alphabetic for ":set all" and findoption().
473 * All option names MUST start with a lowercase letter (for findoption()).
474 * Exception: "t_" options are at the end.
475 * The options with a NULL variable are 'hidden': a set command for them is
476 * ignored and they are not printed.
477 */
478static struct vimoption
479#ifdef FEAT_GUI_W16
480 _far
481#endif
482 options[] =
483{
Bram Moolenaar913077c2012-03-28 19:59:04 +0200484 {"aleph", "al", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000485#ifdef FEAT_RIGHTLEFT
486 (char_u *)&p_aleph, PV_NONE,
487#else
488 (char_u *)NULL, PV_NONE,
489#endif
490 {
491#if (defined(MSDOS) || defined(WIN3264) || defined(OS2)) && !defined(FEAT_GUI_W32)
492 (char_u *)128L,
493#else
494 (char_u *)224L,
495#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000496 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000497 {"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
498#if defined(FEAT_GUI) && defined(MACOS_X)
499 (char_u *)&p_antialias, PV_NONE,
500 {(char_u *)FALSE, (char_u *)FALSE}
501#else
502 (char_u *)NULL, PV_NONE,
503 {(char_u *)FALSE, (char_u *)FALSE}
504#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000505 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200506 {"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000507#ifdef FEAT_ARABIC
508 (char_u *)VAR_WIN, PV_ARAB,
509#else
510 (char_u *)NULL, PV_NONE,
511#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000512 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000513 {"arabicshape", "arshape", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
514#ifdef FEAT_ARABIC
515 (char_u *)&p_arshape, PV_NONE,
516#else
517 (char_u *)NULL, PV_NONE,
518#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000519 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000520 {"allowrevins", "ari", P_BOOL|P_VI_DEF|P_VIM,
521#ifdef FEAT_RIGHTLEFT
522 (char_u *)&p_ari, PV_NONE,
523#else
524 (char_u *)NULL, PV_NONE,
525#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000526 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000527 {"altkeymap", "akm", P_BOOL|P_VI_DEF,
528#ifdef FEAT_FKMAP
529 (char_u *)&p_altkeymap, PV_NONE,
530#else
531 (char_u *)NULL, PV_NONE,
532#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000533 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000534 {"ambiwidth", "ambw", P_STRING|P_VI_DEF|P_RCLR,
535#if defined(FEAT_MBYTE)
536 (char_u *)&p_ambw, PV_NONE,
537 {(char_u *)"single", (char_u *)0L}
538#else
539 (char_u *)NULL, PV_NONE,
540 {(char_u *)0L, (char_u *)0L}
541#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000542 SCRIPTID_INIT},
Bram Moolenaar8dff8182006-04-06 20:18:50 +0000543#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +0000544 {"autochdir", "acd", P_BOOL|P_VI_DEF,
545 (char_u *)&p_acd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000546 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000547#endif
548 {"autoindent", "ai", P_BOOL|P_VI_DEF,
549 (char_u *)&p_ai, PV_AI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000550 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000551 {"autoprint", "ap", P_BOOL|P_VI_DEF,
552 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000553 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000554 {"autoread", "ar", P_BOOL|P_VI_DEF,
Bram Moolenaara23ccb82006-02-27 00:08:02 +0000555 (char_u *)&p_ar, PV_AR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000556 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000557 {"autowrite", "aw", P_BOOL|P_VI_DEF,
558 (char_u *)&p_aw, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000559 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000560 {"autowriteall","awa", P_BOOL|P_VI_DEF,
561 (char_u *)&p_awa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000562 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000563 {"background", "bg", P_STRING|P_VI_DEF|P_RCLR,
564 (char_u *)&p_bg, PV_NONE,
565 {
566#if (defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI)
567 (char_u *)"dark",
568#else
569 (char_u *)"light",
570#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000571 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000572 {"backspace", "bs", P_STRING|P_VI_DEF|P_VIM|P_COMMA|P_NODUP,
573 (char_u *)&p_bs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000574 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000575 {"backup", "bk", P_BOOL|P_VI_DEF|P_VIM,
576 (char_u *)&p_bk, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000577 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000578 {"backupcopy", "bkc", P_STRING|P_VIM|P_COMMA|P_NODUP,
579 (char_u *)&p_bkc, PV_NONE,
580#ifdef UNIX
581 {(char_u *)"yes", (char_u *)"auto"}
582#else
583 {(char_u *)"auto", (char_u *)"auto"}
584#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000585 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000586 {"backupdir", "bdir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE,
587 (char_u *)&p_bdir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000588 {(char_u *)DFLT_BDIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +0000589 {"backupext", "bex", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000590 (char_u *)&p_bex, PV_NONE,
591 {
592#ifdef VMS
593 (char_u *)"_",
594#else
595 (char_u *)"~",
596#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000597 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000598 {"backupskip", "bsk", P_STRING|P_VI_DEF|P_COMMA,
599#ifdef FEAT_WILDIGN
600 (char_u *)&p_bsk, PV_NONE,
601 {(char_u *)"", (char_u *)0L}
602#else
603 (char_u *)NULL, PV_NONE,
604 {(char_u *)0L, (char_u *)0L}
605#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000606 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000607#ifdef FEAT_BEVAL
608 {"balloondelay","bdlay",P_NUM|P_VI_DEF,
609 (char_u *)&p_bdlay, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000610 {(char_u *)600L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000611 {"ballooneval", "beval",P_BOOL|P_VI_DEF|P_NO_MKRC,
612 (char_u *)&p_beval, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000613 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000614# ifdef FEAT_EVAL
Bram Moolenaar39f05632006-03-19 22:15:26 +0000615 {"balloonexpr", "bexpr", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar9b2200a2006-03-20 21:55:45 +0000616 (char_u *)&p_bexpr, PV_BEXPR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000617 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +0000618# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000619#endif
620 {"beautify", "bf", P_BOOL|P_VI_DEF,
621 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000622 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000623 {"binary", "bin", P_BOOL|P_VI_DEF|P_RSTAT,
624 (char_u *)&p_bin, PV_BIN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000625 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000626 {"bioskey", "biosk",P_BOOL|P_VI_DEF,
627#ifdef MSDOS
628 (char_u *)&p_biosk, PV_NONE,
629#else
630 (char_u *)NULL, PV_NONE,
631#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000632 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000633 {"bomb", NULL, P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
634#ifdef FEAT_MBYTE
635 (char_u *)&p_bomb, PV_BOMB,
636#else
637 (char_u *)NULL, PV_NONE,
638#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000639 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000640 {"breakat", "brk", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
641#ifdef FEAT_LINEBREAK
642 (char_u *)&p_breakat, PV_NONE,
643 {(char_u *)" \t!@*-+;:,./?", (char_u *)0L}
644#else
645 (char_u *)NULL, PV_NONE,
646 {(char_u *)0L, (char_u *)0L}
647#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000648 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000649 {"browsedir", "bsdir",P_STRING|P_VI_DEF,
650#ifdef FEAT_BROWSE
651 (char_u *)&p_bsdir, PV_NONE,
652 {(char_u *)"last", (char_u *)0L}
653#else
654 (char_u *)NULL, PV_NONE,
655 {(char_u *)0L, (char_u *)0L}
656#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000657 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000658 {"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
659#if defined(FEAT_QUICKFIX)
660 (char_u *)&p_bh, PV_BH,
661 {(char_u *)"", (char_u *)0L}
662#else
663 (char_u *)NULL, PV_NONE,
664 {(char_u *)0L, (char_u *)0L}
665#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000666 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000667 {"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
668 (char_u *)&p_bl, PV_BL,
669 {(char_u *)1L, (char_u *)0L}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000670 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000671 {"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
672#if defined(FEAT_QUICKFIX)
673 (char_u *)&p_bt, PV_BT,
674 {(char_u *)"", (char_u *)0L}
675#else
676 (char_u *)NULL, PV_NONE,
677 {(char_u *)0L, (char_u *)0L}
678#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000679 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000680 {"casemap", "cmp", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000681#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000682 (char_u *)&p_cmp, PV_NONE,
683 {(char_u *)"internal,keepascii", (char_u *)0L}
Bram Moolenaarfa1d1402006-03-25 21:59:56 +0000684#else
685 (char_u *)NULL, PV_NONE,
686 {(char_u *)0L, (char_u *)0L}
687#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000688 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000689 {"cdpath", "cd", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
690#ifdef FEAT_SEARCHPATH
691 (char_u *)&p_cdpath, PV_NONE,
692 {(char_u *)",,", (char_u *)0L}
693#else
694 (char_u *)NULL, PV_NONE,
695 {(char_u *)0L, (char_u *)0L}
696#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000697 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000698 {"cedit", NULL, P_STRING,
699#ifdef FEAT_CMDWIN
700 (char_u *)&p_cedit, PV_NONE,
701 {(char_u *)"", (char_u *)CTRL_F_STR}
702#else
703 (char_u *)NULL, PV_NONE,
704 {(char_u *)0L, (char_u *)0L}
705#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000706 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000707 {"charconvert", "ccv", P_STRING|P_VI_DEF|P_SECURE,
708#if defined(FEAT_MBYTE) && defined(FEAT_EVAL)
709 (char_u *)&p_ccv, PV_NONE,
710 {(char_u *)"", (char_u *)0L}
711#else
712 (char_u *)NULL, PV_NONE,
713 {(char_u *)0L, (char_u *)0L}
714#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000715 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000716 {"cindent", "cin", P_BOOL|P_VI_DEF|P_VIM,
717#ifdef FEAT_CINDENT
718 (char_u *)&p_cin, PV_CIN,
719#else
720 (char_u *)NULL, PV_NONE,
721#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000722 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000723 {"cinkeys", "cink", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
724#ifdef FEAT_CINDENT
725 (char_u *)&p_cink, PV_CINK,
726 {(char_u *)"0{,0},0),:,0#,!^F,o,O,e", (char_u *)0L}
727#else
728 (char_u *)NULL, PV_NONE,
729 {(char_u *)0L, (char_u *)0L}
730#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000731 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000732 {"cinoptions", "cino", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
733#ifdef FEAT_CINDENT
734 (char_u *)&p_cino, PV_CINO,
735#else
736 (char_u *)NULL, PV_NONE,
737#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000738 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000739 {"cinwords", "cinw", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
740#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
741 (char_u *)&p_cinw, PV_CINW,
742 {(char_u *)"if,else,while,do,for,switch",
743 (char_u *)0L}
744#else
745 (char_u *)NULL, PV_NONE,
746 {(char_u *)0L, (char_u *)0L}
747#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000748 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000749 {"clipboard", "cb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
750#ifdef FEAT_CLIPBOARD
751 (char_u *)&p_cb, PV_NONE,
752# ifdef FEAT_XCLIPBOARD
753 {(char_u *)"autoselect,exclude:cons\\|linux",
754 (char_u *)0L}
755# else
756 {(char_u *)"", (char_u *)0L}
757# endif
758#else
759 (char_u *)NULL, PV_NONE,
760 {(char_u *)"", (char_u *)0L}
761#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000762 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000763 {"cmdheight", "ch", P_NUM|P_VI_DEF|P_RALL,
764 (char_u *)&p_ch, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000765 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000766 {"cmdwinheight", "cwh", P_NUM|P_VI_DEF,
767#ifdef FEAT_CMDWIN
768 (char_u *)&p_cwh, PV_NONE,
769#else
770 (char_u *)NULL, PV_NONE,
771#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000772 {(char_u *)7L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +0200773 {"colorcolumn", "cc", P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_RWIN,
774#ifdef FEAT_SYN_HL
775 (char_u *)VAR_WIN, PV_CC,
776#else
777 (char_u *)NULL, PV_NONE,
778#endif
779 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000780 {"columns", "co", P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
781 (char_u *)&Columns, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000782 {(char_u *)80L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200783 {"comments", "com", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000784#ifdef FEAT_COMMENTS
785 (char_u *)&p_com, PV_COM,
786 {(char_u *)"s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,fb:-",
787 (char_u *)0L}
788#else
789 (char_u *)NULL, PV_NONE,
790 {(char_u *)0L, (char_u *)0L}
791#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000792 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200793 {"commentstring", "cms", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000794#ifdef FEAT_FOLDING
795 (char_u *)&p_cms, PV_CMS,
796 {(char_u *)"/*%s*/", (char_u *)0L}
797#else
798 (char_u *)NULL, PV_NONE,
799 {(char_u *)0L, (char_u *)0L}
800#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000801 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +0000802 /* P_PRI_MKRC isn't needed here, optval_default()
803 * always returns TRUE for 'compatible' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000804 {"compatible", "cp", P_BOOL|P_RALL,
805 (char_u *)&p_cp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000806 {(char_u *)TRUE, (char_u *)FALSE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000807 {"complete", "cpt", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
808#ifdef FEAT_INS_EXPAND
809 (char_u *)&p_cpt, PV_CPT,
810 {(char_u *)".,w,b,u,t,i", (char_u *)0L}
811#else
812 (char_u *)NULL, PV_NONE,
813 {(char_u *)0L, (char_u *)0L}
814#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000815 SCRIPTID_INIT},
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200816 {"concealcursor","cocu", P_STRING|P_ALLOCED|P_RWIN|P_VI_DEF,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200817#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +0200818 (char_u *)VAR_WIN, PV_COCU,
819 {(char_u *)"", (char_u *)NULL}
820#else
821 (char_u *)NULL, PV_NONE,
822 {(char_u *)NULL, (char_u *)0L}
823#endif
824 SCRIPTID_INIT},
825 {"conceallevel","cole", P_NUM|P_RWIN|P_VI_DEF,
826#ifdef FEAT_CONCEAL
827 (char_u *)VAR_WIN, PV_COLE,
Bram Moolenaar860cae12010-06-05 23:22:07 +0200828#else
829 (char_u *)NULL, PV_NONE,
830#endif
831 {(char_u *)0L, (char_u *)0L}
832 SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +0000833 {"completefunc", "cfu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
834#ifdef FEAT_COMPL_FUNC
835 (char_u *)&p_cfu, PV_CFU,
836 {(char_u *)"", (char_u *)0L}
837#else
838 (char_u *)NULL, PV_NONE,
839 {(char_u *)0L, (char_u *)0L}
840#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000841 SCRIPTID_INIT},
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000842 {"completeopt", "cot", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
843#ifdef FEAT_INS_EXPAND
844 (char_u *)&p_cot, PV_NONE,
Bram Moolenaarc270d802006-03-11 21:29:41 +0000845 {(char_u *)"menu,preview", (char_u *)0L}
Bram Moolenaar1c7715d2005-10-03 22:02:18 +0000846#else
847 (char_u *)NULL, PV_NONE,
848 {(char_u *)0L, (char_u *)0L}
849#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000850 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000851 {"confirm", "cf", P_BOOL|P_VI_DEF,
852#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
853 (char_u *)&p_confirm, PV_NONE,
854#else
855 (char_u *)NULL, PV_NONE,
856#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000857 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000858 {"conskey", "consk",P_BOOL|P_VI_DEF,
859#ifdef MSDOS
860 (char_u *)&p_consk, PV_NONE,
861#else
862 (char_u *)NULL, PV_NONE,
863#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000864 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000865 {"copyindent", "ci", P_BOOL|P_VI_DEF|P_VIM,
866 (char_u *)&p_ci, PV_CI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000867 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000868 {"cpoptions", "cpo", P_STRING|P_VIM|P_RALL|P_FLAGLIST,
869 (char_u *)&p_cpo, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000870 {(char_u *)CPO_VI, (char_u *)CPO_VIM}
871 SCRIPTID_INIT},
Bram Moolenaar49771f42010-07-20 17:32:38 +0200872 {"cryptmethod", "cm", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200873#ifdef FEAT_CRYPT
Bram Moolenaar40e6a712010-05-16 22:32:54 +0200874 (char_u *)&p_cm, PV_CM,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200875 {(char_u *)"zip", (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200876#else
877 (char_u *)NULL, PV_NONE,
Bram Moolenaar49771f42010-07-20 17:32:38 +0200878 {(char_u *)0L, (char_u *)0L}
Bram Moolenaar0bbabe82010-05-17 20:32:55 +0200879#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +0200880 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000881 {"cscopepathcomp", "cspc", P_NUM|P_VI_DEF|P_VIM,
882#ifdef FEAT_CSCOPE
883 (char_u *)&p_cspc, PV_NONE,
884#else
885 (char_u *)NULL, PV_NONE,
886#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000887 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000888 {"cscopeprg", "csprg", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
889#ifdef FEAT_CSCOPE
890 (char_u *)&p_csprg, PV_NONE,
891 {(char_u *)"cscope", (char_u *)0L}
892#else
893 (char_u *)NULL, PV_NONE,
894 {(char_u *)0L, (char_u *)0L}
895#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000896 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000897 {"cscopequickfix", "csqf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
898#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
899 (char_u *)&p_csqf, PV_NONE,
900 {(char_u *)"", (char_u *)0L}
901#else
902 (char_u *)NULL, PV_NONE,
903 {(char_u *)0L, (char_u *)0L}
904#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000905 SCRIPTID_INIT},
Bram Moolenaarf7befa92011-06-12 22:13:40 +0200906 {"cscoperelative", "csre", P_BOOL|P_VI_DEF|P_VIM,
907#ifdef FEAT_CSCOPE
908 (char_u *)&p_csre, PV_NONE,
909#else
910 (char_u *)NULL, PV_NONE,
911#endif
912 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000913 {"cscopetag", "cst", P_BOOL|P_VI_DEF|P_VIM,
914#ifdef FEAT_CSCOPE
915 (char_u *)&p_cst, PV_NONE,
916#else
917 (char_u *)NULL, PV_NONE,
918#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000919 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000920 {"cscopetagorder", "csto", P_NUM|P_VI_DEF|P_VIM,
921#ifdef FEAT_CSCOPE
922 (char_u *)&p_csto, PV_NONE,
923#else
924 (char_u *)NULL, PV_NONE,
925#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000926 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000927 {"cscopeverbose", "csverb", P_BOOL|P_VI_DEF|P_VIM,
928#ifdef FEAT_CSCOPE
929 (char_u *)&p_csverbose, PV_NONE,
930#else
931 (char_u *)NULL, PV_NONE,
932#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000933 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar860cae12010-06-05 23:22:07 +0200934 {"cursorbind", "crb", P_BOOL|P_VI_DEF,
935#ifdef FEAT_CURSORBIND
936 (char_u *)VAR_WIN, PV_CRBIND,
937#else
938 (char_u *)NULL, PV_NONE,
939#endif
940 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000941 {"cursorcolumn", "cuc", P_BOOL|P_VI_DEF|P_RWIN,
942#ifdef FEAT_SYN_HL
943 (char_u *)VAR_WIN, PV_CUC,
944#else
945 (char_u *)NULL, PV_NONE,
946#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000947 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +0000948 {"cursorline", "cul", P_BOOL|P_VI_DEF|P_RWIN,
949#ifdef FEAT_SYN_HL
950 (char_u *)VAR_WIN, PV_CUL,
951#else
952 (char_u *)NULL, PV_NONE,
953#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000954 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000955 {"debug", NULL, P_STRING|P_VI_DEF,
956 (char_u *)&p_debug, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000957 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200958 {"define", "def", P_STRING|P_ALLOCED|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000959#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000960 (char_u *)&p_def, PV_DEF,
Bram Moolenaard4755bb2004-09-02 19:12:26 +0000961 {(char_u *)"^\\s*#\\s*define", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +0000962#else
963 (char_u *)NULL, PV_NONE,
964 {(char_u *)NULL, (char_u *)0L}
965#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000966 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000967 {"delcombine", "deco", P_BOOL|P_VI_DEF|P_VIM,
968#ifdef FEAT_MBYTE
969 (char_u *)&p_deco, PV_NONE,
970#else
971 (char_u *)NULL, PV_NONE,
972#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000973 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000974 {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
975#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +0000976 (char_u *)&p_dict, PV_DICT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000977#else
978 (char_u *)NULL, PV_NONE,
979#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000980 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000981 {"diff", NULL, P_BOOL|P_VI_DEF|P_RWIN|P_NOGLOB,
982#ifdef FEAT_DIFF
983 (char_u *)VAR_WIN, PV_DIFF,
984#else
985 (char_u *)NULL, PV_NONE,
986#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000987 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +0200988 {"diffexpr", "dex", P_STRING|P_VI_DEF|P_SECURE|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +0000989#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
990 (char_u *)&p_dex, PV_NONE,
991 {(char_u *)"", (char_u *)0L}
992#else
993 (char_u *)NULL, PV_NONE,
994 {(char_u *)0L, (char_u *)0L}
995#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +0000996 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +0000997 {"diffopt", "dip", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN|P_COMMA|P_NODUP,
998#ifdef FEAT_DIFF
999 (char_u *)&p_dip, PV_NONE,
1000 {(char_u *)"filler", (char_u *)NULL}
1001#else
1002 (char_u *)NULL, PV_NONE,
1003 {(char_u *)"", (char_u *)NULL}
1004#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001005 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001006 {"digraph", "dg", P_BOOL|P_VI_DEF|P_VIM,
1007#ifdef FEAT_DIGRAPHS
1008 (char_u *)&p_dg, PV_NONE,
1009#else
1010 (char_u *)NULL, PV_NONE,
1011#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001012 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001013 {"directory", "dir", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP|P_SECURE,
1014 (char_u *)&p_dir, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001015 {(char_u *)DFLT_DIR, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001016 {"display", "dy", P_STRING|P_VI_DEF|P_COMMA|P_RALL|P_NODUP,
1017 (char_u *)&p_dy, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001018 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001019 {"eadirection", "ead", P_STRING|P_VI_DEF,
1020#ifdef FEAT_VERTSPLIT
1021 (char_u *)&p_ead, PV_NONE,
1022 {(char_u *)"both", (char_u *)0L}
1023#else
1024 (char_u *)NULL, PV_NONE,
1025 {(char_u *)NULL, (char_u *)0L}
1026#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001027 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001028 {"edcompatible","ed", P_BOOL|P_VI_DEF,
1029 (char_u *)&p_ed, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001030 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar865242e2010-07-14 21:12:05 +02001031 {"encoding", "enc", P_STRING|P_VI_DEF|P_RCLR|P_NO_ML,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001032#ifdef FEAT_MBYTE
1033 (char_u *)&p_enc, PV_NONE,
1034 {(char_u *)ENC_DFLT, (char_u *)0L}
1035#else
1036 (char_u *)NULL, PV_NONE,
1037 {(char_u *)0L, (char_u *)0L}
1038#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001039 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001040 {"endofline", "eol", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1041 (char_u *)&p_eol, PV_EOL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001042 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001043 {"equalalways", "ea", P_BOOL|P_VI_DEF|P_RALL,
1044 (char_u *)&p_ea, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001045 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001046 {"equalprg", "ep", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001047 (char_u *)&p_ep, PV_EP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001048 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001049 {"errorbells", "eb", P_BOOL|P_VI_DEF,
1050 (char_u *)&p_eb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001051 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001052 {"errorfile", "ef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1053#ifdef FEAT_QUICKFIX
1054 (char_u *)&p_ef, PV_NONE,
1055 {(char_u *)DFLT_ERRORFILE, (char_u *)0L}
1056#else
1057 (char_u *)NULL, PV_NONE,
1058 {(char_u *)NULL, (char_u *)0L}
1059#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001060 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001061 {"errorformat", "efm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1062#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001063 (char_u *)&p_efm, PV_EFM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001064 {(char_u *)DFLT_EFM, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001065#else
1066 (char_u *)NULL, PV_NONE,
1067 {(char_u *)NULL, (char_u *)0L}
1068#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001069 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001070 {"esckeys", "ek", P_BOOL|P_VIM,
1071 (char_u *)&p_ek, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001072 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001073 {"eventignore", "ei", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1074#ifdef FEAT_AUTOCMD
1075 (char_u *)&p_ei, PV_NONE,
1076#else
1077 (char_u *)NULL, PV_NONE,
1078#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001079 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001080 {"expandtab", "et", P_BOOL|P_VI_DEF|P_VIM,
1081 (char_u *)&p_et, PV_ET,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001082 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001083 {"exrc", "ex", P_BOOL|P_VI_DEF|P_SECURE,
1084 (char_u *)&p_exrc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001085 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001086 {"fileencoding","fenc", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_RBUF|P_NO_MKRC,
1087#ifdef FEAT_MBYTE
1088 (char_u *)&p_fenc, PV_FENC,
1089 {(char_u *)"", (char_u *)0L}
1090#else
1091 (char_u *)NULL, PV_NONE,
1092 {(char_u *)0L, (char_u *)0L}
1093#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001094 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001095 {"fileencodings","fencs", P_STRING|P_VI_DEF|P_COMMA,
1096#ifdef FEAT_MBYTE
1097 (char_u *)&p_fencs, PV_NONE,
1098 {(char_u *)"ucs-bom", (char_u *)0L}
1099#else
1100 (char_u *)NULL, PV_NONE,
1101 {(char_u *)0L, (char_u *)0L}
1102#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001103 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001104 {"fileformat", "ff", P_STRING|P_ALLOCED|P_VI_DEF|P_RSTAT|P_NO_MKRC|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001105 (char_u *)&p_ff, PV_FF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001106 {(char_u *)DFLT_FF, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001107 {"fileformats", "ffs", P_STRING|P_VIM|P_COMMA|P_NODUP,
1108 (char_u *)&p_ffs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001109 {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
1110 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001111 {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001112#ifdef FEAT_AUTOCMD
1113 (char_u *)&p_ft, PV_FT,
1114 {(char_u *)"", (char_u *)0L}
1115#else
1116 (char_u *)NULL, PV_NONE,
1117 {(char_u *)0L, (char_u *)0L}
1118#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001119 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001120 {"fillchars", "fcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1121#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
1122 (char_u *)&p_fcs, PV_NONE,
1123 {(char_u *)"vert:|,fold:-", (char_u *)0L}
1124#else
1125 (char_u *)NULL, PV_NONE,
1126 {(char_u *)"", (char_u *)0L}
1127#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001128 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001129 {"fkmap", "fk", P_BOOL|P_VI_DEF,
1130#ifdef FEAT_FKMAP
1131 (char_u *)&p_fkmap, PV_NONE,
1132#else
1133 (char_u *)NULL, PV_NONE,
1134#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001135 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001136 {"flash", "fl", P_BOOL|P_VI_DEF,
1137 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001138 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001139#ifdef FEAT_FOLDING
1140 {"foldclose", "fcl", P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_RWIN,
1141 (char_u *)&p_fcl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001142 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001143 {"foldcolumn", "fdc", P_NUM|P_VI_DEF|P_RWIN,
1144 (char_u *)VAR_WIN, PV_FDC,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001145 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001146 {"foldenable", "fen", P_BOOL|P_VI_DEF|P_RWIN,
1147 (char_u *)VAR_WIN, PV_FEN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001148 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001149 {"foldexpr", "fde", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1150# ifdef FEAT_EVAL
1151 (char_u *)VAR_WIN, PV_FDE,
1152 {(char_u *)"0", (char_u *)NULL}
1153# else
1154 (char_u *)NULL, PV_NONE,
1155 {(char_u *)NULL, (char_u *)0L}
1156# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001157 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001158 {"foldignore", "fdi", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1159 (char_u *)VAR_WIN, PV_FDI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001160 {(char_u *)"#", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001161 {"foldlevel", "fdl", P_NUM|P_VI_DEF|P_RWIN,
1162 (char_u *)VAR_WIN, PV_FDL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001163 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001164 {"foldlevelstart","fdls", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001165 (char_u *)&p_fdls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001166 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001167 {"foldmarker", "fmr", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|
1168 P_RWIN|P_COMMA|P_NODUP,
1169 (char_u *)VAR_WIN, PV_FMR,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001170 {(char_u *)"{{{,}}}", (char_u *)NULL}
1171 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001172 {"foldmethod", "fdm", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1173 (char_u *)VAR_WIN, PV_FDM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001174 {(char_u *)"manual", (char_u *)NULL} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001175 {"foldminlines","fml", P_NUM|P_VI_DEF|P_RWIN,
1176 (char_u *)VAR_WIN, PV_FML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001177 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001178 {"foldnestmax", "fdn", P_NUM|P_VI_DEF|P_RWIN,
1179 (char_u *)VAR_WIN, PV_FDN,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001180 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001181 {"foldopen", "fdo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001182 (char_u *)&p_fdo, PV_NONE,
1183 {(char_u *)"block,hor,mark,percent,quickfix,search,tag,undo",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001184 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001185 {"foldtext", "fdt", P_STRING|P_ALLOCED|P_VIM|P_VI_DEF|P_RWIN,
1186# ifdef FEAT_EVAL
1187 (char_u *)VAR_WIN, PV_FDT,
1188 {(char_u *)"foldtext()", (char_u *)NULL}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001189# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00001190 (char_u *)NULL, PV_NONE,
1191 {(char_u *)NULL, (char_u *)0L}
Bram Moolenaar7b0294c2004-10-11 10:16:09 +00001192# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001193 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001194#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001195 {"formatexpr", "fex", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001196#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00001197 (char_u *)&p_fex, PV_FEX,
1198 {(char_u *)"", (char_u *)0L}
1199#else
1200 (char_u *)NULL, PV_NONE,
1201 {(char_u *)0L, (char_u *)0L}
1202#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001203 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001204 {"formatoptions","fo", P_STRING|P_ALLOCED|P_VIM|P_FLAGLIST,
1205 (char_u *)&p_fo, PV_FO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001206 {(char_u *)DFLT_FO_VI, (char_u *)DFLT_FO_VIM}
1207 SCRIPTID_INIT},
Bram Moolenaar86b68352004-12-27 21:59:20 +00001208 {"formatlistpat","flp", P_STRING|P_ALLOCED|P_VI_DEF,
1209 (char_u *)&p_flp, PV_FLP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001210 {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*",
1211 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001212 {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1213 (char_u *)&p_fp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001214 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001215 {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF,
1216#ifdef HAVE_FSYNC
1217 (char_u *)&p_fs, PV_NONE,
1218 {(char_u *)TRUE, (char_u *)0L}
1219#else
1220 (char_u *)NULL, PV_NONE,
1221 {(char_u *)FALSE, (char_u *)0L}
1222#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001223 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001224 {"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
1225 (char_u *)&p_gd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001226 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001227 {"graphic", "gr", P_BOOL|P_VI_DEF,
1228 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001229 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001230 {"grepformat", "gfm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1231#ifdef FEAT_QUICKFIX
1232 (char_u *)&p_gefm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001233 {(char_u *)DFLT_GREPFORMAT, (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001234#else
1235 (char_u *)NULL, PV_NONE,
1236 {(char_u *)NULL, (char_u *)0L}
1237#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001238 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001239 {"grepprg", "gp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1240#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001241 (char_u *)&p_gp, PV_GP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001242 {
1243# ifdef WIN3264
1244 /* may be changed to "grep -n" in os_win32.c */
1245 (char_u *)"findstr /n",
1246# else
1247# ifdef UNIX
1248 /* Add an extra file name so that grep will always
1249 * insert a file name in the match line. */
1250 (char_u *)"grep -n $* /dev/null",
1251# else
1252# ifdef VMS
1253 (char_u *)"SEARCH/NUMBERS ",
1254# else
1255 (char_u *)"grep -n ",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001256# endif
1257# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001258# endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001259 (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001260#else
1261 (char_u *)NULL, PV_NONE,
1262 {(char_u *)NULL, (char_u *)0L}
1263#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001264 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001265 {"guicursor", "gcr", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1266#ifdef CURSOR_SHAPE
1267 (char_u *)&p_guicursor, PV_NONE,
1268 {
1269# ifdef FEAT_GUI
1270 (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",
1271# else /* MSDOS or Win32 console */
1272 (char_u *)"n-v-c:block,o:hor50,i-ci:hor15,r-cr:hor30,sm:block",
1273# endif
1274 (char_u *)0L}
1275#else
1276 (char_u *)NULL, PV_NONE,
1277 {(char_u *)NULL, (char_u *)0L}
1278#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001279 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001280 {"guifont", "gfn", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
1281#ifdef FEAT_GUI
1282 (char_u *)&p_guifont, PV_NONE,
1283 {(char_u *)"", (char_u *)0L}
1284#else
1285 (char_u *)NULL, PV_NONE,
1286 {(char_u *)NULL, (char_u *)0L}
1287#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001288 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001289 {"guifontset", "gfs", P_STRING|P_VI_DEF|P_RCLR|P_COMMA,
1290#if defined(FEAT_GUI) && defined(FEAT_XFONTSET)
1291 (char_u *)&p_guifontset, PV_NONE,
1292 {(char_u *)"", (char_u *)0L}
1293#else
1294 (char_u *)NULL, PV_NONE,
1295 {(char_u *)NULL, (char_u *)0L}
1296#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001297 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001298 {"guifontwide", "gfw", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
1299#if defined(FEAT_GUI) && defined(FEAT_MBYTE)
1300 (char_u *)&p_guifontwide, PV_NONE,
1301 {(char_u *)"", (char_u *)0L}
1302#else
1303 (char_u *)NULL, PV_NONE,
1304 {(char_u *)NULL, (char_u *)0L}
1305#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001306 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001307 {"guiheadroom", "ghr", P_NUM|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001308#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001309 (char_u *)&p_ghr, PV_NONE,
1310#else
1311 (char_u *)NULL, PV_NONE,
1312#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001313 {(char_u *)50L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001314 {"guioptions", "go", P_STRING|P_VI_DEF|P_RALL|P_FLAGLIST,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001315#if defined(FEAT_GUI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001316 (char_u *)&p_go, PV_NONE,
1317# if defined(UNIX) && !defined(MACOS)
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001318 {(char_u *)"aegimrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001319# else
Bram Moolenaar32466aa2006-02-24 23:53:04 +00001320 {(char_u *)"egmrLtT", (char_u *)0L}
Bram Moolenaar071d4272004-06-13 20:20:40 +00001321# endif
1322#else
1323 (char_u *)NULL, PV_NONE,
1324 {(char_u *)NULL, (char_u *)0L}
1325#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001326 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001327 {"guipty", NULL, P_BOOL|P_VI_DEF,
1328#if defined(FEAT_GUI)
1329 (char_u *)&p_guipty, PV_NONE,
1330#else
1331 (char_u *)NULL, PV_NONE,
1332#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001333 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar18144c82006-04-12 21:52:12 +00001334 {"guitablabel", "gtl", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00001335#if defined(FEAT_GUI_TABLINE)
1336 (char_u *)&p_gtl, PV_NONE,
1337 {(char_u *)"", (char_u *)0L}
1338#else
1339 (char_u *)NULL, PV_NONE,
1340 {(char_u *)NULL, (char_u *)0L}
1341#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001342 SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001343 {"guitabtooltip", "gtt", P_STRING|P_VI_DEF|P_RWIN,
Bram Moolenaar57657d82006-04-21 22:12:41 +00001344#if defined(FEAT_GUI_TABLINE)
1345 (char_u *)&p_gtt, PV_NONE,
1346 {(char_u *)"", (char_u *)0L}
1347#else
1348 (char_u *)NULL, PV_NONE,
1349 {(char_u *)NULL, (char_u *)0L}
1350#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001351 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001352 {"hardtabs", "ht", P_NUM|P_VI_DEF,
1353 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001354 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001355 {"helpfile", "hf", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1356 (char_u *)&p_hf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001357 {(char_u *)DFLT_HELPFILE, (char_u *)0L}
1358 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001359 {"helpheight", "hh", P_NUM|P_VI_DEF,
1360#ifdef FEAT_WINDOWS
1361 (char_u *)&p_hh, PV_NONE,
1362#else
1363 (char_u *)NULL, PV_NONE,
1364#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001365 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001366 {"helplang", "hlg", P_STRING|P_VI_DEF|P_COMMA,
1367#ifdef FEAT_MULTI_LANG
1368 (char_u *)&p_hlg, PV_NONE,
1369 {(char_u *)"", (char_u *)0L}
1370#else
1371 (char_u *)NULL, PV_NONE,
1372 {(char_u *)0L, (char_u *)0L}
1373#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001374 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001375 {"hidden", "hid", P_BOOL|P_VI_DEF,
1376 (char_u *)&p_hid, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001377 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001378 {"highlight", "hl", P_STRING|P_VI_DEF|P_RCLR|P_COMMA|P_NODUP,
1379 (char_u *)&p_hl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001380 {(char_u *)HIGHLIGHT_INIT, (char_u *)0L}
1381 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001382 {"history", "hi", P_NUM|P_VIM,
1383 (char_u *)&p_hi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001384 {(char_u *)0L, (char_u *)20L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001385 {"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
1386#ifdef FEAT_RIGHTLEFT
1387 (char_u *)&p_hkmap, PV_NONE,
1388#else
1389 (char_u *)NULL, PV_NONE,
1390#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001391 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001392 {"hkmapp", "hkp", P_BOOL|P_VI_DEF|P_VIM,
1393#ifdef FEAT_RIGHTLEFT
1394 (char_u *)&p_hkmapp, PV_NONE,
1395#else
1396 (char_u *)NULL, PV_NONE,
1397#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001398 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001399 {"hlsearch", "hls", P_BOOL|P_VI_DEF|P_VIM|P_RALL,
1400 (char_u *)&p_hls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001401 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001402 {"icon", NULL, P_BOOL|P_VI_DEF,
1403#ifdef FEAT_TITLE
1404 (char_u *)&p_icon, 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 {"iconstring", NULL, P_STRING|P_VI_DEF,
1410#ifdef FEAT_TITLE
1411 (char_u *)&p_iconstring, PV_NONE,
1412#else
1413 (char_u *)NULL, PV_NONE,
1414#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001415 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001416 {"ignorecase", "ic", P_BOOL|P_VI_DEF,
1417 (char_u *)&p_ic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001418 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001419 {"imactivatekey","imak",P_STRING|P_VI_DEF,
Bram Moolenaar9372a112005-12-06 19:59:18 +00001420#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00001421 (char_u *)&p_imak, 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 {"imcmdline", "imc", P_BOOL|P_VI_DEF,
1427#ifdef USE_IM_CONTROL
1428 (char_u *)&p_imcmdline, PV_NONE,
1429#else
1430 (char_u *)NULL, PV_NONE,
1431#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001432 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001433 {"imdisable", "imd", P_BOOL|P_VI_DEF,
1434#ifdef USE_IM_CONTROL
1435 (char_u *)&p_imdisable, PV_NONE,
1436#else
1437 (char_u *)NULL, PV_NONE,
1438#endif
1439#ifdef __sgi
1440 {(char_u *)TRUE, (char_u *)0L}
1441#else
1442 {(char_u *)FALSE, (char_u *)0L}
1443#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001444 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001445 {"iminsert", "imi", P_NUM|P_VI_DEF,
1446 (char_u *)&p_iminsert, PV_IMI,
1447#ifdef B_IMODE_IM
1448 {(char_u *)B_IMODE_IM, (char_u *)0L}
1449#else
1450 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1451#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001452 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001453 {"imsearch", "ims", P_NUM|P_VI_DEF,
1454 (char_u *)&p_imsearch, PV_IMS,
1455#ifdef B_IMODE_IM
1456 {(char_u *)B_IMODE_IM, (char_u *)0L}
1457#else
1458 {(char_u *)B_IMODE_NONE, (char_u *)0L}
1459#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001460 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001461 {"include", "inc", P_STRING|P_ALLOCED|P_VI_DEF,
1462#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001463 (char_u *)&p_inc, PV_INC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001464 {(char_u *)"^\\s*#\\s*include", (char_u *)0L}
1465#else
1466 (char_u *)NULL, PV_NONE,
1467 {(char_u *)0L, (char_u *)0L}
1468#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001469 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001470 {"includeexpr", "inex", P_STRING|P_ALLOCED|P_VI_DEF,
1471#if defined(FEAT_FIND_ID) && defined(FEAT_EVAL)
1472 (char_u *)&p_inex, PV_INEX,
1473 {(char_u *)"", (char_u *)0L}
1474#else
1475 (char_u *)NULL, PV_NONE,
1476 {(char_u *)0L, (char_u *)0L}
1477#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001478 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001479 {"incsearch", "is", P_BOOL|P_VI_DEF|P_VIM,
1480 (char_u *)&p_is, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001481 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001482 {"indentexpr", "inde", P_STRING|P_ALLOCED|P_VI_DEF|P_VIM,
1483#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1484 (char_u *)&p_inde, PV_INDE,
1485 {(char_u *)"", (char_u *)0L}
1486#else
1487 (char_u *)NULL, PV_NONE,
1488 {(char_u *)0L, (char_u *)0L}
1489#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001490 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001491 {"indentkeys", "indk", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
1492#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
1493 (char_u *)&p_indk, PV_INDK,
1494 {(char_u *)"0{,0},:,0#,!^F,o,O,e", (char_u *)0L}
1495#else
1496 (char_u *)NULL, PV_NONE,
1497 {(char_u *)0L, (char_u *)0L}
1498#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001499 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001500 {"infercase", "inf", P_BOOL|P_VI_DEF,
1501 (char_u *)&p_inf, PV_INF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001502 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001503 {"insertmode", "im", P_BOOL|P_VI_DEF|P_VIM,
1504 (char_u *)&p_im, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001505 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001506 {"isfname", "isf", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1507 (char_u *)&p_isf, PV_NONE,
1508 {
1509#ifdef BACKSLASH_IN_FILENAME
1510 /* Excluded are: & and ^ are special in cmd.exe
1511 * ( and ) are used in text separating fnames */
1512 (char_u *)"@,48-57,/,\\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,=",
1513#else
1514# ifdef AMIGA
1515 (char_u *)"@,48-57,/,.,-,_,+,,,$,:",
1516# else
1517# ifdef VMS
1518 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~",
1519# else /* UNIX et al. */
1520# ifdef EBCDIC
1521 (char_u *)"@,240-249,/,.,-,_,+,,,#,$,%,~,=",
1522# else
1523 (char_u *)"@,48-57,/,.,-,_,+,,,#,$,%,~,=",
1524# endif
1525# endif
1526# endif
1527#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001528 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001529 {"isident", "isi", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1530 (char_u *)&p_isi, PV_NONE,
1531 {
1532#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1533 (char_u *)"@,48-57,_,128-167,224-235",
1534#else
1535# ifdef EBCDIC
1536 /* TODO: EBCDIC Check this! @ == isalpha()*/
1537 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1538 "112-120,128,140-142,156,158,172,"
1539 "174,186,191,203-207,219-225,235-239,"
1540 "251-254",
1541# else
1542 (char_u *)"@,48-57,_,192-255",
1543# endif
1544#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001545 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001546 {"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
1547 (char_u *)&p_isk, PV_ISK,
1548 {
1549#ifdef EBCDIC
1550 (char_u *)"@,240-249,_",
1551 /* TODO: EBCDIC Check this! @ == isalpha()*/
1552 (char_u *)"@,240-249,_,66-73,81-89,98-105,"
1553 "112-120,128,140-142,156,158,172,"
1554 "174,186,191,203-207,219-225,235-239,"
1555 "251-254",
1556#else
1557 (char_u *)"@,48-57,_",
1558# if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1559 (char_u *)"@,48-57,_,128-167,224-235"
1560# else
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001561 ISK_LATIN1
Bram Moolenaar071d4272004-06-13 20:20:40 +00001562# endif
1563#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001564 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001565 {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1566 (char_u *)&p_isp, PV_NONE,
1567 {
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001568#if defined(MSDOS) || defined(MSWIN) || defined(OS2) \
1569 || (defined(MACOS) && !defined(MACOS_X)) \
Bram Moolenaar071d4272004-06-13 20:20:40 +00001570 || defined(VMS)
1571 (char_u *)"@,~-255",
1572#else
1573# ifdef EBCDIC
1574 /* all chars above 63 are printable */
1575 (char_u *)"63-255",
1576# else
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00001577 ISP_LATIN1,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001578# endif
1579#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001580 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001581 {"joinspaces", "js", P_BOOL|P_VI_DEF|P_VIM,
1582 (char_u *)&p_js, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001583 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001584 {"key", NULL, P_STRING|P_ALLOCED|P_VI_DEF|P_NO_MKRC,
1585#ifdef FEAT_CRYPT
1586 (char_u *)&p_key, PV_KEY,
1587 {(char_u *)"", (char_u *)0L}
1588#else
1589 (char_u *)NULL, PV_NONE,
1590 {(char_u *)0L, (char_u *)0L}
1591#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001592 SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001593 {"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 +00001594#ifdef FEAT_KEYMAP
1595 (char_u *)&p_keymap, PV_KMAP,
1596 {(char_u *)"", (char_u *)0L}
1597#else
1598 (char_u *)NULL, PV_NONE,
1599 {(char_u *)"", (char_u *)0L}
1600#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001601 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001602 {"keymodel", "km", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1603#ifdef FEAT_VISUAL
1604 (char_u *)&p_km, PV_NONE,
1605#else
1606 (char_u *)NULL, PV_NONE,
1607#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001608 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001609 {"keywordprg", "kp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001610 (char_u *)&p_kp, PV_KP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001611 {
1612#if defined(MSDOS) || defined(MSWIN)
1613 (char_u *)":help",
1614#else
1615#ifdef VMS
1616 (char_u *)"help",
1617#else
1618# if defined(OS2)
1619 (char_u *)"view /",
1620# else
1621# ifdef USEMAN_S
1622 (char_u *)"man -s",
1623# else
1624 (char_u *)"man",
1625# endif
1626# endif
1627#endif
1628#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001629 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001630 {"langmap", "lmap", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1631#ifdef FEAT_LANGMAP
1632 (char_u *)&p_langmap, PV_NONE,
1633 {(char_u *)"", /* unmatched } */
1634#else
1635 (char_u *)NULL, PV_NONE,
1636 {(char_u *)NULL,
1637#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001638 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001639 {"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001640#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
1641 (char_u *)&p_lm, PV_NONE,
1642#else
1643 (char_u *)NULL, PV_NONE,
1644#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001645 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001646 {"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
1647#ifdef FEAT_WINDOWS
1648 (char_u *)&p_ls, PV_NONE,
1649#else
1650 (char_u *)NULL, PV_NONE,
1651#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001652 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001653 {"lazyredraw", "lz", P_BOOL|P_VI_DEF,
1654 (char_u *)&p_lz, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001655 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001656 {"linebreak", "lbr", P_BOOL|P_VI_DEF|P_RWIN,
1657#ifdef FEAT_LINEBREAK
1658 (char_u *)VAR_WIN, PV_LBR,
1659#else
1660 (char_u *)NULL, PV_NONE,
1661#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001662 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001663 {"lines", NULL, P_NUM|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RCLR,
1664 (char_u *)&Rows, PV_NONE,
1665 {
1666#if defined(MSDOS) || defined(WIN3264) || defined(OS2)
1667 (char_u *)25L,
1668#else
1669 (char_u *)24L,
1670#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001671 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001672 {"linespace", "lsp", P_NUM|P_VI_DEF|P_RCLR,
1673#ifdef FEAT_GUI
1674 (char_u *)&p_linespace, PV_NONE,
1675#else
1676 (char_u *)NULL, PV_NONE,
1677#endif
1678#ifdef FEAT_GUI_W32
1679 {(char_u *)1L, (char_u *)0L}
1680#else
1681 {(char_u *)0L, (char_u *)0L}
1682#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001683 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001684 {"lisp", NULL, P_BOOL|P_VI_DEF,
1685#ifdef FEAT_LISP
1686 (char_u *)&p_lisp, PV_LISP,
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 {"lispwords", "lw", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1692#ifdef FEAT_LISP
1693 (char_u *)&p_lispwords, PV_NONE,
1694 {(char_u *)LISPWORD_VALUE, (char_u *)0L}
1695#else
1696 (char_u *)NULL, PV_NONE,
1697 {(char_u *)"", (char_u *)0L}
1698#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001699 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001700 {"list", NULL, P_BOOL|P_VI_DEF|P_RWIN,
1701 (char_u *)VAR_WIN, PV_LIST,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001702 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001703 {"listchars", "lcs", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP,
1704 (char_u *)&p_lcs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001705 {(char_u *)"eol:$", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001706 {"loadplugins", "lpl", P_BOOL|P_VI_DEF,
1707 (char_u *)&p_lpl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001708 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001709#ifdef FEAT_GUI_MAC
1710 {"macatsui", NULL, P_BOOL|P_VI_DEF|P_RCLR,
1711 (char_u *)&p_macatsui, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001712 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf9393ef2006-04-24 19:47:27 +00001713#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00001714 {"magic", NULL, P_BOOL|P_VI_DEF,
1715 (char_u *)&p_magic, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001716 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00001717 {"makeef", "mef", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001718#ifdef FEAT_QUICKFIX
1719 (char_u *)&p_mef, PV_NONE,
1720 {(char_u *)"", (char_u *)0L}
1721#else
1722 (char_u *)NULL, PV_NONE,
1723 {(char_u *)NULL, (char_u *)0L}
1724#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001725 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001726 {"makeprg", "mp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
1727#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001728 (char_u *)&p_mp, PV_MP,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001729# ifdef VMS
1730 {(char_u *)"MMS", (char_u *)0L}
1731# else
1732 {(char_u *)"make", (char_u *)0L}
1733# endif
1734#else
1735 (char_u *)NULL, PV_NONE,
1736 {(char_u *)NULL, (char_u *)0L}
1737#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001738 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001739 {"matchpairs", "mps", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
1740 (char_u *)&p_mps, PV_MPS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001741 {(char_u *)"(:),{:},[:]", (char_u *)0L}
1742 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001743 {"matchtime", "mat", P_NUM|P_VI_DEF,
1744 (char_u *)&p_mat, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001745 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02001746 {"maxcombine", "mco", P_NUM|P_VI_DEF|P_CURSWANT,
Bram Moolenaar362e1a32006-03-06 23:29:24 +00001747#ifdef FEAT_MBYTE
1748 (char_u *)&p_mco, PV_NONE,
1749#else
1750 (char_u *)NULL, PV_NONE,
1751#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001752 {(char_u *)2, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001753 {"maxfuncdepth", "mfd", P_NUM|P_VI_DEF,
1754#ifdef FEAT_EVAL
1755 (char_u *)&p_mfd, PV_NONE,
1756#else
1757 (char_u *)NULL, PV_NONE,
1758#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001759 {(char_u *)100L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001760 {"maxmapdepth", "mmd", P_NUM|P_VI_DEF,
1761 (char_u *)&p_mmd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001762 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001763 {"maxmem", "mm", P_NUM|P_VI_DEF,
1764 (char_u *)&p_mm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001765 {(char_u *)DFLT_MAXMEM, (char_u *)0L}
1766 SCRIPTID_INIT},
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00001767 {"maxmempattern","mmp", P_NUM|P_VI_DEF,
1768 (char_u *)&p_mmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001769 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001770 {"maxmemtot", "mmt", P_NUM|P_VI_DEF,
1771 (char_u *)&p_mmt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001772 {(char_u *)DFLT_MAXMEMTOT, (char_u *)0L}
1773 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001774 {"menuitems", "mis", P_NUM|P_VI_DEF,
1775#ifdef FEAT_MENU
1776 (char_u *)&p_mis, PV_NONE,
1777#else
1778 (char_u *)NULL, PV_NONE,
1779#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001780 {(char_u *)25L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001781 {"mesg", NULL, P_BOOL|P_VI_DEF,
1782 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001783 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001784 {"mkspellmem", "msm", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00001785#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00001786 (char_u *)&p_msm, PV_NONE,
1787 {(char_u *)"460000,2000,500", (char_u *)0L}
1788#else
1789 (char_u *)NULL, PV_NONE,
1790 {(char_u *)0L, (char_u *)0L}
1791#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001792 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001793 {"modeline", "ml", P_BOOL|P_VIM,
1794 (char_u *)&p_ml, PV_ML,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001795 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001796 {"modelines", "mls", P_NUM|P_VI_DEF,
1797 (char_u *)&p_mls, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001798 {(char_u *)5L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001799 {"modifiable", "ma", P_BOOL|P_VI_DEF|P_NOGLOB,
1800 (char_u *)&p_ma, PV_MA,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001801 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001802 {"modified", "mod", P_BOOL|P_NO_MKRC|P_VI_DEF|P_RSTAT,
1803 (char_u *)&p_mod, PV_MOD,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001804 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001805 {"more", NULL, P_BOOL|P_VIM,
1806 (char_u *)&p_more, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001807 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001808 {"mouse", NULL, P_STRING|P_VI_DEF|P_FLAGLIST,
1809 (char_u *)&p_mouse, PV_NONE,
1810 {
1811#if defined(MSDOS) || defined(WIN3264)
1812 (char_u *)"a",
1813#else
1814 (char_u *)"",
1815#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001816 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001817 {"mousefocus", "mousef", P_BOOL|P_VI_DEF,
1818#ifdef FEAT_GUI
1819 (char_u *)&p_mousef, PV_NONE,
1820#else
1821 (char_u *)NULL, PV_NONE,
1822#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001823 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001824 {"mousehide", "mh", P_BOOL|P_VI_DEF,
1825#ifdef FEAT_GUI
1826 (char_u *)&p_mh, PV_NONE,
1827#else
1828 (char_u *)NULL, PV_NONE,
1829#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001830 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001831 {"mousemodel", "mousem", P_STRING|P_VI_DEF,
1832 (char_u *)&p_mousem, PV_NONE,
1833 {
1834#if defined(MSDOS) || defined(MSWIN)
1835 (char_u *)"popup",
1836#else
1837# if defined(MACOS)
1838 (char_u *)"popup_setpos",
1839# else
1840 (char_u *)"extend",
1841# endif
1842#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001843 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001844 {"mouseshape", "mouses", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
1845#ifdef FEAT_MOUSESHAPE
1846 (char_u *)&p_mouseshape, PV_NONE,
1847 {(char_u *)"i-r:beam,s:updown,sd:udsizing,vs:leftright,vd:lrsizing,m:no,ml:up-arrow,v:rightup-arrow", (char_u *)0L}
1848#else
1849 (char_u *)NULL, PV_NONE,
1850 {(char_u *)NULL, (char_u *)0L}
1851#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001852 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001853 {"mousetime", "mouset", P_NUM|P_VI_DEF,
1854 (char_u *)&p_mouset, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001855 {(char_u *)500L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar325b7a22004-07-05 15:58:32 +00001856 {"mzquantum", "mzq", P_NUM,
1857#ifdef FEAT_MZSCHEME
1858 (char_u *)&p_mzq, PV_NONE,
1859#else
1860 (char_u *)NULL, PV_NONE,
1861#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001862 {(char_u *)100L, (char_u *)100L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001863 {"novice", NULL, P_BOOL|P_VI_DEF,
1864 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001865 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001866 {"nrformats", "nf", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_NODUP,
1867 (char_u *)&p_nf, PV_NF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001868 {(char_u *)"octal,hex", (char_u *)0L}
1869 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001870 {"number", "nu", P_BOOL|P_VI_DEF|P_RWIN,
1871 (char_u *)VAR_WIN, PV_NU,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001872 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00001873 {"numberwidth", "nuw", P_NUM|P_RWIN|P_VIM,
1874#ifdef FEAT_LINEBREAK
1875 (char_u *)VAR_WIN, PV_NUW,
1876#else
1877 (char_u *)NULL, PV_NONE,
1878#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001879 {(char_u *)8L, (char_u *)4L} SCRIPTID_INIT},
Bram Moolenaarf75a9632005-09-13 21:20:47 +00001880 {"omnifunc", "ofu", P_STRING|P_ALLOCED|P_VI_DEF|P_SECURE,
Bram Moolenaare344bea2005-09-01 20:46:49 +00001881#ifdef FEAT_COMPL_FUNC
1882 (char_u *)&p_ofu, PV_OFU,
1883 {(char_u *)"", (char_u *)0L}
1884#else
1885 (char_u *)NULL, PV_NONE,
1886 {(char_u *)0L, (char_u *)0L}
1887#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001888 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001889 {"open", NULL, P_BOOL|P_VI_DEF,
1890 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001891 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar043545e2006-10-10 16:44:07 +00001892 {"opendevice", "odev", P_BOOL|P_VI_DEF,
1893#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
1894 (char_u *)&p_odev, PV_NONE,
1895#else
1896 (char_u *)NULL, PV_NONE,
1897#endif
1898 {(char_u *)FALSE, (char_u *)FALSE}
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001899 SCRIPTID_INIT},
Bram Moolenaar2c7a29c2005-12-12 22:02:31 +00001900 {"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
1901 (char_u *)&p_opfunc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001902 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001903 {"optimize", "opt", P_BOOL|P_VI_DEF,
1904 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001905 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001906 {"osfiletype", "oft", P_STRING|P_ALLOCED|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001907 (char_u *)NULL, PV_NONE,
Bram Moolenaarb07269a2011-05-19 13:41:14 +02001908 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001909 {"paragraphs", "para", P_STRING|P_VI_DEF,
1910 (char_u *)&p_para, PV_NONE,
Bram Moolenaar57e48462008-03-12 16:38:55 +00001911 {(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001912 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar7fd16022007-09-06 14:35:35 +00001913 {"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001914 (char_u *)&p_paste, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001915 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001916 {"pastetoggle", "pt", P_STRING|P_VI_DEF,
1917 (char_u *)&p_pt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001918 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001919 {"patchexpr", "pex", P_STRING|P_VI_DEF|P_SECURE,
1920#if defined(FEAT_DIFF) && defined(FEAT_EVAL)
1921 (char_u *)&p_pex, PV_NONE,
1922 {(char_u *)"", (char_u *)0L}
1923#else
1924 (char_u *)NULL, PV_NONE,
1925 {(char_u *)0L, (char_u *)0L}
1926#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001927 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001928 {"patchmode", "pm", P_STRING|P_VI_DEF|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001929 (char_u *)&p_pm, 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 {"path", "pa", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00001932 (char_u *)&p_path, PV_PATH,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001933 {
1934#if defined AMIGA || defined MSDOS || defined MSWIN
1935 (char_u *)".,,",
1936#else
1937# if defined(__EMX__)
1938 (char_u *)".,/emx/include,,",
1939# else /* Unix, probably */
1940 (char_u *)".,/usr/include,,",
1941# endif
1942#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001943 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001944 {"preserveindent", "pi", P_BOOL|P_VI_DEF|P_VIM,
1945 (char_u *)&p_pi, PV_PI,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001946 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar592e0a22004-07-03 16:05:59 +00001947 {"previewheight", "pvh", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001948#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
1949 (char_u *)&p_pvh, PV_NONE,
1950#else
1951 (char_u *)NULL, PV_NONE,
1952#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001953 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001954 {"previewwindow", "pvw", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
1955#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
1956 (char_u *)VAR_WIN, PV_PVW,
1957#else
1958 (char_u *)NULL, PV_NONE,
1959#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001960 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00001961 {"printdevice", "pdev", P_STRING|P_VI_DEF|P_SECURE,
Bram Moolenaar071d4272004-06-13 20:20:40 +00001962#ifdef FEAT_PRINTER
1963 (char_u *)&p_pdev, PV_NONE,
1964 {(char_u *)"", (char_u *)0L}
1965#else
1966 (char_u *)NULL, PV_NONE,
1967 {(char_u *)NULL, (char_u *)0L}
1968#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001969 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001970 {"printencoding", "penc", P_STRING|P_VI_DEF,
1971#ifdef FEAT_POSTSCRIPT
1972 (char_u *)&p_penc, PV_NONE,
1973 {(char_u *)"", (char_u *)0L}
1974#else
1975 (char_u *)NULL, PV_NONE,
1976 {(char_u *)NULL, (char_u *)0L}
1977#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001978 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001979 {"printexpr", "pexpr", P_STRING|P_VI_DEF,
1980#ifdef FEAT_POSTSCRIPT
1981 (char_u *)&p_pexpr, PV_NONE,
1982 {(char_u *)"", (char_u *)0L}
1983#else
1984 (char_u *)NULL, PV_NONE,
1985 {(char_u *)NULL, (char_u *)0L}
1986#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00001987 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00001988 {"printfont", "pfn", P_STRING|P_VI_DEF,
1989#ifdef FEAT_PRINTER
1990 (char_u *)&p_pfn, PV_NONE,
1991 {
1992# ifdef MSWIN
1993 (char_u *)"Courier_New:h10",
1994# else
1995 (char_u *)"courier",
1996# endif
1997 (char_u *)0L}
1998#else
1999 (char_u *)NULL, PV_NONE,
2000 {(char_u *)NULL, (char_u *)0L}
2001#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002002 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002003 {"printheader", "pheader", P_STRING|P_VI_DEF|P_GETTEXT,
2004#ifdef FEAT_PRINTER
2005 (char_u *)&p_header, PV_NONE,
2006 {(char_u *)N_("%<%f%h%m%=Page %N"), (char_u *)0L}
2007#else
2008 (char_u *)NULL, PV_NONE,
2009 {(char_u *)NULL, (char_u *)0L}
2010#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002011 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002012 {"printmbcharset", "pmbcs", P_STRING|P_VI_DEF,
2013#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2014 (char_u *)&p_pmcs, PV_NONE,
2015 {(char_u *)"", (char_u *)0L}
2016#else
2017 (char_u *)NULL, PV_NONE,
2018 {(char_u *)NULL, (char_u *)0L}
2019#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002020 SCRIPTID_INIT},
Bram Moolenaar8299df92004-07-10 09:47:34 +00002021 {"printmbfont", "pmbfn", P_STRING|P_VI_DEF,
2022#if defined(FEAT_POSTSCRIPT) && defined(FEAT_MBYTE)
2023 (char_u *)&p_pmfn, PV_NONE,
2024 {(char_u *)"", (char_u *)0L}
2025#else
2026 (char_u *)NULL, PV_NONE,
2027 {(char_u *)NULL, (char_u *)0L}
2028#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002029 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002030 {"printoptions", "popt", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2031#ifdef FEAT_PRINTER
2032 (char_u *)&p_popt, PV_NONE,
2033 {(char_u *)"", (char_u *)0L}
2034#else
2035 (char_u *)NULL, PV_NONE,
2036 {(char_u *)NULL, (char_u *)0L}
2037#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002038 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002039 {"prompt", NULL, P_BOOL|P_VI_DEF,
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002040 (char_u *)&p_prompt, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002041 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar9d47f172006-03-15 23:03:01 +00002042 {"pumheight", "ph", P_NUM|P_VI_DEF,
2043#ifdef FEAT_INS_EXPAND
2044 (char_u *)&p_ph, PV_NONE,
2045#else
2046 (char_u *)NULL, PV_NONE,
2047#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002048 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00002049 {"quoteescape", "qe", P_STRING|P_ALLOCED|P_VI_DEF,
2050#ifdef FEAT_TEXTOBJ
2051 (char_u *)&p_qe, PV_QE,
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 {"readonly", "ro", P_BOOL|P_VI_DEF|P_RSTAT|P_NOGLOB,
2059 (char_u *)&p_ro, PV_RO,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002060 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002061 {"redraw", NULL, P_BOOL|P_VI_DEF,
2062 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002063 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar91a4e822008-01-19 14:59:58 +00002064 {"redrawtime", "rdt", P_NUM|P_VI_DEF,
2065#ifdef FEAT_RELTIME
2066 (char_u *)&p_rdt, PV_NONE,
2067#else
2068 (char_u *)NULL, PV_NONE,
2069#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002070 {(char_u *)2000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar64486672010-05-16 15:46:46 +02002071 {"relativenumber", "rnu", P_BOOL|P_VI_DEF|P_RWIN,
2072 (char_u *)VAR_WIN, PV_RNU,
2073 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002074 {"remap", NULL, P_BOOL|P_VI_DEF,
2075 (char_u *)&p_remap, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002076 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002077 {"report", NULL, P_NUM|P_VI_DEF,
2078 (char_u *)&p_report, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002079 {(char_u *)2L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002080 {"restorescreen", "rs", P_BOOL|P_VI_DEF,
2081#ifdef WIN3264
2082 (char_u *)&p_rs, PV_NONE,
2083#else
2084 (char_u *)NULL, PV_NONE,
2085#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002086 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002087 {"revins", "ri", P_BOOL|P_VI_DEF|P_VIM,
2088#ifdef FEAT_RIGHTLEFT
2089 (char_u *)&p_ri, PV_NONE,
2090#else
2091 (char_u *)NULL, PV_NONE,
2092#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002093 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002094 {"rightleft", "rl", P_BOOL|P_VI_DEF|P_RWIN,
2095#ifdef FEAT_RIGHTLEFT
2096 (char_u *)VAR_WIN, PV_RL,
2097#else
2098 (char_u *)NULL, PV_NONE,
2099#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002100 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002101 {"rightleftcmd", "rlc", P_STRING|P_ALLOCED|P_VI_DEF|P_RWIN,
2102#ifdef FEAT_RIGHTLEFT
2103 (char_u *)VAR_WIN, PV_RLC,
2104 {(char_u *)"search", (char_u *)NULL}
2105#else
2106 (char_u *)NULL, PV_NONE,
2107 {(char_u *)NULL, (char_u *)0L}
2108#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002109 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002110 {"ruler", "ru", P_BOOL|P_VI_DEF|P_VIM|P_RSTAT,
2111#ifdef FEAT_CMDL_INFO
2112 (char_u *)&p_ru, PV_NONE,
2113#else
2114 (char_u *)NULL, PV_NONE,
2115#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002116 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002117 {"rulerformat", "ruf", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2118#ifdef FEAT_STL_OPT
2119 (char_u *)&p_ruf, PV_NONE,
2120#else
2121 (char_u *)NULL, PV_NONE,
2122#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002123 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002124 {"runtimepath", "rtp", P_STRING|P_VI_DEF|P_EXPAND|P_COMMA|P_NODUP|P_SECURE,
2125 (char_u *)&p_rtp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002126 {(char_u *)DFLT_RUNTIMEPATH, (char_u *)0L}
2127 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002128 {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF,
2129 (char_u *)VAR_WIN, PV_SCROLL,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002130 {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002131 {"scrollbind", "scb", P_BOOL|P_VI_DEF,
2132#ifdef FEAT_SCROLLBIND
2133 (char_u *)VAR_WIN, PV_SCBIND,
2134#else
2135 (char_u *)NULL, PV_NONE,
2136#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002137 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002138 {"scrolljump", "sj", P_NUM|P_VI_DEF|P_VIM,
2139 (char_u *)&p_sj, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002140 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002141 {"scrolloff", "so", P_NUM|P_VI_DEF|P_VIM|P_RALL,
2142 (char_u *)&p_so, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002143 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002144 {"scrollopt", "sbo", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2145#ifdef FEAT_SCROLLBIND
2146 (char_u *)&p_sbo, PV_NONE,
2147 {(char_u *)"ver,jump", (char_u *)0L}
2148#else
2149 (char_u *)NULL, PV_NONE,
2150 {(char_u *)0L, (char_u *)0L}
2151#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002152 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002153 {"sections", "sect", P_STRING|P_VI_DEF,
2154 (char_u *)&p_sections, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002155 {(char_u *)"SHNHH HUnhsh", (char_u *)0L}
2156 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002157 {"secure", NULL, P_BOOL|P_VI_DEF|P_SECURE,
2158 (char_u *)&p_secure, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002159 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002160 {"selection", "sel", P_STRING|P_VI_DEF,
2161#ifdef FEAT_VISUAL
2162 (char_u *)&p_sel, PV_NONE,
2163#else
2164 (char_u *)NULL, PV_NONE,
2165#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002166 {(char_u *)"inclusive", (char_u *)0L}
2167 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002168 {"selectmode", "slm", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2169#ifdef FEAT_VISUAL
2170 (char_u *)&p_slm, PV_NONE,
2171#else
2172 (char_u *)NULL, PV_NONE,
2173#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002174 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002175 {"sessionoptions", "ssop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2176#ifdef FEAT_SESSION
2177 (char_u *)&p_ssop, PV_NONE,
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00002178 {(char_u *)"blank,buffers,curdir,folds,help,options,tabpages,winsize",
Bram Moolenaar071d4272004-06-13 20:20:40 +00002179 (char_u *)0L}
2180#else
2181 (char_u *)NULL, PV_NONE,
2182 {(char_u *)0L, (char_u *)0L}
2183#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002184 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002185 {"shell", "sh", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2186 (char_u *)&p_sh, PV_NONE,
2187 {
2188#ifdef VMS
2189 (char_u *)"-",
2190#else
2191# if defined(MSDOS)
2192 (char_u *)"command",
2193# else
2194# if defined(WIN16)
2195 (char_u *)"command.com",
2196# else
2197# if defined(WIN3264)
2198 (char_u *)"", /* set in set_init_1() */
2199# else
2200# if defined(OS2)
2201 (char_u *)"cmd.exe",
2202# else
2203# if defined(ARCHIE)
2204 (char_u *)"gos",
2205# else
2206 (char_u *)"sh",
2207# endif
2208# endif
2209# endif
2210# endif
2211# endif
2212#endif /* VMS */
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002213 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002214 {"shellcmdflag","shcf", P_STRING|P_VI_DEF|P_SECURE,
2215 (char_u *)&p_shcf, PV_NONE,
2216 {
2217#if defined(MSDOS) || defined(MSWIN)
2218 (char_u *)"/c",
2219#else
2220# if defined(OS2)
2221 (char_u *)"/c",
2222# else
2223 (char_u *)"-c",
2224# endif
2225#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002226 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002227 {"shellpipe", "sp", P_STRING|P_VI_DEF|P_SECURE,
2228#ifdef FEAT_QUICKFIX
2229 (char_u *)&p_sp, PV_NONE,
2230 {
2231#if defined(UNIX) || defined(OS2)
2232# ifdef ARCHIE
2233 (char_u *)"2>",
2234# else
2235 (char_u *)"| tee",
2236# endif
2237#else
2238 (char_u *)">",
2239#endif
2240 (char_u *)0L}
2241#else
2242 (char_u *)NULL, PV_NONE,
2243 {(char_u *)0L, (char_u *)0L}
2244#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002245 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002246 {"shellquote", "shq", P_STRING|P_VI_DEF|P_SECURE,
2247 (char_u *)&p_shq, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002248 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002249 {"shellredir", "srr", P_STRING|P_VI_DEF|P_SECURE,
2250 (char_u *)&p_srr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002251 {(char_u *)">", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002252 {"shellslash", "ssl", P_BOOL|P_VI_DEF,
2253#ifdef BACKSLASH_IN_FILENAME
2254 (char_u *)&p_ssl, PV_NONE,
2255#else
2256 (char_u *)NULL, PV_NONE,
2257#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002258 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar26a60b42005-02-22 08:49:11 +00002259 {"shelltemp", "stmp", P_BOOL,
2260 (char_u *)&p_stmp, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002261 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002262 {"shelltype", "st", P_NUM|P_VI_DEF,
2263#ifdef AMIGA
2264 (char_u *)&p_st, PV_NONE,
2265#else
2266 (char_u *)NULL, PV_NONE,
2267#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002268 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002269 {"shellxquote", "sxq", P_STRING|P_VI_DEF|P_SECURE,
2270 (char_u *)&p_sxq, PV_NONE,
2271 {
2272#if defined(UNIX) && defined(USE_SYSTEM) && !defined(__EMX__)
2273 (char_u *)"\"",
2274#else
2275 (char_u *)"",
2276#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002277 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarf66b3fc2012-02-20 22:18:30 +01002278 {"shellxescape", "sxe", P_STRING|P_VI_DEF|P_SECURE,
2279 (char_u *)&p_sxe, PV_NONE,
2280 {
2281#if defined(MSDOS) || defined(WIN16) || defined(WIN3264)
2282 (char_u *)"\"&|<>()@^",
2283#else
2284 (char_u *)"",
2285#endif
2286 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002287 {"shiftround", "sr", P_BOOL|P_VI_DEF|P_VIM,
2288 (char_u *)&p_sr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002289 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002290 {"shiftwidth", "sw", P_NUM|P_VI_DEF,
2291 (char_u *)&p_sw, PV_SW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002292 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002293 {"shortmess", "shm", P_STRING|P_VIM|P_FLAGLIST,
2294 (char_u *)&p_shm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002295 {(char_u *)"", (char_u *)"filnxtToO"}
2296 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002297 {"shortname", "sn", P_BOOL|P_VI_DEF,
2298#ifdef SHORT_FNAME
2299 (char_u *)NULL, PV_NONE,
2300#else
2301 (char_u *)&p_sn, PV_SN,
2302#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002303 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002304 {"showbreak", "sbr", P_STRING|P_VI_DEF|P_RALL,
2305#ifdef FEAT_LINEBREAK
2306 (char_u *)&p_sbr, PV_NONE,
2307#else
2308 (char_u *)NULL, PV_NONE,
2309#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002310 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002311 {"showcmd", "sc", P_BOOL|P_VIM,
2312#ifdef FEAT_CMDL_INFO
2313 (char_u *)&p_sc, PV_NONE,
2314#else
2315 (char_u *)NULL, PV_NONE,
2316#endif
2317 {(char_u *)FALSE,
2318#ifdef UNIX
2319 (char_u *)FALSE
2320#else
2321 (char_u *)TRUE
2322#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002323 } SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002324 {"showfulltag", "sft", P_BOOL|P_VI_DEF,
2325 (char_u *)&p_sft, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002326 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002327 {"showmatch", "sm", P_BOOL|P_VI_DEF,
2328 (char_u *)&p_sm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002329 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002330 {"showmode", "smd", P_BOOL|P_VIM,
2331 (char_u *)&p_smd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002332 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002333 {"showtabline", "stal", P_NUM|P_VI_DEF|P_RALL,
2334#ifdef FEAT_WINDOWS
2335 (char_u *)&p_stal, PV_NONE,
2336#else
2337 (char_u *)NULL, PV_NONE,
2338#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002339 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002340 {"sidescroll", "ss", P_NUM|P_VI_DEF,
2341 (char_u *)&p_ss, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002342 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002343 {"sidescrolloff", "siso", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
2344 (char_u *)&p_siso, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002345 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002346 {"slowopen", "slow", P_BOOL|P_VI_DEF,
2347 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002348 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002349 {"smartcase", "scs", P_BOOL|P_VI_DEF|P_VIM,
2350 (char_u *)&p_scs, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002351 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002352 {"smartindent", "si", P_BOOL|P_VI_DEF|P_VIM,
2353#ifdef FEAT_SMARTINDENT
2354 (char_u *)&p_si, PV_SI,
2355#else
2356 (char_u *)NULL, PV_NONE,
2357#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002358 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002359 {"smarttab", "sta", P_BOOL|P_VI_DEF|P_VIM,
2360 (char_u *)&p_sta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002361 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002362 {"softtabstop", "sts", P_NUM|P_VI_DEF|P_VIM,
2363 (char_u *)&p_sts, PV_STS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002364 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002365 {"sourceany", NULL, P_BOOL|P_VI_DEF,
2366 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002367 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar217ad922005-03-20 22:37:15 +00002368 {"spell", NULL, P_BOOL|P_VI_DEF|P_RWIN,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002369#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002370 (char_u *)VAR_WIN, PV_SPELL,
2371#else
2372 (char_u *)NULL, PV_NONE,
2373#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002374 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar488c6512005-08-11 20:09:58 +00002375 {"spellcapcheck", "spc", P_STRING|P_ALLOCED|P_VI_DEF|P_RBUF,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002376#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002377 (char_u *)&p_spc, PV_SPC,
Bram Moolenaar0dc065e2005-07-04 22:49:24 +00002378 {(char_u *)"[.?!]\\_[\\])'\" ]\\+", (char_u *)0L}
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002379#else
2380 (char_u *)NULL, PV_NONE,
2381 {(char_u *)0L, (char_u *)0L}
2382#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002383 SCRIPTID_INIT},
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00002384 {"spellfile", "spf", P_STRING|P_EXPAND|P_ALLOCED|P_VI_DEF|P_SECURE|P_COMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002385#ifdef FEAT_SPELL
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002386 (char_u *)&p_spf, PV_SPF,
2387 {(char_u *)"", (char_u *)0L}
2388#else
2389 (char_u *)NULL, PV_NONE,
2390 {(char_u *)0L, (char_u *)0L}
2391#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002392 SCRIPTID_INIT},
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00002393 {"spelllang", "spl", P_STRING|P_ALLOCED|P_VI_DEF|P_COMMA|P_RBUF|P_EXPAND,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002394#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00002395 (char_u *)&p_spl, PV_SPL,
Bram Moolenaar82cf9b62005-06-07 21:09:25 +00002396 {(char_u *)"en", (char_u *)0L}
Bram Moolenaar217ad922005-03-20 22:37:15 +00002397#else
2398 (char_u *)NULL, PV_NONE,
2399 {(char_u *)0L, (char_u *)0L}
2400#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002401 SCRIPTID_INIT},
Bram Moolenaar28e4c8d2006-05-09 16:15:42 +00002402 {"spellsuggest", "sps", P_STRING|P_VI_DEF|P_EXPAND|P_SECURE|P_COMMA,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00002403#ifdef FEAT_SPELL
Bram Moolenaard857f0e2005-06-21 22:37:39 +00002404 (char_u *)&p_sps, PV_NONE,
2405 {(char_u *)"best", (char_u *)0L}
2406#else
2407 (char_u *)NULL, PV_NONE,
2408 {(char_u *)0L, (char_u *)0L}
2409#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002410 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002411 {"splitbelow", "sb", P_BOOL|P_VI_DEF,
2412#ifdef FEAT_WINDOWS
2413 (char_u *)&p_sb, PV_NONE,
2414#else
2415 (char_u *)NULL, PV_NONE,
2416#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002417 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002418 {"splitright", "spr", P_BOOL|P_VI_DEF,
2419#ifdef FEAT_VERTSPLIT
2420 (char_u *)&p_spr, PV_NONE,
2421#else
2422 (char_u *)NULL, PV_NONE,
2423#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002424 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002425 {"startofline", "sol", P_BOOL|P_VI_DEF|P_VIM,
2426 (char_u *)&p_sol, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002427 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002428 {"statusline" ,"stl", P_STRING|P_VI_DEF|P_ALLOCED|P_RSTAT,
2429#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002430 (char_u *)&p_stl, PV_STL,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002431#else
2432 (char_u *)NULL, PV_NONE,
2433#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002434 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002435 {"suffixes", "su", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2436 (char_u *)&p_su, PV_NONE,
2437 {(char_u *)".bak,~,.o,.h,.info,.swp,.obj",
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002438 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002439 {"suffixesadd", "sua", P_STRING|P_VI_DEF|P_ALLOCED|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002440#ifdef FEAT_SEARCHPATH
Bram Moolenaar071d4272004-06-13 20:20:40 +00002441 (char_u *)&p_sua, PV_SUA,
2442 {(char_u *)"", (char_u *)0L}
2443#else
2444 (char_u *)NULL, PV_NONE,
2445 {(char_u *)0L, (char_u *)0L}
2446#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002447 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002448 {"swapfile", "swf", P_BOOL|P_VI_DEF|P_RSTAT,
2449 (char_u *)&p_swf, PV_SWF,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002450 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002451 {"swapsync", "sws", P_STRING|P_VI_DEF,
2452 (char_u *)&p_sws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002453 {(char_u *)"fsync", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002454 {"switchbuf", "swb", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2455 (char_u *)&p_swb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002456 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00002457 {"synmaxcol", "smc", P_NUM|P_VI_DEF|P_RBUF,
2458#ifdef FEAT_SYN_HL
2459 (char_u *)&p_smc, PV_SMC,
2460 {(char_u *)3000L, (char_u *)0L}
2461#else
2462 (char_u *)NULL, PV_NONE,
2463 {(char_u *)0L, (char_u *)0L}
2464#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002465 SCRIPTID_INIT},
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002466 {"syntax", "syn", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002467#ifdef FEAT_SYN_HL
2468 (char_u *)&p_syn, PV_SYN,
2469 {(char_u *)"", (char_u *)0L}
2470#else
2471 (char_u *)NULL, PV_NONE,
2472 {(char_u *)0L, (char_u *)0L}
2473#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002474 SCRIPTID_INIT},
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00002475 {"tabline", "tal", P_STRING|P_VI_DEF|P_RALL,
2476#ifdef FEAT_STL_OPT
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00002477 (char_u *)&p_tal, PV_NONE,
2478#else
2479 (char_u *)NULL, PV_NONE,
2480#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002481 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarfd2ac762006-03-01 22:09:21 +00002482 {"tabpagemax", "tpm", P_NUM|P_VI_DEF,
2483#ifdef FEAT_WINDOWS
2484 (char_u *)&p_tpm, PV_NONE,
2485#else
2486 (char_u *)NULL, PV_NONE,
2487#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002488 {(char_u *)10L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002489 {"tabstop", "ts", P_NUM|P_VI_DEF|P_RBUF,
2490 (char_u *)&p_ts, PV_TS,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002491 {(char_u *)8L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002492 {"tagbsearch", "tbs", P_BOOL|P_VI_DEF,
2493 (char_u *)&p_tbs, PV_NONE,
2494#ifdef VMS /* binary searching doesn't appear to work on VMS */
2495 {(char_u *)0L, (char_u *)0L}
2496#else
2497 {(char_u *)TRUE, (char_u *)0L}
2498#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002499 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002500 {"taglength", "tl", P_NUM|P_VI_DEF,
2501 (char_u *)&p_tl, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002502 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002503 {"tagrelative", "tr", P_BOOL|P_VIM,
2504 (char_u *)&p_tr, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002505 {(char_u *)FALSE, (char_u *)TRUE} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002506 {"tags", "tag", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002507 (char_u *)&p_tags, PV_TAGS,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002508 {
2509#if defined(FEAT_EMACS_TAGS) && !defined(CASE_INSENSITIVE_FILENAME)
2510 (char_u *)"./tags,./TAGS,tags,TAGS",
2511#else
2512 (char_u *)"./tags,tags",
2513#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002514 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002515 {"tagstack", "tgst", P_BOOL|P_VI_DEF,
2516 (char_u *)&p_tgst, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002517 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002518 {"term", NULL, P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2519 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002520 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002521 {"termbidi", "tbidi", P_BOOL|P_VI_DEF,
2522#ifdef FEAT_ARABIC
2523 (char_u *)&p_tbidi, PV_NONE,
2524#else
2525 (char_u *)NULL, PV_NONE,
2526#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002527 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002528 {"termencoding", "tenc", P_STRING|P_VI_DEF|P_RCLR,
2529#ifdef FEAT_MBYTE
2530 (char_u *)&p_tenc, PV_NONE,
2531 {(char_u *)"", (char_u *)0L}
2532#else
2533 (char_u *)NULL, PV_NONE,
2534 {(char_u *)0L, (char_u *)0L}
2535#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002536 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002537 {"terse", NULL, P_BOOL|P_VI_DEF,
2538 (char_u *)&p_terse, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002539 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002540 {"textauto", "ta", P_BOOL|P_VIM,
2541 (char_u *)&p_ta, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002542 {(char_u *)DFLT_TEXTAUTO, (char_u *)TRUE}
2543 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002544 {"textmode", "tx", P_BOOL|P_VI_DEF|P_NO_MKRC,
2545 (char_u *)&p_tx, PV_TX,
2546 {
2547#ifdef USE_CRNL
2548 (char_u *)TRUE,
2549#else
2550 (char_u *)FALSE,
2551#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002552 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1a384422010-07-14 19:53:30 +02002553 {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002554 (char_u *)&p_tw, PV_TW,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002555 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002556 {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_COMMA|P_NODUP,
2557#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002558 (char_u *)&p_tsr, PV_TSR,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002559#else
2560 (char_u *)NULL, PV_NONE,
2561#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002562 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002563 {"tildeop", "top", P_BOOL|P_VI_DEF|P_VIM,
2564 (char_u *)&p_to, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002565 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002566 {"timeout", "to", P_BOOL|P_VI_DEF,
2567 (char_u *)&p_timeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002568 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002569 {"timeoutlen", "tm", P_NUM|P_VI_DEF,
2570 (char_u *)&p_tm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002571 {(char_u *)1000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002572 {"title", NULL, P_BOOL|P_VI_DEF,
2573#ifdef FEAT_TITLE
2574 (char_u *)&p_title, PV_NONE,
2575#else
2576 (char_u *)NULL, PV_NONE,
2577#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002578 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002579 {"titlelen", NULL, P_NUM|P_VI_DEF,
2580#ifdef FEAT_TITLE
2581 (char_u *)&p_titlelen, PV_NONE,
2582#else
2583 (char_u *)NULL, PV_NONE,
2584#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002585 {(char_u *)85L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00002586 {"titleold", NULL, P_STRING|P_VI_DEF|P_GETTEXT|P_SECURE|P_NO_MKRC,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002587#ifdef FEAT_TITLE
2588 (char_u *)&p_titleold, PV_NONE,
2589 {(char_u *)N_("Thanks for flying Vim"),
2590 (char_u *)0L}
2591#else
2592 (char_u *)NULL, PV_NONE,
2593 {(char_u *)0L, (char_u *)0L}
2594#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002595 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002596 {"titlestring", NULL, P_STRING|P_VI_DEF,
2597#ifdef FEAT_TITLE
2598 (char_u *)&p_titlestring, PV_NONE,
2599#else
2600 (char_u *)NULL, PV_NONE,
2601#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002602 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002603#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
2604 {"toolbar", "tb", P_STRING|P_COMMA|P_VI_DEF|P_NODUP,
2605 (char_u *)&p_toolbar, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002606 {(char_u *)"icons,tooltips", (char_u *)0L}
2607 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002608#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02002609#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002610 {"toolbariconsize", "tbis", P_STRING|P_VI_DEF,
2611 (char_u *)&p_tbis, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002612 {(char_u *)"small", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002613#endif
2614 {"ttimeout", NULL, P_BOOL|P_VI_DEF|P_VIM,
2615 (char_u *)&p_ttimeout, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002616 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002617 {"ttimeoutlen", "ttm", P_NUM|P_VI_DEF,
2618 (char_u *)&p_ttm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002619 {(char_u *)-1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002620 {"ttybuiltin", "tbi", P_BOOL|P_VI_DEF,
2621 (char_u *)&p_tbi, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002622 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002623 {"ttyfast", "tf", P_BOOL|P_NO_MKRC|P_VI_DEF,
2624 (char_u *)&p_tf, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002625 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002626 {"ttymouse", "ttym", P_STRING|P_NODEFAULT|P_NO_MKRC|P_VI_DEF,
2627#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
2628 (char_u *)&p_ttym, PV_NONE,
2629#else
2630 (char_u *)NULL, PV_NONE,
2631#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002632 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002633 {"ttyscroll", "tsl", P_NUM|P_VI_DEF,
2634 (char_u *)&p_ttyscroll, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002635 {(char_u *)999L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002636 {"ttytype", "tty", P_STRING|P_EXPAND|P_NODEFAULT|P_NO_MKRC|P_VI_DEF|P_RALL,
2637 (char_u *)&T_NAME, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002638 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar55debbe2010-05-23 23:34:36 +02002639 {"undodir", "udir", P_STRING|P_EXPAND|P_COMMA|P_NODUP|P_SECURE|P_VI_DEF,
2640#ifdef FEAT_PERSISTENT_UNDO
2641 (char_u *)&p_udir, PV_NONE,
2642 {(char_u *)".", (char_u *)0L}
2643#else
2644 (char_u *)NULL, PV_NONE,
2645 {(char_u *)0L, (char_u *)0L}
2646#endif
2647 SCRIPTID_INIT},
2648 {"undofile", "udf", P_BOOL|P_VI_DEF|P_VIM,
2649#ifdef FEAT_PERSISTENT_UNDO
2650 (char_u *)&p_udf, PV_UDF,
2651#else
2652 (char_u *)NULL, PV_NONE,
2653#endif
2654 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002655 {"undolevels", "ul", P_NUM|P_VI_DEF,
2656 (char_u *)&p_ul, PV_NONE,
2657 {
2658#if defined(UNIX) || defined(WIN3264) || defined(OS2) || defined(VMS)
2659 (char_u *)1000L,
2660#else
2661 (char_u *)100L,
2662#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002663 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar59f931e2010-07-24 20:27:03 +02002664 {"undoreload", "ur", P_NUM|P_VI_DEF,
2665 (char_u *)&p_ur, PV_NONE,
2666 { (char_u *)10000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002667 {"updatecount", "uc", P_NUM|P_VI_DEF,
2668 (char_u *)&p_uc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002669 {(char_u *)200L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002670 {"updatetime", "ut", P_NUM|P_VI_DEF,
2671 (char_u *)&p_ut, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002672 {(char_u *)4000L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002673 {"verbose", "vbs", P_NUM|P_VI_DEF,
2674 (char_u *)&p_verbose, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002675 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar54ee7752005-05-31 22:22:17 +00002676 {"verbosefile", "vfile", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2677 (char_u *)&p_vfile, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002678 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002679 {"viewdir", "vdir", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE,
2680#ifdef FEAT_SESSION
2681 (char_u *)&p_vdir, PV_NONE,
2682 {(char_u *)DFLT_VDIR, (char_u *)0L}
2683#else
2684 (char_u *)NULL, PV_NONE,
2685 {(char_u *)0L, (char_u *)0L}
2686#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002687 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002688 {"viewoptions", "vop", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2689#ifdef FEAT_SESSION
2690 (char_u *)&p_vop, PV_NONE,
2691 {(char_u *)"folds,options,cursor", (char_u *)0L}
2692#else
2693 (char_u *)NULL, PV_NONE,
2694 {(char_u *)0L, (char_u *)0L}
2695#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002696 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002697 {"viminfo", "vi", P_STRING|P_COMMA|P_NODUP|P_SECURE,
2698#ifdef FEAT_VIMINFO
2699 (char_u *)&p_viminfo, PV_NONE,
2700#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
Bram Moolenaard812df62008-11-09 12:46:09 +00002701 {(char_u *)"", (char_u *)"'100,<50,s10,h,rA:,rB:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002702#else
2703# ifdef AMIGA
2704 {(char_u *)"",
Bram Moolenaard812df62008-11-09 12:46:09 +00002705 (char_u *)"'100,<50,s10,h,rdf0:,rdf1:,rdf2:"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002706# else
Bram Moolenaard812df62008-11-09 12:46:09 +00002707 {(char_u *)"", (char_u *)"'100,<50,s10,h"}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002708# endif
2709#endif
2710#else
2711 (char_u *)NULL, PV_NONE,
2712 {(char_u *)0L, (char_u *)0L}
2713#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002714 SCRIPTID_INIT},
Bram Moolenaar913077c2012-03-28 19:59:04 +02002715 {"virtualedit", "ve", P_STRING|P_COMMA|P_NODUP|P_VI_DEF|P_VIM|P_CURSWANT,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002716#ifdef FEAT_VIRTUALEDIT
2717 (char_u *)&p_ve, PV_NONE,
2718 {(char_u *)"", (char_u *)""}
2719#else
2720 (char_u *)NULL, PV_NONE,
2721 {(char_u *)0L, (char_u *)0L}
2722#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002723 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002724 {"visualbell", "vb", P_BOOL|P_VI_DEF,
2725 (char_u *)&p_vb, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002726 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002727 {"w300", NULL, P_NUM|P_VI_DEF,
2728 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002729 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002730 {"w1200", NULL, P_NUM|P_VI_DEF,
2731 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002732 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002733 {"w9600", NULL, P_NUM|P_VI_DEF,
2734 (char_u *)NULL, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002735 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002736 {"warn", NULL, P_BOOL|P_VI_DEF,
2737 (char_u *)&p_warn, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002738 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002739 {"weirdinvert", "wiv", P_BOOL|P_VI_DEF|P_RCLR,
2740 (char_u *)&p_wiv, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002741 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002742 {"whichwrap", "ww", P_STRING|P_VIM|P_COMMA|P_FLAGLIST,
2743 (char_u *)&p_ww, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002744 {(char_u *)"", (char_u *)"b,s"} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002745 {"wildchar", "wc", P_NUM|P_VIM,
2746 (char_u *)&p_wc, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002747 {(char_u *)(long)Ctrl_E, (char_u *)(long)TAB}
2748 SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002749 {"wildcharm", "wcm", P_NUM|P_VI_DEF,
Bram Moolenaar071d4272004-06-13 20:20:40 +00002750 (char_u *)&p_wcm, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002751 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002752 {"wildignore", "wig", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2753#ifdef FEAT_WILDIGN
2754 (char_u *)&p_wig, PV_NONE,
2755#else
2756 (char_u *)NULL, PV_NONE,
2757#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002758 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar94950a92010-12-02 16:01:29 +01002759 {"wildignorecase", "wic", P_BOOL|P_VI_DEF,
2760 (char_u *)&p_wic, PV_NONE,
2761 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002762 {"wildmenu", "wmnu", P_BOOL|P_VI_DEF,
2763#ifdef FEAT_WILDMENU
2764 (char_u *)&p_wmnu, PV_NONE,
2765#else
2766 (char_u *)NULL, PV_NONE,
2767#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002768 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002769 {"wildmode", "wim", P_STRING|P_VI_DEF|P_COMMA|P_NODUP,
2770 (char_u *)&p_wim, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002771 {(char_u *)"full", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00002772 {"wildoptions", "wop", P_STRING|P_VI_DEF,
2773#ifdef FEAT_CMDL_COMPL
2774 (char_u *)&p_wop, PV_NONE,
2775 {(char_u *)"", (char_u *)0L}
2776#else
2777 (char_u *)NULL, PV_NONE,
2778 {(char_u *)NULL, (char_u *)0L}
2779#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002780 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002781 {"winaltkeys", "wak", P_STRING|P_VI_DEF,
2782#ifdef FEAT_WAK
2783 (char_u *)&p_wak, PV_NONE,
2784 {(char_u *)"menu", (char_u *)0L}
2785#else
2786 (char_u *)NULL, PV_NONE,
2787 {(char_u *)NULL, (char_u *)0L}
2788#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002789 SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002790 {"window", "wi", P_NUM|P_VI_DEF,
Bram Moolenaar4399ef42005-02-12 14:29:27 +00002791 (char_u *)&p_window, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002792 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002793 {"winheight", "wh", P_NUM|P_VI_DEF,
2794#ifdef FEAT_WINDOWS
2795 (char_u *)&p_wh, PV_NONE,
2796#else
2797 (char_u *)NULL, PV_NONE,
2798#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002799 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002800 {"winfixheight", "wfh", P_BOOL|P_VI_DEF|P_RSTAT,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00002801#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00002802 (char_u *)VAR_WIN, PV_WFH,
2803#else
2804 (char_u *)NULL, PV_NONE,
2805#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002806 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00002807 {"winfixwidth", "wfw", P_BOOL|P_VI_DEF|P_RSTAT,
2808#ifdef FEAT_VERTSPLIT
2809 (char_u *)VAR_WIN, PV_WFW,
2810#else
2811 (char_u *)NULL, PV_NONE,
2812#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002813 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002814 {"winminheight", "wmh", P_NUM|P_VI_DEF,
2815#ifdef FEAT_WINDOWS
2816 (char_u *)&p_wmh, PV_NONE,
2817#else
2818 (char_u *)NULL, PV_NONE,
2819#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002820 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002821 {"winminwidth", "wmw", P_NUM|P_VI_DEF,
2822#ifdef FEAT_VERTSPLIT
2823 (char_u *)&p_wmw, PV_NONE,
2824#else
2825 (char_u *)NULL, PV_NONE,
2826#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002827 {(char_u *)1L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002828 {"winwidth", "wiw", P_NUM|P_VI_DEF,
2829#ifdef FEAT_VERTSPLIT
2830 (char_u *)&p_wiw, PV_NONE,
2831#else
2832 (char_u *)NULL, PV_NONE,
2833#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002834 {(char_u *)20L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002835 {"wrap", NULL, P_BOOL|P_VI_DEF|P_RWIN,
2836 (char_u *)VAR_WIN, PV_WRAP,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002837 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002838 {"wrapmargin", "wm", P_NUM|P_VI_DEF,
2839 (char_u *)&p_wm, PV_WM,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002840 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002841 {"wrapscan", "ws", P_BOOL|P_VI_DEF,
2842 (char_u *)&p_ws, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002843 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002844 {"write", NULL, P_BOOL|P_VI_DEF,
2845 (char_u *)&p_write, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002846 {(char_u *)TRUE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002847 {"writeany", "wa", P_BOOL|P_VI_DEF,
2848 (char_u *)&p_wa, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002849 {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002850 {"writebackup", "wb", P_BOOL|P_VI_DEF|P_VIM,
2851 (char_u *)&p_wb, PV_NONE,
2852 {
2853#ifdef FEAT_WRITEBACKUP
2854 (char_u *)TRUE,
2855#else
2856 (char_u *)FALSE,
2857#endif
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002858 (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002859 {"writedelay", "wd", P_NUM|P_VI_DEF,
2860 (char_u *)&p_wd, PV_NONE,
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002861 {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002862
2863/* terminal output codes */
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002864#define p_term(sss, vvv) {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
Bram Moolenaar071d4272004-06-13 20:20:40 +00002865 (char_u *)&vvv, PV_NONE, \
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002866 {(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
Bram Moolenaar071d4272004-06-13 20:20:40 +00002867
2868 p_term("t_AB", T_CAB)
2869 p_term("t_AF", T_CAF)
2870 p_term("t_AL", T_CAL)
2871 p_term("t_al", T_AL)
2872 p_term("t_bc", T_BC)
2873 p_term("t_cd", T_CD)
2874 p_term("t_ce", T_CE)
2875 p_term("t_cl", T_CL)
2876 p_term("t_cm", T_CM)
2877 p_term("t_Co", T_CCO)
2878 p_term("t_CS", T_CCS)
2879 p_term("t_cs", T_CS)
2880#ifdef FEAT_VERTSPLIT
2881 p_term("t_CV", T_CSV)
2882#endif
2883 p_term("t_ut", T_UT)
2884 p_term("t_da", T_DA)
2885 p_term("t_db", T_DB)
2886 p_term("t_DL", T_CDL)
2887 p_term("t_dl", T_DL)
2888 p_term("t_fs", T_FS)
2889 p_term("t_IE", T_CIE)
2890 p_term("t_IS", T_CIS)
2891 p_term("t_ke", T_KE)
2892 p_term("t_ks", T_KS)
2893 p_term("t_le", T_LE)
2894 p_term("t_mb", T_MB)
2895 p_term("t_md", T_MD)
2896 p_term("t_me", T_ME)
2897 p_term("t_mr", T_MR)
2898 p_term("t_ms", T_MS)
2899 p_term("t_nd", T_ND)
2900 p_term("t_op", T_OP)
2901 p_term("t_RI", T_CRI)
2902 p_term("t_RV", T_CRV)
Bram Moolenaar9584b312013-03-13 19:29:28 +01002903 p_term("t_u7", T_U7)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002904 p_term("t_Sb", T_CSB)
2905 p_term("t_Sf", T_CSF)
2906 p_term("t_se", T_SE)
2907 p_term("t_so", T_SO)
2908 p_term("t_sr", T_SR)
2909 p_term("t_ts", T_TS)
2910 p_term("t_te", T_TE)
2911 p_term("t_ti", T_TI)
2912 p_term("t_ue", T_UE)
2913 p_term("t_us", T_US)
2914 p_term("t_vb", T_VB)
2915 p_term("t_ve", T_VE)
2916 p_term("t_vi", T_VI)
2917 p_term("t_vs", T_VS)
2918 p_term("t_WP", T_CWP)
2919 p_term("t_WS", T_CWS)
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00002920 p_term("t_SI", T_CSI)
2921 p_term("t_EI", T_CEI)
Bram Moolenaar071d4272004-06-13 20:20:40 +00002922 p_term("t_xs", T_XS)
2923 p_term("t_ZH", T_CZH)
2924 p_term("t_ZR", T_CZR)
2925
2926/* terminal key codes are not in here */
2927
Bram Moolenaar2c4278f2009-05-17 11:33:22 +00002928 /* end marker */
2929 {NULL, NULL, 0, NULL, PV_NONE, {NULL, NULL} SCRIPTID_INIT}
Bram Moolenaar071d4272004-06-13 20:20:40 +00002930};
2931
2932#define PARAM_COUNT (sizeof(options) / sizeof(struct vimoption))
2933
2934#ifdef FEAT_MBYTE
2935static char *(p_ambw_values[]) = {"single", "double", NULL};
2936#endif
2937static char *(p_bg_values[]) = {"light", "dark", NULL};
2938static char *(p_nf_values[]) = {"octal", "hex", "alpha", NULL};
2939static char *(p_ff_values[]) = {FF_UNIX, FF_DOS, FF_MAC, NULL};
Bram Moolenaar49771f42010-07-20 17:32:38 +02002940#ifdef FEAT_CRYPT
2941static char *(p_cm_values[]) = {"zip", "blowfish", NULL};
2942#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00002943#ifdef FEAT_CMDL_COMPL
2944static char *(p_wop_values[]) = {"tagfile", NULL};
2945#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002946#ifdef FEAT_WAK
2947static char *(p_wak_values[]) = {"yes", "menu", "no", NULL};
2948#endif
2949static char *(p_mousem_values[]) = {"extend", "popup", "popup_setpos", "mac", NULL};
2950#ifdef FEAT_VISUAL
2951static char *(p_sel_values[]) = {"inclusive", "exclusive", "old", NULL};
2952static char *(p_slm_values[]) = {"mouse", "key", "cmd", NULL};
2953#endif
2954#ifdef FEAT_VISUAL
2955static char *(p_km_values[]) = {"startsel", "stopsel", NULL};
2956#endif
2957#ifdef FEAT_BROWSE
2958static char *(p_bsdir_values[]) = {"current", "last", "buffer", NULL};
2959#endif
2960#ifdef FEAT_SCROLLBIND
2961static char *(p_scbopt_values[]) = {"ver", "hor", "jump", NULL};
2962#endif
Bram Moolenaar57657d82006-04-21 22:12:41 +00002963static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
Bram Moolenaar071d4272004-06-13 20:20:40 +00002964#ifdef FEAT_VERTSPLIT
2965static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
2966#endif
2967#if defined(FEAT_QUICKFIX)
Bram Moolenaar21cf8232004-07-16 20:18:37 +00002968# ifdef FEAT_AUTOCMD
2969static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
2970# else
Bram Moolenaar071d4272004-06-13 20:20:40 +00002971static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
Bram Moolenaar21cf8232004-07-16 20:18:37 +00002972# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002973static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
2974#endif
2975static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
2976#ifdef FEAT_FOLDING
2977static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00002978# ifdef FEAT_DIFF
Bram Moolenaar071d4272004-06-13 20:20:40 +00002979 "diff",
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00002980# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002981 NULL};
2982static char *(p_fcl_values[]) = {"all", NULL};
2983#endif
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00002984#ifdef FEAT_INS_EXPAND
Bram Moolenaarc270d802006-03-11 21:29:41 +00002985static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview", NULL};
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00002986#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00002987
2988static void set_option_default __ARGS((int, int opt_flags, int compatible));
2989static void set_options_default __ARGS((int opt_flags));
Bram Moolenaarf740b292006-02-16 22:11:02 +00002990static char_u *term_bg_default __ARGS((void));
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00002991static void did_set_option __ARGS((int opt_idx, int opt_flags, int new_value));
Bram Moolenaar071d4272004-06-13 20:20:40 +00002992static char_u *illegal_char __ARGS((char_u *, int));
2993static int string_to_key __ARGS((char_u *arg));
2994#ifdef FEAT_CMDWIN
2995static char_u *check_cedit __ARGS((void));
2996#endif
2997#ifdef FEAT_TITLE
2998static void did_set_title __ARGS((int icon));
2999#endif
3000static char_u *option_expand __ARGS((int opt_idx, char_u *val));
3001static void didset_options __ARGS((void));
3002static void check_string_option __ARGS((char_u **pp));
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003003#if defined(FEAT_EVAL) || defined(PROTO)
3004static long_u *insecure_flag __ARGS((int opt_idx, int opt_flags));
3005#else
3006# define insecure_flag(opt_idx, opt_flags) (&options[opt_idx].flags)
3007#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003008static void set_string_option_global __ARGS((int opt_idx, char_u **varp));
3009static void set_string_option __ARGS((int opt_idx, char_u *value, int opt_flags));
3010static 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));
3011static char_u *set_chars_option __ARGS((char_u **varp));
Bram Moolenaar1a384422010-07-14 19:53:30 +02003012#ifdef FEAT_SYN_HL
3013static int int_cmp __ARGS((const void *a, const void *b));
3014#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003015#ifdef FEAT_CLIPBOARD
3016static char_u *check_clipboard_option __ARGS((void));
3017#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003018#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02003019static char_u *compile_cap_prog __ARGS((synblock_T *synblock));
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00003020#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003021#ifdef FEAT_EVAL
3022static void set_option_scriptID_idx __ARGS((int opt_idx, int opt_flags, int id));
3023#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003024static char_u *set_bool_option __ARGS((int opt_idx, char_u *varp, int value, int opt_flags));
Bram Moolenaar555b2802005-05-19 21:08:39 +00003025static 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 +00003026static void check_redraw __ARGS((long_u flags));
3027static int findoption __ARGS((char_u *));
3028static int find_key_option __ARGS((char_u *));
3029static void showoptions __ARGS((int all, int opt_flags));
3030static int optval_default __ARGS((struct vimoption *, char_u *varp));
3031static void showoneopt __ARGS((struct vimoption *, int opt_flags));
3032static int put_setstring __ARGS((FILE *fd, char *cmd, char *name, char_u **valuep, int expand));
3033static int put_setnum __ARGS((FILE *fd, char *cmd, char *name, long *valuep));
3034static int put_setbool __ARGS((FILE *fd, char *cmd, char *name, int value));
3035static int istermoption __ARGS((struct vimoption *));
3036static char_u *get_varp_scope __ARGS((struct vimoption *p, int opt_flags));
3037static char_u *get_varp __ARGS((struct vimoption *));
3038static void option_value2string __ARGS((struct vimoption *, int opt_flags));
3039static int wc_use_keyname __ARGS((char_u *varp, long *wcp));
3040#ifdef FEAT_LANGMAP
3041static void langmap_init __ARGS((void));
3042static void langmap_set __ARGS((void));
3043#endif
3044static void paste_option_changed __ARGS((void));
3045static void compatible_set __ARGS((void));
3046#ifdef FEAT_LINEBREAK
3047static void fill_breakat_flags __ARGS((void));
3048#endif
3049static int opt_strings_flags __ARGS((char_u *val, char **values, unsigned *flagp, int list));
3050static int check_opt_strings __ARGS((char_u *val, char **values, int));
3051static int check_opt_wim __ARGS((void));
3052
3053/*
3054 * Initialize the options, first part.
3055 *
3056 * Called only once from main(), just after creating the first buffer.
3057 */
3058 void
3059set_init_1()
3060{
3061 char_u *p;
3062 int opt_idx;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003063 long_u n;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003064
3065#ifdef FEAT_LANGMAP
3066 langmap_init();
3067#endif
3068
3069 /* Be Vi compatible by default */
3070 p_cp = TRUE;
3071
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003072 /* Use POSIX compatibility when $VIM_POSIX is set. */
3073 if (mch_getenv((char_u *)"VIM_POSIX") != NULL)
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003074 {
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003075 set_string_default("cpo", (char_u *)CPO_ALL);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003076 set_string_default("shm", (char_u *)"A");
3077 }
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003078
Bram Moolenaar071d4272004-06-13 20:20:40 +00003079 /*
3080 * Find default value for 'shell' option.
Bram Moolenaar7c626922005-02-07 22:01:03 +00003081 * Don't use it if it is empty.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003082 */
Bram Moolenaar7c626922005-02-07 22:01:03 +00003083 if (((p = mch_getenv((char_u *)"SHELL")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003084#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
3085# ifdef __EMX__
Bram Moolenaar7c626922005-02-07 22:01:03 +00003086 || ((p = mch_getenv((char_u *)"EMXSHELL")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003087# endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003088 || ((p = mch_getenv((char_u *)"COMSPEC")) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003089# ifdef WIN3264
Bram Moolenaar7c626922005-02-07 22:01:03 +00003090 || ((p = default_shell()) != NULL && *p != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003091# endif
3092#endif
Bram Moolenaar7c626922005-02-07 22:01:03 +00003093 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00003094 set_string_default("sh", p);
3095
3096#ifdef FEAT_WILDIGN
3097 /*
3098 * Set the default for 'backupskip' to include environment variables for
3099 * temp files.
3100 */
3101 {
3102# ifdef UNIX
3103 static char *(names[4]) = {"", "TMPDIR", "TEMP", "TMP"};
3104# else
3105 static char *(names[3]) = {"TMPDIR", "TEMP", "TMP"};
3106# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003107 int len;
3108 garray_T ga;
3109 int mustfree;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003110
3111 ga_init2(&ga, 1, 100);
3112 for (n = 0; n < (long)(sizeof(names) / sizeof(char *)); ++n)
3113 {
Bram Moolenaar05159a02005-02-26 23:04:13 +00003114 mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003115# ifdef UNIX
3116 if (*names[n] == NUL)
3117 p = (char_u *)"/tmp";
3118 else
3119# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003120 p = vim_getenv((char_u *)names[n], &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003121 if (p != NULL && *p != NUL)
3122 {
3123 /* First time count the NUL, otherwise count the ','. */
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00003124 len = (int)STRLEN(p) + 3;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003125 if (ga_grow(&ga, len) == OK)
3126 {
3127 if (ga.ga_len > 0)
3128 STRCAT(ga.ga_data, ",");
3129 STRCAT(ga.ga_data, p);
3130 add_pathsep(ga.ga_data);
3131 STRCAT(ga.ga_data, "*");
Bram Moolenaar071d4272004-06-13 20:20:40 +00003132 ga.ga_len += len;
3133 }
3134 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003135 if (mustfree)
3136 vim_free(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003137 }
3138 if (ga.ga_data != NULL)
3139 {
3140 set_string_default("bsk", ga.ga_data);
3141 vim_free(ga.ga_data);
3142 }
3143 }
3144#endif
3145
3146 /*
3147 * 'maxmemtot' and 'maxmem' may have to be adjusted for available memory
3148 */
3149 opt_idx = findoption((char_u *)"maxmemtot");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003150 if (opt_idx >= 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003151 {
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003152#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3153 if (options[opt_idx].def_val[VI_DEFAULT] == (char_u *)0L)
3154#endif
3155 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00003156#ifdef HAVE_AVAIL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003157 /* Use amount of memory available at this moment. */
Bram Moolenaar11b73d62012-06-29 15:51:30 +02003158 n = (mch_avail_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003159#else
3160# ifdef HAVE_TOTAL_MEM
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003161 /* Use amount of memory available to Vim. */
Bram Moolenaar914572a2007-05-01 11:37:47 +00003162 n = (mch_total_mem(FALSE) >> 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003163# else
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003164 n = (0x7fffffff >> 11);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003165# endif
3166#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003167 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003168 opt_idx = findoption((char_u *)"maxmem");
3169 if (opt_idx >= 0)
3170 {
3171#if !defined(HAVE_AVAIL_MEM) && !defined(HAVE_TOTAL_MEM)
3172 if ((long)options[opt_idx].def_val[VI_DEFAULT] > n
3173 || (long)options[opt_idx].def_val[VI_DEFAULT] == 0L)
3174#endif
3175 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)n;
3176 }
3177 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003178 }
3179
3180#ifdef FEAT_GUI_W32
3181 /* force 'shortname' for Win32s */
3182 if (gui_is_win32s())
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003183 {
3184 opt_idx = findoption((char_u *)"shortname");
3185 if (opt_idx >= 0)
3186 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)TRUE;
3187 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003188#endif
3189
3190#ifdef FEAT_SEARCHPATH
3191 {
3192 char_u *cdpath;
3193 char_u *buf;
3194 int i;
3195 int j;
Bram Moolenaar05159a02005-02-26 23:04:13 +00003196 int mustfree = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003197
3198 /* Initialize the 'cdpath' option's default value. */
Bram Moolenaar05159a02005-02-26 23:04:13 +00003199 cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003200 if (cdpath != NULL)
3201 {
3202 buf = alloc((unsigned)((STRLEN(cdpath) << 1) + 2));
3203 if (buf != NULL)
3204 {
3205 buf[0] = ','; /* start with ",", current dir first */
3206 j = 1;
3207 for (i = 0; cdpath[i] != NUL; ++i)
3208 {
3209 if (vim_ispathlistsep(cdpath[i]))
3210 buf[j++] = ',';
3211 else
3212 {
3213 if (cdpath[i] == ' ' || cdpath[i] == ',')
3214 buf[j++] = '\\';
3215 buf[j++] = cdpath[i];
3216 }
3217 }
3218 buf[j] = NUL;
3219 opt_idx = findoption((char_u *)"cdpath");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003220 if (opt_idx >= 0)
3221 {
3222 options[opt_idx].def_val[VI_DEFAULT] = buf;
3223 options[opt_idx].flags |= P_DEF_ALLOCED;
3224 }
Bram Moolenaara9d52e32010-07-31 16:44:19 +02003225 else
3226 vim_free(buf); /* cannot happen */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003227 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00003228 if (mustfree)
3229 vim_free(cdpath);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003230 }
3231 }
3232#endif
3233
3234#if defined(FEAT_POSTSCRIPT) && (defined(MSWIN) || defined(OS2) || defined(VMS) || defined(EBCDIC) || defined(MAC) || defined(hpux))
3235 /* Set print encoding on platforms that don't default to latin1 */
3236 set_string_default("penc",
3237# if defined(MSWIN) || defined(OS2)
3238 (char_u *)"cp1252"
3239# else
3240# ifdef VMS
3241 (char_u *)"dec-mcs"
3242# else
3243# ifdef EBCDIC
3244 (char_u *)"ebcdic-uk"
3245# else
3246# ifdef MAC
3247 (char_u *)"mac-roman"
3248# else /* HPUX */
3249 (char_u *)"hp-roman8"
3250# endif
3251# endif
3252# endif
3253# endif
3254 );
3255#endif
3256
3257#ifdef FEAT_POSTSCRIPT
3258 /* 'printexpr' must be allocated to be able to evaluate it. */
3259 set_string_default("pexpr",
Bram Moolenaared203462004-06-16 11:19:22 +00003260# if defined(MSWIN) || defined(MSDOS) || defined(OS2)
3261 (char_u *)"system('copy' . ' ' . v:fname_in . (&printdevice == '' ? ' LPT1:' : (' \"' . &printdevice . '\"'))) . delete(v:fname_in)"
Bram Moolenaar071d4272004-06-13 20:20:40 +00003262# else
3263# ifdef VMS
3264 (char_u *)"system('print/delete' . (&printdevice == '' ? '' : ' /queue=' . &printdevice) . ' ' . v:fname_in)"
3265
3266# else
3267 (char_u *)"system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice) . ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error"
3268# endif
3269# endif
3270 );
3271#endif
3272
3273 /*
3274 * Set all the options (except the terminal options) to their default
3275 * value. Also set the global value for local options.
3276 */
3277 set_options_default(0);
3278
3279#ifdef FEAT_GUI
3280 if (found_reverse_arg)
3281 set_option_value((char_u *)"bg", 0L, (char_u *)"dark", 0);
3282#endif
3283
3284 curbuf->b_p_initialized = TRUE;
3285 curbuf->b_p_ar = -1; /* no local 'autoread' value */
3286 check_buf_options(curbuf);
3287 check_win_options(curwin);
3288 check_options();
3289
3290 /* Must be before option_expand(), because that one needs vim_isIDc() */
3291 didset_options();
3292
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00003293#ifdef FEAT_SPELL
Bram Moolenaar6bb68362005-03-22 23:03:44 +00003294 /* Use the current chartab for the generic chartab. */
3295 init_spell_chartab();
3296#endif
3297
Bram Moolenaar071d4272004-06-13 20:20:40 +00003298#ifdef FEAT_LINEBREAK
3299 /*
3300 * initialize the table for 'breakat'.
3301 */
3302 fill_breakat_flags();
3303#endif
3304
3305 /*
3306 * Expand environment variables and things like "~" for the defaults.
3307 * If option_expand() returns non-NULL the variable is expanded. This can
3308 * only happen for non-indirect options.
3309 * Also set the default to the expanded value, so ":set" does not list
3310 * them.
3311 * Don't set the P_ALLOCED flag, because we don't want to free the
3312 * default.
3313 */
3314 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
3315 {
3316 if ((options[opt_idx].flags & P_GETTEXT)
3317 && options[opt_idx].var != NULL)
3318 p = (char_u *)_(*(char **)options[opt_idx].var);
3319 else
3320 p = option_expand(opt_idx, NULL);
3321 if (p != NULL && (p = vim_strsave(p)) != NULL)
3322 {
3323 *(char_u **)options[opt_idx].var = p;
3324 /* VIMEXP
3325 * Defaults for all expanded options are currently the same for Vi
3326 * and Vim. When this changes, add some code here! Also need to
3327 * split P_DEF_ALLOCED in two.
3328 */
3329 if (options[opt_idx].flags & P_DEF_ALLOCED)
3330 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3331 options[opt_idx].def_val[VI_DEFAULT] = p;
3332 options[opt_idx].flags |= P_DEF_ALLOCED;
3333 }
3334 }
3335
3336 /* Initialize the highlight_attr[] table. */
3337 highlight_changed();
3338
3339 save_file_ff(curbuf); /* Buffer is unchanged */
3340
3341 /* Parse default for 'wildmode' */
3342 check_opt_wim();
3343
3344#if defined(FEAT_ARABIC)
3345 /* Detect use of mlterm.
3346 * Mlterm is a terminal emulator akin to xterm that has some special
3347 * abilities (bidi namely).
3348 * NOTE: mlterm's author is being asked to 'set' a variable
3349 * instead of an environment variable due to inheritance.
3350 */
3351 if (mch_getenv((char_u *)"MLTERM") != NULL)
3352 set_option_value((char_u *)"tbidi", 1L, NULL, 0);
3353#endif
3354
3355#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
3356 /* Parse default for 'fillchars'. */
3357 (void)set_chars_option(&p_fcs);
3358#endif
3359
3360#ifdef FEAT_CLIPBOARD
3361 /* Parse default for 'clipboard' */
3362 (void)check_clipboard_option();
3363#endif
3364
3365#ifdef FEAT_MBYTE
3366# if defined(WIN3264) && defined(FEAT_GETTEXT)
3367 /*
3368 * If $LANG isn't set, try to get a good value for it. This makes the
3369 * right language be used automatically. Don't do this for English.
3370 */
3371 if (mch_getenv((char_u *)"LANG") == NULL)
3372 {
3373 char buf[20];
3374
3375 /* Could use LOCALE_SISO639LANGNAME, but it's not in Win95.
3376 * LOCALE_SABBREVLANGNAME gives us three letters, like "enu", we use
3377 * only the first two. */
3378 n = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME,
3379 (LPTSTR)buf, 20);
3380 if (n >= 2 && STRNICMP(buf, "en", 2) != 0)
3381 {
3382 /* There are a few exceptions (probably more) */
3383 if (STRNICMP(buf, "cht", 3) == 0 || STRNICMP(buf, "zht", 3) == 0)
3384 STRCPY(buf, "zh_TW");
3385 else if (STRNICMP(buf, "chs", 3) == 0
3386 || STRNICMP(buf, "zhc", 3) == 0)
3387 STRCPY(buf, "zh_CN");
3388 else if (STRNICMP(buf, "jp", 2) == 0)
3389 STRCPY(buf, "ja");
3390 else
3391 buf[2] = NUL; /* truncate to two-letter code */
3392 vim_setenv("LANG", buf);
3393 }
3394 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003395# else
Bram Moolenaar9d47f172006-03-15 23:03:01 +00003396# ifdef MACOS_CONVERT
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00003397 /* Moved to os_mac_conv.c to avoid dependency problems. */
3398 mac_lang_init();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003399# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003400# endif
3401
3402 /* enc_locale() will try to find the encoding of the current locale. */
3403 p = enc_locale();
3404 if (p != NULL)
3405 {
3406 char_u *save_enc;
3407
3408 /* Try setting 'encoding' and check if the value is valid.
3409 * If not, go back to the default "latin1". */
3410 save_enc = p_enc;
3411 p_enc = p;
Bram Moolenaar733f0a22007-03-02 18:56:27 +00003412 if (STRCMP(p_enc, "gb18030") == 0)
3413 {
3414 /* We don't support "gb18030", but "cp936" is a good substitute
3415 * for practical purposes, thus use that. It's not an alias to
3416 * still support conversion between gb18030 and utf-8. */
3417 p_enc = vim_strsave((char_u *)"cp936");
3418 vim_free(p);
3419 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003420 if (mb_init() == NULL)
3421 {
3422 opt_idx = findoption((char_u *)"encoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003423 if (opt_idx >= 0)
3424 {
3425 options[opt_idx].def_val[VI_DEFAULT] = p_enc;
3426 options[opt_idx].flags |= P_DEF_ALLOCED;
3427 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003428
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003429#if defined(MSDOS) || defined(MSWIN) || defined(OS2) || defined(MACOS) \
3430 || defined(VMS)
3431 if (STRCMP(p_enc, "latin1") == 0
3432# ifdef FEAT_MBYTE
3433 || enc_utf8
3434# endif
3435 )
3436 {
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003437 /* Adjust the default for 'isprint' and 'iskeyword' to match
3438 * latin1. Also set the defaults for when 'nocompatible' is
3439 * set. */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003440 set_string_option_direct((char_u *)"isp", -1,
Bram Moolenaar4ea8fe12006-03-09 22:32:39 +00003441 ISP_LATIN1, OPT_FREE, SID_NONE);
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003442 set_string_option_direct((char_u *)"isk", -1,
3443 ISK_LATIN1, OPT_FREE, SID_NONE);
3444 opt_idx = findoption((char_u *)"isp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003445 if (opt_idx >= 0)
3446 options[opt_idx].def_val[VIM_DEFAULT] = ISP_LATIN1;
Bram Moolenaar362e1a32006-03-06 23:29:24 +00003447 opt_idx = findoption((char_u *)"isk");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003448 if (opt_idx >= 0)
3449 options[opt_idx].def_val[VIM_DEFAULT] = ISK_LATIN1;
Bram Moolenaarc0197e22004-09-13 20:26:32 +00003450 (void)init_chartab();
3451 }
3452#endif
3453
Bram Moolenaar071d4272004-06-13 20:20:40 +00003454# if defined(WIN3264) && !defined(FEAT_GUI)
3455 /* Win32 console: When GetACP() returns a different value from
3456 * GetConsoleCP() set 'termencoding'. */
3457 if (GetACP() != GetConsoleCP())
3458 {
3459 char buf[50];
3460
3461 sprintf(buf, "cp%ld", (long)GetConsoleCP());
3462 p_tenc = vim_strsave((char_u *)buf);
3463 if (p_tenc != NULL)
3464 {
3465 opt_idx = findoption((char_u *)"termencoding");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003466 if (opt_idx >= 0)
3467 {
3468 options[opt_idx].def_val[VI_DEFAULT] = p_tenc;
3469 options[opt_idx].flags |= P_DEF_ALLOCED;
3470 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003471 convert_setup(&input_conv, p_tenc, p_enc);
3472 convert_setup(&output_conv, p_enc, p_tenc);
3473 }
3474 else
3475 p_tenc = empty_option;
3476 }
3477# endif
Bram Moolenaar05159a02005-02-26 23:04:13 +00003478# if defined(WIN3264) && defined(FEAT_MBYTE)
3479 /* $HOME may have characters in active code page. */
3480 init_homedir();
3481# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003482 }
3483 else
3484 {
3485 vim_free(p_enc);
3486 p_enc = save_enc;
3487 }
3488 }
3489#endif
3490
3491#ifdef FEAT_MULTI_LANG
3492 /* Set the default for 'helplang'. */
3493 set_helplang_default(get_mess_lang());
3494#endif
3495}
3496
3497/*
3498 * Set an option to its default value.
3499 * This does not take care of side effects!
3500 */
3501 static void
3502set_option_default(opt_idx, opt_flags, compatible)
3503 int opt_idx;
3504 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3505 int compatible; /* use Vi default value */
3506{
3507 char_u *varp; /* pointer to variable for current option */
3508 int dvi; /* index in def_val[] */
3509 long_u flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003510 long_u *flagsp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003511 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
3512
3513 varp = get_varp_scope(&(options[opt_idx]), both ? OPT_LOCAL : opt_flags);
3514 flags = options[opt_idx].flags;
Bram Moolenaar3638c682005-06-08 22:05:14 +00003515 if (varp != NULL) /* skip hidden option, nothing to do for it */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003516 {
3517 dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
3518 if (flags & P_STRING)
3519 {
3520 /* Use set_string_option_direct() for local options to handle
3521 * freeing and allocating the value. */
3522 if (options[opt_idx].indir != PV_NONE)
3523 set_string_option_direct(NULL, opt_idx,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003524 options[opt_idx].def_val[dvi], opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003525 else
3526 {
3527 if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
3528 free_string_option(*(char_u **)(varp));
3529 *(char_u **)varp = options[opt_idx].def_val[dvi];
3530 options[opt_idx].flags &= ~P_ALLOCED;
3531 }
3532 }
3533 else if (flags & P_NUM)
3534 {
Bram Moolenaar5fc1a8b2006-10-17 16:34:24 +00003535 if (options[opt_idx].indir == PV_SCROLL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003536 win_comp_scroll(curwin);
3537 else
3538 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003539 *(long *)varp = (long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar071d4272004-06-13 20:20:40 +00003540 /* May also set global value for local option. */
3541 if (both)
3542 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3543 *(long *)varp;
3544 }
3545 }
3546 else /* P_BOOL */
3547 {
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003548 /* the cast to long is required for Manx C, long_i is needed for
3549 * MSVC */
3550 *(int *)varp = (int)(long)(long_i)options[opt_idx].def_val[dvi];
Bram Moolenaar8243a792007-05-01 17:05:03 +00003551#ifdef UNIX
3552 /* 'modeline' defaults to off for root */
3553 if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID)
3554 *(int *)varp = FALSE;
3555#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003556 /* May also set global value for local option. */
3557 if (both)
3558 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) =
3559 *(int *)varp;
3560 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00003561
Bram Moolenaard1f56e62006-02-22 21:25:37 +00003562 /* The default value is not insecure. */
3563 flagsp = insecure_flag(opt_idx, opt_flags);
3564 *flagsp = *flagsp & ~P_INSECURE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003565 }
3566
3567#ifdef FEAT_EVAL
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003568 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003569#endif
3570}
3571
3572/*
3573 * Set all options (except terminal options) to their default value.
3574 */
3575 static void
3576set_options_default(opt_flags)
3577 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
3578{
3579 int i;
3580#ifdef FEAT_WINDOWS
3581 win_T *wp;
Bram Moolenaarf740b292006-02-16 22:11:02 +00003582 tabpage_T *tp;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003583#endif
3584
3585 for (i = 0; !istermoption(&options[i]); i++)
3586 if (!(options[i].flags & P_NODEFAULT))
3587 set_option_default(i, opt_flags, p_cp);
3588
3589#ifdef FEAT_WINDOWS
3590 /* The 'scroll' option must be computed for all windows. */
Bram Moolenaarf740b292006-02-16 22:11:02 +00003591 FOR_ALL_TAB_WINDOWS(tp, wp)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003592 win_comp_scroll(wp);
3593#else
3594 win_comp_scroll(curwin);
3595#endif
3596}
3597
3598/*
3599 * Set the Vi-default value of a string option.
3600 * Used for 'sh', 'backupskip' and 'term'.
3601 */
3602 void
3603set_string_default(name, val)
3604 char *name;
3605 char_u *val;
3606{
3607 char_u *p;
3608 int opt_idx;
3609
3610 p = vim_strsave(val);
3611 if (p != NULL) /* we don't want a NULL */
3612 {
3613 opt_idx = findoption((char_u *)name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003614 if (opt_idx >= 0)
3615 {
3616 if (options[opt_idx].flags & P_DEF_ALLOCED)
3617 vim_free(options[opt_idx].def_val[VI_DEFAULT]);
3618 options[opt_idx].def_val[VI_DEFAULT] = p;
3619 options[opt_idx].flags |= P_DEF_ALLOCED;
3620 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003621 }
3622}
3623
3624/*
3625 * Set the Vi-default value of a number option.
3626 * Used for 'lines' and 'columns'.
3627 */
3628 void
3629set_number_default(name, val)
3630 char *name;
3631 long val;
3632{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003633 int opt_idx;
3634
3635 opt_idx = findoption((char_u *)name);
3636 if (opt_idx >= 0)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00003637 options[opt_idx].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003638}
3639
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00003640#if defined(EXITFREE) || defined(PROTO)
3641/*
3642 * Free all options.
3643 */
3644 void
3645free_all_options()
3646{
3647 int i;
3648
3649 for (i = 0; !istermoption(&options[i]); i++)
3650 {
3651 if (options[i].indir == PV_NONE)
3652 {
3653 /* global option: free value and default value. */
3654 if (options[i].flags & P_ALLOCED && options[i].var != NULL)
3655 free_string_option(*(char_u **)options[i].var);
3656 if (options[i].flags & P_DEF_ALLOCED)
3657 free_string_option(options[i].def_val[VI_DEFAULT]);
3658 }
3659 else if (options[i].var != VAR_WIN
3660 && (options[i].flags & P_STRING))
3661 /* buffer-local option: free global value */
3662 free_string_option(*(char_u **)options[i].var);
3663 }
3664}
3665#endif
3666
3667
Bram Moolenaar071d4272004-06-13 20:20:40 +00003668/*
3669 * Initialize the options, part two: After getting Rows and Columns and
3670 * setting 'term'.
3671 */
3672 void
3673set_init_2()
3674{
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003675 int idx;
3676
Bram Moolenaar071d4272004-06-13 20:20:40 +00003677 /*
3678 * 'scroll' defaults to half the window height. Note that this default is
3679 * wrong when the window height changes.
3680 */
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003681 set_number_default("scroll", (long)((long_u)Rows >> 1));
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003682 idx = findoption((char_u *)"scroll");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003683 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar26a60b42005-02-22 08:49:11 +00003684 set_option_default(idx, OPT_LOCAL, p_cp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003685 comp_col();
3686
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003687 /*
3688 * 'window' is only for backwards compatibility with Vi.
3689 * Default is Rows - 1.
3690 */
Bram Moolenaard68071d2006-05-02 22:08:30 +00003691 if (!option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00003692 p_window = Rows - 1;
3693 set_number_default("window", Rows - 1);
3694
Bram Moolenaarf740b292006-02-16 22:11:02 +00003695 /* For DOS console the default is always black. */
Bram Moolenaar071d4272004-06-13 20:20:40 +00003696#if !((defined(MSDOS) || defined(OS2) || defined(WIN3264)) && !defined(FEAT_GUI))
Bram Moolenaarf740b292006-02-16 22:11:02 +00003697 /*
3698 * If 'background' wasn't set by the user, try guessing the value,
3699 * depending on the terminal name. Only need to check for terminals
3700 * with a dark background, that can handle color.
3701 */
3702 idx = findoption((char_u *)"bg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003703 if (idx >= 0 && !(options[idx].flags & P_WAS_SET)
3704 && *term_bg_default() == 'd')
Bram Moolenaar071d4272004-06-13 20:20:40 +00003705 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00003706 set_string_option_direct(NULL, idx, (char_u *)"dark", OPT_FREE, 0);
Bram Moolenaarf740b292006-02-16 22:11:02 +00003707 /* don't mark it as set, when starting the GUI it may be
3708 * changed again */
3709 options[idx].flags &= ~P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +00003710 }
3711#endif
Bram Moolenaar58d98232005-07-23 22:25:46 +00003712
3713#ifdef CURSOR_SHAPE
3714 parse_shape_opt(SHAPE_CURSOR); /* set cursor shapes from 'guicursor' */
3715#endif
3716#ifdef FEAT_MOUSESHAPE
3717 parse_shape_opt(SHAPE_MOUSE); /* set mouse shapes from 'mouseshape' */
3718#endif
3719#ifdef FEAT_PRINTER
3720 (void)parse_printoptions(); /* parse 'printoptions' default value */
3721#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003722}
3723
3724/*
Bram Moolenaarf740b292006-02-16 22:11:02 +00003725 * Return "dark" or "light" depending on the kind of terminal.
3726 * This is just guessing! Recognized are:
3727 * "linux" Linux console
3728 * "screen.linux" Linux console with screen
3729 * "cygwin" Cygwin shell
3730 * "putty" Putty program
3731 * We also check the COLORFGBG environment variable, which is set by
3732 * rxvt and derivatives. This variable contains either two or three
3733 * values separated by semicolons; we want the last value in either
3734 * case. If this value is 0-6 or 8, our background is dark.
3735 */
3736 static char_u *
3737term_bg_default()
3738{
Bram Moolenaarf740b292006-02-16 22:11:02 +00003739#if defined(MSDOS) || defined(OS2) || defined(WIN3264)
3740 /* DOS console nearly always black */
3741 return (char_u *)"dark";
3742#else
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00003743 char_u *p;
3744
Bram Moolenaarf740b292006-02-16 22:11:02 +00003745 if (STRCMP(T_NAME, "linux") == 0
3746 || STRCMP(T_NAME, "screen.linux") == 0
3747 || STRCMP(T_NAME, "cygwin") == 0
3748 || STRCMP(T_NAME, "putty") == 0
3749 || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
3750 && (p = vim_strrchr(p, ';')) != NULL
3751 && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')
3752 && p[2] == NUL))
3753 return (char_u *)"dark";
3754 return (char_u *)"light";
3755#endif
3756}
3757
3758/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00003759 * Initialize the options, part three: After reading the .vimrc
3760 */
3761 void
3762set_init_3()
3763{
3764#if defined(UNIX) || defined(OS2) || defined(WIN3264)
3765/*
3766 * Set 'shellpipe' and 'shellredir', depending on the 'shell' option.
3767 * This is done after other initializations, where 'shell' might have been
3768 * set, but only if they have not been set before.
3769 */
3770 char_u *p;
3771 int idx_srr;
3772 int do_srr;
3773#ifdef FEAT_QUICKFIX
3774 int idx_sp;
3775 int do_sp;
3776#endif
3777
3778 idx_srr = findoption((char_u *)"srr");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003779 if (idx_srr < 0)
3780 do_srr = FALSE;
3781 else
3782 do_srr = !(options[idx_srr].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003783#ifdef FEAT_QUICKFIX
3784 idx_sp = findoption((char_u *)"sp");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003785 if (idx_sp < 0)
3786 do_sp = FALSE;
3787 else
3788 do_sp = !(options[idx_sp].flags & P_WAS_SET);
Bram Moolenaar071d4272004-06-13 20:20:40 +00003789#endif
3790
3791 /*
3792 * Isolate the name of the shell:
3793 * - Skip beyond any path. E.g., "/usr/bin/csh -f" -> "csh -f".
3794 * - Remove any argument. E.g., "csh -f" -> "csh".
Bram Moolenaarae61bcf2010-05-13 13:12:06 +02003795 * But don't allow a space in the path, so that this works:
3796 * "/usr/bin/csh --rcfile ~/.cshrc"
3797 * But don't do that for Windows, it's common to have a space in the path.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003798 */
Bram Moolenaarae61bcf2010-05-13 13:12:06 +02003799#ifdef WIN3264
Bram Moolenaar071d4272004-06-13 20:20:40 +00003800 p = gettail(p_sh);
3801 p = vim_strnsave(p, (int)(skiptowhite(p) - p));
Bram Moolenaarae61bcf2010-05-13 13:12:06 +02003802#else
3803 p = skiptowhite(p_sh);
3804 if (*p == NUL)
3805 {
3806 /* No white space, use the tail. */
3807 p = vim_strsave(gettail(p_sh));
3808 }
3809 else
3810 {
3811 char_u *p1, *p2;
3812
3813 /* Find the last path separator before the space. */
3814 p1 = p_sh;
3815 for (p2 = p_sh; p2 < p; mb_ptr_adv(p2))
3816 if (vim_ispathsep(*p2))
3817 p1 = p2 + 1;
3818 p = vim_strnsave(p1, (int)(p - p1));
3819 }
3820#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00003821 if (p != NULL)
3822 {
3823 /*
3824 * Default for p_sp is "| tee", for p_srr is ">".
3825 * For known shells it is changed here to include stderr.
3826 */
3827 if ( fnamecmp(p, "csh") == 0
3828 || fnamecmp(p, "tcsh") == 0
3829# if defined(OS2) || defined(WIN3264) /* also check with .exe extension */
3830 || fnamecmp(p, "csh.exe") == 0
3831 || fnamecmp(p, "tcsh.exe") == 0
3832# endif
3833 )
3834 {
3835#if defined(FEAT_QUICKFIX)
3836 if (do_sp)
3837 {
3838# ifdef WIN3264
3839 p_sp = (char_u *)">&";
3840# else
3841 p_sp = (char_u *)"|& tee";
3842# endif
3843 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3844 }
3845#endif
3846 if (do_srr)
3847 {
3848 p_srr = (char_u *)">&";
3849 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3850 }
3851 }
3852 else
3853# ifndef OS2 /* Always use bourne shell style redirection if we reach this */
3854 if ( fnamecmp(p, "sh") == 0
3855 || fnamecmp(p, "ksh") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003856 || fnamecmp(p, "mksh") == 0
3857 || fnamecmp(p, "pdksh") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003858 || fnamecmp(p, "zsh") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003859 || fnamecmp(p, "zsh-beta") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003860 || fnamecmp(p, "bash") == 0
3861# ifdef WIN3264
3862 || fnamecmp(p, "cmd") == 0
3863 || fnamecmp(p, "sh.exe") == 0
3864 || fnamecmp(p, "ksh.exe") == 0
Bram Moolenaarf1fda2d2011-04-28 12:57:36 +02003865 || fnamecmp(p, "mksh.exe") == 0
3866 || fnamecmp(p, "pdksh.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003867 || fnamecmp(p, "zsh.exe") == 0
Bram Moolenaarc1e37902006-04-18 21:55:01 +00003868 || fnamecmp(p, "zsh-beta.exe") == 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00003869 || fnamecmp(p, "bash.exe") == 0
3870 || fnamecmp(p, "cmd.exe") == 0
3871# endif
3872 )
3873# endif
3874 {
3875#if defined(FEAT_QUICKFIX)
3876 if (do_sp)
3877 {
3878# ifdef WIN3264
3879 p_sp = (char_u *)">%s 2>&1";
3880# else
3881 p_sp = (char_u *)"2>&1| tee";
3882# endif
3883 options[idx_sp].def_val[VI_DEFAULT] = p_sp;
3884 }
3885#endif
3886 if (do_srr)
3887 {
3888 p_srr = (char_u *)">%s 2>&1";
3889 options[idx_srr].def_val[VI_DEFAULT] = p_srr;
3890 }
3891 }
3892 vim_free(p);
3893 }
3894#endif
3895
3896#if defined(MSDOS) || defined(WIN3264) || defined(OS2)
3897 /*
Bram Moolenaara64ba222012-02-12 23:23:31 +01003898 * Set 'shellcmdflag', 'shellxquote', and 'shellquote' depending on the
3899 * 'shell' option.
Bram Moolenaar071d4272004-06-13 20:20:40 +00003900 * This is done after other initializations, where 'shell' might have been
3901 * set, but only if they have not been set before. Default for p_shcf is
3902 * "/c", for p_shq is "". For "sh" like shells it is changed here to
3903 * "-c" and "\"", but not for DJGPP, because it starts the shell without
3904 * command.com. And for Win32 we need to set p_sxq instead.
3905 */
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00003906 if (strstr((char *)gettail(p_sh), "sh") != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00003907 {
3908 int idx3;
3909
3910 idx3 = findoption((char_u *)"shcf");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003911 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003912 {
3913 p_shcf = (char_u *)"-c";
3914 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3915 }
3916
3917# ifndef DJGPP
3918# ifdef WIN3264
3919 /* Somehow Win32 requires the quotes around the redirection too */
3920 idx3 = findoption((char_u *)"sxq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003921 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003922 {
3923 p_sxq = (char_u *)"\"";
3924 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3925 }
3926# else
3927 idx3 = findoption((char_u *)"shq");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003928 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003929 {
3930 p_shq = (char_u *)"\"";
3931 options[idx3].def_val[VI_DEFAULT] = p_shq;
3932 }
3933# endif
3934# endif
3935 }
Bram Moolenaara64ba222012-02-12 23:23:31 +01003936 else if (strstr((char *)gettail(p_sh), "cmd.exe") != NULL)
3937 {
3938 int idx3;
3939
3940 /*
3941 * cmd.exe on Windows will strip the first and last double quote given
3942 * on the command line, e.g. most of the time things like:
3943 * cmd /c "my path/to/echo" "my args to echo"
3944 * become:
3945 * my path/to/echo" "my args to echo
3946 * when executed.
3947 *
Bram Moolenaar034b1152012-02-19 18:19:30 +01003948 * To avoid this, set shellxquote to surround the command in
3949 * parenthesis. This appears to make most commands work, without
3950 * breaking commands that worked previously, such as
3951 * '"path with spaces/cmd" "a&b"'.
Bram Moolenaara64ba222012-02-12 23:23:31 +01003952 */
Bram Moolenaara64ba222012-02-12 23:23:31 +01003953 idx3 = findoption((char_u *)"sxq");
3954 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
3955 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01003956 p_sxq = (char_u *)"(";
Bram Moolenaara64ba222012-02-12 23:23:31 +01003957 options[idx3].def_val[VI_DEFAULT] = p_sxq;
3958 }
3959
Bram Moolenaara64ba222012-02-12 23:23:31 +01003960 idx3 = findoption((char_u *)"shcf");
3961 if (idx3 >= 0 && !(options[idx3].flags & P_WAS_SET))
3962 {
Bram Moolenaar034b1152012-02-19 18:19:30 +01003963 p_shcf = (char_u *)"/c";
Bram Moolenaara64ba222012-02-12 23:23:31 +01003964 options[idx3].def_val[VI_DEFAULT] = p_shcf;
3965 }
3966 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00003967#endif
3968
3969#ifdef FEAT_TITLE
3970 set_title_defaults();
3971#endif
3972}
3973
3974#if defined(FEAT_MULTI_LANG) || defined(PROTO)
3975/*
3976 * When 'helplang' is still at its default value, set it to "lang".
3977 * Only the first two characters of "lang" are used.
3978 */
3979 void
3980set_helplang_default(lang)
3981 char_u *lang;
3982{
3983 int idx;
3984
3985 if (lang == NULL || STRLEN(lang) < 2) /* safety check */
3986 return;
3987 idx = findoption((char_u *)"hlg");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00003988 if (idx >= 0 && !(options[idx].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00003989 {
3990 if (options[idx].flags & P_ALLOCED)
3991 free_string_option(p_hlg);
3992 p_hlg = vim_strsave(lang);
3993 if (p_hlg == NULL)
3994 p_hlg = empty_option;
3995 else
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00003996 {
3997 /* zh_CN becomes "cn", zh_TW becomes "tw". */
3998 if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5)
3999 {
4000 p_hlg[0] = TOLOWER_ASC(p_hlg[3]);
4001 p_hlg[1] = TOLOWER_ASC(p_hlg[4]);
4002 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004003 p_hlg[2] = NUL;
Bram Moolenaarab79bcb2004-07-18 21:34:53 +00004004 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004005 options[idx].flags |= P_ALLOCED;
4006 }
4007}
4008#endif
4009
4010#ifdef FEAT_GUI
4011static char_u *gui_bg_default __ARGS((void));
4012
4013 static char_u *
4014gui_bg_default()
4015{
4016 if (gui_get_lightness(gui.back_pixel) < 127)
4017 return (char_u *)"dark";
4018 return (char_u *)"light";
4019}
4020
4021/*
4022 * Option initializations that can only be done after opening the GUI window.
4023 */
4024 void
4025init_gui_options()
4026{
4027 /* Set the 'background' option according to the lightness of the
4028 * background color, unless the user has set it already. */
4029 if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
4030 {
4031 set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
4032 highlight_changed();
4033 }
4034}
4035#endif
4036
4037#ifdef FEAT_TITLE
4038/*
4039 * 'title' and 'icon' only default to true if they have not been set or reset
4040 * in .vimrc and we can read the old value.
4041 * When 'title' and 'icon' have been reset in .vimrc, we won't even check if
4042 * they can be reset. This reduces startup time when using X on a remote
4043 * machine.
4044 */
4045 void
4046set_title_defaults()
4047{
4048 int idx1;
4049 long val;
4050
4051 /*
4052 * If GUI is (going to be) used, we can always set the window title and
4053 * icon name. Saves a bit of time, because the X11 display server does
4054 * not need to be contacted.
4055 */
4056 idx1 = findoption((char_u *)"title");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004057 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004058 {
4059#ifdef FEAT_GUI
4060 if (gui.starting || gui.in_use)
4061 val = TRUE;
4062 else
4063#endif
4064 val = mch_can_restore_title();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004065 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004066 p_title = val;
4067 }
4068 idx1 = findoption((char_u *)"icon");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00004069 if (idx1 >= 0 && !(options[idx1].flags & P_WAS_SET))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004070 {
4071#ifdef FEAT_GUI
4072 if (gui.starting || gui.in_use)
4073 val = TRUE;
4074 else
4075#endif
4076 val = mch_can_restore_icon();
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004077 options[idx1].def_val[VI_DEFAULT] = (char_u *)(long_i)val;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004078 p_icon = val;
4079 }
4080}
4081#endif
4082
4083/*
4084 * Parse 'arg' for option settings.
4085 *
4086 * 'arg' may be IObuff, but only when no errors can be present and option
4087 * does not need to be expanded with option_expand().
4088 * "opt_flags":
4089 * 0 for ":set"
Bram Moolenaara3227e22006-03-08 21:32:40 +00004090 * OPT_GLOBAL for ":setglobal"
4091 * OPT_LOCAL for ":setlocal" and a modeline
Bram Moolenaar071d4272004-06-13 20:20:40 +00004092 * OPT_MODELINE for a modeline
Bram Moolenaara3227e22006-03-08 21:32:40 +00004093 * OPT_WINONLY to only set window-local options
4094 * OPT_NOWIN to skip setting window-local options
Bram Moolenaar071d4272004-06-13 20:20:40 +00004095 *
4096 * returns FAIL if an error is detected, OK otherwise
4097 */
4098 int
4099do_set(arg, opt_flags)
4100 char_u *arg; /* option string (may be written to!) */
4101 int opt_flags;
4102{
4103 int opt_idx;
4104 char_u *errmsg;
4105 char_u errbuf[80];
4106 char_u *startarg;
4107 int prefix; /* 1: nothing, 0: "no", 2: "inv" in front of name */
4108 int nextchar; /* next non-white char after option name */
4109 int afterchar; /* character just after option name */
4110 int len;
4111 int i;
4112 long value;
4113 int key;
4114 long_u flags; /* flags for current option */
4115 char_u *varp = NULL; /* pointer to variable for current option */
4116 int did_show = FALSE; /* already showed one value */
4117 int adding; /* "opt+=arg" */
4118 int prepending; /* "opt^=arg" */
4119 int removing; /* "opt-=arg" */
4120 int cp_val = 0;
4121 char_u key_name[2];
4122
4123 if (*arg == NUL)
4124 {
4125 showoptions(0, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004126 did_show = TRUE;
4127 goto theend;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004128 }
4129
4130 while (*arg != NUL) /* loop to process all options */
4131 {
4132 errmsg = NULL;
4133 startarg = arg; /* remember for error message */
4134
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004135 if (STRNCMP(arg, "all", 3) == 0 && !isalpha(arg[3])
4136 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004137 {
4138 /*
4139 * ":set all" show all options.
4140 * ":set all&" set all options to their default value.
4141 */
4142 arg += 3;
4143 if (*arg == '&')
4144 {
4145 ++arg;
4146 /* Only for :set command set global value of local options. */
4147 set_options_default(OPT_FREE | opt_flags);
4148 }
4149 else
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004150 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00004151 showoptions(1, opt_flags);
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004152 did_show = TRUE;
4153 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004154 }
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00004155 else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004156 {
4157 showoptions(2, opt_flags);
4158 show_termcodes();
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004159 did_show = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004160 arg += 7;
4161 }
4162 else
4163 {
4164 prefix = 1;
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +00004165 if (STRNCMP(arg, "no", 2) == 0 && STRNCMP(arg, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004166 {
4167 prefix = 0;
4168 arg += 2;
4169 }
4170 else if (STRNCMP(arg, "inv", 3) == 0)
4171 {
4172 prefix = 2;
4173 arg += 3;
4174 }
4175
4176 /* find end of name */
4177 key = 0;
4178 if (*arg == '<')
4179 {
4180 nextchar = 0;
4181 opt_idx = -1;
4182 /* look out for <t_>;> */
4183 if (arg[1] == 't' && arg[2] == '_' && arg[3] && arg[4])
4184 len = 5;
4185 else
4186 {
4187 len = 1;
4188 while (arg[len] != NUL && arg[len] != '>')
4189 ++len;
4190 }
4191 if (arg[len] != '>')
4192 {
4193 errmsg = e_invarg;
4194 goto skip;
4195 }
4196 arg[len] = NUL; /* put NUL after name */
4197 if (arg[1] == 't' && arg[2] == '_') /* could be term code */
4198 opt_idx = findoption(arg + 1);
4199 arg[len++] = '>'; /* restore '>' */
4200 if (opt_idx == -1)
4201 key = find_key_option(arg + 1);
4202 }
4203 else
4204 {
4205 len = 0;
4206 /*
4207 * The two characters after "t_" may not be alphanumeric.
4208 */
4209 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
4210 len = 4;
4211 else
4212 while (ASCII_ISALNUM(arg[len]) || arg[len] == '_')
4213 ++len;
4214 nextchar = arg[len];
4215 arg[len] = NUL; /* put NUL after name */
4216 opt_idx = findoption(arg);
4217 arg[len] = nextchar; /* restore nextchar */
4218 if (opt_idx == -1)
4219 key = find_key_option(arg);
4220 }
4221
4222 /* remember character after option name */
4223 afterchar = arg[len];
4224
4225 /* skip white space, allow ":set ai ?" */
4226 while (vim_iswhite(arg[len]))
4227 ++len;
4228
4229 adding = FALSE;
4230 prepending = FALSE;
4231 removing = FALSE;
4232 if (arg[len] != NUL && arg[len + 1] == '=')
4233 {
4234 if (arg[len] == '+')
4235 {
4236 adding = TRUE; /* "+=" */
4237 ++len;
4238 }
4239 else if (arg[len] == '^')
4240 {
4241 prepending = TRUE; /* "^=" */
4242 ++len;
4243 }
4244 else if (arg[len] == '-')
4245 {
4246 removing = TRUE; /* "-=" */
4247 ++len;
4248 }
4249 }
4250 nextchar = arg[len];
4251
4252 if (opt_idx == -1 && key == 0) /* found a mismatch: skip */
4253 {
4254 errmsg = (char_u *)N_("E518: Unknown option");
4255 goto skip;
4256 }
4257
4258 if (opt_idx >= 0)
4259 {
4260 if (options[opt_idx].var == NULL) /* hidden option: skip */
4261 {
4262 /* Only give an error message when requesting the value of
4263 * a hidden option, ignore setting it. */
4264 if (vim_strchr((char_u *)"=:!&<", nextchar) == NULL
4265 && (!(options[opt_idx].flags & P_BOOL)
4266 || nextchar == '?'))
4267 errmsg = (char_u *)N_("E519: Option not supported");
4268 goto skip;
4269 }
4270
4271 flags = options[opt_idx].flags;
4272 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
4273 }
4274 else
4275 {
4276 flags = P_STRING;
4277 if (key < 0)
4278 {
4279 key_name[0] = KEY2TERMCAP0(key);
4280 key_name[1] = KEY2TERMCAP1(key);
4281 }
4282 else
4283 {
4284 key_name[0] = KS_KEY;
4285 key_name[1] = (key & 0xff);
4286 }
4287 }
4288
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004289 /* Skip all options that are not window-local (used when showing
4290 * an already loaded buffer in a window). */
4291 if ((opt_flags & OPT_WINONLY)
4292 && (opt_idx < 0 || options[opt_idx].var != VAR_WIN))
4293 goto skip;
4294
Bram Moolenaara3227e22006-03-08 21:32:40 +00004295 /* Skip all options that are window-local (used for :vimgrep). */
4296 if ((opt_flags & OPT_NOWIN) && opt_idx >= 0
4297 && options[opt_idx].var == VAR_WIN)
4298 goto skip;
4299
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004300 /* Disallow changing some options from modelines. */
4301 if (opt_flags & OPT_MODELINE)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004302 {
Bram Moolenaar865242e2010-07-14 21:12:05 +02004303 if (flags & (P_SECURE | P_NO_ML))
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004304 {
4305 errmsg = (char_u *)_("E520: Not allowed in a modeline");
4306 goto skip;
4307 }
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004308#ifdef FEAT_DIFF
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004309 /* In diff mode some options are overruled. This avoids that
4310 * 'foldmethod' becomes "marker" instead of "diff" and that
4311 * "wrap" gets set. */
4312 if (curwin->w_p_diff
Bram Moolenaara9d52e32010-07-31 16:44:19 +02004313 && opt_idx >= 0 /* shut up coverity warning */
Bram Moolenaar1bf0ddc2009-02-11 15:47:05 +00004314 && (options[opt_idx].indir == PV_FDM
4315 || options[opt_idx].indir == PV_WRAP))
4316 goto skip;
Bram Moolenaarf69d9a32009-02-11 21:48:40 +00004317#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00004318 }
4319
4320#ifdef HAVE_SANDBOX
4321 /* Disallow changing some options in the sandbox */
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004322 if (sandbox != 0 && (flags & P_SECURE))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004323 {
4324 errmsg = (char_u *)_(e_sandbox);
4325 goto skip;
4326 }
4327#endif
4328
4329 if (vim_strchr((char_u *)"?=:!&<", nextchar) != NULL)
4330 {
4331 arg += len;
4332 cp_val = p_cp;
4333 if (nextchar == '&' && arg[1] == 'v' && arg[2] == 'i')
4334 {
4335 if (arg[3] == 'm') /* "opt&vim": set to Vim default */
4336 {
4337 cp_val = FALSE;
4338 arg += 3;
4339 }
4340 else /* "opt&vi": set to Vi default */
4341 {
4342 cp_val = TRUE;
4343 arg += 2;
4344 }
4345 }
4346 if (vim_strchr((char_u *)"?!&<", nextchar) != NULL
4347 && arg[1] != NUL && !vim_iswhite(arg[1]))
4348 {
4349 errmsg = e_trailing;
4350 goto skip;
4351 }
4352 }
4353
4354 /*
4355 * allow '=' and ':' as MSDOS command.com allows only one
4356 * '=' character per "set" command line. grrr. (jw)
4357 */
4358 if (nextchar == '?'
4359 || (prefix == 1
4360 && vim_strchr((char_u *)"=:&<", nextchar) == NULL
4361 && !(flags & P_BOOL)))
4362 {
4363 /*
4364 * print value
4365 */
4366 if (did_show)
4367 msg_putchar('\n'); /* cursor below last one */
4368 else
4369 {
4370 gotocmdline(TRUE); /* cursor at status line */
4371 did_show = TRUE; /* remember that we did a line */
4372 }
4373 if (opt_idx >= 0)
4374 {
4375 showoneopt(&options[opt_idx], opt_flags);
4376#ifdef FEAT_EVAL
4377 if (p_verbose > 0)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00004378 {
4379 /* Mention where the option was last set. */
4380 if (varp == options[opt_idx].var)
4381 last_set_msg(options[opt_idx].scriptID);
4382 else if ((int)options[opt_idx].indir & PV_WIN)
4383 last_set_msg(curwin->w_p_scriptID[
4384 (int)options[opt_idx].indir & PV_MASK]);
4385 else if ((int)options[opt_idx].indir & PV_BUF)
4386 last_set_msg(curbuf->b_p_scriptID[
4387 (int)options[opt_idx].indir & PV_MASK]);
4388 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00004389#endif
4390 }
4391 else
4392 {
4393 char_u *p;
4394
4395 p = find_termcode(key_name);
4396 if (p == NULL)
4397 {
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004398 errmsg = (char_u *)N_("E846: Key code not set");
Bram Moolenaar071d4272004-06-13 20:20:40 +00004399 goto skip;
4400 }
4401 else
4402 (void)show_one_termcode(key_name, p, TRUE);
4403 }
4404 if (nextchar != '?'
4405 && nextchar != NUL && !vim_iswhite(afterchar))
4406 errmsg = e_trailing;
4407 }
4408 else
4409 {
4410 if (flags & P_BOOL) /* boolean */
4411 {
4412 if (nextchar == '=' || nextchar == ':')
4413 {
4414 errmsg = e_invarg;
4415 goto skip;
4416 }
4417
4418 /*
4419 * ":set opt!": invert
4420 * ":set opt&": reset to default value
4421 * ":set opt<": reset to global value
4422 */
4423 if (nextchar == '!')
4424 value = *(int *)(varp) ^ 1;
4425 else if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004426 value = (int)(long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004427 ((flags & P_VI_DEF) || cp_val)
4428 ? VI_DEFAULT : VIM_DEFAULT];
4429 else if (nextchar == '<')
4430 {
4431 /* For 'autoread' -1 means to use global value. */
4432 if ((int *)varp == &curbuf->b_p_ar
4433 && opt_flags == OPT_LOCAL)
4434 value = -1;
4435 else
4436 value = *(int *)get_varp_scope(&(options[opt_idx]),
4437 OPT_GLOBAL);
4438 }
4439 else
4440 {
4441 /*
4442 * ":set invopt": invert
4443 * ":set opt" or ":set noopt": set or reset
4444 */
4445 if (nextchar != NUL && !vim_iswhite(afterchar))
4446 {
4447 errmsg = e_trailing;
4448 goto skip;
4449 }
4450 if (prefix == 2) /* inv */
4451 value = *(int *)(varp) ^ 1;
4452 else
4453 value = prefix;
4454 }
4455
4456 errmsg = set_bool_option(opt_idx, varp, (int)value,
4457 opt_flags);
4458 }
4459 else /* numeric or string */
4460 {
4461 if (vim_strchr((char_u *)"=:&<", nextchar) == NULL
4462 || prefix != 1)
4463 {
4464 errmsg = e_invarg;
4465 goto skip;
4466 }
4467
4468 if (flags & P_NUM) /* numeric */
4469 {
4470 /*
4471 * Different ways to set a number option:
4472 * & set to default value
4473 * < set to global value
4474 * <xx> accept special key codes for 'wildchar'
4475 * c accept any non-digit for 'wildchar'
4476 * [-]0-9 set number
4477 * other error
4478 */
4479 ++arg;
4480 if (nextchar == '&')
Bram Moolenaareb3593b2006-04-22 22:33:57 +00004481 value = (long)(long_i)options[opt_idx].def_val[
Bram Moolenaar071d4272004-06-13 20:20:40 +00004482 ((flags & P_VI_DEF) || cp_val)
4483 ? VI_DEFAULT : VIM_DEFAULT];
4484 else if (nextchar == '<')
4485 value = *(long *)get_varp_scope(&(options[opt_idx]),
4486 OPT_GLOBAL);
4487 else if (((long *)varp == &p_wc
4488 || (long *)varp == &p_wcm)
4489 && (*arg == '<'
4490 || *arg == '^'
4491 || ((!arg[1] || vim_iswhite(arg[1]))
4492 && !VIM_ISDIGIT(*arg))))
4493 {
4494 value = string_to_key(arg);
4495 if (value == 0 && (long *)varp != &p_wcm)
4496 {
4497 errmsg = e_invarg;
4498 goto skip;
4499 }
4500 }
4501 /* allow negative numbers (for 'undolevels') */
4502 else if (*arg == '-' || VIM_ISDIGIT(*arg))
4503 {
4504 i = 0;
4505 if (*arg == '-')
4506 i = 1;
4507#ifdef HAVE_STRTOL
4508 value = strtol((char *)arg, NULL, 0);
4509 if (arg[i] == '0' && TOLOWER_ASC(arg[i + 1]) == 'x')
4510 i += 2;
4511#else
4512 value = atol((char *)arg);
4513#endif
4514 while (VIM_ISDIGIT(arg[i]))
4515 ++i;
4516 if (arg[i] != NUL && !vim_iswhite(arg[i]))
4517 {
4518 errmsg = e_invarg;
4519 goto skip;
4520 }
4521 }
4522 else
4523 {
4524 errmsg = (char_u *)N_("E521: Number required after =");
4525 goto skip;
4526 }
4527
4528 if (adding)
4529 value = *(long *)varp + value;
4530 if (prepending)
4531 value = *(long *)varp * value;
4532 if (removing)
4533 value = *(long *)varp - value;
4534 errmsg = set_num_option(opt_idx, varp, value,
Bram Moolenaar555b2802005-05-19 21:08:39 +00004535 errbuf, sizeof(errbuf), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004536 }
4537 else if (opt_idx >= 0) /* string */
4538 {
4539 char_u *save_arg = NULL;
4540 char_u *s = NULL;
4541 char_u *oldval; /* previous value if *varp */
4542 char_u *newval;
4543 char_u *origval;
4544 unsigned newlen;
4545 int comma;
4546 int bs;
4547 int new_value_alloced; /* new string option
4548 was allocated */
4549
4550 /* When using ":set opt=val" for a global option
4551 * with a local value the local value will be
4552 * reset, use the global value here. */
4553 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004554 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00004555 varp = options[opt_idx].var;
4556
4557 /* The old value is kept until we are sure that the
4558 * new value is valid. */
4559 oldval = *(char_u **)varp;
4560 if (nextchar == '&') /* set to default val */
4561 {
4562 newval = options[opt_idx].def_val[
4563 ((flags & P_VI_DEF) || cp_val)
4564 ? VI_DEFAULT : VIM_DEFAULT];
4565 if ((char_u **)varp == &p_bg)
4566 {
4567 /* guess the value of 'background' */
4568#ifdef FEAT_GUI
4569 if (gui.in_use)
4570 newval = gui_bg_default();
4571 else
4572#endif
Bram Moolenaarf740b292006-02-16 22:11:02 +00004573 newval = term_bg_default();
Bram Moolenaar071d4272004-06-13 20:20:40 +00004574 }
4575
4576 /* expand environment variables and ~ (since the
4577 * default value was already expanded, only
4578 * required when an environment variable was set
4579 * later */
4580 if (newval == NULL)
4581 newval = empty_option;
4582 else
4583 {
4584 s = option_expand(opt_idx, newval);
4585 if (s == NULL)
4586 s = newval;
4587 newval = vim_strsave(s);
4588 }
4589 new_value_alloced = TRUE;
4590 }
4591 else if (nextchar == '<') /* set to global val */
4592 {
4593 newval = vim_strsave(*(char_u **)get_varp_scope(
4594 &(options[opt_idx]), OPT_GLOBAL));
4595 new_value_alloced = TRUE;
4596 }
4597 else
4598 {
4599 ++arg; /* jump to after the '=' or ':' */
4600
4601 /*
4602 * Set 'keywordprg' to ":help" if an empty
4603 * value was passed to :set by the user.
4604 * Misuse errbuf[] for the resulting string.
4605 */
4606 if (varp == (char_u *)&p_kp
4607 && (*arg == NUL || *arg == ' '))
4608 {
4609 STRCPY(errbuf, ":help");
4610 save_arg = arg;
4611 arg = errbuf;
4612 }
4613 /*
Bram Moolenaar4e5ccfa2011-11-30 11:15:47 +01004614 * Convert 'backspace' number to string, for
4615 * adding, prepending and removing string.
4616 */
4617 else if (varp == (char_u *)&p_bs
4618 && VIM_ISDIGIT(**(char_u **)varp))
4619 {
4620 i = getdigits((char_u **)varp);
4621 switch (i)
4622 {
4623 case 0:
4624 *(char_u **)varp = empty_option;
4625 break;
4626 case 1:
4627 *(char_u **)varp = vim_strsave(
4628 (char_u *)"indent,eol");
4629 break;
4630 case 2:
4631 *(char_u **)varp = vim_strsave(
4632 (char_u *)"indent,eol,start");
4633 break;
4634 }
4635 vim_free(oldval);
4636 oldval = *(char_u **)varp;
4637 }
4638 /*
Bram Moolenaar071d4272004-06-13 20:20:40 +00004639 * Convert 'whichwrap' number to string, for
4640 * backwards compatibility with Vim 3.0.
4641 * Misuse errbuf[] for the resulting string.
4642 */
4643 else if (varp == (char_u *)&p_ww
4644 && VIM_ISDIGIT(*arg))
4645 {
4646 *errbuf = NUL;
4647 i = getdigits(&arg);
4648 if (i & 1)
4649 STRCAT(errbuf, "b,");
4650 if (i & 2)
4651 STRCAT(errbuf, "s,");
4652 if (i & 4)
4653 STRCAT(errbuf, "h,l,");
4654 if (i & 8)
4655 STRCAT(errbuf, "<,>,");
4656 if (i & 16)
4657 STRCAT(errbuf, "[,],");
4658 if (*errbuf != NUL) /* remove trailing , */
4659 errbuf[STRLEN(errbuf) - 1] = NUL;
4660 save_arg = arg;
4661 arg = errbuf;
4662 }
4663 /*
4664 * Remove '>' before 'dir' and 'bdir', for
4665 * backwards compatibility with version 3.0
4666 */
4667 else if ( *arg == '>'
4668 && (varp == (char_u *)&p_dir
4669 || varp == (char_u *)&p_bdir))
4670 {
4671 ++arg;
4672 }
4673
4674 /* When setting the local value of a global
4675 * option, the old value may be the global value. */
Bram Moolenaara23ccb82006-02-27 00:08:02 +00004676 if (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004677 && (opt_flags & OPT_LOCAL))
4678 origval = *(char_u **)get_varp(
4679 &options[opt_idx]);
4680 else
4681 origval = oldval;
4682
4683 /*
4684 * Copy the new string into allocated memory.
4685 * Can't use set_string_option_direct(), because
4686 * we need to remove the backslashes.
4687 */
4688 /* get a bit too much */
4689 newlen = (unsigned)STRLEN(arg) + 1;
4690 if (adding || prepending || removing)
4691 newlen += (unsigned)STRLEN(origval) + 1;
4692 newval = alloc(newlen);
4693 if (newval == NULL) /* out of mem, don't change */
4694 break;
4695 s = newval;
4696
4697 /*
4698 * Copy the string, skip over escaped chars.
4699 * For MS-DOS and WIN32 backslashes before normal
4700 * file name characters are not removed, and keep
4701 * backslash at start, for "\\machine\path", but
4702 * do remove it for "\\\\machine\\path".
4703 * The reverse is found in ExpandOldSetting().
4704 */
4705 while (*arg && !vim_iswhite(*arg))
4706 {
4707 if (*arg == '\\' && arg[1] != NUL
4708#ifdef BACKSLASH_IN_FILENAME
4709 && !((flags & P_EXPAND)
4710 && vim_isfilec(arg[1])
4711 && (arg[1] != '\\'
4712 || (s == newval
4713 && arg[2] != '\\')))
4714#endif
4715 )
4716 ++arg; /* remove backslash */
4717#ifdef FEAT_MBYTE
4718 if (has_mbyte
Bram Moolenaar0fa313a2005-08-10 21:07:57 +00004719 && (i = (*mb_ptr2len)(arg)) > 1)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004720 {
4721 /* copy multibyte char */
4722 mch_memmove(s, arg, (size_t)i);
4723 arg += i;
4724 s += i;
4725 }
4726 else
4727#endif
4728 *s++ = *arg++;
4729 }
4730 *s = NUL;
4731
4732 /*
4733 * Expand environment variables and ~.
4734 * Don't do it when adding without inserting a
4735 * comma.
4736 */
4737 if (!(adding || prepending || removing)
4738 || (flags & P_COMMA))
4739 {
4740 s = option_expand(opt_idx, newval);
4741 if (s != NULL)
4742 {
4743 vim_free(newval);
4744 newlen = (unsigned)STRLEN(s) + 1;
4745 if (adding || prepending || removing)
4746 newlen += (unsigned)STRLEN(origval) + 1;
4747 newval = alloc(newlen);
4748 if (newval == NULL)
4749 break;
4750 STRCPY(newval, s);
4751 }
4752 }
4753
4754 /* locate newval[] in origval[] when removing it
4755 * and when adding to avoid duplicates */
4756 i = 0; /* init for GCC */
4757 if (removing || (flags & P_NODUP))
4758 {
4759 i = (int)STRLEN(newval);
4760 bs = 0;
4761 for (s = origval; *s; ++s)
4762 {
4763 if ((!(flags & P_COMMA)
4764 || s == origval
4765 || (s[-1] == ',' && !(bs & 1)))
4766 && STRNCMP(s, newval, i) == 0
4767 && (!(flags & P_COMMA)
4768 || s[i] == ','
4769 || s[i] == NUL))
4770 break;
Bram Moolenaar0b2f94d2011-03-22 14:35:05 +01004771 /* Count backslashes. Only a comma with an
4772 * even number of backslashes before it is
Bram Moolenaar071d4272004-06-13 20:20:40 +00004773 * recognized as a separator */
4774 if (s > origval && s[-1] == '\\')
4775 ++bs;
4776 else
4777 bs = 0;
4778 }
4779
4780 /* do not add if already there */
4781 if ((adding || prepending) && *s)
4782 {
4783 prepending = FALSE;
4784 adding = FALSE;
4785 STRCPY(newval, origval);
4786 }
4787 }
4788
4789 /* concatenate the two strings; add a ',' if
4790 * needed */
4791 if (adding || prepending)
4792 {
4793 comma = ((flags & P_COMMA) && *origval != NUL
4794 && *newval != NUL);
4795 if (adding)
4796 {
4797 i = (int)STRLEN(origval);
4798 mch_memmove(newval + i + comma, newval,
4799 STRLEN(newval) + 1);
4800 mch_memmove(newval, origval, (size_t)i);
4801 }
4802 else
4803 {
4804 i = (int)STRLEN(newval);
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004805 STRMOVE(newval + i + comma, origval);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004806 }
4807 if (comma)
4808 newval[i] = ',';
4809 }
4810
4811 /* Remove newval[] from origval[]. (Note: "i" has
4812 * been set above and is used here). */
4813 if (removing)
4814 {
4815 STRCPY(newval, origval);
4816 if (*s)
4817 {
4818 /* may need to remove a comma */
4819 if (flags & P_COMMA)
4820 {
4821 if (s == origval)
4822 {
4823 /* include comma after string */
4824 if (s[i] == ',')
4825 ++i;
4826 }
4827 else
4828 {
4829 /* include comma before string */
4830 --s;
4831 ++i;
4832 }
4833 }
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004834 STRMOVE(newval + (s - origval), s + i);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004835 }
4836 }
4837
4838 if (flags & P_FLAGLIST)
4839 {
4840 /* Remove flags that appear twice. */
4841 for (s = newval; *s; ++s)
4842 if ((!(flags & P_COMMA) || *s != ',')
4843 && vim_strchr(s + 1, *s) != NULL)
4844 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00004845 STRMOVE(s, s + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004846 --s;
4847 }
4848 }
4849
4850 if (save_arg != NULL) /* number for 'whichwrap' */
4851 arg = save_arg;
4852 new_value_alloced = TRUE;
4853 }
4854
4855 /* Set the new value. */
4856 *(char_u **)(varp) = newval;
4857
4858 /* Handle side effects, and set the global value for
4859 * ":set" on local options. */
4860 errmsg = did_set_string_option(opt_idx, (char_u **)varp,
4861 new_value_alloced, oldval, errbuf, opt_flags);
4862
4863 /* If error detected, print the error message. */
4864 if (errmsg != NULL)
4865 goto skip;
4866 }
4867 else /* key code option */
4868 {
4869 char_u *p;
4870
4871 if (nextchar == '&')
4872 {
4873 if (add_termcap_entry(key_name, TRUE) == FAIL)
4874 errmsg = (char_u *)N_("E522: Not found in termcap");
4875 }
4876 else
4877 {
4878 ++arg; /* jump to after the '=' or ':' */
4879 for (p = arg; *p && !vim_iswhite(*p); ++p)
4880 if (*p == '\\' && p[1] != NUL)
4881 ++p;
4882 nextchar = *p;
4883 *p = NUL;
4884 add_termcode(key_name, arg, FALSE);
4885 *p = nextchar;
4886 }
4887 if (full_screen)
4888 ttest(FALSE);
4889 redraw_all_later(CLEAR);
4890 }
4891 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004892
Bram Moolenaar071d4272004-06-13 20:20:40 +00004893 if (opt_idx >= 0)
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004894 did_set_option(opt_idx, opt_flags,
4895 !prepending && !adding && !removing);
Bram Moolenaar071d4272004-06-13 20:20:40 +00004896 }
4897
4898skip:
4899 /*
4900 * Advance to next argument.
4901 * - skip until a blank found, taking care of backslashes
4902 * - skip blanks
4903 * - skip one "=val" argument (for hidden options ":set gfn =xx")
4904 */
4905 for (i = 0; i < 2 ; ++i)
4906 {
4907 while (*arg != NUL && !vim_iswhite(*arg))
4908 if (*arg++ == '\\' && *arg != NUL)
4909 ++arg;
4910 arg = skipwhite(arg);
4911 if (*arg != '=')
4912 break;
4913 }
4914 }
4915
4916 if (errmsg != NULL)
4917 {
Bram Moolenaarce0842a2005-07-18 21:58:11 +00004918 vim_strncpy(IObuff, (char_u *)_(errmsg), IOSIZE - 1);
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00004919 i = (int)STRLEN(IObuff) + 2;
Bram Moolenaar071d4272004-06-13 20:20:40 +00004920 if (i + (arg - startarg) < IOSIZE)
4921 {
4922 /* append the argument with the error */
4923 STRCAT(IObuff, ": ");
4924 mch_memmove(IObuff + i, startarg, (arg - startarg));
4925 IObuff[i + (arg - startarg)] = NUL;
4926 }
4927 /* make sure all characters are printable */
4928 trans_characters(IObuff, IOSIZE);
4929
4930 ++no_wait_return; /* wait_return done later */
4931 emsg(IObuff); /* show error highlighted */
4932 --no_wait_return;
4933
4934 return FAIL;
4935 }
4936
4937 arg = skipwhite(arg);
4938 }
4939
Bram Moolenaar26a60b42005-02-22 08:49:11 +00004940theend:
4941 if (silent_mode && did_show)
4942 {
4943 /* After displaying option values in silent mode. */
4944 silent_mode = FALSE;
4945 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
4946 msg_putchar('\n');
4947 cursor_on(); /* msg_start() switches it off */
4948 out_flush();
4949 silent_mode = TRUE;
4950 info_message = FALSE; /* use mch_msg(), not mch_errmsg() */
4951 }
4952
Bram Moolenaar071d4272004-06-13 20:20:40 +00004953 return OK;
4954}
4955
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004956/*
4957 * Call this when an option has been given a new value through a user command.
4958 * Sets the P_WAS_SET flag and takes care of the P_INSECURE flag.
4959 */
4960 static void
4961did_set_option(opt_idx, opt_flags, new_value)
4962 int opt_idx;
4963 int opt_flags; /* possibly with OPT_MODELINE */
4964 int new_value; /* value was replaced completely */
4965{
Bram Moolenaard1f56e62006-02-22 21:25:37 +00004966 long_u *p;
4967
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004968 options[opt_idx].flags |= P_WAS_SET;
4969
4970 /* When an option is set in the sandbox, from a modeline or in secure mode
4971 * set the P_INSECURE flag. Otherwise, if a new value is stored reset the
Bram Moolenaard1f56e62006-02-22 21:25:37 +00004972 * flag. */
4973 p = insecure_flag(opt_idx, opt_flags);
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004974 if (secure
4975#ifdef HAVE_SANDBOX
4976 || sandbox != 0
4977#endif
4978 || (opt_flags & OPT_MODELINE))
Bram Moolenaard1f56e62006-02-22 21:25:37 +00004979 *p = *p | P_INSECURE;
4980 else if (new_value)
4981 *p = *p & ~P_INSECURE;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00004982}
4983
Bram Moolenaar071d4272004-06-13 20:20:40 +00004984 static char_u *
4985illegal_char(errbuf, c)
4986 char_u *errbuf;
4987 int c;
4988{
4989 if (errbuf == NULL)
4990 return (char_u *)"";
4991 sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
Bram Moolenaar555b2802005-05-19 21:08:39 +00004992 (char *)transchar(c));
Bram Moolenaar071d4272004-06-13 20:20:40 +00004993 return errbuf;
4994}
4995
4996/*
4997 * Convert a key name or string into a key value.
4998 * Used for 'wildchar' and 'cedit' options.
4999 */
5000 static int
5001string_to_key(arg)
5002 char_u *arg;
5003{
5004 if (*arg == '<')
5005 return find_key_option(arg + 1);
5006 if (*arg == '^')
5007 return Ctrl_chr(arg[1]);
5008 return *arg;
5009}
5010
5011#ifdef FEAT_CMDWIN
5012/*
5013 * Check value of 'cedit' and set cedit_key.
5014 * Returns NULL if value is OK, error message otherwise.
5015 */
5016 static char_u *
5017check_cedit()
5018{
5019 int n;
5020
5021 if (*p_cedit == NUL)
5022 cedit_key = -1;
5023 else
5024 {
5025 n = string_to_key(p_cedit);
5026 if (vim_isprintc(n))
5027 return e_invarg;
5028 cedit_key = n;
5029 }
5030 return NULL;
5031}
5032#endif
5033
5034#ifdef FEAT_TITLE
5035/*
5036 * When changing 'title', 'titlestring', 'icon' or 'iconstring', call
5037 * maketitle() to create and display it.
5038 * When switching the title or icon off, call mch_restore_title() to get
5039 * the old value back.
5040 */
5041 static void
5042did_set_title(icon)
5043 int icon; /* Did set icon instead of title */
5044{
5045 if (starting != NO_SCREEN
5046#ifdef FEAT_GUI
5047 && !gui.starting
5048#endif
5049 )
5050 {
5051 maketitle();
5052 if (icon)
5053 {
5054 if (!p_icon)
5055 mch_restore_title(2);
5056 }
5057 else
5058 {
5059 if (!p_title)
5060 mch_restore_title(1);
5061 }
5062 }
5063}
5064#endif
5065
5066/*
5067 * set_options_bin - called when 'bin' changes value.
5068 */
5069 void
5070set_options_bin(oldval, newval, opt_flags)
5071 int oldval;
5072 int newval;
5073 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5074{
5075 /*
5076 * The option values that are changed when 'bin' changes are
5077 * copied when 'bin is set and restored when 'bin' is reset.
5078 */
5079 if (newval)
5080 {
5081 if (!oldval) /* switched on */
5082 {
5083 if (!(opt_flags & OPT_GLOBAL))
5084 {
5085 curbuf->b_p_tw_nobin = curbuf->b_p_tw;
5086 curbuf->b_p_wm_nobin = curbuf->b_p_wm;
5087 curbuf->b_p_ml_nobin = curbuf->b_p_ml;
5088 curbuf->b_p_et_nobin = curbuf->b_p_et;
5089 }
5090 if (!(opt_flags & OPT_LOCAL))
5091 {
5092 p_tw_nobin = p_tw;
5093 p_wm_nobin = p_wm;
5094 p_ml_nobin = p_ml;
5095 p_et_nobin = p_et;
5096 }
5097 }
5098
5099 if (!(opt_flags & OPT_GLOBAL))
5100 {
5101 curbuf->b_p_tw = 0; /* no automatic line wrap */
5102 curbuf->b_p_wm = 0; /* no automatic line wrap */
5103 curbuf->b_p_ml = 0; /* no modelines */
5104 curbuf->b_p_et = 0; /* no expandtab */
5105 }
5106 if (!(opt_flags & OPT_LOCAL))
5107 {
5108 p_tw = 0;
5109 p_wm = 0;
5110 p_ml = FALSE;
5111 p_et = FALSE;
5112 p_bin = TRUE; /* needed when called for the "-b" argument */
5113 }
5114 }
5115 else if (oldval) /* switched off */
5116 {
5117 if (!(opt_flags & OPT_GLOBAL))
5118 {
5119 curbuf->b_p_tw = curbuf->b_p_tw_nobin;
5120 curbuf->b_p_wm = curbuf->b_p_wm_nobin;
5121 curbuf->b_p_ml = curbuf->b_p_ml_nobin;
5122 curbuf->b_p_et = curbuf->b_p_et_nobin;
5123 }
5124 if (!(opt_flags & OPT_LOCAL))
5125 {
5126 p_tw = p_tw_nobin;
5127 p_wm = p_wm_nobin;
5128 p_ml = p_ml_nobin;
5129 p_et = p_et_nobin;
5130 }
5131 }
5132}
5133
5134#ifdef FEAT_VIMINFO
5135/*
5136 * Find the parameter represented by the given character (eg ', :, ", or /),
5137 * and return its associated value in the 'viminfo' string.
5138 * Only works for number parameters, not for 'r' or 'n'.
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00005139 * If the parameter is not specified in the string or there is no following
5140 * number, return -1.
Bram Moolenaar071d4272004-06-13 20:20:40 +00005141 */
5142 int
5143get_viminfo_parameter(type)
5144 int type;
5145{
5146 char_u *p;
5147
5148 p = find_viminfo_parameter(type);
5149 if (p != NULL && VIM_ISDIGIT(*p))
5150 return atoi((char *)p);
5151 return -1;
5152}
5153
5154/*
5155 * Find the parameter represented by the given character (eg ''', ':', '"', or
5156 * '/') in the 'viminfo' option and return a pointer to the string after it.
5157 * Return NULL if the parameter is not specified in the string.
5158 */
5159 char_u *
5160find_viminfo_parameter(type)
5161 int type;
5162{
5163 char_u *p;
5164
5165 for (p = p_viminfo; *p; ++p)
5166 {
5167 if (*p == type)
5168 return p + 1;
5169 if (*p == 'n') /* 'n' is always the last one */
5170 break;
5171 p = vim_strchr(p, ','); /* skip until next ',' */
5172 if (p == NULL) /* hit the end without finding parameter */
5173 break;
5174 }
5175 return NULL;
5176}
5177#endif
5178
5179/*
5180 * Expand environment variables for some string options.
5181 * These string options cannot be indirect!
5182 * If "val" is NULL expand the current value of the option.
5183 * Return pointer to NameBuff, or NULL when not expanded.
5184 */
5185 static char_u *
5186option_expand(opt_idx, val)
5187 int opt_idx;
5188 char_u *val;
5189{
5190 /* if option doesn't need expansion nothing to do */
5191 if (!(options[opt_idx].flags & P_EXPAND) || options[opt_idx].var == NULL)
5192 return NULL;
5193
5194 /* If val is longer than MAXPATHL no meaningful expansion can be done,
5195 * expand_env() would truncate the string. */
5196 if (val != NULL && STRLEN(val) > MAXPATHL)
5197 return NULL;
5198
5199 if (val == NULL)
5200 val = *(char_u **)options[opt_idx].var;
5201
5202 /*
5203 * Expanding this with NameBuff, expand_env() must not be passed IObuff.
5204 * Escape spaces when expanding 'tags', they are used to separate file
5205 * names.
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005206 * For 'spellsuggest' expand after "file:".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005207 */
5208 expand_env_esc(val, NameBuff, MAXPATHL,
Bram Moolenaar9f0545d2007-09-26 20:36:32 +00005209 (char_u **)options[opt_idx].var == &p_tags, FALSE,
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005210#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005211 (char_u **)options[opt_idx].var == &p_sps ? (char_u *)"file:" :
5212#endif
5213 NULL);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005214 if (STRCMP(NameBuff, val) == 0) /* they are the same */
5215 return NULL;
5216
5217 return NameBuff;
5218}
5219
5220/*
5221 * After setting various option values: recompute variables that depend on
5222 * option values.
5223 */
5224 static void
5225didset_options()
5226{
5227 /* initialize the table for 'iskeyword' et.al. */
5228 (void)init_chartab();
5229
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005230#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005231 (void)opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE);
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00005232#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005233 (void)opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE);
5234#ifdef FEAT_SESSION
5235 (void)opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE);
5236 (void)opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE);
5237#endif
5238#ifdef FEAT_FOLDING
5239 (void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
5240#endif
5241 (void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
5242#ifdef FEAT_VIRTUALEDIT
5243 (void)opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE);
5244#endif
5245#if defined(FEAT_MOUSE) && (defined(UNIX) || defined(VMS))
5246 (void)opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE);
5247#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005248#ifdef FEAT_SPELL
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00005249 (void)spell_check_msm();
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00005250 (void)spell_check_sps();
Bram Moolenaar860cae12010-06-05 23:22:07 +02005251 (void)compile_cap_prog(curwin->w_s);
Bram Moolenaard857f0e2005-06-21 22:37:39 +00005252#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005253#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
5254 (void)opt_strings_flags(p_toolbar, p_toolbar_values, &toolbar_flags, TRUE);
5255#endif
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005256#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005257 (void)opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE);
5258#endif
5259#ifdef FEAT_CMDWIN
5260 /* set cedit_key */
5261 (void)check_cedit();
5262#endif
5263}
5264
5265/*
5266 * Check for string options that are NULL (normally only termcap options).
5267 */
5268 void
5269check_options()
5270{
5271 int opt_idx;
5272
5273 for (opt_idx = 0; options[opt_idx].fullname != NULL; opt_idx++)
5274 if ((options[opt_idx].flags & P_STRING) && options[opt_idx].var != NULL)
5275 check_string_option((char_u **)get_varp(&(options[opt_idx])));
5276}
5277
5278/*
5279 * Check string options in a buffer for NULL value.
5280 */
5281 void
5282check_buf_options(buf)
5283 buf_T *buf;
5284{
5285#if defined(FEAT_QUICKFIX)
5286 check_string_option(&buf->b_p_bh);
5287 check_string_option(&buf->b_p_bt);
5288#endif
5289#ifdef FEAT_MBYTE
5290 check_string_option(&buf->b_p_fenc);
5291#endif
5292 check_string_option(&buf->b_p_ff);
5293#ifdef FEAT_FIND_ID
5294 check_string_option(&buf->b_p_def);
5295 check_string_option(&buf->b_p_inc);
5296# ifdef FEAT_EVAL
5297 check_string_option(&buf->b_p_inex);
5298# endif
5299#endif
5300#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
5301 check_string_option(&buf->b_p_inde);
5302 check_string_option(&buf->b_p_indk);
5303#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005304#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
5305 check_string_option(&buf->b_p_bexpr);
5306#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02005307#if defined(FEAT_CRYPT)
5308 check_string_option(&buf->b_p_cm);
5309#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00005310#if defined(FEAT_EVAL)
5311 check_string_option(&buf->b_p_fex);
5312#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005313#ifdef FEAT_CRYPT
5314 check_string_option(&buf->b_p_key);
5315#endif
5316 check_string_option(&buf->b_p_kp);
5317 check_string_option(&buf->b_p_mps);
5318 check_string_option(&buf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00005319 check_string_option(&buf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005320 check_string_option(&buf->b_p_isk);
5321#ifdef FEAT_COMMENTS
5322 check_string_option(&buf->b_p_com);
5323#endif
5324#ifdef FEAT_FOLDING
5325 check_string_option(&buf->b_p_cms);
5326#endif
5327 check_string_option(&buf->b_p_nf);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005328#ifdef FEAT_TEXTOBJ
5329 check_string_option(&buf->b_p_qe);
5330#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005331#ifdef FEAT_SYN_HL
5332 check_string_option(&buf->b_p_syn);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00005333#endif
5334#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02005335 check_string_option(&buf->b_s.b_p_spc);
5336 check_string_option(&buf->b_s.b_p_spf);
5337 check_string_option(&buf->b_s.b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005338#endif
5339#ifdef FEAT_SEARCHPATH
5340 check_string_option(&buf->b_p_sua);
5341#endif
5342#ifdef FEAT_CINDENT
5343 check_string_option(&buf->b_p_cink);
5344 check_string_option(&buf->b_p_cino);
5345#endif
5346#ifdef FEAT_AUTOCMD
5347 check_string_option(&buf->b_p_ft);
5348#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005349#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
5350 check_string_option(&buf->b_p_cinw);
5351#endif
5352#ifdef FEAT_INS_EXPAND
5353 check_string_option(&buf->b_p_cpt);
5354#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005355#ifdef FEAT_COMPL_FUNC
5356 check_string_option(&buf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00005357 check_string_option(&buf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00005358#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005359#ifdef FEAT_KEYMAP
5360 check_string_option(&buf->b_p_keymap);
5361#endif
5362#ifdef FEAT_QUICKFIX
5363 check_string_option(&buf->b_p_gp);
5364 check_string_option(&buf->b_p_mp);
5365 check_string_option(&buf->b_p_efm);
5366#endif
5367 check_string_option(&buf->b_p_ep);
5368 check_string_option(&buf->b_p_path);
5369 check_string_option(&buf->b_p_tags);
5370#ifdef FEAT_INS_EXPAND
5371 check_string_option(&buf->b_p_dict);
5372 check_string_option(&buf->b_p_tsr);
5373#endif
5374}
5375
5376/*
5377 * Free the string allocated for an option.
5378 * Checks for the string being empty_option. This may happen if we're out of
5379 * memory, vim_strsave() returned NULL, which was replaced by empty_option by
5380 * check_options().
5381 * Does NOT check for P_ALLOCED flag!
5382 */
5383 void
5384free_string_option(p)
5385 char_u *p;
5386{
5387 if (p != empty_option)
5388 vim_free(p);
5389}
5390
5391 void
5392clear_string_option(pp)
5393 char_u **pp;
5394{
5395 if (*pp != empty_option)
5396 vim_free(*pp);
5397 *pp = empty_option;
5398}
5399
5400 static void
5401check_string_option(pp)
5402 char_u **pp;
5403{
5404 if (*pp == NULL)
5405 *pp = empty_option;
5406}
5407
5408/*
5409 * Mark a terminal option as allocated, found by a pointer into term_strings[].
5410 */
5411 void
5412set_term_option_alloced(p)
5413 char_u **p;
5414{
5415 int opt_idx;
5416
5417 for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
5418 if (options[opt_idx].var == (char_u *)p)
5419 {
5420 options[opt_idx].flags |= P_ALLOCED;
5421 return;
5422 }
5423 return; /* cannot happen: didn't find it! */
5424}
5425
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005426#if defined(FEAT_EVAL) || defined(PROTO)
5427/*
5428 * Return TRUE when option "opt" was set from a modeline or in secure mode.
5429 * Return FALSE when it wasn't.
5430 * Return -1 for an unknown option.
5431 */
5432 int
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005433was_set_insecurely(opt, opt_flags)
5434 char_u *opt;
5435 int opt_flags;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005436{
5437 int idx = findoption(opt);
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005438 long_u *flagp;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005439
5440 if (idx >= 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005441 {
5442 flagp = insecure_flag(idx, opt_flags);
5443 return (*flagp & P_INSECURE) != 0;
5444 }
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005445 EMSG2(_(e_intern2), "was_set_insecurely()");
5446 return -1;
5447}
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005448
5449/*
5450 * Get a pointer to the flags used for the P_INSECURE flag of option
5451 * "opt_idx". For some local options a local flags field is used.
5452 */
5453 static long_u *
5454insecure_flag(opt_idx, opt_flags)
5455 int opt_idx;
5456 int opt_flags;
5457{
5458 if (opt_flags & OPT_LOCAL)
5459 switch ((int)options[opt_idx].indir)
5460 {
5461#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005462 case PV_STL: return &curwin->w_p_stl_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005463#endif
5464#ifdef FEAT_EVAL
Bram Moolenaar2e978902006-05-13 12:37:50 +00005465# ifdef FEAT_FOLDING
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005466 case PV_FDE: return &curwin->w_p_fde_flags;
5467 case PV_FDT: return &curwin->w_p_fdt_flags;
Bram Moolenaar2e978902006-05-13 12:37:50 +00005468# endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00005469# ifdef FEAT_BEVAL
5470 case PV_BEXPR: return &curbuf->b_p_bexpr_flags;
5471# endif
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005472# if defined(FEAT_CINDENT)
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005473 case PV_INDE: return &curbuf->b_p_inde_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005474# endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005475 case PV_FEX: return &curbuf->b_p_fex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005476# ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005477 case PV_INEX: return &curbuf->b_p_inex_flags;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00005478# endif
5479#endif
5480 }
5481
5482 /* Nothing special, return global flags field. */
5483 return &options[opt_idx].flags;
5484}
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005485#endif
5486
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005487#ifdef FEAT_TITLE
5488static void redraw_titles __ARGS((void));
5489
5490/*
5491 * Redraw the window title and/or tab page text later.
5492 */
5493static void redraw_titles()
5494{
5495 need_maketitle = TRUE;
5496# ifdef FEAT_WINDOWS
5497 redraw_tabline = TRUE;
5498# endif
5499}
5500#endif
5501
Bram Moolenaar071d4272004-06-13 20:20:40 +00005502/*
5503 * Set a string option to a new value (without checking the effect).
5504 * The string is copied into allocated memory.
5505 * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005506 * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
Bram Moolenaard55de222007-05-06 13:38:48 +00005507 * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
Bram Moolenaar071d4272004-06-13 20:20:40 +00005508 */
5509 void
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005510set_string_option_direct(name, opt_idx, val, opt_flags, set_sid)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005511 char_u *name;
5512 int opt_idx;
5513 char_u *val;
5514 int opt_flags; /* OPT_FREE, OPT_LOCAL and/or OPT_GLOBAL */
Bram Moolenaar78a15312009-05-15 19:33:18 +00005515 int set_sid UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005516{
5517 char_u *s;
5518 char_u **varp;
5519 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
Bram Moolenaar89d40322006-08-29 15:30:07 +00005520 int idx = opt_idx;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005521
Bram Moolenaar89d40322006-08-29 15:30:07 +00005522 if (idx == -1) /* use name */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005523 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005524 idx = findoption(name);
5525 if (idx < 0) /* not found (should not happen) */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005526 {
5527 EMSG2(_(e_intern2), "set_string_option_direct()");
Bram Moolenaar071d4272004-06-13 20:20:40 +00005528 return;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005529 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005530 }
5531
Bram Moolenaar89d40322006-08-29 15:30:07 +00005532 if (options[idx].var == NULL) /* can't set hidden option */
Bram Moolenaar071d4272004-06-13 20:20:40 +00005533 return;
5534
5535 s = vim_strsave(val);
5536 if (s != NULL)
5537 {
Bram Moolenaar89d40322006-08-29 15:30:07 +00005538 varp = (char_u **)get_varp_scope(&(options[idx]),
Bram Moolenaar071d4272004-06-13 20:20:40 +00005539 both ? OPT_LOCAL : opt_flags);
Bram Moolenaar89d40322006-08-29 15:30:07 +00005540 if ((opt_flags & OPT_FREE) && (options[idx].flags & P_ALLOCED))
Bram Moolenaar071d4272004-06-13 20:20:40 +00005541 free_string_option(*varp);
5542 *varp = s;
5543
5544 /* For buffer/window local option may also set the global value. */
5545 if (both)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005546 set_string_option_global(idx, varp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005547
Bram Moolenaar89d40322006-08-29 15:30:07 +00005548 options[idx].flags |= P_ALLOCED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005549
5550 /* When setting both values of a global option with a local value,
5551 * make the local value empty, so that the global value is used. */
Bram Moolenaar89d40322006-08-29 15:30:07 +00005552 if (((int)options[idx].indir & PV_BOTH) && both)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005553 {
5554 free_string_option(*varp);
5555 *varp = empty_option;
5556 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005557# ifdef FEAT_EVAL
5558 if (set_sid != SID_NONE)
Bram Moolenaar89d40322006-08-29 15:30:07 +00005559 set_option_scriptID_idx(idx, opt_flags,
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00005560 set_sid == 0 ? current_SID : set_sid);
5561# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005562 }
5563}
5564
5565/*
5566 * Set global value for string option when it's a local option.
5567 */
5568 static void
5569set_string_option_global(opt_idx, varp)
5570 int opt_idx; /* option index */
5571 char_u **varp; /* pointer to option variable */
5572{
5573 char_u **p, *s;
5574
5575 /* the global value is always allocated */
5576 if (options[opt_idx].var == VAR_WIN)
5577 p = (char_u **)GLOBAL_WO(varp);
5578 else
5579 p = (char_u **)options[opt_idx].var;
5580 if (options[opt_idx].indir != PV_NONE
5581 && p != varp
5582 && (s = vim_strsave(*varp)) != NULL)
5583 {
5584 free_string_option(*p);
5585 *p = s;
5586 }
5587}
5588
5589/*
5590 * Set a string option to a new value, and handle the effects.
5591 */
5592 static void
5593set_string_option(opt_idx, value, opt_flags)
5594 int opt_idx;
5595 char_u *value;
5596 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5597{
5598 char_u *s;
5599 char_u **varp;
5600 char_u *oldval;
5601
5602 if (options[opt_idx].var == NULL) /* don't set hidden option */
5603 return;
5604
5605 s = vim_strsave(value);
5606 if (s != NULL)
5607 {
5608 varp = (char_u **)get_varp_scope(&(options[opt_idx]),
5609 (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00005610 ? (((int)options[opt_idx].indir & PV_BOTH)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005611 ? OPT_GLOBAL : OPT_LOCAL)
5612 : opt_flags);
5613 oldval = *varp;
5614 *varp = s;
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00005615 if (did_set_string_option(opt_idx, varp, TRUE, oldval, NULL,
5616 opt_flags) == NULL)
5617 did_set_option(opt_idx, opt_flags, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005618 }
5619}
5620
5621/*
5622 * Handle string options that need some action to perform when changed.
5623 * Returns NULL for success, or an error message for an error.
5624 */
5625 static char_u *
5626did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
5627 opt_flags)
5628 int opt_idx; /* index in options[] table */
5629 char_u **varp; /* pointer to the option variable */
5630 int new_value_alloced; /* new value was allocated */
5631 char_u *oldval; /* previous value of the option */
5632 char_u *errbuf; /* buffer for errors, or NULL */
5633 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
5634{
5635 char_u *errmsg = NULL;
5636 char_u *s, *p;
5637 int did_chartab = FALSE;
5638 char_u **gvarp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00005639 long_u free_oldval = (options[opt_idx].flags & P_ALLOCED);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00005640#ifdef FEAT_GUI
5641 /* set when changing an option that only requires a redraw in the GUI */
5642 int redraw_gui_only = FALSE;
5643#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005644
5645 /* Get the global option to compare with, otherwise we would have to check
5646 * two values for all local options. */
5647 gvarp = (char_u **)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL);
5648
5649 /* Disallow changing some options from secure mode */
5650 if ((secure
5651#ifdef HAVE_SANDBOX
5652 || sandbox != 0
5653#endif
5654 ) && (options[opt_idx].flags & P_SECURE))
5655 {
5656 errmsg = e_secure;
5657 }
5658
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005659 /* Check for a "normal" file name in some options. Disallow a path
5660 * separator (slash and/or backslash), wildcards and characters that are
5661 * often illegal in a file name. */
5662 else if ((options[opt_idx].flags & P_NFNAME)
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005663 && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL)
Bram Moolenaar293ee4d2004-12-09 21:34:53 +00005664 {
5665 errmsg = e_invarg;
5666 }
5667
Bram Moolenaar071d4272004-06-13 20:20:40 +00005668 /* 'term' */
5669 else if (varp == &T_NAME)
5670 {
5671 if (T_NAME[0] == NUL)
5672 errmsg = (char_u *)N_("E529: Cannot set 'term' to empty string");
5673#ifdef FEAT_GUI
5674 if (gui.in_use)
5675 errmsg = (char_u *)N_("E530: Cannot change term in GUI");
5676 else if (term_is_gui(T_NAME))
5677 errmsg = (char_u *)N_("E531: Use \":gui\" to start the GUI");
5678#endif
5679 else if (set_termname(T_NAME) == FAIL)
5680 errmsg = (char_u *)N_("E522: Not found in termcap");
5681 else
5682 /* Screen colors may have changed. */
5683 redraw_later_clear();
5684 }
5685
5686 /* 'backupcopy' */
5687 else if (varp == &p_bkc)
5688 {
5689 if (opt_strings_flags(p_bkc, p_bkc_values, &bkc_flags, TRUE) != OK)
5690 errmsg = e_invarg;
5691 if (((bkc_flags & BKC_AUTO) != 0)
5692 + ((bkc_flags & BKC_YES) != 0)
5693 + ((bkc_flags & BKC_NO) != 0) != 1)
5694 {
5695 /* Must have exactly one of "auto", "yes" and "no". */
5696 (void)opt_strings_flags(oldval, p_bkc_values, &bkc_flags, TRUE);
5697 errmsg = e_invarg;
5698 }
5699 }
5700
5701 /* 'backupext' and 'patchmode' */
5702 else if (varp == &p_bex || varp == &p_pm)
5703 {
5704 if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
5705 *p_pm == '.' ? p_pm + 1 : p_pm) == 0)
5706 errmsg = (char_u *)N_("E589: 'backupext' and 'patchmode' are equal");
5707 }
5708
5709 /*
5710 * 'isident', 'iskeyword', 'isprint or 'isfname' option: refill chartab[]
5711 * If the new option is invalid, use old value. 'lisp' option: refill
5712 * chartab[] for '-' char
5713 */
5714 else if ( varp == &p_isi
5715 || varp == &(curbuf->b_p_isk)
5716 || varp == &p_isp
5717 || varp == &p_isf)
5718 {
5719 if (init_chartab() == FAIL)
5720 {
5721 did_chartab = TRUE; /* need to restore it below */
5722 errmsg = e_invarg; /* error in value */
5723 }
5724 }
5725
5726 /* 'helpfile' */
5727 else if (varp == &p_hf)
5728 {
5729 /* May compute new values for $VIM and $VIMRUNTIME */
5730 if (didset_vim)
5731 {
5732 vim_setenv((char_u *)"VIM", (char_u *)"");
5733 didset_vim = FALSE;
5734 }
5735 if (didset_vimruntime)
5736 {
5737 vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
5738 didset_vimruntime = FALSE;
5739 }
5740 }
5741
Bram Moolenaar1a384422010-07-14 19:53:30 +02005742#ifdef FEAT_SYN_HL
5743 /* 'colorcolumn' */
5744 else if (varp == &curwin->w_p_cc)
5745 errmsg = check_colorcolumn(curwin);
5746#endif
5747
Bram Moolenaar071d4272004-06-13 20:20:40 +00005748#ifdef FEAT_MULTI_LANG
5749 /* 'helplang' */
5750 else if (varp == &p_hlg)
5751 {
5752 /* Check for "", "ab", "ab,cd", etc. */
5753 for (s = p_hlg; *s != NUL; s += 3)
5754 {
5755 if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
5756 {
5757 errmsg = e_invarg;
5758 break;
5759 }
5760 if (s[2] == NUL)
5761 break;
5762 }
5763 }
5764#endif
5765
5766 /* 'highlight' */
5767 else if (varp == &p_hl)
5768 {
5769 if (highlight_changed() == FAIL)
5770 errmsg = e_invarg; /* invalid flags */
5771 }
5772
5773 /* 'nrformats' */
5774 else if (gvarp == &p_nf)
5775 {
5776 if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
5777 errmsg = e_invarg;
5778 }
5779
5780#ifdef FEAT_SESSION
5781 /* 'sessionoptions' */
5782 else if (varp == &p_ssop)
5783 {
5784 if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
5785 errmsg = e_invarg;
5786 if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
5787 {
5788 /* Don't allow both "sesdir" and "curdir". */
5789 (void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
5790 errmsg = e_invarg;
5791 }
5792 }
5793 /* 'viewoptions' */
5794 else if (varp == &p_vop)
5795 {
5796 if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
5797 errmsg = e_invarg;
5798 }
5799#endif
5800
5801 /* 'scrollopt' */
5802#ifdef FEAT_SCROLLBIND
5803 else if (varp == &p_sbo)
5804 {
5805 if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
5806 errmsg = e_invarg;
5807 }
5808#endif
5809
5810 /* 'ambiwidth' */
5811#ifdef FEAT_MBYTE
5812 else if (varp == &p_ambw)
5813 {
5814 if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
5815 errmsg = e_invarg;
Bram Moolenaar5c3bd0a2010-08-04 20:55:44 +02005816 else if (set_chars_option(&p_lcs) != NULL)
5817 errmsg = (char_u *)_("E834: Conflicts with value of 'listchars'");
5818# if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
5819 else if (set_chars_option(&p_fcs) != NULL)
5820 errmsg = (char_u *)_("E835: Conflicts with value of 'fillchars'");
5821# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005822 }
5823#endif
5824
5825 /* 'background' */
5826 else if (varp == &p_bg)
5827 {
5828 if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
5829 {
5830#ifdef FEAT_EVAL
5831 int dark = (*p_bg == 'd');
5832#endif
5833
5834 init_highlight(FALSE, FALSE);
5835
5836#ifdef FEAT_EVAL
5837 if (dark != (*p_bg == 'd')
5838 && get_var_value((char_u *)"g:colors_name") != NULL)
5839 {
5840 /* The color scheme must have set 'background' back to another
5841 * value, that's not what we want here. Disable the color
5842 * scheme and set the colors again. */
Bram Moolenaar2ce06f62005-01-31 19:19:04 +00005843 do_unlet((char_u *)"g:colors_name", TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00005844 free_string_option(p_bg);
5845 p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
5846 check_string_option(&p_bg);
5847 init_highlight(FALSE, FALSE);
5848 }
5849#endif
5850 }
5851 else
5852 errmsg = e_invarg;
5853 }
5854
5855 /* 'wildmode' */
5856 else if (varp == &p_wim)
5857 {
5858 if (check_opt_wim() == FAIL)
5859 errmsg = e_invarg;
5860 }
5861
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00005862#ifdef FEAT_CMDL_COMPL
5863 /* 'wildoptions' */
5864 else if (varp == &p_wop)
5865 {
5866 if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
5867 errmsg = e_invarg;
5868 }
5869#endif
5870
Bram Moolenaar071d4272004-06-13 20:20:40 +00005871#ifdef FEAT_WAK
5872 /* 'winaltkeys' */
5873 else if (varp == &p_wak)
5874 {
5875 if (*p_wak == NUL
5876 || check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
5877 errmsg = e_invarg;
5878# ifdef FEAT_MENU
5879# ifdef FEAT_GUI_MOTIF
5880 else if (gui.in_use)
5881 gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
5882# else
5883# ifdef FEAT_GUI_GTK
5884 else if (gui.in_use)
5885 gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
5886# endif
5887# endif
5888# endif
5889 }
5890#endif
5891
5892#ifdef FEAT_AUTOCMD
5893 /* 'eventignore' */
5894 else if (varp == &p_ei)
5895 {
5896 if (check_ei() == FAIL)
5897 errmsg = e_invarg;
5898 }
5899#endif
5900
5901#ifdef FEAT_MBYTE
5902 /* 'encoding' and 'fileencoding' */
5903 else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc)
5904 {
5905 if (gvarp == &p_fenc)
5906 {
Bram Moolenaarf2f70252008-02-13 17:36:06 +00005907 if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005908 errmsg = e_modifiable;
5909 else if (vim_strchr(*varp, ',') != NULL)
5910 /* No comma allowed in 'fileencoding'; catches confusing it
5911 * with 'fileencodings'. */
5912 errmsg = e_invarg;
Bram Moolenaar071d4272004-06-13 20:20:40 +00005913 else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005914 {
5915# ifdef FEAT_TITLE
Bram Moolenaar071d4272004-06-13 20:20:40 +00005916 /* May show a "+" in the title now. */
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005917 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00005918# endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00005919 /* Add 'fileencoding' to the swap file. */
5920 ml_setflags(curbuf);
5921 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00005922 }
5923 if (errmsg == NULL)
5924 {
5925 /* canonize the value, so that STRCMP() can be used on it */
5926 p = enc_canonize(*varp);
5927 if (p != NULL)
5928 {
5929 vim_free(*varp);
5930 *varp = p;
5931 }
5932 if (varp == &p_enc)
5933 {
5934 errmsg = mb_init();
5935# ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00005936 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00005937# endif
5938 }
5939 }
5940
Bram Moolenaar182c5be2010-06-25 05:37:59 +02005941# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00005942 if (errmsg == NULL && varp == &p_tenc && gui.in_use)
5943 {
5944 /* GTK+ 2 uses only a single encoding, and that is UTF-8. */
5945 if (STRCMP(p_tenc, "utf-8") != 0)
5946 errmsg = (char_u *)N_("E617: Cannot be changed in the GTK+ 2 GUI");
5947 }
5948# endif
5949
5950 if (errmsg == NULL)
5951 {
5952# ifdef FEAT_KEYMAP
5953 /* When 'keymap' is used and 'encoding' changes, reload the keymap
5954 * (with another encoding). */
5955 if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
5956 (void)keymap_init();
5957# endif
5958
5959 /* When 'termencoding' is not empty and 'encoding' changes or when
5960 * 'termencoding' changes, need to setup for keyboard input and
5961 * display output conversion. */
5962 if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
5963 {
5964 convert_setup(&input_conv, p_tenc, p_enc);
5965 convert_setup(&output_conv, p_enc, p_tenc);
5966 }
Bram Moolenaar05159a02005-02-26 23:04:13 +00005967
5968# if defined(WIN3264) && defined(FEAT_MBYTE)
5969 /* $HOME may have characters in active code page. */
5970 if (varp == &p_enc)
5971 init_homedir();
5972# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00005973 }
5974 }
5975#endif
5976
5977#if defined(FEAT_POSTSCRIPT)
5978 else if (varp == &p_penc)
5979 {
5980 /* Canonize printencoding if VIM standard one */
5981 p = enc_canonize(p_penc);
5982 if (p != NULL)
5983 {
5984 vim_free(p_penc);
5985 p_penc = p;
5986 }
5987 else
5988 {
5989 /* Ensure lower case and '-' for '_' */
5990 for (s = p_penc; *s != NUL; s++)
5991 {
5992 if (*s == '_')
5993 *s = '-';
5994 else
5995 *s = TOLOWER_ASC(*s);
5996 }
5997 }
5998 }
5999#endif
6000
Bram Moolenaar9372a112005-12-06 19:59:18 +00006001#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006002 else if (varp == &p_imak)
6003 {
6004 if (gui.in_use && !im_xim_isvalid_imactivate())
6005 errmsg = e_invarg;
6006 }
6007#endif
6008
6009#ifdef FEAT_KEYMAP
6010 else if (varp == &curbuf->b_p_keymap)
6011 {
6012 /* load or unload key mapping tables */
6013 errmsg = keymap_init();
6014
Bram Moolenaarfab06232009-03-04 03:13:35 +00006015 if (errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006016 {
Bram Moolenaarfab06232009-03-04 03:13:35 +00006017 if (*curbuf->b_p_keymap != NUL)
6018 {
6019 /* Installed a new keymap, switch on using it. */
6020 curbuf->b_p_iminsert = B_IMODE_LMAP;
6021 if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
6022 curbuf->b_p_imsearch = B_IMODE_LMAP;
6023 }
6024 else
6025 {
6026 /* Cleared the keymap, may reset 'iminsert' and 'imsearch'. */
6027 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
6028 curbuf->b_p_iminsert = B_IMODE_NONE;
6029 if (curbuf->b_p_imsearch == B_IMODE_LMAP)
6030 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
6031 }
6032 if ((opt_flags & OPT_LOCAL) == 0)
6033 {
6034 set_iminsert_global();
6035 set_imsearch_global();
6036 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006037# ifdef FEAT_WINDOWS
6038 status_redraw_curbuf();
6039# endif
6040 }
6041 }
6042#endif
6043
6044 /* 'fileformat' */
6045 else if (gvarp == &p_ff)
6046 {
6047 if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
6048 errmsg = e_modifiable;
6049 else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
6050 errmsg = e_invarg;
6051 else
6052 {
6053 /* may also change 'textmode' */
6054 if (get_fileformat(curbuf) == EOL_DOS)
6055 curbuf->b_p_tx = TRUE;
6056 else
6057 curbuf->b_p_tx = FALSE;
6058#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00006059 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00006060#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006061 /* update flag in swap file */
6062 ml_setflags(curbuf);
Bram Moolenaar0413d482010-02-11 17:02:11 +01006063 /* Redraw needed when switching to/from "mac": a CR in the text
6064 * will be displayed differently. */
6065 if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
6066 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006067 }
6068 }
6069
6070 /* 'fileformats' */
6071 else if (varp == &p_ffs)
6072 {
6073 if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
6074 errmsg = e_invarg;
6075 else
6076 {
6077 /* also change 'textauto' */
6078 if (*p_ffs == NUL)
6079 p_ta = FALSE;
6080 else
6081 p_ta = TRUE;
6082 }
6083 }
6084
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006085#if defined(FEAT_CRYPT)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006086 /* 'cryptkey' */
6087 else if (gvarp == &p_key)
6088 {
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006089# if defined(FEAT_CMDHIST)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006090 /* Make sure the ":set" command doesn't show the new value in the
6091 * history. */
6092 remove_key_from_history();
Bram Moolenaara8ffcbb2010-06-21 06:15:46 +02006093# endif
6094 if (STRCMP(curbuf->b_p_key, oldval) != 0)
6095 /* Need to update the swapfile. */
Bram Moolenaar49771f42010-07-20 17:32:38 +02006096 ml_set_crypt_key(curbuf, oldval, get_crypt_method(curbuf));
6097 }
6098
6099 else if (gvarp == &p_cm)
6100 {
6101 if (opt_flags & OPT_LOCAL)
6102 p = curbuf->b_p_cm;
6103 else
6104 p = p_cm;
6105 if (check_opt_strings(p, p_cm_values, TRUE) != OK)
6106 errmsg = e_invarg;
6107 else if (get_crypt_method(curbuf) > 0 && blowfish_self_test() == FAIL)
6108 errmsg = e_invarg;
6109 else
6110 {
6111 /* When setting the global value to empty, make it "zip". */
6112 if (*p_cm == NUL)
6113 {
6114 if (new_value_alloced)
6115 free_string_option(p_cm);
6116 p_cm = vim_strsave((char_u *)"zip");
6117 new_value_alloced = TRUE;
6118 }
6119
6120 /* Need to update the swapfile when the effective method changed.
6121 * Set "s" to the effective old value, "p" to the effective new
6122 * method and compare. */
6123 if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
6124 s = p_cm; /* was previously using the global value */
6125 else
6126 s = oldval;
6127 if (*curbuf->b_p_cm == NUL)
6128 p = p_cm; /* is now using the global value */
6129 else
6130 p = curbuf->b_p_cm;
6131 if (STRCMP(s, p) != 0)
6132 ml_set_crypt_key(curbuf, curbuf->b_p_key,
6133 crypt_method_from_string(s));
6134
6135 /* If the global value changes need to update the swapfile for all
6136 * buffers using that value. */
6137 if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
6138 {
6139 buf_T *buf;
6140
6141 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
6142 if (buf != curbuf && *buf->b_p_cm == NUL)
6143 ml_set_crypt_key(buf, buf->b_p_key,
6144 crypt_method_from_string(oldval));
6145 }
6146 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006147 }
6148#endif
6149
6150 /* 'matchpairs' */
6151 else if (gvarp == &p_mps)
6152 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006153#ifdef FEAT_MBYTE
6154 if (has_mbyte)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006155 {
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006156 for (p = *varp; *p != NUL; ++p)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006157 {
Bram Moolenaar09365022013-01-17 17:37:35 +01006158 int x2 = -1;
6159 int x3 = -1;
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006160
6161 if (*p != NUL)
6162 p += mb_ptr2len(p);
6163 if (*p != NUL)
6164 x2 = *p++;
6165 if (*p != NUL)
6166 {
6167 x3 = mb_ptr2char(p);
6168 p += mb_ptr2len(p);
6169 }
Bram Moolenaar09365022013-01-17 17:37:35 +01006170 if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006171 {
6172 errmsg = e_invarg;
6173 break;
6174 }
6175 if (*p == NUL)
6176 break;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006177 }
Bram Moolenaar8c7694a2013-01-17 17:02:05 +01006178 }
6179 else
6180#endif
6181 {
6182 /* Check for "x:y,x:y" */
6183 for (p = *varp; *p != NUL; p += 4)
6184 {
6185 if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
6186 {
6187 errmsg = e_invarg;
6188 break;
6189 }
6190 if (p[3] == NUL)
6191 break;
6192 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006193 }
6194 }
6195
6196#ifdef FEAT_COMMENTS
6197 /* 'comments' */
6198 else if (gvarp == &p_com)
6199 {
6200 for (s = *varp; *s; )
6201 {
6202 while (*s && *s != ':')
6203 {
6204 if (vim_strchr((char_u *)COM_ALL, *s) == NULL
6205 && !VIM_ISDIGIT(*s) && *s != '-')
6206 {
6207 errmsg = illegal_char(errbuf, *s);
6208 break;
6209 }
6210 ++s;
6211 }
6212 if (*s++ == NUL)
6213 errmsg = (char_u *)N_("E524: Missing colon");
6214 else if (*s == ',' || *s == NUL)
6215 errmsg = (char_u *)N_("E525: Zero length string");
6216 if (errmsg != NULL)
6217 break;
6218 while (*s && *s != ',')
6219 {
6220 if (*s == '\\' && s[1] != NUL)
6221 ++s;
6222 ++s;
6223 }
6224 s = skip_to_option_part(s);
6225 }
6226 }
6227#endif
6228
6229 /* 'listchars' */
6230 else if (varp == &p_lcs)
6231 {
6232 errmsg = set_chars_option(varp);
6233 }
6234
6235#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
6236 /* 'fillchars' */
6237 else if (varp == &p_fcs)
6238 {
6239 errmsg = set_chars_option(varp);
6240 }
6241#endif
6242
6243#ifdef FEAT_CMDWIN
6244 /* 'cedit' */
6245 else if (varp == &p_cedit)
6246 {
6247 errmsg = check_cedit();
6248 }
6249#endif
6250
Bram Moolenaar54ee7752005-05-31 22:22:17 +00006251 /* 'verbosefile' */
6252 else if (varp == &p_vfile)
6253 {
6254 verbose_stop();
6255 if (*p_vfile != NUL && verbose_open() == FAIL)
6256 errmsg = e_invarg;
6257 }
6258
Bram Moolenaar071d4272004-06-13 20:20:40 +00006259#ifdef FEAT_VIMINFO
6260 /* 'viminfo' */
6261 else if (varp == &p_viminfo)
6262 {
6263 for (s = p_viminfo; *s;)
6264 {
6265 /* Check it's a valid character */
6266 if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
6267 {
6268 errmsg = illegal_char(errbuf, *s);
6269 break;
6270 }
6271 if (*s == 'n') /* name is always last one */
6272 {
6273 break;
6274 }
6275 else if (*s == 'r') /* skip until next ',' */
6276 {
6277 while (*++s && *s != ',')
6278 ;
6279 }
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00006280 else if (*s == '%')
6281 {
6282 /* optional number */
6283 while (vim_isdigit(*++s))
6284 ;
6285 }
6286 else if (*s == '!' || *s == 'h' || *s == 'c')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006287 ++s; /* no extra chars */
6288 else /* must have a number */
6289 {
6290 while (vim_isdigit(*++s))
6291 ;
6292
6293 if (!VIM_ISDIGIT(*(s - 1)))
6294 {
6295 if (errbuf != NULL)
6296 {
Bram Moolenaar8f999f12005-01-25 22:12:55 +00006297 sprintf((char *)errbuf,
6298 _("E526: Missing number after <%s>"),
Bram Moolenaar071d4272004-06-13 20:20:40 +00006299 transchar_byte(*(s - 1)));
6300 errmsg = errbuf;
6301 }
6302 else
6303 errmsg = (char_u *)"";
6304 break;
6305 }
6306 }
6307 if (*s == ',')
6308 ++s;
6309 else if (*s)
6310 {
6311 if (errbuf != NULL)
6312 errmsg = (char_u *)N_("E527: Missing comma");
6313 else
6314 errmsg = (char_u *)"";
6315 break;
6316 }
6317 }
6318 if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
6319 errmsg = (char_u *)N_("E528: Must specify a ' value");
6320 }
6321#endif /* FEAT_VIMINFO */
6322
6323 /* terminal options */
6324 else if (istermoption(&options[opt_idx]) && full_screen)
6325 {
6326 /* ":set t_Co=0" and ":set t_Co=1" do ":set t_Co=" */
6327 if (varp == &T_CCO)
6328 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006329 int colors = atoi((char *)T_CCO);
6330
6331 /* Only reinitialize colors if t_Co value has really changed to
6332 * avoid expensive reload of colorscheme if t_Co is set to the
6333 * same value multiple times. */
6334 if (colors != t_colors)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006335 {
Bram Moolenaarc84e8952009-03-18 13:21:18 +00006336 t_colors = colors;
6337 if (t_colors <= 1)
6338 {
6339 if (new_value_alloced)
6340 vim_free(T_CCO);
6341 T_CCO = empty_option;
6342 }
6343 /* We now have a different color setup, initialize it again. */
6344 init_highlight(TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006345 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006346 }
6347 ttest(FALSE);
6348 if (varp == &T_ME)
6349 {
6350 out_str(T_ME);
6351 redraw_later(CLEAR);
6352#if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32))
6353 /* Since t_me has been set, this probably means that the user
6354 * wants to use this as default colors. Need to reset default
6355 * background/foreground colors. */
6356 mch_set_normal_colors();
6357#endif
6358 }
6359 }
6360
6361#ifdef FEAT_LINEBREAK
6362 /* 'showbreak' */
6363 else if (varp == &p_sbr)
6364 {
6365 for (s = p_sbr; *s; )
6366 {
6367 if (ptr2cells(s) != 1)
6368 errmsg = (char_u *)N_("E595: contains unprintable or wide character");
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00006369 mb_ptr_adv(s);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006370 }
6371 }
6372#endif
6373
6374#ifdef FEAT_GUI
6375 /* 'guifont' */
6376 else if (varp == &p_guifont)
6377 {
6378 if (gui.in_use)
6379 {
6380 p = p_guifont;
Bram Moolenaar9372a112005-12-06 19:59:18 +00006381# if defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006382 /*
6383 * Put up a font dialog and let the user select a new value.
6384 * If this is cancelled go back to the old value but don't
6385 * give an error message.
6386 */
6387 if (STRCMP(p, "*") == 0)
6388 {
6389 p = gui_mch_font_dialog(oldval);
6390
6391 if (new_value_alloced)
6392 free_string_option(p_guifont);
6393
6394 p_guifont = (p != NULL) ? p : vim_strsave(oldval);
6395 new_value_alloced = TRUE;
6396 }
6397# endif
6398 if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
6399 {
6400# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
6401 if (STRCMP(p_guifont, "*") == 0)
6402 {
6403 /* Dialog was cancelled: Keep the old value without giving
6404 * an error message. */
6405 if (new_value_alloced)
6406 free_string_option(p_guifont);
6407 p_guifont = vim_strsave(oldval);
6408 new_value_alloced = TRUE;
6409 }
6410 else
6411# endif
6412 errmsg = (char_u *)N_("E596: Invalid font(s)");
6413 }
6414 }
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006415 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006416 }
6417# ifdef FEAT_XFONTSET
6418 else if (varp == &p_guifontset)
6419 {
6420 if (STRCMP(p_guifontset, "*") == 0)
6421 errmsg = (char_u *)N_("E597: can't select fontset");
6422 else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
6423 errmsg = (char_u *)N_("E598: Invalid fontset");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006424 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006425 }
6426# endif
6427# ifdef FEAT_MBYTE
6428 else if (varp == &p_guifontwide)
6429 {
6430 if (STRCMP(p_guifontwide, "*") == 0)
6431 errmsg = (char_u *)N_("E533: can't select wide font");
6432 else if (gui_get_wide_font() == FAIL)
6433 errmsg = (char_u *)N_("E534: Invalid wide font");
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006434 redraw_gui_only = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00006435 }
6436# endif
6437#endif
6438
6439#ifdef CURSOR_SHAPE
6440 /* 'guicursor' */
6441 else if (varp == &p_guicursor)
6442 errmsg = parse_shape_opt(SHAPE_CURSOR);
6443#endif
6444
6445#ifdef FEAT_MOUSESHAPE
6446 /* 'mouseshape' */
6447 else if (varp == &p_mouseshape)
6448 {
6449 errmsg = parse_shape_opt(SHAPE_MOUSE);
6450 update_mouseshape(-1);
6451 }
6452#endif
6453
6454#ifdef FEAT_PRINTER
6455 else if (varp == &p_popt)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006456 errmsg = parse_printoptions();
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00006457# if defined(FEAT_MBYTE) && defined(FEAT_POSTSCRIPT)
Bram Moolenaar8299df92004-07-10 09:47:34 +00006458 else if (varp == &p_pmfn)
Bram Moolenaar58d98232005-07-23 22:25:46 +00006459 errmsg = parse_printmbfont();
Bram Moolenaar8299df92004-07-10 09:47:34 +00006460# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006461#endif
6462
6463#ifdef FEAT_LANGMAP
6464 /* 'langmap' */
6465 else if (varp == &p_langmap)
6466 langmap_set();
6467#endif
6468
6469#ifdef FEAT_LINEBREAK
6470 /* 'breakat' */
6471 else if (varp == &p_breakat)
6472 fill_breakat_flags();
6473#endif
6474
6475#ifdef FEAT_TITLE
6476 /* 'titlestring' and 'iconstring' */
6477 else if (varp == &p_titlestring || varp == &p_iconstring)
6478 {
6479# ifdef FEAT_STL_OPT
6480 int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
6481
6482 /* NULL => statusline syntax */
6483 if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
6484 stl_syntax |= flagval;
6485 else
6486 stl_syntax &= ~flagval;
6487# endif
6488 did_set_title(varp == &p_iconstring);
6489
6490 }
6491#endif
6492
6493#ifdef FEAT_GUI
6494 /* 'guioptions' */
6495 else if (varp == &p_go)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006496 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006497 gui_init_which_components(oldval);
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006498 redraw_gui_only = TRUE;
6499 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006500#endif
6501
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006502#if defined(FEAT_GUI_TABLINE)
6503 /* 'guitablabel' */
6504 else if (varp == &p_gtl)
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006505 {
Bram Moolenaar18144c82006-04-12 21:52:12 +00006506 redraw_tabline = TRUE;
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00006507 redraw_gui_only = TRUE;
6508 }
6509 /* 'guitabtooltip' */
6510 else if (varp == &p_gtt)
6511 {
6512 redraw_gui_only = TRUE;
6513 }
Bram Moolenaar5c8837f2006-02-25 21:52:33 +00006514#endif
6515
Bram Moolenaar071d4272004-06-13 20:20:40 +00006516#if defined(FEAT_MOUSE_TTY) && (defined(UNIX) || defined(VMS))
6517 /* 'ttymouse' */
6518 else if (varp == &p_ttym)
6519 {
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00006520 /* Switch the mouse off before changing the escape sequences used for
6521 * that. */
6522 mch_setmouse(FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006523 if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
6524 errmsg = e_invarg;
6525 else
6526 check_mouse_termcode();
Bram Moolenaar6bb68362005-03-22 23:03:44 +00006527 if (termcap_active)
6528 setmouse(); /* may switch it on again */
Bram Moolenaar071d4272004-06-13 20:20:40 +00006529 }
6530#endif
6531
6532#ifdef FEAT_VISUAL
6533 /* 'selection' */
6534 else if (varp == &p_sel)
6535 {
6536 if (*p_sel == NUL
6537 || check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
6538 errmsg = e_invarg;
6539 }
6540
6541 /* 'selectmode' */
6542 else if (varp == &p_slm)
6543 {
6544 if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
6545 errmsg = e_invarg;
6546 }
6547#endif
6548
6549#ifdef FEAT_BROWSE
6550 /* 'browsedir' */
6551 else if (varp == &p_bsdir)
6552 {
6553 if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
6554 && !mch_isdir(p_bsdir))
6555 errmsg = e_invarg;
6556 }
6557#endif
6558
6559#ifdef FEAT_VISUAL
6560 /* 'keymodel' */
6561 else if (varp == &p_km)
6562 {
6563 if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
6564 errmsg = e_invarg;
6565 else
6566 {
6567 km_stopsel = (vim_strchr(p_km, 'o') != NULL);
6568 km_startsel = (vim_strchr(p_km, 'a') != NULL);
6569 }
6570 }
6571#endif
6572
6573 /* 'mousemodel' */
6574 else if (varp == &p_mousem)
6575 {
6576 if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
6577 errmsg = e_invarg;
6578#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
6579 else if (*p_mousem != *oldval)
6580 /* Changed from "extend" to "popup" or "popup_setpos" or vv: need
6581 * to create or delete the popup menus. */
6582 gui_motif_update_mousemodel(root_menu);
6583#endif
6584 }
6585
6586 /* 'switchbuf' */
6587 else if (varp == &p_swb)
6588 {
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00006589 if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006590 errmsg = e_invarg;
6591 }
6592
6593 /* 'debug' */
6594 else if (varp == &p_debug)
6595 {
Bram Moolenaar57657d82006-04-21 22:12:41 +00006596 if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006597 errmsg = e_invarg;
6598 }
6599
6600 /* 'display' */
6601 else if (varp == &p_dy)
6602 {
6603 if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
6604 errmsg = e_invarg;
6605 else
6606 (void)init_chartab();
6607
6608 }
6609
6610#ifdef FEAT_VERTSPLIT
6611 /* 'eadirection' */
6612 else if (varp == &p_ead)
6613 {
6614 if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
6615 errmsg = e_invarg;
6616 }
6617#endif
6618
6619#ifdef FEAT_CLIPBOARD
6620 /* 'clipboard' */
6621 else if (varp == &p_cb)
6622 errmsg = check_clipboard_option();
6623#endif
6624
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00006625#ifdef FEAT_SPELL
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006626 /* When 'spelllang' or 'spellfile' is set and there is a window for this
6627 * buffer in which 'spell' is set load the wordlists. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006628 else if (varp == &(curbuf->b_s.b_p_spl) || varp == &(curbuf->b_s.b_p_spf))
Bram Moolenaar217ad922005-03-20 22:37:15 +00006629 {
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006630 win_T *wp;
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006631 int l;
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006632
Bram Moolenaar860cae12010-06-05 23:22:07 +02006633 if (varp == &(curbuf->b_s.b_p_spf))
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006634 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006635 l = (int)STRLEN(curbuf->b_s.b_p_spf);
6636 if (l > 0 && (l < 4 || STRCMP(curbuf->b_s.b_p_spf + l - 4,
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006637 ".add") != 0))
6638 errmsg = e_invarg;
6639 }
6640
6641 if (errmsg == NULL)
6642 {
6643 FOR_ALL_WINDOWS(wp)
6644 if (wp->w_buffer == curbuf && wp->w_p_spell)
6645 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006646 errmsg = did_set_spelllang(wp);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006647# ifdef FEAT_WINDOWS
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006648 break;
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00006649# endif
Bram Moolenaar9ba0eb82005-06-13 22:28:56 +00006650 }
6651 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006652 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006653 /* When 'spellcapcheck' is set compile the regexp program. */
Bram Moolenaar860cae12010-06-05 23:22:07 +02006654 else if (varp == &(curwin->w_s->b_p_spc))
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006655 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02006656 errmsg = compile_cap_prog(curwin->w_s);
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00006657 }
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006658 /* 'spellsuggest' */
6659 else if (varp == &p_sps)
6660 {
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +00006661 if (spell_check_sps() != OK)
Bram Moolenaard857f0e2005-06-21 22:37:39 +00006662 errmsg = e_invarg;
6663 }
Bram Moolenaar8aff23a2005-08-19 20:40:30 +00006664 /* 'mkspellmem' */
6665 else if (varp == &p_msm)
6666 {
6667 if (spell_check_msm() != OK)
6668 errmsg = e_invarg;
6669 }
Bram Moolenaar217ad922005-03-20 22:37:15 +00006670#endif
6671
Bram Moolenaar071d4272004-06-13 20:20:40 +00006672#ifdef FEAT_QUICKFIX
6673 /* When 'bufhidden' is set, check for valid value. */
6674 else if (gvarp == &p_bh)
6675 {
6676 if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
6677 errmsg = e_invarg;
6678 }
6679
6680 /* When 'buftype' is set, check for valid value. */
6681 else if (gvarp == &p_bt)
6682 {
6683 if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
6684 errmsg = e_invarg;
6685 else
6686 {
6687# ifdef FEAT_WINDOWS
6688 if (curwin->w_status_height)
6689 {
6690 curwin->w_redr_status = TRUE;
6691 redraw_later(VALID);
6692 }
6693# endif
6694 curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
Bram Moolenaar5075aad2010-01-27 15:58:13 +01006695# ifdef FEAT_TITLE
6696 redraw_titles();
6697# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006698 }
6699 }
6700#endif
6701
6702#ifdef FEAT_STL_OPT
6703 /* 'statusline' or 'rulerformat' */
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006704 else if (gvarp == &p_stl || varp == &p_ruf)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006705 {
6706 int wid;
6707
6708 if (varp == &p_ruf) /* reset ru_wid first */
6709 ru_wid = 0;
6710 s = *varp;
6711 if (varp == &p_ruf && *s == '%')
6712 {
6713 /* set ru_wid if 'ruf' starts with "%99(" */
6714 if (*++s == '-') /* ignore a '-' */
6715 s++;
6716 wid = getdigits(&s);
6717 if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
6718 ru_wid = wid;
6719 else
6720 errmsg = check_stl_option(p_ruf);
6721 }
Bram Moolenaar3709e7c2006-08-08 14:29:16 +00006722 /* check 'statusline' only if it doesn't start with "%!" */
Bram Moolenaar177d8c62007-09-06 11:33:37 +00006723 else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006724 errmsg = check_stl_option(s);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00006725 if (varp == &p_ruf && errmsg == NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006726 comp_col();
6727 }
6728#endif
6729
6730#ifdef FEAT_INS_EXPAND
6731 /* check if it is a valid value for 'complete' -- Acevedo */
6732 else if (gvarp == &p_cpt)
6733 {
6734 for (s = *varp; *s;)
6735 {
Bram Moolenaar11b73d62012-06-29 15:51:30 +02006736 while (*s == ',' || *s == ' ')
Bram Moolenaar071d4272004-06-13 20:20:40 +00006737 s++;
6738 if (!*s)
6739 break;
6740 if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
6741 {
6742 errmsg = illegal_char(errbuf, *s);
6743 break;
6744 }
6745 if (*++s != NUL && *s != ',' && *s != ' ')
6746 {
6747 if (s[-1] == 'k' || s[-1] == 's')
6748 {
6749 /* skip optional filename after 'k' and 's' */
6750 while (*s && *s != ',' && *s != ' ')
6751 {
6752 if (*s == '\\')
6753 ++s;
6754 ++s;
6755 }
6756 }
6757 else
6758 {
6759 if (errbuf != NULL)
6760 {
6761 sprintf((char *)errbuf,
6762 _("E535: Illegal character after <%c>"),
6763 *--s);
6764 errmsg = errbuf;
6765 }
6766 else
6767 errmsg = (char_u *)"";
6768 break;
6769 }
6770 }
6771 }
6772 }
Bram Moolenaar1c7715d2005-10-03 22:02:18 +00006773
6774 /* 'completeopt' */
6775 else if (varp == &p_cot)
6776 {
6777 if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
6778 errmsg = e_invarg;
6779 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006780#endif /* FEAT_INS_EXPAND */
6781
6782
6783#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32)
6784 else if (varp == &p_toolbar)
6785 {
6786 if (opt_strings_flags(p_toolbar, p_toolbar_values,
6787 &toolbar_flags, TRUE) != OK)
6788 errmsg = e_invarg;
6789 else
6790 {
6791 out_flush();
6792 gui_mch_show_toolbar((toolbar_flags &
6793 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6794 }
6795 }
6796#endif
6797
Bram Moolenaar182c5be2010-06-25 05:37:59 +02006798#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
Bram Moolenaar071d4272004-06-13 20:20:40 +00006799 /* 'toolbariconsize': GTK+ 2 only */
6800 else if (varp == &p_tbis)
6801 {
6802 if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
6803 errmsg = e_invarg;
6804 else
6805 {
6806 out_flush();
6807 gui_mch_show_toolbar((toolbar_flags &
6808 (TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
6809 }
6810 }
6811#endif
6812
6813 /* 'pastetoggle': translate key codes like in a mapping */
6814 else if (varp == &p_pt)
6815 {
6816 if (*p_pt)
6817 {
Bram Moolenaar9c102382006-05-03 21:26:49 +00006818 (void)replace_termcodes(p_pt, &p, TRUE, TRUE, FALSE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00006819 if (p != NULL)
6820 {
6821 if (new_value_alloced)
6822 free_string_option(p_pt);
6823 p_pt = p;
6824 new_value_alloced = TRUE;
6825 }
6826 }
6827 }
6828
6829 /* 'backspace' */
6830 else if (varp == &p_bs)
6831 {
6832 if (VIM_ISDIGIT(*p_bs))
6833 {
6834 if (*p_bs >'2' || p_bs[1] != NUL)
6835 errmsg = e_invarg;
6836 }
6837 else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
6838 errmsg = e_invarg;
6839 }
6840
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00006841#ifdef FEAT_MBYTE
Bram Moolenaar071d4272004-06-13 20:20:40 +00006842 /* 'casemap' */
6843 else if (varp == &p_cmp)
6844 {
6845 if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
6846 errmsg = e_invarg;
6847 }
Bram Moolenaarfa1d1402006-03-25 21:59:56 +00006848#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006849
6850#ifdef FEAT_DIFF
6851 /* 'diffopt' */
6852 else if (varp == &p_dip)
6853 {
6854 if (diffopt_changed() == FAIL)
6855 errmsg = e_invarg;
6856 }
6857#endif
6858
6859#ifdef FEAT_FOLDING
6860 /* 'foldmethod' */
6861 else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
6862 {
6863 if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
6864 || *curwin->w_p_fdm == NUL)
6865 errmsg = e_invarg;
6866 else
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01006867 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00006868 foldUpdateAll(curwin);
Bram Moolenaarf4d7f942010-02-24 14:34:19 +01006869 if (foldmethodIsDiff(curwin))
6870 newFoldLevel();
6871 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006872 }
6873# ifdef FEAT_EVAL
6874 /* 'foldexpr' */
6875 else if (varp == &curwin->w_p_fde)
6876 {
6877 if (foldmethodIsExpr(curwin))
6878 foldUpdateAll(curwin);
6879 }
6880# endif
6881 /* 'foldmarker' */
6882 else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
6883 {
6884 p = vim_strchr(*varp, ',');
6885 if (p == NULL)
6886 errmsg = (char_u *)N_("E536: comma required");
6887 else if (p == *varp || p[1] == NUL)
6888 errmsg = e_invarg;
6889 else if (foldmethodIsMarker(curwin))
6890 foldUpdateAll(curwin);
6891 }
6892 /* 'commentstring' */
6893 else if (gvarp == &p_cms)
6894 {
6895 if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
6896 errmsg = (char_u *)N_("E537: 'commentstring' must be empty or contain %s");
6897 }
6898 /* 'foldopen' */
6899 else if (varp == &p_fdo)
6900 {
6901 if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
6902 errmsg = e_invarg;
6903 }
6904 /* 'foldclose' */
6905 else if (varp == &p_fcl)
6906 {
6907 if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
6908 errmsg = e_invarg;
6909 }
Bram Moolenaar7fc904b2006-04-13 20:37:35 +00006910 /* 'foldignore' */
6911 else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
6912 {
6913 if (foldmethodIsIndent(curwin))
6914 foldUpdateAll(curwin);
6915 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00006916#endif
6917
6918#ifdef FEAT_VIRTUALEDIT
6919 /* 'virtualedit' */
6920 else if (varp == &p_ve)
6921 {
6922 if (opt_strings_flags(p_ve, p_ve_values, &ve_flags, TRUE) != OK)
6923 errmsg = e_invarg;
6924 else if (STRCMP(p_ve, oldval) != 0)
6925 {
6926 /* Recompute cursor position in case the new 've' setting
6927 * changes something. */
6928 validate_virtcol();
6929 coladvance(curwin->w_virtcol);
6930 }
6931 }
6932#endif
6933
6934#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
6935 else if (varp == &p_csqf)
6936 {
6937 if (p_csqf != NULL)
6938 {
6939 p = p_csqf;
6940 while (*p != NUL)
6941 {
6942 if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
6943 || p[1] == NUL
6944 || vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
6945 || (p[2] != NUL && p[2] != ','))
6946 {
6947 errmsg = e_invarg;
6948 break;
6949 }
6950 else if (p[2] == NUL)
6951 break;
6952 else
6953 p += 3;
6954 }
6955 }
6956 }
6957#endif
6958
6959 /* Options that are a list of flags. */
6960 else
6961 {
6962 p = NULL;
6963 if (varp == &p_ww)
6964 p = (char_u *)WW_ALL;
6965 if (varp == &p_shm)
6966 p = (char_u *)SHM_ALL;
6967 else if (varp == &(p_cpo))
6968 p = (char_u *)CPO_ALL;
6969 else if (varp == &(curbuf->b_p_fo))
6970 p = (char_u *)FO_ALL;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02006971#ifdef FEAT_CONCEAL
6972 else if (varp == &curwin->w_p_cocu)
6973 p = (char_u *)COCU_ALL;
6974#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00006975 else if (varp == &p_mouse)
6976 {
6977#ifdef FEAT_MOUSE
6978 p = (char_u *)MOUSE_ALL;
6979#else
6980 if (*p_mouse != NUL)
6981 errmsg = (char_u *)N_("E538: No mouse support");
6982#endif
6983 }
6984#if defined(FEAT_GUI)
6985 else if (varp == &p_go)
6986 p = (char_u *)GO_ALL;
6987#endif
6988 if (p != NULL)
6989 {
6990 for (s = *varp; *s; ++s)
6991 if (vim_strchr(p, *s) == NULL)
6992 {
6993 errmsg = illegal_char(errbuf, *s);
6994 break;
6995 }
6996 }
6997 }
6998
6999 /*
7000 * If error detected, restore the previous value.
7001 */
7002 if (errmsg != NULL)
7003 {
7004 if (new_value_alloced)
7005 free_string_option(*varp);
7006 *varp = oldval;
7007 /*
7008 * When resetting some values, need to act on it.
7009 */
7010 if (did_chartab)
7011 (void)init_chartab();
7012 if (varp == &p_hl)
7013 (void)highlight_changed();
7014 }
7015 else
7016 {
7017#ifdef FEAT_EVAL
7018 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007019 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007020#endif
7021 /*
7022 * Free string options that are in allocated memory.
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007023 * Use "free_oldval", because recursiveness may change the flags under
7024 * our fingers (esp. init_highlight()).
Bram Moolenaar071d4272004-06-13 20:20:40 +00007025 */
Bram Moolenaarc0197e22004-09-13 20:26:32 +00007026 if (free_oldval)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007027 free_string_option(oldval);
7028 if (new_value_alloced)
7029 options[opt_idx].flags |= P_ALLOCED;
7030 else
7031 options[opt_idx].flags &= ~P_ALLOCED;
7032
7033 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
Bram Moolenaara23ccb82006-02-27 00:08:02 +00007034 && ((int)options[opt_idx].indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007035 {
7036 /* global option with local value set to use global value; free
7037 * the local value and make it empty */
7038 p = get_varp_scope(&(options[opt_idx]), OPT_LOCAL);
7039 free_string_option(*(char_u **)p);
7040 *(char_u **)p = empty_option;
7041 }
7042
7043 /* May set global value for local option. */
7044 else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
7045 set_string_option_global(opt_idx, varp);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007046
7047#ifdef FEAT_AUTOCMD
7048 /*
7049 * Trigger the autocommand only after setting the flags.
7050 */
7051# ifdef FEAT_SYN_HL
7052 /* When 'syntax' is set, load the syntax of that name */
7053 if (varp == &(curbuf->b_p_syn))
7054 {
7055 apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn,
7056 curbuf->b_fname, TRUE, curbuf);
7057 }
7058# endif
7059 else if (varp == &(curbuf->b_p_ft))
7060 {
7061 /* 'filetype' is set, trigger the FileType autocommand */
7062 did_filetype = TRUE;
7063 apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft,
7064 curbuf->b_fname, TRUE, curbuf);
7065 }
7066#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007067#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02007068 if (varp == &(curwin->w_s->b_p_spl))
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007069 {
7070 char_u fname[200];
7071
7072 /*
7073 * Source the spell/LANG.vim in 'runtimepath'.
7074 * They could set 'spellcapcheck' depending on the language.
7075 * Use the first name in 'spelllang' up to '_region' or
7076 * '.encoding'.
7077 */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007078 for (p = curwin->w_s->b_p_spl; *p != NUL; ++p)
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007079 if (vim_strchr((char_u *)"_.,", *p) != NULL)
7080 break;
7081 vim_snprintf((char *)fname, 200, "spell/%.*s.vim",
Bram Moolenaar860cae12010-06-05 23:22:07 +02007082 (int)(p - curwin->w_s->b_p_spl), curwin->w_s->b_p_spl);
Bram Moolenaar90cfdbe2005-08-12 19:59:19 +00007083 source_runtime(fname, TRUE);
7084 }
7085#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007086 }
7087
7088#ifdef FEAT_MOUSE
7089 if (varp == &p_mouse)
7090 {
7091# ifdef FEAT_MOUSE_TTY
7092 if (*p_mouse == NUL)
7093 mch_setmouse(FALSE); /* switch mouse off */
7094 else
7095# endif
7096 setmouse(); /* in case 'mouse' changed */
7097 }
7098#endif
7099
Bram Moolenaar913077c2012-03-28 19:59:04 +02007100 if (curwin->w_curswant != MAXCOL
7101 && (options[opt_idx].flags & (P_CURSWANT | P_RCLR)) != 0)
7102 curwin->w_set_curswant = TRUE;
7103
Bram Moolenaarfaff14a2009-02-04 16:29:07 +00007104#ifdef FEAT_GUI
7105 /* check redraw when it's not a GUI option or the GUI is active. */
7106 if (!redraw_gui_only || gui.in_use)
7107#endif
7108 check_redraw(options[opt_idx].flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007109
7110 return errmsg;
7111}
7112
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007113#if defined(FEAT_SYN_HL) || defined(PROTO)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007114/*
7115 * Simple int comparison function for use with qsort()
7116 */
7117 static int
7118int_cmp(a, b)
7119 const void *a;
7120 const void *b;
7121{
7122 return *(const int *)a - *(const int *)b;
7123}
7124
7125/*
7126 * Handle setting 'colorcolumn' or 'textwidth' in window "wp".
7127 * Returns error message, NULL if it's OK.
7128 */
7129 char_u *
7130check_colorcolumn(wp)
7131 win_T *wp;
7132{
7133 char_u *s;
7134 int col;
7135 int count = 0;
7136 int color_cols[256];
7137 int i;
7138 int j = 0;
7139
Bram Moolenaar50f834d2011-09-21 13:40:17 +02007140 if (wp->w_buffer == NULL)
7141 return NULL; /* buffer was closed */
7142
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007143 for (s = wp->w_p_cc; *s != NUL && count < 255;)
Bram Moolenaar1a384422010-07-14 19:53:30 +02007144 {
7145 if (*s == '-' || *s == '+')
7146 {
7147 /* -N and +N: add to 'textwidth' */
7148 col = (*s == '-') ? -1 : 1;
7149 ++s;
7150 if (!VIM_ISDIGIT(*s))
7151 return e_invarg;
7152 col = col * getdigits(&s);
7153 if (wp->w_buffer->b_p_tw == 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007154 goto skip; /* 'textwidth' not set, skip this item */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007155 col += wp->w_buffer->b_p_tw;
7156 if (col < 0)
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007157 goto skip;
Bram Moolenaar1a384422010-07-14 19:53:30 +02007158 }
7159 else if (VIM_ISDIGIT(*s))
7160 col = getdigits(&s);
7161 else
7162 return e_invarg;
7163 color_cols[count++] = col - 1; /* 1-based to 0-based */
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007164skip:
Bram Moolenaar1a384422010-07-14 19:53:30 +02007165 if (*s == NUL)
7166 break;
7167 if (*s != ',')
7168 return e_invarg;
Bram Moolenaar11505dc2010-07-16 21:29:06 +02007169 if (*++s == NUL)
7170 return e_invarg; /* illegal trailing comma as in "set cc=80," */
Bram Moolenaar1a384422010-07-14 19:53:30 +02007171 }
7172
7173 vim_free(wp->w_p_cc_cols);
7174 if (count == 0)
7175 wp->w_p_cc_cols = NULL;
7176 else
7177 {
7178 wp->w_p_cc_cols = (int *)alloc((unsigned)sizeof(int) * (count + 1));
7179 if (wp->w_p_cc_cols != NULL)
7180 {
7181 /* sort the columns for faster usage on screen redraw inside
7182 * win_line() */
7183 qsort(color_cols, count, sizeof(int), int_cmp);
7184
7185 for (i = 0; i < count; ++i)
7186 /* skip duplicates */
7187 if (j == 0 || wp->w_p_cc_cols[j - 1] != color_cols[i])
7188 wp->w_p_cc_cols[j++] = color_cols[i];
7189 wp->w_p_cc_cols[j] = -1; /* end marker */
7190 }
7191 }
7192
7193 return NULL; /* no error */
7194}
7195#endif
7196
Bram Moolenaar071d4272004-06-13 20:20:40 +00007197/*
7198 * Handle setting 'listchars' or 'fillchars'.
7199 * Returns error message, NULL if it's OK.
7200 */
7201 static char_u *
7202set_chars_option(varp)
7203 char_u **varp;
7204{
7205 int round, i, len, entries;
7206 char_u *p, *s;
7207 int c1, c2 = 0;
7208 struct charstab
7209 {
7210 int *cp;
7211 char *name;
7212 };
7213#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7214 static struct charstab filltab[] =
7215 {
7216 {&fill_stl, "stl"},
7217 {&fill_stlnc, "stlnc"},
7218 {&fill_vert, "vert"},
7219 {&fill_fold, "fold"},
7220 {&fill_diff, "diff"},
7221 };
7222#endif
7223 static struct charstab lcstab[] =
7224 {
7225 {&lcs_eol, "eol"},
7226 {&lcs_ext, "extends"},
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00007227 {&lcs_nbsp, "nbsp"},
Bram Moolenaar071d4272004-06-13 20:20:40 +00007228 {&lcs_prec, "precedes"},
7229 {&lcs_tab2, "tab"},
7230 {&lcs_trail, "trail"},
Bram Moolenaar860cae12010-06-05 23:22:07 +02007231#ifdef FEAT_CONCEAL
7232 {&lcs_conceal, "conceal"},
7233#else
7234 {NULL, "conceal"},
7235#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007236 };
7237 struct charstab *tab;
7238
7239#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7240 if (varp == &p_lcs)
7241#endif
7242 {
7243 tab = lcstab;
7244 entries = sizeof(lcstab) / sizeof(struct charstab);
7245 }
7246#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7247 else
7248 {
7249 tab = filltab;
7250 entries = sizeof(filltab) / sizeof(struct charstab);
7251 }
7252#endif
7253
7254 /* first round: check for valid value, second round: assign values */
7255 for (round = 0; round <= 1; ++round)
7256 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007257 if (round > 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007258 {
7259 /* After checking that the value is valid: set defaults: space for
7260 * 'fillchars', NUL for 'listchars' */
7261 for (i = 0; i < entries; ++i)
Bram Moolenaar860cae12010-06-05 23:22:07 +02007262 if (tab[i].cp != NULL)
7263 *(tab[i].cp) = (varp == &p_lcs ? NUL : ' ');
Bram Moolenaar071d4272004-06-13 20:20:40 +00007264 if (varp == &p_lcs)
7265 lcs_tab1 = NUL;
7266#if defined(FEAT_WINDOWS) || defined(FEAT_FOLDING)
7267 else
7268 fill_diff = '-';
7269#endif
7270 }
7271 p = *varp;
7272 while (*p)
7273 {
7274 for (i = 0; i < entries; ++i)
7275 {
7276 len = (int)STRLEN(tab[i].name);
7277 if (STRNCMP(p, tab[i].name, len) == 0
7278 && p[len] == ':'
7279 && p[len + 1] != NUL)
7280 {
7281 s = p + len + 1;
7282#ifdef FEAT_MBYTE
7283 c1 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007284 if (mb_char2cells(c1) > 1)
7285 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007286#else
7287 c1 = *s++;
7288#endif
7289 if (tab[i].cp == &lcs_tab2)
7290 {
7291 if (*s == NUL)
7292 continue;
7293#ifdef FEAT_MBYTE
7294 c2 = mb_ptr2char_adv(&s);
Bram Moolenaar910f66f2006-04-05 20:41:53 +00007295 if (mb_char2cells(c2) > 1)
7296 continue;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007297#else
7298 c2 = *s++;
7299#endif
7300 }
7301 if (*s == ',' || *s == NUL)
7302 {
7303 if (round)
7304 {
7305 if (tab[i].cp == &lcs_tab2)
7306 {
7307 lcs_tab1 = c1;
7308 lcs_tab2 = c2;
7309 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02007310 else if (tab[i].cp != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007311 *(tab[i].cp) = c1;
7312
7313 }
7314 p = s;
7315 break;
7316 }
7317 }
7318 }
7319
7320 if (i == entries)
7321 return e_invarg;
7322 if (*p == ',')
7323 ++p;
7324 }
7325 }
7326
7327 return NULL; /* no error */
7328}
7329
7330#ifdef FEAT_STL_OPT
7331/*
7332 * Check validity of options with the 'statusline' format.
7333 * Return error message or NULL.
7334 */
7335 char_u *
7336check_stl_option(s)
7337 char_u *s;
7338{
7339 int itemcnt = 0;
7340 int groupdepth = 0;
7341 static char_u errbuf[80];
7342
7343 while (*s && itemcnt < STL_MAX_ITEM)
7344 {
7345 /* Check for valid keys after % sequences */
7346 while (*s && *s != '%')
7347 s++;
7348 if (!*s)
7349 break;
7350 s++;
7351 if (*s != '%' && *s != ')')
7352 ++itemcnt;
7353 if (*s == '%' || *s == STL_TRUNCMARK || *s == STL_MIDDLEMARK)
7354 {
7355 s++;
7356 continue;
7357 }
7358 if (*s == ')')
7359 {
7360 s++;
7361 if (--groupdepth < 0)
7362 break;
7363 continue;
7364 }
7365 if (*s == '-')
7366 s++;
7367 while (VIM_ISDIGIT(*s))
7368 s++;
Bram Moolenaar238a5642006-02-21 22:12:05 +00007369 if (*s == STL_USER_HL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007370 continue;
7371 if (*s == '.')
7372 {
7373 s++;
7374 while (*s && VIM_ISDIGIT(*s))
7375 s++;
7376 }
7377 if (*s == '(')
7378 {
7379 groupdepth++;
7380 continue;
7381 }
7382 if (vim_strchr(STL_ALL, *s) == NULL)
7383 {
7384 return illegal_char(errbuf, *s);
7385 }
7386 if (*s == '{')
7387 {
7388 s++;
7389 while (*s != '}' && *s)
7390 s++;
7391 if (*s != '}')
7392 return (char_u *)N_("E540: Unclosed expression sequence");
7393 }
7394 }
7395 if (itemcnt >= STL_MAX_ITEM)
7396 return (char_u *)N_("E541: too many items");
7397 if (groupdepth != 0)
7398 return (char_u *)N_("E542: unbalanced groups");
7399 return NULL;
7400}
7401#endif
7402
7403#ifdef FEAT_CLIPBOARD
7404/*
7405 * Extract the items in the 'clipboard' option and set global values.
7406 */
7407 static char_u *
7408check_clipboard_option()
7409{
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007410 int new_unnamed = 0;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007411 int new_autoselect_star = FALSE;
7412 int new_autoselect_plus = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007413 int new_autoselectml = FALSE;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007414 int new_html = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007415 regprog_T *new_exclude_prog = NULL;
7416 char_u *errmsg = NULL;
7417 char_u *p;
7418
7419 for (p = p_cb; *p != NUL; )
7420 {
7421 if (STRNCMP(p, "unnamed", 7) == 0 && (p[7] == ',' || p[7] == NUL))
7422 {
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007423 new_unnamed |= CLIP_UNNAMED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007424 p += 7;
7425 }
Bram Moolenaar11b73d62012-06-29 15:51:30 +02007426 else if (STRNCMP(p, "unnamedplus", 11) == 0
Bram Moolenaarbf9680e2010-12-02 21:43:16 +01007427 && (p[11] == ',' || p[11] == NUL))
7428 {
7429 new_unnamed |= CLIP_UNNAMED_PLUS;
7430 p += 11;
7431 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007432 else if (STRNCMP(p, "autoselect", 10) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007433 && (p[10] == ',' || p[10] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007434 {
Bram Moolenaar89af4392012-07-10 18:31:54 +02007435 new_autoselect_star = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007436 p += 10;
7437 }
Bram Moolenaar89af4392012-07-10 18:31:54 +02007438 else if (STRNCMP(p, "autoselectplus", 14) == 0
7439 && (p[14] == ',' || p[14] == NUL))
7440 {
7441 new_autoselect_plus = TRUE;
7442 p += 14;
7443 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007444 else if (STRNCMP(p, "autoselectml", 12) == 0
Bram Moolenaar89af4392012-07-10 18:31:54 +02007445 && (p[12] == ',' || p[12] == NUL))
Bram Moolenaar071d4272004-06-13 20:20:40 +00007446 {
7447 new_autoselectml = TRUE;
7448 p += 12;
7449 }
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007450 else if (STRNCMP(p, "html", 4) == 0 && (p[4] == ',' || p[4] == NUL))
7451 {
7452 new_html = TRUE;
7453 p += 4;
7454 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007455 else if (STRNCMP(p, "exclude:", 8) == 0 && new_exclude_prog == NULL)
7456 {
7457 p += 8;
7458 new_exclude_prog = vim_regcomp(p, RE_MAGIC);
7459 if (new_exclude_prog == NULL)
7460 errmsg = e_invarg;
7461 break;
7462 }
7463 else
7464 {
7465 errmsg = e_invarg;
7466 break;
7467 }
7468 if (*p == ',')
7469 ++p;
7470 }
7471 if (errmsg == NULL)
7472 {
7473 clip_unnamed = new_unnamed;
Bram Moolenaar89af4392012-07-10 18:31:54 +02007474 clip_autoselect_star = new_autoselect_star;
7475 clip_autoselect_plus = new_autoselect_plus;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007476 clip_autoselectml = new_autoselectml;
Bram Moolenaar3a6eaa52009-06-16 13:23:06 +00007477 clip_html = new_html;
Bram Moolenaar071d4272004-06-13 20:20:40 +00007478 vim_free(clip_exclude_prog);
7479 clip_exclude_prog = new_exclude_prog;
Bram Moolenaara76638f2010-06-05 12:49:46 +02007480#ifdef FEAT_GUI_GTK
7481 if (gui.in_use)
7482 {
7483 gui_gtk_set_selection_targets();
7484 gui_gtk_set_dnd_targets();
7485 }
7486#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007487 }
7488 else
7489 vim_free(new_exclude_prog);
7490
7491 return errmsg;
7492}
7493#endif
7494
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007495#ifdef FEAT_SPELL
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007496/*
7497 * Set curbuf->b_cap_prog to the regexp program for 'spellcapcheck'.
7498 * Return error message when failed, NULL when OK.
7499 */
7500 static char_u *
Bram Moolenaar860cae12010-06-05 23:22:07 +02007501compile_cap_prog(synblock)
7502 synblock_T *synblock;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007503{
Bram Moolenaar860cae12010-06-05 23:22:07 +02007504 regprog_T *rp = synblock->b_cap_prog;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007505 char_u *re;
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007506
Bram Moolenaar860cae12010-06-05 23:22:07 +02007507 if (*synblock->b_p_spc == NUL)
7508 synblock->b_cap_prog = NULL;
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007509 else
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007510 {
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007511 /* Prepend a ^ so that we only match at one column */
Bram Moolenaar860cae12010-06-05 23:22:07 +02007512 re = concat_str((char_u *)"^", synblock->b_p_spc);
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007513 if (re != NULL)
7514 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007515 synblock->b_cap_prog = vim_regcomp(re, RE_MAGIC);
7516 if (synblock->b_cap_prog == NULL)
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007517 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007518 synblock->b_cap_prog = rp; /* restore the previous program */
Bram Moolenaar18f9a792005-12-08 22:02:51 +00007519 return e_invarg;
7520 }
7521 vim_free(re);
7522 }
Bram Moolenaar0d9c26d2005-07-02 23:19:16 +00007523 }
7524
7525 vim_free(rp);
7526 return NULL;
7527}
7528#endif
7529
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007530#if defined(FEAT_EVAL) || defined(PROTO)
7531/*
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007532 * Set the scriptID for an option, taking care of setting the buffer- or
7533 * window-local value.
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007534 */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007535 static void
7536set_option_scriptID_idx(opt_idx, opt_flags, id)
7537 int opt_idx;
7538 int opt_flags;
7539 int id;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007540{
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007541 int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
7542 int indir = (int)options[opt_idx].indir;
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007543
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007544 /* Remember where the option was set. For local options need to do that
7545 * in the buffer or window structure. */
7546 if (both || (opt_flags & OPT_GLOBAL) || (indir & (PV_BUF|PV_WIN)) == 0)
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007547 options[opt_idx].scriptID = id;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007548 if (both || (opt_flags & OPT_LOCAL))
7549 {
7550 if (indir & PV_BUF)
7551 curbuf->b_p_scriptID[indir & PV_MASK] = id;
7552 else if (indir & PV_WIN)
7553 curwin->w_p_scriptID[indir & PV_MASK] = id;
7554 }
Bram Moolenaard1f56e62006-02-22 21:25:37 +00007555}
7556#endif
7557
Bram Moolenaar071d4272004-06-13 20:20:40 +00007558/*
7559 * Set the value of a boolean option, and take care of side effects.
7560 * Returns NULL for success, or an error message for an error.
7561 */
7562 static char_u *
7563set_bool_option(opt_idx, varp, value, opt_flags)
7564 int opt_idx; /* index in options[] table */
7565 char_u *varp; /* pointer to the option variable */
7566 int value; /* new value */
7567 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
7568{
7569 int old_value = *(int *)varp;
7570
Bram Moolenaar071d4272004-06-13 20:20:40 +00007571 /* Disallow changing some options from secure mode */
7572 if ((secure
7573#ifdef HAVE_SANDBOX
7574 || sandbox != 0
7575#endif
7576 ) && (options[opt_idx].flags & P_SECURE))
7577 return e_secure;
7578
7579 *(int *)varp = value; /* set the new value */
7580#ifdef FEAT_EVAL
7581 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007582 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007583#endif
7584
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00007585#ifdef FEAT_GUI
7586 need_mouse_correct = TRUE;
7587#endif
7588
Bram Moolenaar071d4272004-06-13 20:20:40 +00007589 /* May set global value for local option. */
7590 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
7591 *(int *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = value;
7592
7593 /*
7594 * Handle side effects of changing a bool option.
7595 */
7596
7597 /* 'compatible' */
7598 if ((int *)varp == &p_cp)
7599 {
7600 compatible_set();
7601 }
7602
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007603#ifdef FEAT_PERSISTENT_UNDO
7604 /* 'undofile' */
7605 else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
7606 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007607 /* Only take action when the option was set. When reset we do not
7608 * delete the undo file, the option may be set again without making
7609 * any changes in between. */
7610 if (curbuf->b_p_udf || p_udf)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007611 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007612 char_u hash[UNDO_HASH_SIZE];
7613 buf_T *save_curbuf = curbuf;
7614
7615 for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007616 {
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007617 /* When 'undofile' is set globally: for every buffer, otherwise
7618 * only for the current buffer: Try to read in the undofile,
7619 * if one exists, the buffer wasn't changed and the buffer was
7620 * loaded */
7621 if ((curbuf == save_curbuf
7622 || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
7623 && !curbufIsChanged() && curbuf->b_ml.ml_mfp != NULL)
7624 {
7625 u_compute_hash(hash);
7626 u_read_undo(NULL, hash, curbuf->b_fname);
7627 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007628 }
Bram Moolenaare8d8fd22012-10-21 03:46:05 +02007629 curbuf = save_curbuf;
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007630 }
Bram Moolenaar374d32d2012-01-04 19:34:37 +01007631 }
7632#endif
7633
Bram Moolenaar20754022013-03-13 20:42:32 +01007634 /* If 'number' is set, reset 'relativenumber'. */
7635 /* If 'relativenumber' is set, reset 'number'. */
7636 else if ((int *)varp == &curwin->w_p_nu && curwin->w_p_nu)
Bram Moolenaar801f8b82009-07-29 13:42:05 +00007637 {
Bram Moolenaar20754022013-03-13 20:42:32 +01007638 curwin->w_p_rnu = FALSE;
7639
7640 /* Only reset the global value if the own value is set globally. */
7641 if (((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0))
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007642 curwin->w_allbuf_opt.wo_rnu = FALSE;
Bram Moolenaar20754022013-03-13 20:42:32 +01007643 }
7644 else if ((int *)varp == &curwin->w_p_rnu && curwin->w_p_rnu)
7645 {
7646 curwin->w_p_nu = FALSE;
7647
7648 /* Only reset the global value if the own value is set globally. */
7649 if (((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0))
Bram Moolenaarf4e5e862013-02-13 15:44:26 +01007650 curwin->w_allbuf_opt.wo_nu = FALSE;
Bram Moolenaar20754022013-03-13 20:42:32 +01007651 }
7652 else if ((int *)varp == &curwin->w_allbuf_opt.wo_nu
7653 && curwin->w_allbuf_opt.wo_nu)
7654 {
7655 curwin->w_allbuf_opt.wo_rnu = FALSE;
7656 }
7657 else if ((int *)varp == &curwin->w_allbuf_opt.wo_rnu
7658 && curwin->w_allbuf_opt.wo_rnu)
7659 {
7660 curwin->w_allbuf_opt.wo_nu = FALSE;
Bram Moolenaar801f8b82009-07-29 13:42:05 +00007661 }
7662
Bram Moolenaar071d4272004-06-13 20:20:40 +00007663 else if ((int *)varp == &curbuf->b_p_ro)
7664 {
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007665 /* when 'readonly' is reset globally, also reset readonlymode */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007666 if (!curbuf->b_p_ro && (opt_flags & OPT_LOCAL) == 0)
7667 readonlymode = FALSE;
Bram Moolenaard5cdbeb2005-10-10 20:59:28 +00007668
7669 /* when 'readonly' is set may give W10 again */
7670 if (curbuf->b_p_ro)
7671 curbuf->b_did_warn = FALSE;
7672
Bram Moolenaar071d4272004-06-13 20:20:40 +00007673#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007674 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007675#endif
7676 }
7677
Bram Moolenaar9c449722010-07-20 18:44:27 +02007678#ifdef FEAT_GUI
7679 else if ((int *)varp == &p_mh)
7680 {
7681 if (!p_mh)
7682 gui_mch_mousehide(FALSE);
7683 }
7684#endif
7685
Bram Moolenaara539df02010-08-01 14:35:05 +02007686#ifdef FEAT_TITLE
7687 /* when 'modifiable' is changed, redraw the window title */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007688 else if ((int *)varp == &curbuf->b_p_ma)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007689 {
7690 redraw_titles();
7691 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00007692 /* when 'endofline' is changed, redraw the window title */
7693 else if ((int *)varp == &curbuf->b_p_eol)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007694 {
7695 redraw_titles();
7696 }
7697# ifdef FEAT_MBYTE
7698 /* when 'bomb' is changed, redraw the window title and tab page text */
Bram Moolenaar83eb8852007-08-12 13:51:26 +00007699 else if ((int *)varp == &curbuf->b_p_bomb)
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007700 {
7701 redraw_titles();
7702 }
7703# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007704#endif
7705
7706 /* when 'bin' is set also set some other options */
7707 else if ((int *)varp == &curbuf->b_p_bin)
7708 {
7709 set_options_bin(old_value, curbuf->b_p_bin, opt_flags);
7710#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007711 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007712#endif
7713 }
7714
7715#ifdef FEAT_AUTOCMD
7716 /* when 'buflisted' changes, trigger autocommands */
7717 else if ((int *)varp == &curbuf->b_p_bl && old_value != curbuf->b_p_bl)
7718 {
7719 apply_autocmds(curbuf->b_p_bl ? EVENT_BUFADD : EVENT_BUFDELETE,
7720 NULL, NULL, TRUE, curbuf);
7721 }
7722#endif
7723
7724 /* when 'swf' is set, create swapfile, when reset remove swapfile */
7725 else if ((int *)varp == &curbuf->b_p_swf)
7726 {
7727 if (curbuf->b_p_swf && p_uc)
7728 ml_open_file(curbuf); /* create the swap file */
7729 else
Bram Moolenaard55de222007-05-06 13:38:48 +00007730 /* no need to reset curbuf->b_may_swap, ml_open_file() will check
7731 * buf->b_p_swf */
Bram Moolenaar071d4272004-06-13 20:20:40 +00007732 mf_close_file(curbuf, TRUE); /* remove the swap file */
7733 }
7734
7735 /* when 'terse' is set change 'shortmess' */
7736 else if ((int *)varp == &p_terse)
7737 {
7738 char_u *p;
7739
7740 p = vim_strchr(p_shm, SHM_SEARCH);
7741
7742 /* insert 's' in p_shm */
7743 if (p_terse && p == NULL)
7744 {
7745 STRCPY(IObuff, p_shm);
7746 STRCAT(IObuff, "s");
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007747 set_string_option_direct((char_u *)"shm", -1, IObuff, OPT_FREE, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007748 }
7749 /* remove 's' from p_shm */
7750 else if (!p_terse && p != NULL)
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00007751 STRMOVE(p, p + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007752 }
7753
7754 /* when 'paste' is set or reset also change other options */
7755 else if ((int *)varp == &p_paste)
7756 {
7757 paste_option_changed();
7758 }
7759
7760 /* when 'insertmode' is set from an autocommand need to do work here */
7761 else if ((int *)varp == &p_im)
7762 {
7763 if (p_im)
7764 {
7765 if ((State & INSERT) == 0)
7766 need_start_insertmode = TRUE;
7767 stop_insert_mode = FALSE;
7768 }
7769 else
7770 {
7771 need_start_insertmode = FALSE;
7772 stop_insert_mode = TRUE;
Bram Moolenaard12f5c12006-01-25 22:10:52 +00007773 if (restart_edit != 0 && mode_displayed)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007774 clear_cmdline = TRUE; /* remove "(insert)" */
7775 restart_edit = 0;
7776 }
7777 }
7778
7779 /* when 'ignorecase' is set or reset and 'hlsearch' is set, redraw */
7780 else if ((int *)varp == &p_ic && p_hls)
7781 {
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007782 redraw_all_later(SOME_VALID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007783 }
7784
7785#ifdef FEAT_SEARCH_EXTRA
7786 /* when 'hlsearch' is set or reset: reset no_hlsearch */
7787 else if ((int *)varp == &p_hls)
7788 {
7789 no_hlsearch = FALSE;
7790 }
7791#endif
7792
7793#ifdef FEAT_SCROLLBIND
7794 /* when 'scrollbind' is set: snapshot the current position to avoid a jump
7795 * at the end of normal_cmd() */
7796 else if ((int *)varp == &curwin->w_p_scb)
7797 {
7798 if (curwin->w_p_scb)
7799 do_check_scrollbind(FALSE);
7800 }
7801#endif
7802
7803#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
7804 /* There can be only one window with 'previewwindow' set. */
7805 else if ((int *)varp == &curwin->w_p_pvw)
7806 {
7807 if (curwin->w_p_pvw)
7808 {
7809 win_T *win;
7810
7811 for (win = firstwin; win != NULL; win = win->w_next)
7812 if (win->w_p_pvw && win != curwin)
7813 {
7814 curwin->w_p_pvw = FALSE;
7815 return (char_u *)N_("E590: A preview window already exists");
7816 }
7817 }
7818 }
7819#endif
7820
7821 /* when 'textmode' is set or reset also change 'fileformat' */
7822 else if ((int *)varp == &curbuf->b_p_tx)
7823 {
7824 set_fileformat(curbuf->b_p_tx ? EOL_DOS : EOL_UNIX, opt_flags);
7825 }
7826
7827 /* when 'textauto' is set or reset also change 'fileformats' */
7828 else if ((int *)varp == &p_ta)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007829 set_string_option_direct((char_u *)"ffs", -1,
7830 p_ta ? (char_u *)DFLT_FFS_VIM : (char_u *)"",
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00007831 OPT_FREE | opt_flags, 0);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007832
7833 /*
7834 * When 'lisp' option changes include/exclude '-' in
7835 * keyword characters.
7836 */
7837#ifdef FEAT_LISP
7838 else if (varp == (char_u *)&(curbuf->b_p_lisp))
7839 {
7840 (void)buf_init_chartab(curbuf, FALSE); /* ignore errors */
7841 }
7842#endif
7843
7844#ifdef FEAT_TITLE
7845 /* when 'title' changed, may need to change the title; same for 'icon' */
7846 else if ((int *)varp == &p_title)
7847 {
7848 did_set_title(FALSE);
7849 }
7850
7851 else if ((int *)varp == &p_icon)
7852 {
7853 did_set_title(TRUE);
7854 }
7855#endif
7856
7857 else if ((int *)varp == &curbuf->b_changed)
7858 {
7859 if (!value)
7860 save_file_ff(curbuf); /* Buffer is unchanged */
7861#ifdef FEAT_TITLE
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00007862 redraw_titles();
Bram Moolenaar071d4272004-06-13 20:20:40 +00007863#endif
7864#ifdef FEAT_AUTOCMD
7865 modified_was_set = value;
7866#endif
7867 }
7868
7869#ifdef BACKSLASH_IN_FILENAME
7870 else if ((int *)varp == &p_ssl)
7871 {
7872 if (p_ssl)
7873 {
7874 psepc = '/';
7875 psepcN = '\\';
7876 pseps[0] = '/';
Bram Moolenaar071d4272004-06-13 20:20:40 +00007877 }
7878 else
7879 {
7880 psepc = '\\';
7881 psepcN = '/';
7882 pseps[0] = '\\';
Bram Moolenaar071d4272004-06-13 20:20:40 +00007883 }
7884
7885 /* need to adjust the file name arguments and buffer names. */
7886 buflist_slash_adjust();
7887 alist_slash_adjust();
7888# ifdef FEAT_EVAL
7889 scriptnames_slash_adjust();
7890# endif
7891 }
7892#endif
7893
7894 /* If 'wrap' is set, set w_leftcol to zero. */
7895 else if ((int *)varp == &curwin->w_p_wrap)
7896 {
7897 if (curwin->w_p_wrap)
7898 curwin->w_leftcol = 0;
7899 }
7900
7901#ifdef FEAT_WINDOWS
7902 else if ((int *)varp == &p_ea)
7903 {
7904 if (p_ea && !old_value)
7905 win_equal(curwin, FALSE, 0);
7906 }
7907#endif
7908
7909 else if ((int *)varp == &p_wiv)
7910 {
7911 /*
7912 * When 'weirdinvert' changed, set/reset 't_xs'.
7913 * Then set 'weirdinvert' according to value of 't_xs'.
7914 */
7915 if (p_wiv && !old_value)
7916 T_XS = (char_u *)"y";
7917 else if (!p_wiv && old_value)
7918 T_XS = empty_option;
7919 p_wiv = (*T_XS != NUL);
7920 }
7921
Bram Moolenaarf1f8bc52005-03-07 23:20:08 +00007922#ifdef FEAT_BEVAL
Bram Moolenaar071d4272004-06-13 20:20:40 +00007923 else if ((int *)varp == &p_beval)
7924 {
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01007925 if (p_beval && !old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007926 gui_mch_enable_beval_area(balloonEval);
Bram Moolenaar49e4ec62011-11-30 11:31:30 +01007927 else if (!p_beval && old_value)
Bram Moolenaar071d4272004-06-13 20:20:40 +00007928 gui_mch_disable_beval_area(balloonEval);
7929 }
Bram Moolenaar8dff8182006-04-06 20:18:50 +00007930#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007931
Bram Moolenaar8dff8182006-04-06 20:18:50 +00007932#ifdef FEAT_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00007933 else if ((int *)varp == &p_acd)
7934 {
Bram Moolenaar498efdb2006-09-05 14:31:54 +00007935 /* Change directories when the 'acd' option is set now. */
7936 DO_AUTOCHDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +00007937 }
7938#endif
7939
7940#ifdef FEAT_DIFF
7941 /* 'diff' */
7942 else if ((int *)varp == &curwin->w_p_diff)
7943 {
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00007944 /* May add or remove the buffer from the list of diff buffers. */
7945 diff_buf_adjust(curwin);
7946# ifdef FEAT_FOLDING
Bram Moolenaar071d4272004-06-13 20:20:40 +00007947 if (foldmethodIsDiff(curwin))
7948 foldUpdateAll(curwin);
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00007949# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00007950 }
7951#endif
7952
7953#ifdef USE_IM_CONTROL
7954 /* 'imdisable' */
7955 else if ((int *)varp == &p_imdisable)
7956 {
7957 /* Only de-activate it here, it will be enabled when changing mode. */
7958 if (p_imdisable)
7959 im_set_active(FALSE);
Bram Moolenaar725a9622011-10-12 16:57:13 +02007960 else if (State & INSERT)
7961 /* When the option is set from an autocommand, it may need to take
7962 * effect right away. */
7963 im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
Bram Moolenaar071d4272004-06-13 20:20:40 +00007964 }
7965#endif
7966
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00007967#ifdef FEAT_SPELL
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00007968 /* 'spell' */
7969 else if ((int *)varp == &curwin->w_p_spell)
7970 {
7971 if (curwin->w_p_spell)
7972 {
Bram Moolenaar860cae12010-06-05 23:22:07 +02007973 char_u *errmsg = did_set_spelllang(curwin);
Bram Moolenaar0cb032e2005-04-23 20:52:00 +00007974 if (errmsg != NULL)
7975 EMSG(_(errmsg));
7976 }
7977 }
7978#endif
7979
Bram Moolenaar071d4272004-06-13 20:20:40 +00007980#ifdef FEAT_FKMAP
7981 else if ((int *)varp == &p_altkeymap)
7982 {
7983 if (old_value != p_altkeymap)
7984 {
7985 if (!p_altkeymap)
7986 {
7987 p_hkmap = p_fkmap;
7988 p_fkmap = 0;
7989 }
7990 else
7991 {
7992 p_fkmap = p_hkmap;
7993 p_hkmap = 0;
7994 }
7995 (void)init_chartab();
7996 }
7997 }
7998
7999 /*
8000 * In case some second language keymapping options have changed, check
8001 * and correct the setting in a consistent way.
8002 */
8003
8004 /*
8005 * If hkmap or fkmap are set, reset Arabic keymapping.
8006 */
8007 if ((p_hkmap || p_fkmap) && p_altkeymap)
8008 {
8009 p_altkeymap = p_fkmap;
8010# ifdef FEAT_ARABIC
8011 curwin->w_p_arab = FALSE;
8012# endif
8013 (void)init_chartab();
8014 }
8015
8016 /*
8017 * If hkmap set, reset Farsi keymapping.
8018 */
8019 if (p_hkmap && p_altkeymap)
8020 {
8021 p_altkeymap = 0;
8022 p_fkmap = 0;
8023# ifdef FEAT_ARABIC
8024 curwin->w_p_arab = FALSE;
8025# endif
8026 (void)init_chartab();
8027 }
8028
8029 /*
8030 * If fkmap set, reset Hebrew keymapping.
8031 */
8032 if (p_fkmap && !p_altkeymap)
8033 {
8034 p_altkeymap = 1;
8035 p_hkmap = 0;
8036# ifdef FEAT_ARABIC
8037 curwin->w_p_arab = FALSE;
8038# endif
8039 (void)init_chartab();
8040 }
8041#endif
8042
8043#ifdef FEAT_ARABIC
8044 if ((int *)varp == &curwin->w_p_arab)
8045 {
8046 if (curwin->w_p_arab)
8047 {
8048 /*
8049 * 'arabic' is set, handle various sub-settings.
8050 */
8051 if (!p_tbidi)
8052 {
8053 /* set rightleft mode */
8054 if (!curwin->w_p_rl)
8055 {
8056 curwin->w_p_rl = TRUE;
8057 changed_window_setting();
8058 }
8059
8060 /* Enable Arabic shaping (major part of what Arabic requires) */
8061 if (!p_arshape)
8062 {
8063 p_arshape = TRUE;
8064 redraw_later_clear();
8065 }
8066 }
8067
8068 /* Arabic requires a utf-8 encoding, inform the user if its not
8069 * set. */
8070 if (STRCMP(p_enc, "utf-8") != 0)
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008071 {
Bram Moolenaar496c5262009-03-18 14:42:00 +00008072 static char *w_arabic = N_("W17: Arabic requires UTF-8, do ':set encoding=utf-8'");
8073
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008074 msg_source(hl_attr(HLF_W));
Bram Moolenaar496c5262009-03-18 14:42:00 +00008075 MSG_ATTR(_(w_arabic), hl_attr(HLF_W));
8076#ifdef FEAT_EVAL
8077 set_vim_var_string(VV_WARNINGMSG, (char_u *)_(w_arabic), -1);
8078#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008079 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008080
8081# ifdef FEAT_MBYTE
8082 /* set 'delcombine' */
8083 p_deco = TRUE;
8084# endif
8085
8086# ifdef FEAT_KEYMAP
8087 /* Force-set the necessary keymap for arabic */
8088 set_option_value((char_u *)"keymap", 0L, (char_u *)"arabic",
8089 OPT_LOCAL);
8090# endif
8091# ifdef FEAT_FKMAP
8092 p_altkeymap = 0;
8093 p_hkmap = 0;
8094 p_fkmap = 0;
8095 (void)init_chartab();
8096# endif
8097 }
8098 else
8099 {
8100 /*
8101 * 'arabic' is reset, handle various sub-settings.
8102 */
8103 if (!p_tbidi)
8104 {
8105 /* reset rightleft mode */
8106 if (curwin->w_p_rl)
8107 {
8108 curwin->w_p_rl = FALSE;
8109 changed_window_setting();
8110 }
8111
8112 /* 'arabicshape' isn't reset, it is a global option and
8113 * another window may still need it "on". */
8114 }
8115
8116 /* 'delcombine' isn't reset, it is a global option and another
8117 * window may still want it "on". */
8118
8119# ifdef FEAT_KEYMAP
8120 /* Revert to the default keymap */
8121 curbuf->b_p_iminsert = B_IMODE_NONE;
8122 curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
8123# endif
8124 }
Bram Moolenaar801f8b82009-07-29 13:42:05 +00008125 }
8126
Bram Moolenaar319bdbd2009-09-11 13:20:33 +00008127#endif
8128
Bram Moolenaar071d4272004-06-13 20:20:40 +00008129 /*
8130 * End of handling side effects for bool options.
8131 */
8132
8133 options[opt_idx].flags |= P_WAS_SET;
8134
8135 comp_col(); /* in case 'ruler' or 'showcmd' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008136 if (curwin->w_curswant != MAXCOL
8137 && (options[opt_idx].flags & (P_CURSWANT | P_RCLR)) != 0)
8138 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008139 check_redraw(options[opt_idx].flags);
8140
8141 return NULL;
8142}
8143
8144/*
8145 * Set the value of a number option, and take care of side effects.
8146 * Returns NULL for success, or an error message for an error.
8147 */
8148 static char_u *
Bram Moolenaar555b2802005-05-19 21:08:39 +00008149set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008150 int opt_idx; /* index in options[] table */
8151 char_u *varp; /* pointer to the option variable */
8152 long value; /* new value */
8153 char_u *errbuf; /* buffer for error messages */
Bram Moolenaar555b2802005-05-19 21:08:39 +00008154 size_t errbuflen; /* length of "errbuf" */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008155 int opt_flags; /* OPT_LOCAL, OPT_GLOBAL and
8156 OPT_MODELINE */
8157{
8158 char_u *errmsg = NULL;
8159 long old_value = *(long *)varp;
8160 long old_Rows = Rows; /* remember old Rows */
8161 long old_Columns = Columns; /* remember old Columns */
8162 long *pp = (long *)varp;
8163
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008164 /* Disallow changing some options from secure mode. */
8165 if ((secure
8166#ifdef HAVE_SANDBOX
8167 || sandbox != 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00008168#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008169 ) && (options[opt_idx].flags & P_SECURE))
8170 return e_secure;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008171
8172 *pp = value;
8173#ifdef FEAT_EVAL
8174 /* Remember where the option was set. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00008175 set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008176#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008177#ifdef FEAT_GUI
8178 need_mouse_correct = TRUE;
8179#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008180
Bram Moolenaar14f24742012-08-08 18:01:05 +02008181 if (curbuf->b_p_sw < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008182 {
8183 errmsg = e_positive;
8184 curbuf->b_p_sw = curbuf->b_p_ts;
8185 }
8186
8187 /*
8188 * Number options that need some action when changed
8189 */
8190#ifdef FEAT_WINDOWS
8191 if (pp == &p_wh || pp == &p_hh)
8192 {
8193 if (p_wh < 1)
8194 {
8195 errmsg = e_positive;
8196 p_wh = 1;
8197 }
8198 if (p_wmh > p_wh)
8199 {
8200 errmsg = e_winheight;
8201 p_wh = p_wmh;
8202 }
8203 if (p_hh < 0)
8204 {
8205 errmsg = e_positive;
8206 p_hh = 0;
8207 }
8208
8209 /* Change window height NOW */
8210 if (lastwin != firstwin)
8211 {
8212 if (pp == &p_wh && curwin->w_height < p_wh)
8213 win_setheight((int)p_wh);
8214 if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh)
8215 win_setheight((int)p_hh);
8216 }
8217 }
8218
8219 /* 'winminheight' */
8220 else if (pp == &p_wmh)
8221 {
8222 if (p_wmh < 0)
8223 {
8224 errmsg = e_positive;
8225 p_wmh = 0;
8226 }
8227 if (p_wmh > p_wh)
8228 {
8229 errmsg = e_winheight;
8230 p_wmh = p_wh;
8231 }
8232 win_setminheight();
8233 }
8234
8235# ifdef FEAT_VERTSPLIT
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008236 else if (pp == &p_wiw)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008237 {
8238 if (p_wiw < 1)
8239 {
8240 errmsg = e_positive;
8241 p_wiw = 1;
8242 }
8243 if (p_wmw > p_wiw)
8244 {
8245 errmsg = e_winwidth;
8246 p_wiw = p_wmw;
8247 }
8248
8249 /* Change window width NOW */
8250 if (lastwin != firstwin && curwin->w_width < p_wiw)
8251 win_setwidth((int)p_wiw);
8252 }
8253
8254 /* 'winminwidth' */
8255 else if (pp == &p_wmw)
8256 {
8257 if (p_wmw < 0)
8258 {
8259 errmsg = e_positive;
8260 p_wmw = 0;
8261 }
8262 if (p_wmw > p_wiw)
8263 {
8264 errmsg = e_winwidth;
8265 p_wmw = p_wiw;
8266 }
8267 win_setminheight();
8268 }
8269# endif
8270
8271#endif
8272
8273#ifdef FEAT_WINDOWS
8274 /* (re)set last window status line */
8275 else if (pp == &p_ls)
8276 {
8277 last_status(FALSE);
8278 }
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008279
8280 /* (re)set tab page line */
Bram Moolenaarfaa959a2006-02-20 21:37:40 +00008281 else if (pp == &p_stal)
Bram Moolenaar4c7ed462006-02-15 22:18:42 +00008282 {
8283 shell_new_rows(); /* recompute window positions and heights */
8284 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008285#endif
8286
8287#ifdef FEAT_GUI
8288 else if (pp == &p_linespace)
8289 {
Bram Moolenaar02743632005-07-25 20:42:36 +00008290 /* Recompute gui.char_height and resize the Vim window to keep the
8291 * same number of lines. */
8292 if (gui.in_use && gui_mch_adjust_charheight() == OK)
Bram Moolenaar3964b7e2006-03-27 20:59:33 +00008293 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008294 }
8295#endif
8296
8297#ifdef FEAT_FOLDING
8298 /* 'foldlevel' */
8299 else if (pp == &curwin->w_p_fdl)
8300 {
8301 if (curwin->w_p_fdl < 0)
8302 curwin->w_p_fdl = 0;
8303 newFoldLevel();
8304 }
8305
Bram Moolenaar1f26d2f2009-02-11 10:35:36 +00008306 /* 'foldminlines' */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008307 else if (pp == &curwin->w_p_fml)
8308 {
8309 foldUpdateAll(curwin);
8310 }
8311
8312 /* 'foldnestmax' */
8313 else if (pp == &curwin->w_p_fdn)
8314 {
8315 if (foldmethodIsSyntax(curwin) || foldmethodIsIndent(curwin))
8316 foldUpdateAll(curwin);
8317 }
8318
8319 /* 'foldcolumn' */
8320 else if (pp == &curwin->w_p_fdc)
8321 {
8322 if (curwin->w_p_fdc < 0)
8323 {
8324 errmsg = e_positive;
8325 curwin->w_p_fdc = 0;
8326 }
8327 else if (curwin->w_p_fdc > 12)
8328 {
8329 errmsg = e_invarg;
8330 curwin->w_p_fdc = 12;
8331 }
8332 }
8333
8334 /* 'shiftwidth' or 'tabstop' */
8335 else if (pp == &curbuf->b_p_sw || pp == &curbuf->b_p_ts)
8336 {
8337 if (foldmethodIsIndent(curwin))
8338 foldUpdateAll(curwin);
8339 }
8340#endif /* FEAT_FOLDING */
8341
Bram Moolenaar362e1a32006-03-06 23:29:24 +00008342#ifdef FEAT_MBYTE
8343 /* 'maxcombine' */
8344 else if (pp == &p_mco)
8345 {
8346 if (p_mco > MAX_MCO)
8347 p_mco = MAX_MCO;
8348 else if (p_mco < 0)
8349 p_mco = 0;
8350 screenclear(); /* will re-allocate the screen */
8351 }
8352#endif
8353
Bram Moolenaar071d4272004-06-13 20:20:40 +00008354 else if (pp == &curbuf->b_p_iminsert)
8355 {
8356 if (curbuf->b_p_iminsert < 0 || curbuf->b_p_iminsert > B_IMODE_LAST)
8357 {
8358 errmsg = e_invarg;
8359 curbuf->b_p_iminsert = B_IMODE_NONE;
8360 }
8361 p_iminsert = curbuf->b_p_iminsert;
8362 if (termcap_active) /* don't do this in the alternate screen */
8363 showmode();
8364#if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
8365 /* Show/unshow value of 'keymap' in status lines. */
8366 status_redraw_curbuf();
8367#endif
8368 }
8369
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008370 else if (pp == &p_window)
8371 {
8372 if (p_window < 1)
8373 p_window = 1;
8374 else if (p_window >= Rows)
8375 p_window = Rows - 1;
8376 }
8377
Bram Moolenaar071d4272004-06-13 20:20:40 +00008378 else if (pp == &curbuf->b_p_imsearch)
8379 {
8380 if (curbuf->b_p_imsearch < -1 || curbuf->b_p_imsearch > B_IMODE_LAST)
8381 {
8382 errmsg = e_invarg;
8383 curbuf->b_p_imsearch = B_IMODE_NONE;
8384 }
8385 p_imsearch = curbuf->b_p_imsearch;
8386 }
8387
8388#ifdef FEAT_TITLE
8389 /* if 'titlelen' has changed, redraw the title */
8390 else if (pp == &p_titlelen)
8391 {
8392 if (p_titlelen < 0)
8393 {
8394 errmsg = e_positive;
8395 p_titlelen = 85;
8396 }
8397 if (starting != NO_SCREEN && old_value != p_titlelen)
8398 need_maketitle = TRUE;
8399 }
8400#endif
8401
8402 /* if p_ch changed value, change the command line height */
8403 else if (pp == &p_ch)
8404 {
8405 if (p_ch < 1)
8406 {
8407 errmsg = e_positive;
8408 p_ch = 1;
8409 }
Bram Moolenaar719939c2007-09-25 12:51:28 +00008410 if (p_ch > Rows - min_rows() + 1)
8411 p_ch = Rows - min_rows() + 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008412
8413 /* Only compute the new window layout when startup has been
8414 * completed. Otherwise the frame sizes may be wrong. */
8415 if (p_ch != old_value && full_screen
8416#ifdef FEAT_GUI
8417 && !gui.starting
8418#endif
8419 )
Bram Moolenaarc6fe9192006-04-09 21:54:49 +00008420 command_height();
Bram Moolenaar071d4272004-06-13 20:20:40 +00008421 }
8422
8423 /* when 'updatecount' changes from zero to non-zero, open swap files */
8424 else if (pp == &p_uc)
8425 {
8426 if (p_uc < 0)
8427 {
8428 errmsg = e_positive;
8429 p_uc = 100;
8430 }
8431 if (p_uc && !old_value)
8432 ml_open_files();
8433 }
Bram Moolenaar860cae12010-06-05 23:22:07 +02008434#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008435 else if (pp == &curwin->w_p_cole)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008436 {
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008437 if (curwin->w_p_cole < 0)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008438 {
8439 errmsg = e_positive;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008440 curwin->w_p_cole = 0;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008441 }
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008442 else if (curwin->w_p_cole > 3)
Bram Moolenaar860cae12010-06-05 23:22:07 +02008443 {
8444 errmsg = e_invarg;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02008445 curwin->w_p_cole = 3;
Bram Moolenaar860cae12010-06-05 23:22:07 +02008446 }
8447 }
8448#endif
Bram Moolenaar2df6dcc2004-07-12 15:53:54 +00008449#ifdef MZSCHEME_GUI_THREADS
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008450 else if (pp == &p_mzq)
8451 mzvim_reset_timer();
8452#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00008453
8454 /* sync undo before 'undolevels' changes */
8455 else if (pp == &p_ul)
8456 {
8457 /* use the old value, otherwise u_sync() may not work properly */
8458 p_ul = old_value;
Bram Moolenaar779b74b2006-04-10 14:55:34 +00008459 u_sync(TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008460 p_ul = value;
8461 }
8462
Bram Moolenaar592e0a22004-07-03 16:05:59 +00008463#ifdef FEAT_LINEBREAK
8464 /* 'numberwidth' must be positive */
8465 else if (pp == &curwin->w_p_nuw)
8466 {
8467 if (curwin->w_p_nuw < 1)
8468 {
8469 errmsg = e_positive;
8470 curwin->w_p_nuw = 1;
8471 }
8472 if (curwin->w_p_nuw > 10)
8473 {
8474 errmsg = e_invarg;
8475 curwin->w_p_nuw = 10;
8476 }
8477 curwin->w_nrwidth_line_count = 0;
8478 }
8479#endif
8480
Bram Moolenaar1a384422010-07-14 19:53:30 +02008481 else if (pp == &curbuf->b_p_tw)
8482 {
8483 if (curbuf->b_p_tw < 0)
8484 {
8485 errmsg = e_positive;
8486 curbuf->b_p_tw = 0;
8487 }
8488#ifdef FEAT_SYN_HL
8489# ifdef FEAT_WINDOWS
8490 {
8491 win_T *wp;
8492 tabpage_T *tp;
8493
8494 FOR_ALL_TAB_WINDOWS(tp, wp)
8495 check_colorcolumn(wp);
8496 }
8497# else
8498 check_colorcolumn(curwin);
8499# endif
8500#endif
8501 }
8502
Bram Moolenaar071d4272004-06-13 20:20:40 +00008503 /*
8504 * Check the bounds for numeric options here
8505 */
8506 if (Rows < min_rows() && full_screen)
8507 {
8508 if (errbuf != NULL)
8509 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008510 vim_snprintf((char *)errbuf, errbuflen,
8511 _("E593: Need at least %d lines"), min_rows());
Bram Moolenaar071d4272004-06-13 20:20:40 +00008512 errmsg = errbuf;
8513 }
8514 Rows = min_rows();
8515 }
8516 if (Columns < MIN_COLUMNS && full_screen)
8517 {
8518 if (errbuf != NULL)
8519 {
Bram Moolenaar555b2802005-05-19 21:08:39 +00008520 vim_snprintf((char *)errbuf, errbuflen,
8521 _("E594: Need at least %d columns"), MIN_COLUMNS);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008522 errmsg = errbuf;
8523 }
8524 Columns = MIN_COLUMNS;
8525 }
Bram Moolenaar482aaeb2005-09-29 18:26:07 +00008526 /* Limit the values to avoid an overflow in Rows * Columns. */
8527 if (Columns > 10000)
8528 Columns = 10000;
8529 if (Rows > 1000)
8530 Rows = 1000;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008531
8532#ifdef DJGPP
8533 /* avoid a crash by checking for a too large value of 'columns' */
8534 if (old_Columns != Columns && full_screen && term_console)
8535 mch_check_columns();
8536#endif
8537
8538 /*
8539 * If the screen (shell) height has been changed, assume it is the
8540 * physical screenheight.
8541 */
8542 if (old_Rows != Rows || old_Columns != Columns)
8543 {
8544 /* Changing the screen size is not allowed while updating the screen. */
8545 if (updating_screen)
8546 *pp = old_value;
8547 else if (full_screen
8548#ifdef FEAT_GUI
8549 && !gui.starting
8550#endif
8551 )
8552 set_shellsize((int)Columns, (int)Rows, TRUE);
8553 else
8554 {
8555 /* Postpone the resizing; check the size and cmdline position for
8556 * messages. */
8557 check_shellsize();
8558 if (cmdline_row > Rows - p_ch && Rows > p_ch)
8559 cmdline_row = Rows - p_ch;
8560 }
Bram Moolenaard68071d2006-05-02 22:08:30 +00008561 if (p_window >= Rows || !option_was_set((char_u *)"window"))
Bram Moolenaar4399ef42005-02-12 14:29:27 +00008562 p_window = Rows - 1;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008563 }
8564
Bram Moolenaar071d4272004-06-13 20:20:40 +00008565 if (curbuf->b_p_ts <= 0)
8566 {
8567 errmsg = e_positive;
8568 curbuf->b_p_ts = 8;
8569 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008570 if (p_tm < 0)
8571 {
8572 errmsg = e_positive;
8573 p_tm = 0;
8574 }
8575 if ((curwin->w_p_scr <= 0
8576 || (curwin->w_p_scr > curwin->w_height
8577 && curwin->w_height > 0))
8578 && full_screen)
8579 {
8580 if (pp == &(curwin->w_p_scr))
8581 {
8582 if (curwin->w_p_scr != 0)
8583 errmsg = e_scroll;
8584 win_comp_scroll(curwin);
8585 }
8586 /* If 'scroll' became invalid because of a side effect silently adjust
8587 * it. */
8588 else if (curwin->w_p_scr <= 0)
8589 curwin->w_p_scr = 1;
8590 else /* curwin->w_p_scr > curwin->w_height */
8591 curwin->w_p_scr = curwin->w_height;
8592 }
Bram Moolenaar991e10f2008-10-02 20:48:41 +00008593 if (p_hi < 0)
8594 {
8595 errmsg = e_positive;
8596 p_hi = 0;
8597 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008598 if (p_report < 0)
8599 {
8600 errmsg = e_positive;
8601 p_report = 1;
8602 }
Bram Moolenaar1e015462005-09-25 22:16:38 +00008603 if ((p_sj < -100 || p_sj >= Rows) && full_screen)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008604 {
8605 if (Rows != old_Rows) /* Rows changed, just adjust p_sj */
8606 p_sj = Rows / 2;
8607 else
8608 {
8609 errmsg = e_scroll;
8610 p_sj = 1;
8611 }
8612 }
8613 if (p_so < 0 && full_screen)
8614 {
8615 errmsg = e_scroll;
8616 p_so = 0;
8617 }
8618 if (p_siso < 0 && full_screen)
8619 {
8620 errmsg = e_positive;
8621 p_siso = 0;
8622 }
8623#ifdef FEAT_CMDWIN
8624 if (p_cwh < 1)
8625 {
8626 errmsg = e_positive;
8627 p_cwh = 1;
8628 }
8629#endif
8630 if (p_ut < 0)
8631 {
8632 errmsg = e_positive;
8633 p_ut = 2000;
8634 }
8635 if (p_ss < 0)
8636 {
8637 errmsg = e_positive;
8638 p_ss = 0;
8639 }
8640
8641 /* May set global value for local option. */
8642 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
8643 *(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
8644
8645 options[opt_idx].flags |= P_WAS_SET;
8646
8647 comp_col(); /* in case 'columns' or 'ls' changed */
Bram Moolenaar913077c2012-03-28 19:59:04 +02008648 if (curwin->w_curswant != MAXCOL
8649 && (options[opt_idx].flags & (P_CURSWANT | P_RCLR)) != 0)
8650 curwin->w_set_curswant = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008651 check_redraw(options[opt_idx].flags);
8652
8653 return errmsg;
8654}
8655
8656/*
8657 * Called after an option changed: check if something needs to be redrawn.
8658 */
8659 static void
8660check_redraw(flags)
8661 long_u flags;
8662{
8663 /* Careful: P_RCLR and P_RALL are a combination of other P_ flags */
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008664 int doclear = (flags & P_RCLR) == P_RCLR;
8665 int all = ((flags & P_RALL) == P_RALL || doclear);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008666
8667#ifdef FEAT_WINDOWS
8668 if ((flags & P_RSTAT) || all) /* mark all status lines dirty */
8669 status_redraw_all();
8670#endif
8671
8672 if ((flags & P_RBUF) || (flags & P_RWIN) || all)
8673 changed_window_setting();
8674 if (flags & P_RBUF)
8675 redraw_curbuf_later(NOT_VALID);
Bram Moolenaar70b2a562012-01-10 22:26:17 +01008676 if (doclear)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008677 redraw_all_later(CLEAR);
8678 else if (all)
8679 redraw_all_later(NOT_VALID);
8680}
8681
8682/*
8683 * Find index for option 'arg'.
8684 * Return -1 if not found.
8685 */
8686 static int
8687findoption(arg)
8688 char_u *arg;
8689{
8690 int opt_idx;
8691 char *s, *p;
8692 static short quick_tab[27] = {0, 0}; /* quick access table */
8693 int is_term_opt;
8694
8695 /*
8696 * For first call: Initialize the quick-access table.
8697 * It contains the index for the first option that starts with a certain
8698 * letter. There are 26 letters, plus the first "t_" option.
8699 */
8700 if (quick_tab[1] == 0)
8701 {
8702 p = options[0].fullname;
8703 for (opt_idx = 1; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8704 {
8705 if (s[0] != p[0])
8706 {
8707 if (s[0] == 't' && s[1] == '_')
8708 quick_tab[26] = opt_idx;
8709 else
8710 quick_tab[CharOrdLow(s[0])] = opt_idx;
8711 }
8712 p = s;
8713 }
8714 }
8715
8716 /*
8717 * Check for name starting with an illegal character.
8718 */
8719#ifdef EBCDIC
8720 if (!islower(arg[0]))
8721#else
8722 if (arg[0] < 'a' || arg[0] > 'z')
8723#endif
8724 return -1;
8725
8726 is_term_opt = (arg[0] == 't' && arg[1] == '_');
8727 if (is_term_opt)
8728 opt_idx = quick_tab[26];
8729 else
8730 opt_idx = quick_tab[CharOrdLow(arg[0])];
8731 for ( ; (s = options[opt_idx].fullname) != NULL; opt_idx++)
8732 {
8733 if (STRCMP(arg, s) == 0) /* match full name */
8734 break;
8735 }
8736 if (s == NULL && !is_term_opt)
8737 {
8738 opt_idx = quick_tab[CharOrdLow(arg[0])];
8739 for ( ; options[opt_idx].fullname != NULL; opt_idx++)
8740 {
8741 s = options[opt_idx].shortname;
8742 if (s != NULL && STRCMP(arg, s) == 0) /* match short name */
8743 break;
8744 s = NULL;
8745 }
8746 }
8747 if (s == NULL)
8748 opt_idx = -1;
8749 return opt_idx;
8750}
8751
Bram Moolenaar325b7a22004-07-05 15:58:32 +00008752#if defined(FEAT_EVAL) || defined(FEAT_TCL) || defined(FEAT_MZSCHEME)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008753/*
8754 * Get the value for an option.
8755 *
8756 * Returns:
8757 * Number or Toggle option: 1, *numval gets value.
8758 * String option: 0, *stringval gets allocated string.
8759 * Hidden Number or Toggle option: -1.
8760 * hidden String option: -2.
8761 * unknown option: -3.
8762 */
8763 int
8764get_option_value(name, numval, stringval, opt_flags)
8765 char_u *name;
8766 long *numval;
Bram Moolenaar370df582010-06-22 05:16:38 +02008767 char_u **stringval; /* NULL when only checking existence */
Bram Moolenaar071d4272004-06-13 20:20:40 +00008768 int opt_flags;
8769{
8770 int opt_idx;
8771 char_u *varp;
8772
8773 opt_idx = findoption(name);
8774 if (opt_idx < 0) /* unknown option */
8775 return -3;
8776
8777 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
8778
8779 if (options[opt_idx].flags & P_STRING)
8780 {
8781 if (varp == NULL) /* hidden option */
8782 return -2;
8783 if (stringval != NULL)
8784 {
8785#ifdef FEAT_CRYPT
8786 /* never return the value of the crypt key */
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +00008787 if ((char_u **)varp == &curbuf->b_p_key
8788 && **(char_u **)(varp) != NUL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008789 *stringval = vim_strsave((char_u *)"*****");
8790 else
8791#endif
8792 *stringval = vim_strsave(*(char_u **)(varp));
8793 }
8794 return 0;
8795 }
8796
8797 if (varp == NULL) /* hidden option */
8798 return -1;
8799 if (options[opt_idx].flags & P_NUM)
8800 *numval = *(long *)varp;
8801 else
8802 {
8803 /* Special case: 'modified' is b_changed, but we also want to consider
8804 * it set when 'ff' or 'fenc' changed. */
8805 if ((int *)varp == &curbuf->b_changed)
8806 *numval = curbufIsChanged();
8807 else
8808 *numval = *(int *)varp;
8809 }
8810 return 1;
8811}
8812#endif
8813
8814/*
8815 * Set the value of option "name".
8816 * Use "string" for string options, use "number" for other options.
8817 */
8818 void
8819set_option_value(name, number, string, opt_flags)
8820 char_u *name;
8821 long number;
8822 char_u *string;
8823 int opt_flags; /* OPT_LOCAL or 0 (both) */
8824{
8825 int opt_idx;
8826 char_u *varp;
Bram Moolenaara93fa7e2006-04-17 22:14:47 +00008827 long_u flags;
Bram Moolenaar071d4272004-06-13 20:20:40 +00008828
8829 opt_idx = findoption(name);
Bram Moolenaarfc1421e2006-04-20 22:17:20 +00008830 if (opt_idx < 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008831 EMSG2(_("E355: Unknown option: %s"), name);
8832 else
8833 {
8834 flags = options[opt_idx].flags;
8835#ifdef HAVE_SANDBOX
8836 /* Disallow changing some options in the sandbox */
8837 if (sandbox > 0 && (flags & P_SECURE))
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008838 {
Bram Moolenaar071d4272004-06-13 20:20:40 +00008839 EMSG(_(e_sandbox));
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008840 return;
8841 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008842#endif
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008843 if (flags & P_STRING)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008844 set_string_option(opt_idx, string, opt_flags);
8845 else
8846 {
Bram Moolenaarb3163762008-07-08 15:15:08 +00008847 varp = get_varp_scope(&(options[opt_idx]), opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008848 if (varp != NULL) /* hidden option is not changed */
8849 {
Bram Moolenaar96bb6212007-06-19 18:52:53 +00008850 if (number == 0 && string != NULL)
8851 {
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00008852 int idx;
Bram Moolenaar96bb6212007-06-19 18:52:53 +00008853
8854 /* Either we are given a string or we are setting option
8855 * to zero. */
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00008856 for (idx = 0; string[idx] == '0'; ++idx)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00008857 ;
Bram Moolenaarfe86f2d2008-11-28 20:29:07 +00008858 if (string[idx] != NUL || idx == 0)
Bram Moolenaar96bb6212007-06-19 18:52:53 +00008859 {
8860 /* There's another character after zeros or the string
8861 * is empty. In both cases, we are trying to set a
8862 * num option using a string. */
8863 EMSG3(_("E521: Number required: &%s = '%s'"),
8864 name, string);
8865 return; /* do nothing as we hit an error */
8866
8867 }
8868 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00008869 if (flags & P_NUM)
Bram Moolenaar555b2802005-05-19 21:08:39 +00008870 (void)set_num_option(opt_idx, varp, number,
8871 NULL, 0, opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008872 else
Bram Moolenaarb71eaae2006-01-20 23:10:18 +00008873 (void)set_bool_option(opt_idx, varp, (int)number,
8874 opt_flags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008875 }
8876 }
8877 }
8878}
8879
8880/*
8881 * Get the terminal code for a terminal option.
8882 * Returns NULL when not found.
8883 */
8884 char_u *
8885get_term_code(tname)
8886 char_u *tname;
8887{
8888 int opt_idx;
8889 char_u *varp;
8890
8891 if (tname[0] != 't' || tname[1] != '_' ||
8892 tname[2] == NUL || tname[3] == NUL)
8893 return NULL;
8894 if ((opt_idx = findoption(tname)) >= 0)
8895 {
8896 varp = get_varp(&(options[opt_idx]));
8897 if (varp != NULL)
8898 varp = *(char_u **)(varp);
8899 return varp;
8900 }
8901 return find_termcode(tname + 2);
8902}
8903
8904 char_u *
8905get_highlight_default()
8906{
8907 int i;
8908
8909 i = findoption((char_u *)"hl");
8910 if (i >= 0)
8911 return options[i].def_val[VI_DEFAULT];
8912 return (char_u *)NULL;
8913}
8914
Bram Moolenaar1cd871b2004-12-19 22:46:22 +00008915#if defined(FEAT_MBYTE) || defined(PROTO)
8916 char_u *
8917get_encoding_default()
8918{
8919 int i;
8920
8921 i = findoption((char_u *)"enc");
8922 if (i >= 0)
8923 return options[i].def_val[VI_DEFAULT];
8924 return (char_u *)NULL;
8925}
8926#endif
8927
Bram Moolenaar071d4272004-06-13 20:20:40 +00008928/*
8929 * Translate a string like "t_xx", "<t_xx>" or "<S-Tab>" to a key number.
8930 */
8931 static int
8932find_key_option(arg)
8933 char_u *arg;
8934{
8935 int key;
8936 int modifiers;
8937
8938 /*
8939 * Don't use get_special_key_code() for t_xx, we don't want it to call
8940 * add_termcap_entry().
8941 */
8942 if (arg[0] == 't' && arg[1] == '_' && arg[2] && arg[3])
8943 key = TERMCAP2KEY(arg[2], arg[3]);
8944 else
8945 {
8946 --arg; /* put arg at the '<' */
8947 modifiers = 0;
Bram Moolenaar2a8ced02008-12-24 11:54:31 +00008948 key = find_special_key(&arg, &modifiers, TRUE, TRUE);
Bram Moolenaar071d4272004-06-13 20:20:40 +00008949 if (modifiers) /* can't handle modifiers here */
8950 key = 0;
8951 }
8952 return key;
8953}
8954
8955/*
8956 * if 'all' == 0: show changed options
8957 * if 'all' == 1: show all normal options
8958 * if 'all' == 2: show all terminal options
8959 */
8960 static void
8961showoptions(all, opt_flags)
8962 int all;
8963 int opt_flags; /* OPT_LOCAL and/or OPT_GLOBAL */
8964{
8965 struct vimoption *p;
8966 int col;
8967 int isterm;
8968 char_u *varp;
8969 struct vimoption **items;
8970 int item_count;
8971 int run;
8972 int row, rows;
8973 int cols;
8974 int i;
8975 int len;
8976
8977#define INC 20
8978#define GAP 3
8979
8980 items = (struct vimoption **)alloc((unsigned)(sizeof(struct vimoption *) *
8981 PARAM_COUNT));
8982 if (items == NULL)
8983 return;
8984
8985 /* Highlight title */
8986 if (all == 2)
8987 MSG_PUTS_TITLE(_("\n--- Terminal codes ---"));
8988 else if (opt_flags & OPT_GLOBAL)
8989 MSG_PUTS_TITLE(_("\n--- Global option values ---"));
8990 else if (opt_flags & OPT_LOCAL)
8991 MSG_PUTS_TITLE(_("\n--- Local option values ---"));
8992 else
8993 MSG_PUTS_TITLE(_("\n--- Options ---"));
8994
8995 /*
8996 * do the loop two times:
8997 * 1. display the short items
8998 * 2. display the long items (only strings and numbers)
8999 */
9000 for (run = 1; run <= 2 && !got_int; ++run)
9001 {
9002 /*
9003 * collect the items in items[]
9004 */
9005 item_count = 0;
9006 for (p = &options[0]; p->fullname != NULL; p++)
9007 {
9008 varp = NULL;
9009 isterm = istermoption(p);
9010 if (opt_flags != 0)
9011 {
9012 if (p->indir != PV_NONE && !isterm)
9013 varp = get_varp_scope(p, opt_flags);
9014 }
9015 else
9016 varp = get_varp(p);
9017 if (varp != NULL
9018 && ((all == 2 && isterm)
9019 || (all == 1 && !isterm)
9020 || (all == 0 && !optval_default(p, varp))))
9021 {
9022 if (p->flags & P_BOOL)
9023 len = 1; /* a toggle option fits always */
9024 else
9025 {
9026 option_value2string(p, opt_flags);
9027 len = (int)STRLEN(p->fullname) + vim_strsize(NameBuff) + 1;
9028 }
9029 if ((len <= INC - GAP && run == 1) ||
9030 (len > INC - GAP && run == 2))
9031 items[item_count++] = p;
9032 }
9033 }
9034
9035 /*
9036 * display the items
9037 */
9038 if (run == 1)
9039 {
9040 cols = (Columns + GAP - 3) / INC;
9041 if (cols == 0)
9042 cols = 1;
9043 rows = (item_count + cols - 1) / cols;
9044 }
9045 else /* run == 2 */
9046 rows = item_count;
9047 for (row = 0; row < rows && !got_int; ++row)
9048 {
9049 msg_putchar('\n'); /* go to next line */
9050 if (got_int) /* 'q' typed in more */
9051 break;
9052 col = 0;
9053 for (i = row; i < item_count; i += rows)
9054 {
9055 msg_col = col; /* make columns */
9056 showoneopt(items[i], opt_flags);
9057 col += INC;
9058 }
9059 out_flush();
9060 ui_breakcheck();
9061 }
9062 }
9063 vim_free(items);
9064}
9065
9066/*
9067 * Return TRUE if option "p" has its default value.
9068 */
9069 static int
9070optval_default(p, varp)
9071 struct vimoption *p;
9072 char_u *varp;
9073{
9074 int dvi;
9075
9076 if (varp == NULL)
9077 return TRUE; /* hidden option is always at default */
9078 dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
9079 if (p->flags & P_NUM)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009080 return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009081 if (p->flags & P_BOOL)
Bram Moolenaareb3593b2006-04-22 22:33:57 +00009082 /* the cast to long is required for Manx C, long_i is
9083 * needed for MSVC */
9084 return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009085 /* P_STRING */
9086 return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
9087}
9088
9089/*
9090 * showoneopt: show the value of one option
9091 * must not be called with a hidden option!
9092 */
9093 static void
9094showoneopt(p, opt_flags)
9095 struct vimoption *p;
9096 int opt_flags; /* OPT_LOCAL or OPT_GLOBAL */
9097{
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009098 char_u *varp;
9099 int save_silent = silent_mode;
9100
9101 silent_mode = FALSE;
9102 info_message = TRUE; /* use mch_msg(), not mch_errmsg() */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009103
9104 varp = get_varp_scope(p, opt_flags);
9105
9106 /* for 'modified' we also need to check if 'ff' or 'fenc' changed. */
9107 if ((p->flags & P_BOOL) && ((int *)varp == &curbuf->b_changed
9108 ? !curbufIsChanged() : !*(int *)varp))
9109 MSG_PUTS("no");
9110 else if ((p->flags & P_BOOL) && *(int *)varp < 0)
9111 MSG_PUTS("--");
9112 else
9113 MSG_PUTS(" ");
9114 MSG_PUTS(p->fullname);
9115 if (!(p->flags & P_BOOL))
9116 {
9117 msg_putchar('=');
9118 /* put value string in NameBuff */
9119 option_value2string(p, opt_flags);
9120 msg_outtrans(NameBuff);
9121 }
Bram Moolenaar26a60b42005-02-22 08:49:11 +00009122
9123 silent_mode = save_silent;
9124 info_message = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009125}
9126
9127/*
9128 * Write modified options as ":set" commands to a file.
9129 *
9130 * There are three values for "opt_flags":
9131 * OPT_GLOBAL: Write global option values and fresh values of
9132 * buffer-local options (used for start of a session
9133 * file).
9134 * OPT_GLOBAL + OPT_LOCAL: Idem, add fresh values of window-local options for
9135 * curwin (used for a vimrc file).
9136 * OPT_LOCAL: Write buffer-local option values for curbuf, fresh
9137 * and local values for window-local options of
9138 * curwin. Local values are also written when at the
9139 * default value, because a modeline or autocommand
9140 * may have set them when doing ":edit file" and the
9141 * user has set them back at the default or fresh
9142 * value.
9143 * When "local_only" is TRUE, don't write fresh
9144 * values, only local values (for ":mkview").
9145 * (fresh value = value used for a new buffer or window for a local option).
9146 *
9147 * Return FAIL on error, OK otherwise.
9148 */
9149 int
9150makeset(fd, opt_flags, local_only)
9151 FILE *fd;
9152 int opt_flags;
9153 int local_only;
9154{
9155 struct vimoption *p;
9156 char_u *varp; /* currently used value */
9157 char_u *varp_fresh; /* local value */
9158 char_u *varp_local = NULL; /* fresh value */
9159 char *cmd;
9160 int round;
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009161 int pri;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009162
9163 /*
9164 * The options that don't have a default (terminal name, columns, lines)
9165 * are never written. Terminal options are also not written.
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009166 * Do the loop over "options[]" twice: once for options with the
9167 * P_PRI_MKRC flag and once without.
Bram Moolenaar071d4272004-06-13 20:20:40 +00009168 */
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009169 for (pri = 1; pri >= 0; --pri)
9170 {
9171 for (p = &options[0]; !istermoption(p); p++)
9172 if (!(p->flags & P_NO_MKRC)
9173 && !istermoption(p)
9174 && ((pri == 1) == ((p->flags & P_PRI_MKRC) != 0)))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009175 {
9176 /* skip global option when only doing locals */
9177 if (p->indir == PV_NONE && !(opt_flags & OPT_GLOBAL))
9178 continue;
9179
9180 /* Do not store options like 'bufhidden' and 'syntax' in a vimrc
9181 * file, they are always buffer-specific. */
9182 if ((opt_flags & OPT_GLOBAL) && (p->flags & P_NOGLOB))
9183 continue;
9184
9185 /* Global values are only written when not at the default value. */
9186 varp = get_varp_scope(p, opt_flags);
9187 if ((opt_flags & OPT_GLOBAL) && optval_default(p, varp))
9188 continue;
9189
9190 round = 2;
9191 if (p->indir != PV_NONE)
9192 {
9193 if (p->var == VAR_WIN)
9194 {
9195 /* skip window-local option when only doing globals */
9196 if (!(opt_flags & OPT_LOCAL))
9197 continue;
9198 /* When fresh value of window-local option is not at the
9199 * default, need to write it too. */
9200 if (!(opt_flags & OPT_GLOBAL) && !local_only)
9201 {
9202 varp_fresh = get_varp_scope(p, OPT_GLOBAL);
9203 if (!optval_default(p, varp_fresh))
9204 {
9205 round = 1;
9206 varp_local = varp;
9207 varp = varp_fresh;
9208 }
9209 }
9210 }
9211 }
9212
9213 /* Round 1: fresh value for window-local options.
9214 * Round 2: other values */
9215 for ( ; round <= 2; varp = varp_local, ++round)
9216 {
9217 if (round == 1 || (opt_flags & OPT_GLOBAL))
9218 cmd = "set";
9219 else
9220 cmd = "setlocal";
9221
9222 if (p->flags & P_BOOL)
9223 {
9224 if (put_setbool(fd, cmd, p->fullname, *(int *)varp) == FAIL)
9225 return FAIL;
9226 }
9227 else if (p->flags & P_NUM)
9228 {
9229 if (put_setnum(fd, cmd, p->fullname, (long *)varp) == FAIL)
9230 return FAIL;
9231 }
9232 else /* P_STRING */
9233 {
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009234#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9235 int do_endif = FALSE;
9236
Bram Moolenaar071d4272004-06-13 20:20:40 +00009237 /* Don't set 'syntax' and 'filetype' again if the value is
9238 * already right, avoids reloading the syntax file. */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009239 if (
9240# if defined(FEAT_SYN_HL)
9241 p->indir == PV_SYN
9242# if defined(FEAT_AUTOCMD)
9243 ||
9244# endif
9245# endif
9246# if defined(FEAT_AUTOCMD)
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009247 p->indir == PV_FT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009248# endif
Bram Moolenaar15bfa092008-07-24 16:45:38 +00009249 )
Bram Moolenaar071d4272004-06-13 20:20:40 +00009250 {
9251 if (fprintf(fd, "if &%s != '%s'", p->fullname,
9252 *(char_u **)(varp)) < 0
9253 || put_eol(fd) < 0)
9254 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009255 do_endif = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009256 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009257#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009258 if (put_setstring(fd, cmd, p->fullname, (char_u **)varp,
9259 (p->flags & P_EXPAND) != 0) == FAIL)
9260 return FAIL;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009261#if defined(FEAT_SYN_HL) || defined(FEAT_AUTOCMD)
9262 if (do_endif)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009263 {
9264 if (put_line(fd, "endif") == FAIL)
9265 return FAIL;
9266 }
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009267#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009268 }
9269 }
9270 }
Bram Moolenaar7fd16022007-09-06 14:35:35 +00009271 }
Bram Moolenaar071d4272004-06-13 20:20:40 +00009272 return OK;
9273}
9274
9275#if defined(FEAT_FOLDING) || defined(PROTO)
9276/*
9277 * Generate set commands for the local fold options only. Used when
9278 * 'sessionoptions' or 'viewoptions' contains "folds" but not "options".
9279 */
9280 int
9281makefoldset(fd)
9282 FILE *fd;
9283{
9284 if (put_setstring(fd, "setlocal", "fdm", &curwin->w_p_fdm, FALSE) == FAIL
9285# ifdef FEAT_EVAL
9286 || put_setstring(fd, "setlocal", "fde", &curwin->w_p_fde, FALSE)
9287 == FAIL
9288# endif
9289 || put_setstring(fd, "setlocal", "fmr", &curwin->w_p_fmr, FALSE)
9290 == FAIL
9291 || put_setstring(fd, "setlocal", "fdi", &curwin->w_p_fdi, FALSE)
9292 == FAIL
9293 || put_setnum(fd, "setlocal", "fdl", &curwin->w_p_fdl) == FAIL
9294 || put_setnum(fd, "setlocal", "fml", &curwin->w_p_fml) == FAIL
9295 || put_setnum(fd, "setlocal", "fdn", &curwin->w_p_fdn) == FAIL
9296 || put_setbool(fd, "setlocal", "fen", curwin->w_p_fen) == FAIL
9297 )
9298 return FAIL;
9299
9300 return OK;
9301}
9302#endif
9303
9304 static int
9305put_setstring(fd, cmd, name, valuep, expand)
9306 FILE *fd;
9307 char *cmd;
9308 char *name;
9309 char_u **valuep;
9310 int expand;
9311{
9312 char_u *s;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009313 char_u *buf;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009314
9315 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9316 return FAIL;
9317 if (*valuep != NULL)
9318 {
9319 /* Output 'pastetoggle' as key names. For other
9320 * options some characters have to be escaped with
9321 * CTRL-V or backslash */
9322 if (valuep == &p_pt)
9323 {
9324 s = *valuep;
9325 while (*s != NUL)
Bram Moolenaar7d96acd2008-06-09 15:07:54 +00009326 if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009327 return FAIL;
9328 }
9329 else if (expand)
9330 {
Bram Moolenaarf8441472011-04-28 17:24:58 +02009331 buf = alloc(MAXPATHL);
9332 if (buf == NULL)
9333 return FAIL;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009334 home_replace(NULL, *valuep, buf, MAXPATHL, FALSE);
9335 if (put_escstr(fd, buf, 2) == FAIL)
Bram Moolenaarf8441472011-04-28 17:24:58 +02009336 {
9337 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009338 return FAIL;
Bram Moolenaarf8441472011-04-28 17:24:58 +02009339 }
9340 vim_free(buf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009341 }
9342 else if (put_escstr(fd, *valuep, 2) == FAIL)
9343 return FAIL;
9344 }
9345 if (put_eol(fd) < 0)
9346 return FAIL;
9347 return OK;
9348}
9349
9350 static int
9351put_setnum(fd, cmd, name, valuep)
9352 FILE *fd;
9353 char *cmd;
9354 char *name;
9355 long *valuep;
9356{
9357 long wc;
9358
9359 if (fprintf(fd, "%s %s=", cmd, name) < 0)
9360 return FAIL;
9361 if (wc_use_keyname((char_u *)valuep, &wc))
9362 {
9363 /* print 'wildchar' and 'wildcharm' as a key name */
9364 if (fputs((char *)get_special_key_name((int)wc, 0), fd) < 0)
9365 return FAIL;
9366 }
9367 else if (fprintf(fd, "%ld", *valuep) < 0)
9368 return FAIL;
9369 if (put_eol(fd) < 0)
9370 return FAIL;
9371 return OK;
9372}
9373
9374 static int
9375put_setbool(fd, cmd, name, value)
9376 FILE *fd;
9377 char *cmd;
9378 char *name;
9379 int value;
9380{
Bram Moolenaar893de922007-10-02 18:40:57 +00009381 if (value < 0) /* global/local option using global value */
9382 return OK;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009383 if (fprintf(fd, "%s %s%s", cmd, value ? "" : "no", name) < 0
9384 || put_eol(fd) < 0)
9385 return FAIL;
9386 return OK;
9387}
9388
9389/*
9390 * Clear all the terminal options.
9391 * If the option has been allocated, free the memory.
9392 * Terminal options are never hidden or indirect.
9393 */
9394 void
9395clear_termoptions()
9396{
Bram Moolenaar071d4272004-06-13 20:20:40 +00009397 /*
9398 * Reset a few things before clearing the old options. This may cause
9399 * outputting a few things that the terminal doesn't understand, but the
9400 * screen will be cleared later, so this is OK.
9401 */
9402#ifdef FEAT_MOUSE_TTY
9403 mch_setmouse(FALSE); /* switch mouse off */
9404#endif
9405#ifdef FEAT_TITLE
9406 mch_restore_title(3); /* restore window titles */
9407#endif
9408#if defined(FEAT_XCLIPBOARD) && defined(FEAT_GUI)
9409 /* When starting the GUI close the display opened for the clipboard.
9410 * After restoring the title, because that will need the display. */
9411 if (gui.starting)
9412 clear_xterm_clip();
9413#endif
9414#ifdef WIN3264
9415 /*
9416 * Check if this is allowed now.
9417 */
9418 if (can_end_termcap_mode(FALSE) == TRUE)
9419#endif
9420 stoptermcap(); /* stop termcap mode */
9421
Bram Moolenaarf461c8e2005-06-25 23:04:51 +00009422 free_termoptions();
9423}
9424
9425 void
9426free_termoptions()
9427{
9428 struct vimoption *p;
9429
Bram Moolenaar071d4272004-06-13 20:20:40 +00009430 for (p = &options[0]; p->fullname != NULL; p++)
9431 if (istermoption(p))
9432 {
9433 if (p->flags & P_ALLOCED)
9434 free_string_option(*(char_u **)(p->var));
9435 if (p->flags & P_DEF_ALLOCED)
9436 free_string_option(p->def_val[VI_DEFAULT]);
9437 *(char_u **)(p->var) = empty_option;
9438 p->def_val[VI_DEFAULT] = empty_option;
9439 p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
9440 }
9441 clear_termcodes();
9442}
9443
9444/*
Bram Moolenaar363cb672009-07-22 12:28:17 +00009445 * Free the string for one term option, if it was allocated.
9446 * Set the string to empty_option and clear allocated flag.
9447 * "var" points to the option value.
9448 */
9449 void
9450free_one_termoption(var)
9451 char_u *var;
9452{
9453 struct vimoption *p;
9454
9455 for (p = &options[0]; p->fullname != NULL; p++)
9456 if (p->var == var)
9457 {
9458 if (p->flags & P_ALLOCED)
9459 free_string_option(*(char_u **)(p->var));
9460 *(char_u **)(p->var) = empty_option;
9461 p->flags &= ~P_ALLOCED;
9462 break;
9463 }
9464}
9465
9466/*
Bram Moolenaar071d4272004-06-13 20:20:40 +00009467 * Set the terminal option defaults to the current value.
9468 * Used after setting the terminal name.
9469 */
9470 void
9471set_term_defaults()
9472{
9473 struct vimoption *p;
9474
9475 for (p = &options[0]; p->fullname != NULL; p++)
9476 {
9477 if (istermoption(p) && p->def_val[VI_DEFAULT] != *(char_u **)(p->var))
9478 {
9479 if (p->flags & P_DEF_ALLOCED)
9480 {
9481 free_string_option(p->def_val[VI_DEFAULT]);
9482 p->flags &= ~P_DEF_ALLOCED;
9483 }
9484 p->def_val[VI_DEFAULT] = *(char_u **)(p->var);
9485 if (p->flags & P_ALLOCED)
9486 {
9487 p->flags |= P_DEF_ALLOCED;
9488 p->flags &= ~P_ALLOCED; /* don't free the value now */
9489 }
9490 }
9491 }
9492}
9493
9494/*
9495 * return TRUE if 'p' starts with 't_'
9496 */
9497 static int
9498istermoption(p)
9499 struct vimoption *p;
9500{
9501 return (p->fullname[0] == 't' && p->fullname[1] == '_');
9502}
9503
9504/*
9505 * Compute columns for ruler and shown command. 'sc_col' is also used to
9506 * decide what the maximum length of a message on the status line can be.
9507 * If there is a status line for the last window, 'sc_col' is independent
9508 * of 'ru_col'.
9509 */
9510
9511#define COL_RULER 17 /* columns needed by standard ruler */
9512
9513 void
9514comp_col()
9515{
9516#if defined(FEAT_CMDL_INFO) && defined(FEAT_WINDOWS)
9517 int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin));
9518
9519 sc_col = 0;
9520 ru_col = 0;
9521 if (p_ru)
9522 {
9523#ifdef FEAT_STL_OPT
9524 ru_col = (ru_wid ? ru_wid : COL_RULER) + 1;
9525#else
9526 ru_col = COL_RULER + 1;
9527#endif
9528 /* no last status line, adjust sc_col */
9529 if (!last_has_status)
9530 sc_col = ru_col;
9531 }
9532 if (p_sc)
9533 {
9534 sc_col += SHOWCMD_COLS;
9535 if (!p_ru || last_has_status) /* no need for separating space */
9536 ++sc_col;
9537 }
9538 sc_col = Columns - sc_col;
9539 ru_col = Columns - ru_col;
9540 if (sc_col <= 0) /* screen too narrow, will become a mess */
9541 sc_col = 1;
9542 if (ru_col <= 0)
9543 ru_col = 1;
9544#else
9545 sc_col = Columns;
9546 ru_col = Columns;
9547#endif
9548}
9549
9550/*
9551 * Get pointer to option variable, depending on local or global scope.
9552 */
9553 static char_u *
9554get_varp_scope(p, opt_flags)
9555 struct vimoption *p;
9556 int opt_flags;
9557{
9558 if ((opt_flags & OPT_GLOBAL) && p->indir != PV_NONE)
9559 {
9560 if (p->var == VAR_WIN)
9561 return (char_u *)GLOBAL_WO(get_varp(p));
9562 return p->var;
9563 }
Bram Moolenaara23ccb82006-02-27 00:08:02 +00009564 if ((opt_flags & OPT_LOCAL) && ((int)p->indir & PV_BOTH))
Bram Moolenaar071d4272004-06-13 20:20:40 +00009565 {
9566 switch ((int)p->indir)
9567 {
9568#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009569 case PV_EFM: return (char_u *)&(curbuf->b_p_efm);
9570 case PV_GP: return (char_u *)&(curbuf->b_p_gp);
9571 case PV_MP: return (char_u *)&(curbuf->b_p_mp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009572#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009573 case PV_EP: return (char_u *)&(curbuf->b_p_ep);
9574 case PV_KP: return (char_u *)&(curbuf->b_p_kp);
9575 case PV_PATH: return (char_u *)&(curbuf->b_p_path);
Bram Moolenaara23ccb82006-02-27 00:08:02 +00009576 case PV_AR: return (char_u *)&(curbuf->b_p_ar);
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009577 case PV_TAGS: return (char_u *)&(curbuf->b_p_tags);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009578#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009579 case PV_DEF: return (char_u *)&(curbuf->b_p_def);
9580 case PV_INC: return (char_u *)&(curbuf->b_p_inc);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009581#endif
9582#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009583 case PV_DICT: return (char_u *)&(curbuf->b_p_dict);
9584 case PV_TSR: return (char_u *)&(curbuf->b_p_tsr);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009585#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00009586#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9587 case PV_BEXPR: return (char_u *)&(curbuf->b_p_bexpr);
9588#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02009589#if defined(FEAT_CRYPT)
9590 case PV_CM: return (char_u *)&(curbuf->b_p_cm);
9591#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009592#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009593 case PV_STL: return (char_u *)&(curwin->w_p_stl);
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009594#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009595 }
9596 return NULL; /* "cannot happen" */
9597 }
9598 return get_varp(p);
9599}
9600
9601/*
9602 * Get pointer to option variable.
9603 */
9604 static char_u *
9605get_varp(p)
9606 struct vimoption *p;
9607{
9608 /* hidden option, always return NULL */
9609 if (p->var == NULL)
9610 return NULL;
9611
9612 switch ((int)p->indir)
9613 {
9614 case PV_NONE: return p->var;
9615
9616 /* global option with local value: use local value if it's been set */
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009617 case PV_EP: return *curbuf->b_p_ep != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009618 ? (char_u *)&curbuf->b_p_ep : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009619 case PV_KP: return *curbuf->b_p_kp != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009620 ? (char_u *)&curbuf->b_p_kp : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009621 case PV_PATH: return *curbuf->b_p_path != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009622 ? (char_u *)&(curbuf->b_p_path) : p->var;
Bram Moolenaara23ccb82006-02-27 00:08:02 +00009623 case PV_AR: return curbuf->b_p_ar >= 0
Bram Moolenaar071d4272004-06-13 20:20:40 +00009624 ? (char_u *)&(curbuf->b_p_ar) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009625 case PV_TAGS: return *curbuf->b_p_tags != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009626 ? (char_u *)&(curbuf->b_p_tags) : p->var;
9627#ifdef FEAT_FIND_ID
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009628 case PV_DEF: return *curbuf->b_p_def != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009629 ? (char_u *)&(curbuf->b_p_def) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009630 case PV_INC: return *curbuf->b_p_inc != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009631 ? (char_u *)&(curbuf->b_p_inc) : p->var;
9632#endif
9633#ifdef FEAT_INS_EXPAND
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009634 case PV_DICT: return *curbuf->b_p_dict != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009635 ? (char_u *)&(curbuf->b_p_dict) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009636 case PV_TSR: return *curbuf->b_p_tsr != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009637 ? (char_u *)&(curbuf->b_p_tsr) : p->var;
9638#endif
9639#ifdef FEAT_QUICKFIX
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009640 case PV_EFM: return *curbuf->b_p_efm != NUL
Bram Moolenaar071d4272004-06-13 20:20:40 +00009641 ? (char_u *)&(curbuf->b_p_efm) : p->var;
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009642 case PV_GP: return *curbuf->b_p_gp != NUL
9643 ? (char_u *)&(curbuf->b_p_gp) : p->var;
9644 case PV_MP: return *curbuf->b_p_mp != NUL
9645 ? (char_u *)&(curbuf->b_p_mp) : p->var;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009646#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +00009647#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
9648 case PV_BEXPR: return *curbuf->b_p_bexpr != NUL
9649 ? (char_u *)&(curbuf->b_p_bexpr) : p->var;
9650#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +02009651#if defined(FEAT_CRYPT)
9652 case PV_CM: return *curbuf->b_p_cm != NUL
9653 ? (char_u *)&(curbuf->b_p_cm) : p->var;
9654#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009655#ifdef FEAT_STL_OPT
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009656 case PV_STL: return *curwin->w_p_stl != NUL
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009657 ? (char_u *)&(curwin->w_p_stl) : p->var;
9658#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009659
9660#ifdef FEAT_ARABIC
9661 case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
9662#endif
9663 case PV_LIST: return (char_u *)&(curwin->w_p_list);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00009664#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00009665 case PV_SPELL: return (char_u *)&(curwin->w_p_spell);
9666#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00009667#ifdef FEAT_SYN_HL
9668 case PV_CUC: return (char_u *)&(curwin->w_p_cuc);
9669 case PV_CUL: return (char_u *)&(curwin->w_p_cul);
Bram Moolenaar1a384422010-07-14 19:53:30 +02009670 case PV_CC: return (char_u *)&(curwin->w_p_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00009671#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009672#ifdef FEAT_DIFF
9673 case PV_DIFF: return (char_u *)&(curwin->w_p_diff);
9674#endif
9675#ifdef FEAT_FOLDING
9676 case PV_FDC: return (char_u *)&(curwin->w_p_fdc);
9677 case PV_FEN: return (char_u *)&(curwin->w_p_fen);
9678 case PV_FDI: return (char_u *)&(curwin->w_p_fdi);
9679 case PV_FDL: return (char_u *)&(curwin->w_p_fdl);
9680 case PV_FDM: return (char_u *)&(curwin->w_p_fdm);
9681 case PV_FML: return (char_u *)&(curwin->w_p_fml);
9682 case PV_FDN: return (char_u *)&(curwin->w_p_fdn);
9683# ifdef FEAT_EVAL
9684 case PV_FDE: return (char_u *)&(curwin->w_p_fde);
9685 case PV_FDT: return (char_u *)&(curwin->w_p_fdt);
9686# endif
9687 case PV_FMR: return (char_u *)&(curwin->w_p_fmr);
9688#endif
9689 case PV_NU: return (char_u *)&(curwin->w_p_nu);
Bram Moolenaar64486672010-05-16 15:46:46 +02009690 case PV_RNU: return (char_u *)&(curwin->w_p_rnu);
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009691#ifdef FEAT_LINEBREAK
9692 case PV_NUW: return (char_u *)&(curwin->w_p_nuw);
9693#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009694#ifdef FEAT_WINDOWS
Bram Moolenaar071d4272004-06-13 20:20:40 +00009695 case PV_WFH: return (char_u *)&(curwin->w_p_wfh);
9696#endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +00009697#ifdef FEAT_VERTSPLIT
9698 case PV_WFW: return (char_u *)&(curwin->w_p_wfw);
9699#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009700#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
9701 case PV_PVW: return (char_u *)&(curwin->w_p_pvw);
9702#endif
9703#ifdef FEAT_RIGHTLEFT
9704 case PV_RL: return (char_u *)&(curwin->w_p_rl);
9705 case PV_RLC: return (char_u *)&(curwin->w_p_rlc);
9706#endif
9707 case PV_SCROLL: return (char_u *)&(curwin->w_p_scr);
9708 case PV_WRAP: return (char_u *)&(curwin->w_p_wrap);
9709#ifdef FEAT_LINEBREAK
9710 case PV_LBR: return (char_u *)&(curwin->w_p_lbr);
9711#endif
9712#ifdef FEAT_SCROLLBIND
9713 case PV_SCBIND: return (char_u *)&(curwin->w_p_scb);
9714#endif
Bram Moolenaar860cae12010-06-05 23:22:07 +02009715#ifdef FEAT_CURSORBIND
9716 case PV_CRBIND: return (char_u *)&(curwin->w_p_crb);
9717#endif
9718#ifdef FEAT_CONCEAL
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009719 case PV_COCU: return (char_u *)&(curwin->w_p_cocu);
9720 case PV_COLE: return (char_u *)&(curwin->w_p_cole);
Bram Moolenaar860cae12010-06-05 23:22:07 +02009721#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009722
9723 case PV_AI: return (char_u *)&(curbuf->b_p_ai);
9724 case PV_BIN: return (char_u *)&(curbuf->b_p_bin);
9725#ifdef FEAT_MBYTE
9726 case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
9727#endif
9728#if defined(FEAT_QUICKFIX)
9729 case PV_BH: return (char_u *)&(curbuf->b_p_bh);
9730 case PV_BT: return (char_u *)&(curbuf->b_p_bt);
9731#endif
9732 case PV_BL: return (char_u *)&(curbuf->b_p_bl);
9733 case PV_CI: return (char_u *)&(curbuf->b_p_ci);
9734#ifdef FEAT_CINDENT
9735 case PV_CIN: return (char_u *)&(curbuf->b_p_cin);
9736 case PV_CINK: return (char_u *)&(curbuf->b_p_cink);
9737 case PV_CINO: return (char_u *)&(curbuf->b_p_cino);
9738#endif
9739#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
9740 case PV_CINW: return (char_u *)&(curbuf->b_p_cinw);
9741#endif
9742#ifdef FEAT_COMMENTS
9743 case PV_COM: return (char_u *)&(curbuf->b_p_com);
9744#endif
9745#ifdef FEAT_FOLDING
9746 case PV_CMS: return (char_u *)&(curbuf->b_p_cms);
9747#endif
9748#ifdef FEAT_INS_EXPAND
9749 case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
9750#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00009751#ifdef FEAT_COMPL_FUNC
9752 case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +00009753 case PV_OFU: return (char_u *)&(curbuf->b_p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00009754#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009755 case PV_EOL: return (char_u *)&(curbuf->b_p_eol);
9756 case PV_ET: return (char_u *)&(curbuf->b_p_et);
9757#ifdef FEAT_MBYTE
9758 case PV_FENC: return (char_u *)&(curbuf->b_p_fenc);
9759#endif
9760 case PV_FF: return (char_u *)&(curbuf->b_p_ff);
9761#ifdef FEAT_AUTOCMD
9762 case PV_FT: return (char_u *)&(curbuf->b_p_ft);
9763#endif
9764 case PV_FO: return (char_u *)&(curbuf->b_p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +00009765 case PV_FLP: return (char_u *)&(curbuf->b_p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009766 case PV_IMI: return (char_u *)&(curbuf->b_p_iminsert);
9767 case PV_IMS: return (char_u *)&(curbuf->b_p_imsearch);
9768 case PV_INF: return (char_u *)&(curbuf->b_p_inf);
9769 case PV_ISK: return (char_u *)&(curbuf->b_p_isk);
9770#ifdef FEAT_FIND_ID
9771# ifdef FEAT_EVAL
9772 case PV_INEX: return (char_u *)&(curbuf->b_p_inex);
9773# endif
9774#endif
9775#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
9776 case PV_INDE: return (char_u *)&(curbuf->b_p_inde);
9777 case PV_INDK: return (char_u *)&(curbuf->b_p_indk);
9778#endif
Bram Moolenaar5e3cb7e2006-02-27 23:58:35 +00009779#ifdef FEAT_EVAL
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +00009780 case PV_FEX: return (char_u *)&(curbuf->b_p_fex);
9781#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009782#ifdef FEAT_CRYPT
9783 case PV_KEY: return (char_u *)&(curbuf->b_p_key);
9784#endif
9785#ifdef FEAT_LISP
9786 case PV_LISP: return (char_u *)&(curbuf->b_p_lisp);
9787#endif
9788 case PV_ML: return (char_u *)&(curbuf->b_p_ml);
9789 case PV_MPS: return (char_u *)&(curbuf->b_p_mps);
9790 case PV_MA: return (char_u *)&(curbuf->b_p_ma);
9791 case PV_MOD: return (char_u *)&(curbuf->b_changed);
9792 case PV_NF: return (char_u *)&(curbuf->b_p_nf);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009793 case PV_PI: return (char_u *)&(curbuf->b_p_pi);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +00009794#ifdef FEAT_TEXTOBJ
9795 case PV_QE: return (char_u *)&(curbuf->b_p_qe);
9796#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009797 case PV_RO: return (char_u *)&(curbuf->b_p_ro);
9798#ifdef FEAT_SMARTINDENT
9799 case PV_SI: return (char_u *)&(curbuf->b_p_si);
9800#endif
9801#ifndef SHORT_FNAME
9802 case PV_SN: return (char_u *)&(curbuf->b_p_sn);
9803#endif
9804 case PV_STS: return (char_u *)&(curbuf->b_p_sts);
9805#ifdef FEAT_SEARCHPATH
9806 case PV_SUA: return (char_u *)&(curbuf->b_p_sua);
9807#endif
9808 case PV_SWF: return (char_u *)&(curbuf->b_p_swf);
9809#ifdef FEAT_SYN_HL
Bram Moolenaar3b56eb32005-07-11 22:40:32 +00009810 case PV_SMC: return (char_u *)&(curbuf->b_p_smc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00009811 case PV_SYN: return (char_u *)&(curbuf->b_p_syn);
9812#endif
9813#ifdef FEAT_SPELL
Bram Moolenaar860cae12010-06-05 23:22:07 +02009814 case PV_SPC: return (char_u *)&(curwin->w_s->b_p_spc);
9815 case PV_SPF: return (char_u *)&(curwin->w_s->b_p_spf);
9816 case PV_SPL: return (char_u *)&(curwin->w_s->b_p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +00009817#endif
9818 case PV_SW: return (char_u *)&(curbuf->b_p_sw);
9819 case PV_TS: return (char_u *)&(curbuf->b_p_ts);
9820 case PV_TW: return (char_u *)&(curbuf->b_p_tw);
9821 case PV_TX: return (char_u *)&(curbuf->b_p_tx);
Bram Moolenaar55debbe2010-05-23 23:34:36 +02009822#ifdef FEAT_PERSISTENT_UNDO
9823 case PV_UDF: return (char_u *)&(curbuf->b_p_udf);
9824#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009825 case PV_WM: return (char_u *)&(curbuf->b_p_wm);
9826#ifdef FEAT_KEYMAP
9827 case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap);
9828#endif
9829 default: EMSG(_("E356: get_varp ERROR"));
9830 }
9831 /* always return a valid pointer to avoid a crash! */
9832 return (char_u *)&(curbuf->b_p_wm);
9833}
9834
9835/*
9836 * Get the value of 'equalprg', either the buffer-local one or the global one.
9837 */
9838 char_u *
9839get_equalprg()
9840{
9841 if (*curbuf->b_p_ep == NUL)
9842 return p_ep;
9843 return curbuf->b_p_ep;
9844}
9845
9846#if defined(FEAT_WINDOWS) || defined(PROTO)
9847/*
9848 * Copy options from one window to another.
9849 * Used when splitting a window.
9850 */
9851 void
9852win_copy_options(wp_from, wp_to)
9853 win_T *wp_from;
9854 win_T *wp_to;
9855{
9856 copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt);
9857 copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt);
9858# ifdef FEAT_RIGHTLEFT
9859# ifdef FEAT_FKMAP
9860 /* Is this right? */
9861 wp_to->w_farsi = wp_from->w_farsi;
9862# endif
9863# endif
9864}
9865#endif
9866
9867/*
9868 * Copy the options from one winopt_T to another.
9869 * Doesn't free the old option values in "to", use clear_winopt() for that.
9870 * The 'scroll' option is not copied, because it depends on the window height.
9871 * The 'previewwindow' option is reset, there can be only one preview window.
9872 */
9873 void
9874copy_winopt(from, to)
9875 winopt_T *from;
9876 winopt_T *to;
9877{
9878#ifdef FEAT_ARABIC
9879 to->wo_arab = from->wo_arab;
9880#endif
9881 to->wo_list = from->wo_list;
9882 to->wo_nu = from->wo_nu;
Bram Moolenaar64486672010-05-16 15:46:46 +02009883 to->wo_rnu = from->wo_rnu;
Bram Moolenaar592e0a22004-07-03 16:05:59 +00009884#ifdef FEAT_LINEBREAK
9885 to->wo_nuw = from->wo_nuw;
9886#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009887#ifdef FEAT_RIGHTLEFT
9888 to->wo_rl = from->wo_rl;
9889 to->wo_rlc = vim_strsave(from->wo_rlc);
9890#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009891#ifdef FEAT_STL_OPT
9892 to->wo_stl = vim_strsave(from->wo_stl);
9893#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009894 to->wo_wrap = from->wo_wrap;
9895#ifdef FEAT_LINEBREAK
9896 to->wo_lbr = from->wo_lbr;
9897#endif
9898#ifdef FEAT_SCROLLBIND
9899 to->wo_scb = from->wo_scb;
9900#endif
Bram Moolenaar4161dcc2010-12-02 15:33:21 +01009901#ifdef FEAT_CURSORBIND
9902 to->wo_crb = from->wo_crb;
9903#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00009904#ifdef FEAT_SPELL
Bram Moolenaar217ad922005-03-20 22:37:15 +00009905 to->wo_spell = from->wo_spell;
9906#endif
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00009907#ifdef FEAT_SYN_HL
9908 to->wo_cuc = from->wo_cuc;
9909 to->wo_cul = from->wo_cul;
Bram Moolenaar1a384422010-07-14 19:53:30 +02009910 to->wo_cc = vim_strsave(from->wo_cc);
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +00009911#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009912#ifdef FEAT_DIFF
9913 to->wo_diff = from->wo_diff;
9914#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009915#ifdef FEAT_CONCEAL
9916 to->wo_cocu = vim_strsave(from->wo_cocu);
Bram Moolenaard497a302010-07-23 22:27:03 +02009917 to->wo_cole = from->wo_cole;
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009918#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009919#ifdef FEAT_FOLDING
9920 to->wo_fdc = from->wo_fdc;
9921 to->wo_fen = from->wo_fen;
9922 to->wo_fdi = vim_strsave(from->wo_fdi);
9923 to->wo_fml = from->wo_fml;
9924 to->wo_fdl = from->wo_fdl;
9925 to->wo_fdm = vim_strsave(from->wo_fdm);
9926 to->wo_fdn = from->wo_fdn;
9927# ifdef FEAT_EVAL
9928 to->wo_fde = vim_strsave(from->wo_fde);
9929 to->wo_fdt = vim_strsave(from->wo_fdt);
9930# endif
9931 to->wo_fmr = vim_strsave(from->wo_fmr);
9932#endif
9933 check_winopt(to); /* don't want NULL pointers */
9934}
9935
9936/*
9937 * Check string options in a window for a NULL value.
9938 */
9939 void
9940check_win_options(win)
9941 win_T *win;
9942{
9943 check_winopt(&win->w_onebuf_opt);
9944 check_winopt(&win->w_allbuf_opt);
9945}
9946
9947/*
9948 * Check for NULL pointers in a winopt_T and replace them with empty_option.
9949 */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009950 void
9951check_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +00009952 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009953{
9954#ifdef FEAT_FOLDING
9955 check_string_option(&wop->wo_fdi);
9956 check_string_option(&wop->wo_fdm);
9957# ifdef FEAT_EVAL
9958 check_string_option(&wop->wo_fde);
9959 check_string_option(&wop->wo_fdt);
9960# endif
9961 check_string_option(&wop->wo_fmr);
9962#endif
9963#ifdef FEAT_RIGHTLEFT
9964 check_string_option(&wop->wo_rlc);
9965#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009966#ifdef FEAT_STL_OPT
9967 check_string_option(&wop->wo_stl);
9968#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +02009969#ifdef FEAT_SYN_HL
9970 check_string_option(&wop->wo_cc);
9971#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +02009972#ifdef FEAT_CONCEAL
9973 check_string_option(&wop->wo_cocu);
9974#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +00009975}
9976
9977/*
9978 * Free the allocated memory inside a winopt_T.
9979 */
Bram Moolenaar071d4272004-06-13 20:20:40 +00009980 void
9981clear_winopt(wop)
Bram Moolenaar78a15312009-05-15 19:33:18 +00009982 winopt_T *wop UNUSED;
Bram Moolenaar071d4272004-06-13 20:20:40 +00009983{
9984#ifdef FEAT_FOLDING
9985 clear_string_option(&wop->wo_fdi);
9986 clear_string_option(&wop->wo_fdm);
9987# ifdef FEAT_EVAL
9988 clear_string_option(&wop->wo_fde);
9989 clear_string_option(&wop->wo_fdt);
9990# endif
9991 clear_string_option(&wop->wo_fmr);
9992#endif
9993#ifdef FEAT_RIGHTLEFT
9994 clear_string_option(&wop->wo_rlc);
9995#endif
Bram Moolenaarb5bf5b82004-12-24 14:35:23 +00009996#ifdef FEAT_STL_OPT
9997 clear_string_option(&wop->wo_stl);
9998#endif
Bram Moolenaar1a384422010-07-14 19:53:30 +02009999#ifdef FEAT_SYN_HL
10000 clear_string_option(&wop->wo_cc);
10001#endif
Bram Moolenaarf5963f72010-07-23 22:10:27 +020010002#ifdef FEAT_CONCEAL
10003 clear_string_option(&wop->wo_cocu);
10004#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010005}
10006
10007/*
10008 * Copy global option values to local options for one buffer.
10009 * Used when creating a new buffer and sometimes when entering a buffer.
10010 * flags:
10011 * BCO_ENTER We will enter the buf buffer.
10012 * BCO_ALWAYS Always copy the options, but only set b_p_initialized when
10013 * appropriate.
10014 * BCO_NOHELP Don't copy the values to a help buffer.
10015 */
10016 void
10017buf_copy_options(buf, flags)
10018 buf_T *buf;
10019 int flags;
10020{
10021 int should_copy = TRUE;
10022 char_u *save_p_isk = NULL; /* init for GCC */
10023 int dont_do_help;
10024 int did_isk = FALSE;
10025
10026 /*
Bram Moolenaar1a384422010-07-14 19:53:30 +020010027 * Don't do anything if the buffer is invalid.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010028 */
10029 if (buf == NULL || !buf_valid(buf))
10030 return;
10031
10032 /*
10033 * Skip this when the option defaults have not been set yet. Happens when
10034 * main() allocates the first buffer.
10035 */
10036 if (p_cpo != NULL)
10037 {
10038 /*
10039 * Always copy when entering and 'cpo' contains 'S'.
10040 * Don't copy when already initialized.
10041 * Don't copy when 'cpo' contains 's' and not entering.
10042 * 'S' BCO_ENTER initialized 's' should_copy
10043 * yes yes X X TRUE
10044 * yes no yes X FALSE
10045 * no X yes X FALSE
10046 * X no no yes FALSE
10047 * X no no no TRUE
10048 * no yes no X TRUE
10049 */
10050 if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
10051 && (buf->b_p_initialized
10052 || (!(flags & BCO_ENTER)
10053 && vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
10054 should_copy = FALSE;
10055
10056 if (should_copy || (flags & BCO_ALWAYS))
10057 {
10058 /* Don't copy the options specific to a help buffer when
10059 * BCO_NOHELP is given or the options were initialized already
10060 * (jumping back to a help file with CTRL-T or CTRL-O) */
10061 dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
10062 || buf->b_p_initialized;
10063 if (dont_do_help) /* don't free b_p_isk */
10064 {
10065 save_p_isk = buf->b_p_isk;
10066 buf->b_p_isk = NULL;
10067 }
10068 /*
10069 * Always free the allocated strings.
10070 * If not already initialized, set 'readonly' and copy 'fileformat'.
10071 */
10072 if (!buf->b_p_initialized)
10073 {
10074 free_buf_options(buf, TRUE);
10075 buf->b_p_ro = FALSE; /* don't copy readonly */
10076 buf->b_p_tx = p_tx;
10077#ifdef FEAT_MBYTE
10078 buf->b_p_fenc = vim_strsave(p_fenc);
10079#endif
10080 buf->b_p_ff = vim_strsave(p_ff);
10081#if defined(FEAT_QUICKFIX)
10082 buf->b_p_bh = empty_option;
10083 buf->b_p_bt = empty_option;
10084#endif
10085 }
10086 else
10087 free_buf_options(buf, FALSE);
10088
10089 buf->b_p_ai = p_ai;
10090 buf->b_p_ai_nopaste = p_ai_nopaste;
10091 buf->b_p_sw = p_sw;
10092 buf->b_p_tw = p_tw;
10093 buf->b_p_tw_nopaste = p_tw_nopaste;
10094 buf->b_p_tw_nobin = p_tw_nobin;
10095 buf->b_p_wm = p_wm;
10096 buf->b_p_wm_nopaste = p_wm_nopaste;
10097 buf->b_p_wm_nobin = p_wm_nobin;
10098 buf->b_p_bin = p_bin;
Bram Moolenaare8bb2552005-07-08 22:26:47 +000010099#ifdef FEAT_MBYTE
10100 buf->b_p_bomb = p_bomb;
10101#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010102 buf->b_p_et = p_et;
10103 buf->b_p_et_nobin = p_et_nobin;
10104 buf->b_p_ml = p_ml;
10105 buf->b_p_ml_nobin = p_ml_nobin;
10106 buf->b_p_inf = p_inf;
10107 buf->b_p_swf = p_swf;
10108#ifdef FEAT_INS_EXPAND
10109 buf->b_p_cpt = vim_strsave(p_cpt);
10110#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010111#ifdef FEAT_COMPL_FUNC
10112 buf->b_p_cfu = vim_strsave(p_cfu);
Bram Moolenaare344bea2005-09-01 20:46:49 +000010113 buf->b_p_ofu = vim_strsave(p_ofu);
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010114#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010115 buf->b_p_sts = p_sts;
10116 buf->b_p_sts_nopaste = p_sts_nopaste;
10117#ifndef SHORT_FNAME
10118 buf->b_p_sn = p_sn;
10119#endif
10120#ifdef FEAT_COMMENTS
10121 buf->b_p_com = vim_strsave(p_com);
10122#endif
10123#ifdef FEAT_FOLDING
10124 buf->b_p_cms = vim_strsave(p_cms);
10125#endif
10126 buf->b_p_fo = vim_strsave(p_fo);
Bram Moolenaar86b68352004-12-27 21:59:20 +000010127 buf->b_p_flp = vim_strsave(p_flp);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010128 buf->b_p_nf = vim_strsave(p_nf);
10129 buf->b_p_mps = vim_strsave(p_mps);
10130#ifdef FEAT_SMARTINDENT
10131 buf->b_p_si = p_si;
10132#endif
10133 buf->b_p_ci = p_ci;
10134#ifdef FEAT_CINDENT
10135 buf->b_p_cin = p_cin;
10136 buf->b_p_cink = vim_strsave(p_cink);
10137 buf->b_p_cino = vim_strsave(p_cino);
10138#endif
10139#ifdef FEAT_AUTOCMD
10140 /* Don't copy 'filetype', it must be detected */
10141 buf->b_p_ft = empty_option;
10142#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010143 buf->b_p_pi = p_pi;
10144#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
10145 buf->b_p_cinw = vim_strsave(p_cinw);
10146#endif
10147#ifdef FEAT_LISP
10148 buf->b_p_lisp = p_lisp;
10149#endif
10150#ifdef FEAT_SYN_HL
10151 /* Don't copy 'syntax', it must be set */
10152 buf->b_p_syn = empty_option;
Bram Moolenaar3b56eb32005-07-11 22:40:32 +000010153 buf->b_p_smc = p_smc;
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010154#endif
10155#ifdef FEAT_SPELL
Bram Moolenaard5784f92010-10-13 14:05:35 +020010156 buf->b_s.b_p_spc = vim_strsave(p_spc);
Bram Moolenaar860cae12010-06-05 23:22:07 +020010157 (void)compile_cap_prog(&buf->b_s);
10158 buf->b_s.b_p_spf = vim_strsave(p_spf);
10159 buf->b_s.b_p_spl = vim_strsave(p_spl);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010160#endif
10161#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
10162 buf->b_p_inde = vim_strsave(p_inde);
10163 buf->b_p_indk = vim_strsave(p_indk);
10164#endif
Bram Moolenaar1d2ba7f2006-02-14 22:29:30 +000010165#if defined(FEAT_EVAL)
10166 buf->b_p_fex = vim_strsave(p_fex);
10167#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010168#ifdef FEAT_CRYPT
10169 buf->b_p_key = vim_strsave(p_key);
10170#endif
10171#ifdef FEAT_SEARCHPATH
10172 buf->b_p_sua = vim_strsave(p_sua);
10173#endif
10174#ifdef FEAT_KEYMAP
10175 buf->b_p_keymap = vim_strsave(p_keymap);
10176 buf->b_kmap_state |= KEYMAP_INIT;
10177#endif
10178 /* This isn't really an option, but copying the langmap and IME
10179 * state from the current buffer is better than resetting it. */
10180 buf->b_p_iminsert = p_iminsert;
10181 buf->b_p_imsearch = p_imsearch;
10182
10183 /* options that are normally global but also have a local value
10184 * are not copied, start using the global value */
10185 buf->b_p_ar = -1;
10186#ifdef FEAT_QUICKFIX
10187 buf->b_p_gp = empty_option;
10188 buf->b_p_mp = empty_option;
10189 buf->b_p_efm = empty_option;
10190#endif
10191 buf->b_p_ep = empty_option;
10192 buf->b_p_kp = empty_option;
10193 buf->b_p_path = empty_option;
10194 buf->b_p_tags = empty_option;
10195#ifdef FEAT_FIND_ID
10196 buf->b_p_def = empty_option;
10197 buf->b_p_inc = empty_option;
10198# ifdef FEAT_EVAL
10199 buf->b_p_inex = vim_strsave(p_inex);
10200# endif
10201#endif
10202#ifdef FEAT_INS_EXPAND
10203 buf->b_p_dict = empty_option;
10204 buf->b_p_tsr = empty_option;
10205#endif
Bram Moolenaarcfbc5ee2004-07-02 15:38:35 +000010206#ifdef FEAT_TEXTOBJ
10207 buf->b_p_qe = vim_strsave(p_qe);
10208#endif
Bram Moolenaar9b2200a2006-03-20 21:55:45 +000010209#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
10210 buf->b_p_bexpr = empty_option;
10211#endif
Bram Moolenaar49771f42010-07-20 17:32:38 +020010212#if defined(FEAT_CRYPT)
10213 buf->b_p_cm = empty_option;
10214#endif
Bram Moolenaar55debbe2010-05-23 23:34:36 +020010215#ifdef FEAT_PERSISTENT_UNDO
10216 buf->b_p_udf = p_udf;
10217#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010218
10219 /*
10220 * Don't copy the options set by ex_help(), use the saved values,
10221 * when going from a help buffer to a non-help buffer.
10222 * Don't touch these at all when BCO_NOHELP is used and going from
10223 * or to a help buffer.
10224 */
10225 if (dont_do_help)
10226 buf->b_p_isk = save_p_isk;
10227 else
10228 {
10229 buf->b_p_isk = vim_strsave(p_isk);
10230 did_isk = TRUE;
10231 buf->b_p_ts = p_ts;
10232 buf->b_help = FALSE;
10233#ifdef FEAT_QUICKFIX
10234 if (buf->b_p_bt[0] == 'h')
10235 clear_string_option(&buf->b_p_bt);
10236#endif
10237 buf->b_p_ma = p_ma;
10238 }
10239 }
10240
10241 /*
10242 * When the options should be copied (ignoring BCO_ALWAYS), set the
10243 * flag that indicates that the options have been initialized.
10244 */
10245 if (should_copy)
10246 buf->b_p_initialized = TRUE;
10247 }
10248
10249 check_buf_options(buf); /* make sure we don't have NULLs */
10250 if (did_isk)
10251 (void)buf_init_chartab(buf, FALSE);
10252}
10253
10254/*
10255 * Reset the 'modifiable' option and its default value.
10256 */
10257 void
10258reset_modifiable()
10259{
10260 int opt_idx;
10261
10262 curbuf->b_p_ma = FALSE;
10263 p_ma = FALSE;
10264 opt_idx = findoption((char_u *)"ma");
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000010265 if (opt_idx >= 0)
10266 options[opt_idx].def_val[VI_DEFAULT] = FALSE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010267}
10268
10269/*
10270 * Set the global value for 'iminsert' to the local value.
10271 */
10272 void
10273set_iminsert_global()
10274{
10275 p_iminsert = curbuf->b_p_iminsert;
10276}
10277
10278/*
10279 * Set the global value for 'imsearch' to the local value.
10280 */
10281 void
10282set_imsearch_global()
10283{
10284 p_imsearch = curbuf->b_p_imsearch;
10285}
10286
10287#if defined(FEAT_CMDL_COMPL) || defined(PROTO)
10288static int expand_option_idx = -1;
10289static char_u expand_option_name[5] = {'t', '_', NUL, NUL, NUL};
10290static int expand_option_flags = 0;
10291
10292 void
10293set_context_in_set_cmd(xp, arg, opt_flags)
10294 expand_T *xp;
10295 char_u *arg;
10296 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
10297{
10298 int nextchar;
10299 long_u flags = 0; /* init for GCC */
10300 int opt_idx = 0; /* init for GCC */
10301 char_u *p;
10302 char_u *s;
10303 int is_term_option = FALSE;
10304 int key;
10305
10306 expand_option_flags = opt_flags;
10307
10308 xp->xp_context = EXPAND_SETTINGS;
10309 if (*arg == NUL)
10310 {
10311 xp->xp_pattern = arg;
10312 return;
10313 }
10314 p = arg + STRLEN(arg) - 1;
10315 if (*p == ' ' && *(p - 1) != '\\')
10316 {
10317 xp->xp_pattern = p + 1;
10318 return;
10319 }
10320 while (p > arg)
10321 {
10322 s = p;
10323 /* count number of backslashes before ' ' or ',' */
10324 if (*p == ' ' || *p == ',')
10325 {
10326 while (s > arg && *(s - 1) == '\\')
10327 --s;
10328 }
10329 /* break at a space with an even number of backslashes */
10330 if (*p == ' ' && ((p - s) & 1) == 0)
10331 {
10332 ++p;
10333 break;
10334 }
10335 --p;
10336 }
Bram Moolenaar2a7b9ee2009-06-16 15:50:33 +000010337 if (STRNCMP(p, "no", 2) == 0 && STRNCMP(p, "novice", 6) != 0)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010338 {
10339 xp->xp_context = EXPAND_BOOL_SETTINGS;
10340 p += 2;
10341 }
10342 if (STRNCMP(p, "inv", 3) == 0)
10343 {
10344 xp->xp_context = EXPAND_BOOL_SETTINGS;
10345 p += 3;
10346 }
10347 xp->xp_pattern = arg = p;
10348 if (*arg == '<')
10349 {
10350 while (*p != '>')
10351 if (*p++ == NUL) /* expand terminal option name */
10352 return;
10353 key = get_special_key_code(arg + 1);
10354 if (key == 0) /* unknown name */
10355 {
10356 xp->xp_context = EXPAND_NOTHING;
10357 return;
10358 }
10359 nextchar = *++p;
10360 is_term_option = TRUE;
10361 expand_option_name[2] = KEY2TERMCAP0(key);
10362 expand_option_name[3] = KEY2TERMCAP1(key);
10363 }
10364 else
10365 {
10366 if (p[0] == 't' && p[1] == '_')
10367 {
10368 p += 2;
10369 if (*p != NUL)
10370 ++p;
10371 if (*p == NUL)
10372 return; /* expand option name */
10373 nextchar = *++p;
10374 is_term_option = TRUE;
10375 expand_option_name[2] = p[-2];
10376 expand_option_name[3] = p[-1];
10377 }
10378 else
10379 {
10380 /* Allow * wildcard */
10381 while (ASCII_ISALNUM(*p) || *p == '_' || *p == '*')
10382 p++;
10383 if (*p == NUL)
10384 return;
10385 nextchar = *p;
10386 *p = NUL;
10387 opt_idx = findoption(arg);
10388 *p = nextchar;
10389 if (opt_idx == -1 || options[opt_idx].var == NULL)
10390 {
10391 xp->xp_context = EXPAND_NOTHING;
10392 return;
10393 }
10394 flags = options[opt_idx].flags;
10395 if (flags & P_BOOL)
10396 {
10397 xp->xp_context = EXPAND_NOTHING;
10398 return;
10399 }
10400 }
10401 }
10402 /* handle "-=" and "+=" */
10403 if ((nextchar == '-' || nextchar == '+' || nextchar == '^') && p[1] == '=')
10404 {
10405 ++p;
10406 nextchar = '=';
10407 }
10408 if ((nextchar != '=' && nextchar != ':')
10409 || xp->xp_context == EXPAND_BOOL_SETTINGS)
10410 {
10411 xp->xp_context = EXPAND_UNSUCCESSFUL;
10412 return;
10413 }
10414 if (xp->xp_context != EXPAND_BOOL_SETTINGS && p[1] == NUL)
10415 {
10416 xp->xp_context = EXPAND_OLD_SETTING;
10417 if (is_term_option)
10418 expand_option_idx = -1;
10419 else
10420 expand_option_idx = opt_idx;
10421 xp->xp_pattern = p + 1;
10422 return;
10423 }
10424 xp->xp_context = EXPAND_NOTHING;
10425 if (is_term_option || (flags & P_NUM))
10426 return;
10427
10428 xp->xp_pattern = p + 1;
10429
10430 if (flags & P_EXPAND)
10431 {
10432 p = options[opt_idx].var;
10433 if (p == (char_u *)&p_bdir
10434 || p == (char_u *)&p_dir
10435 || p == (char_u *)&p_path
10436 || p == (char_u *)&p_rtp
10437#ifdef FEAT_SEARCHPATH
10438 || p == (char_u *)&p_cdpath
10439#endif
10440#ifdef FEAT_SESSION
10441 || p == (char_u *)&p_vdir
10442#endif
10443 )
10444 {
10445 xp->xp_context = EXPAND_DIRECTORIES;
10446 if (p == (char_u *)&p_path
10447#ifdef FEAT_SEARCHPATH
10448 || p == (char_u *)&p_cdpath
10449#endif
10450 )
10451 xp->xp_backslash = XP_BS_THREE;
10452 else
10453 xp->xp_backslash = XP_BS_ONE;
10454 }
10455 else
10456 {
10457 xp->xp_context = EXPAND_FILES;
10458 /* for 'tags' need three backslashes for a space */
10459 if (p == (char_u *)&p_tags)
10460 xp->xp_backslash = XP_BS_THREE;
10461 else
10462 xp->xp_backslash = XP_BS_ONE;
10463 }
10464 }
10465
10466 /* For an option that is a list of file names, find the start of the
10467 * last file name. */
10468 for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
10469 {
10470 /* count number of backslashes before ' ' or ',' */
10471 if (*p == ' ' || *p == ',')
10472 {
10473 s = p;
10474 while (s > xp->xp_pattern && *(s - 1) == '\\')
10475 --s;
10476 if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
10477 || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
10478 {
10479 xp->xp_pattern = p + 1;
10480 break;
10481 }
10482 }
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000010483
Bram Moolenaarb9a02fc2006-03-12 22:08:12 +000010484#ifdef FEAT_SPELL
Bram Moolenaar24bbcfe2005-06-28 23:32:02 +000010485 /* for 'spellsuggest' start at "file:" */
10486 if (options[opt_idx].var == (char_u *)&p_sps
10487 && STRNCMP(p, "file:", 5) == 0)
10488 {
10489 xp->xp_pattern = p + 5;
10490 break;
10491 }
10492#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010493 }
10494
10495 return;
10496}
10497
10498 int
10499ExpandSettings(xp, regmatch, num_file, file)
10500 expand_T *xp;
10501 regmatch_T *regmatch;
10502 int *num_file;
10503 char_u ***file;
10504{
10505 int num_normal = 0; /* Nr of matching non-term-code settings */
10506 int num_term = 0; /* Nr of matching terminal code settings */
10507 int opt_idx;
10508 int match;
10509 int count = 0;
10510 char_u *str;
10511 int loop;
10512 int is_term_opt;
10513 char_u name_buf[MAX_KEY_NAME_LEN];
10514 static char *(names[]) = {"all", "termcap"};
10515 int ic = regmatch->rm_ic; /* remember the ignore-case flag */
10516
10517 /* do this loop twice:
10518 * loop == 0: count the number of matching options
10519 * loop == 1: copy the matching options into allocated memory
10520 */
10521 for (loop = 0; loop <= 1; ++loop)
10522 {
10523 regmatch->rm_ic = ic;
10524 if (xp->xp_context != EXPAND_BOOL_SETTINGS)
10525 {
Bram Moolenaar2c4278f2009-05-17 11:33:22 +000010526 for (match = 0; match < (int)(sizeof(names) / sizeof(char *));
10527 ++match)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010528 if (vim_regexec(regmatch, (char_u *)names[match], (colnr_T)0))
10529 {
10530 if (loop == 0)
10531 num_normal++;
10532 else
10533 (*file)[count++] = vim_strsave((char_u *)names[match]);
10534 }
10535 }
10536 for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
10537 opt_idx++)
10538 {
10539 if (options[opt_idx].var == NULL)
10540 continue;
10541 if (xp->xp_context == EXPAND_BOOL_SETTINGS
10542 && !(options[opt_idx].flags & P_BOOL))
10543 continue;
10544 is_term_opt = istermoption(&options[opt_idx]);
10545 if (is_term_opt && num_normal > 0)
10546 continue;
10547 match = FALSE;
10548 if (vim_regexec(regmatch, str, (colnr_T)0)
10549 || (options[opt_idx].shortname != NULL
10550 && vim_regexec(regmatch,
10551 (char_u *)options[opt_idx].shortname, (colnr_T)0)))
10552 match = TRUE;
10553 else if (is_term_opt)
10554 {
10555 name_buf[0] = '<';
10556 name_buf[1] = 't';
10557 name_buf[2] = '_';
10558 name_buf[3] = str[2];
10559 name_buf[4] = str[3];
10560 name_buf[5] = '>';
10561 name_buf[6] = NUL;
10562 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10563 {
10564 match = TRUE;
10565 str = name_buf;
10566 }
10567 }
10568 if (match)
10569 {
10570 if (loop == 0)
10571 {
10572 if (is_term_opt)
10573 num_term++;
10574 else
10575 num_normal++;
10576 }
10577 else
10578 (*file)[count++] = vim_strsave(str);
10579 }
10580 }
10581 /*
10582 * Check terminal key codes, these are not in the option table
10583 */
10584 if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0)
10585 {
10586 for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++)
10587 {
10588 if (!isprint(str[0]) || !isprint(str[1]))
10589 continue;
10590
10591 name_buf[0] = 't';
10592 name_buf[1] = '_';
10593 name_buf[2] = str[0];
10594 name_buf[3] = str[1];
10595 name_buf[4] = NUL;
10596
10597 match = FALSE;
10598 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10599 match = TRUE;
10600 else
10601 {
10602 name_buf[0] = '<';
10603 name_buf[1] = 't';
10604 name_buf[2] = '_';
10605 name_buf[3] = str[0];
10606 name_buf[4] = str[1];
10607 name_buf[5] = '>';
10608 name_buf[6] = NUL;
10609
10610 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10611 match = TRUE;
10612 }
10613 if (match)
10614 {
10615 if (loop == 0)
10616 num_term++;
10617 else
10618 (*file)[count++] = vim_strsave(name_buf);
10619 }
10620 }
10621
10622 /*
10623 * Check special key names.
10624 */
10625 regmatch->rm_ic = TRUE; /* ignore case here */
10626 for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++)
10627 {
10628 name_buf[0] = '<';
10629 STRCPY(name_buf + 1, str);
10630 STRCAT(name_buf, ">");
10631
10632 if (vim_regexec(regmatch, name_buf, (colnr_T)0))
10633 {
10634 if (loop == 0)
10635 num_term++;
10636 else
10637 (*file)[count++] = vim_strsave(name_buf);
10638 }
10639 }
10640 }
10641 if (loop == 0)
10642 {
10643 if (num_normal > 0)
10644 *num_file = num_normal;
10645 else if (num_term > 0)
10646 *num_file = num_term;
10647 else
10648 return OK;
10649 *file = (char_u **)alloc((unsigned)(*num_file * sizeof(char_u *)));
10650 if (*file == NULL)
10651 {
10652 *file = (char_u **)"";
10653 return FAIL;
10654 }
10655 }
10656 }
10657 return OK;
10658}
10659
10660 int
10661ExpandOldSetting(num_file, file)
10662 int *num_file;
10663 char_u ***file;
10664{
10665 char_u *var = NULL; /* init for GCC */
10666 char_u *buf;
10667
10668 *num_file = 0;
10669 *file = (char_u **)alloc((unsigned)sizeof(char_u *));
10670 if (*file == NULL)
10671 return FAIL;
10672
10673 /*
10674 * For a terminal key code expand_option_idx is < 0.
10675 */
10676 if (expand_option_idx < 0)
10677 {
10678 var = find_termcode(expand_option_name + 2);
10679 if (var == NULL)
10680 expand_option_idx = findoption(expand_option_name);
10681 }
10682
10683 if (expand_option_idx >= 0)
10684 {
10685 /* put string of option value in NameBuff */
10686 option_value2string(&options[expand_option_idx], expand_option_flags);
10687 var = NameBuff;
10688 }
10689 else if (var == NULL)
10690 var = (char_u *)"";
10691
10692 /* A backslash is required before some characters. This is the reverse of
10693 * what happens in do_set(). */
10694 buf = vim_strsave_escaped(var, escape_chars);
10695
10696 if (buf == NULL)
10697 {
10698 vim_free(*file);
10699 *file = NULL;
10700 return FAIL;
10701 }
10702
10703#ifdef BACKSLASH_IN_FILENAME
10704 /* For MS-Windows et al. we don't double backslashes at the start and
10705 * before a file name character. */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000010706 for (var = buf; *var != NUL; mb_ptr_adv(var))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010707 if (var[0] == '\\' && var[1] == '\\'
10708 && expand_option_idx >= 0
10709 && (options[expand_option_idx].flags & P_EXPAND)
10710 && vim_isfilec(var[2])
10711 && (var[2] != '\\' || (var == buf && var[4] != '\\')))
Bram Moolenaarc1a11ed2008-06-24 22:09:24 +000010712 STRMOVE(var, var + 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010713#endif
10714
10715 *file[0] = buf;
10716 *num_file = 1;
10717 return OK;
10718}
10719#endif
10720
10721/*
10722 * Get the value for the numeric or string option *opp in a nice format into
10723 * NameBuff[]. Must not be called with a hidden option!
10724 */
10725 static void
10726option_value2string(opp, opt_flags)
10727 struct vimoption *opp;
10728 int opt_flags; /* OPT_GLOBAL and/or OPT_LOCAL */
10729{
10730 char_u *varp;
10731
10732 varp = get_varp_scope(opp, opt_flags);
10733
10734 if (opp->flags & P_NUM)
10735 {
10736 long wc = 0;
10737
10738 if (wc_use_keyname(varp, &wc))
10739 STRCPY(NameBuff, get_special_key_name((int)wc, 0));
10740 else if (wc != 0)
10741 STRCPY(NameBuff, transchar((int)wc));
10742 else
10743 sprintf((char *)NameBuff, "%ld", *(long *)varp);
10744 }
10745 else /* P_STRING */
10746 {
10747 varp = *(char_u **)(varp);
10748 if (varp == NULL) /* just in case */
10749 NameBuff[0] = NUL;
10750#ifdef FEAT_CRYPT
10751 /* don't show the actual value of 'key', only that it's set */
Bram Moolenaareb3593b2006-04-22 22:33:57 +000010752 else if (opp->var == (char_u *)&p_key && *varp)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010753 STRCPY(NameBuff, "*****");
10754#endif
10755 else if (opp->flags & P_EXPAND)
10756 home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE);
10757 /* Translate 'pastetoggle' into special key names */
10758 else if ((char_u **)opp->var == &p_pt)
10759 str2specialbuf(p_pt, NameBuff, MAXPATHL);
10760 else
Bram Moolenaarce0842a2005-07-18 21:58:11 +000010761 vim_strncpy(NameBuff, varp, MAXPATHL - 1);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010762 }
10763}
10764
10765/*
10766 * Return TRUE if "varp" points to 'wildchar' or 'wildcharm' and it can be
10767 * printed as a keyname.
10768 * "*wcp" is set to the value of the option if it's 'wildchar' or 'wildcharm'.
10769 */
10770 static int
10771wc_use_keyname(varp, wcp)
10772 char_u *varp;
10773 long *wcp;
10774{
10775 if (((long *)varp == &p_wc) || ((long *)varp == &p_wcm))
10776 {
10777 *wcp = *(long *)varp;
10778 if (IS_SPECIAL(*wcp) || find_special_key_in_table((int)*wcp) >= 0)
10779 return TRUE;
10780 }
10781 return FALSE;
10782}
10783
10784#ifdef FEAT_LANGMAP
10785/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000010786 * Any character has an equivalent 'langmap' character. This is used for
10787 * keyboards that have a special language mode that sends characters above
10788 * 128 (although other characters can be translated too). The "to" field is a
10789 * Vim command character. This avoids having to switch the keyboard back to
10790 * ASCII mode when leaving Insert mode.
10791 *
10792 * langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
10793 * commands.
10794 * When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
10795 * langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
10796 * 256.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010797 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000010798# ifdef FEAT_MBYTE
10799/*
10800 * With multi-byte support use growarray for 'langmap' chars >= 256
10801 */
10802typedef struct
10803{
10804 int from;
10805 int to;
10806} langmap_entry_T;
10807
10808static garray_T langmap_mapga;
10809static void langmap_set_entry __ARGS((int from, int to));
Bram Moolenaar071d4272004-06-13 20:20:40 +000010810
10811/*
Bram Moolenaar28e8d272009-02-21 19:28:48 +000010812 * Search for an entry in "langmap_mapga" for "from". If found set the "to"
10813 * field. If not found insert a new entry at the appropriate location.
Bram Moolenaar071d4272004-06-13 20:20:40 +000010814 */
Bram Moolenaar28e8d272009-02-21 19:28:48 +000010815 static void
10816langmap_set_entry(from, to)
10817 int from;
10818 int to;
10819{
10820 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
Bram Moolenaarcc448b32010-07-14 16:52:17 +020010821 int a = 0;
10822 int b = langmap_mapga.ga_len;
Bram Moolenaar28e8d272009-02-21 19:28:48 +000010823
10824 /* Do a binary search for an existing entry. */
10825 while (a != b)
10826 {
10827 int i = (a + b) / 2;
10828 int d = entries[i].from - from;
10829
10830 if (d == 0)
10831 {
10832 entries[i].to = to;
10833 return;
10834 }
10835 if (d < 0)
10836 a = i + 1;
10837 else
10838 b = i;
10839 }
10840
10841 if (ga_grow(&langmap_mapga, 1) != OK)
10842 return; /* out of memory */
10843
10844 /* insert new entry at position "a" */
10845 entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
10846 mch_memmove(entries + 1, entries,
10847 (langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
10848 ++langmap_mapga.ga_len;
10849 entries[0].from = from;
10850 entries[0].to = to;
10851}
10852
10853/*
10854 * Apply 'langmap' to multi-byte character "c" and return the result.
10855 */
10856 int
10857langmap_adjust_mb(c)
10858 int c;
10859{
10860 langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
10861 int a = 0;
10862 int b = langmap_mapga.ga_len;
10863
10864 while (a != b)
10865 {
10866 int i = (a + b) / 2;
10867 int d = entries[i].from - c;
10868
10869 if (d == 0)
10870 return entries[i].to; /* found matching entry */
10871 if (d < 0)
10872 a = i + 1;
10873 else
10874 b = i;
10875 }
10876 return c; /* no entry found, return "c" unmodified */
10877}
10878# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010879
10880 static void
10881langmap_init()
10882{
10883 int i;
10884
Bram Moolenaar28e8d272009-02-21 19:28:48 +000010885 for (i = 0; i < 256; i++)
10886 langmap_mapchar[i] = i; /* we init with a one-to-one map */
10887# ifdef FEAT_MBYTE
10888 ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
10889# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000010890}
10891
10892/*
10893 * Called when langmap option is set; the language map can be
10894 * changed at any time!
10895 */
10896 static void
10897langmap_set()
10898{
10899 char_u *p;
10900 char_u *p2;
10901 int from, to;
10902
Bram Moolenaar28e8d272009-02-21 19:28:48 +000010903#ifdef FEAT_MBYTE
10904 ga_clear(&langmap_mapga); /* clear the previous map first */
10905#endif
10906 langmap_init(); /* back to one-to-one map */
Bram Moolenaar071d4272004-06-13 20:20:40 +000010907
10908 for (p = p_langmap; p[0] != NUL; )
10909 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000010910 for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
10911 mb_ptr_adv(p2))
Bram Moolenaar071d4272004-06-13 20:20:40 +000010912 {
10913 if (p2[0] == '\\' && p2[1] != NUL)
10914 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010915 }
10916 if (p2[0] == ';')
10917 ++p2; /* abcd;ABCD form, p2 points to A */
10918 else
10919 p2 = NULL; /* aAbBcCdD form, p2 is NULL */
10920 while (p[0])
10921 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020010922 if (p[0] == ',')
10923 {
10924 ++p;
10925 break;
10926 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000010927 if (p[0] == '\\' && p[1] != NUL)
10928 ++p;
10929#ifdef FEAT_MBYTE
10930 from = (*mb_ptr2char)(p);
10931#else
10932 from = p[0];
10933#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020010934 to = NUL;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010935 if (p2 == NULL)
10936 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000010937 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020010938 if (p[0] != ',')
10939 {
10940 if (p[0] == '\\')
10941 ++p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010942#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020010943 to = (*mb_ptr2char)(p);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010944#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020010945 to = p[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000010946#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020010947 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000010948 }
10949 else
10950 {
Bram Moolenaar6af05062010-05-14 17:32:58 +020010951 if (p2[0] != ',')
10952 {
10953 if (p2[0] == '\\')
10954 ++p2;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010955#ifdef FEAT_MBYTE
Bram Moolenaar6af05062010-05-14 17:32:58 +020010956 to = (*mb_ptr2char)(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010957#else
Bram Moolenaar6af05062010-05-14 17:32:58 +020010958 to = p2[0];
Bram Moolenaar071d4272004-06-13 20:20:40 +000010959#endif
Bram Moolenaar6af05062010-05-14 17:32:58 +020010960 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000010961 }
10962 if (to == NUL)
10963 {
10964 EMSG2(_("E357: 'langmap': Matching character missing for %s"),
10965 transchar(from));
10966 return;
10967 }
Bram Moolenaar28e8d272009-02-21 19:28:48 +000010968
10969#ifdef FEAT_MBYTE
10970 if (from >= 256)
10971 langmap_set_entry(from, to);
10972 else
10973#endif
10974 langmap_mapchar[from & 255] = to;
Bram Moolenaar071d4272004-06-13 20:20:40 +000010975
10976 /* Advance to next pair */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000010977 mb_ptr_adv(p);
Bram Moolenaar6af05062010-05-14 17:32:58 +020010978 if (p2 != NULL)
Bram Moolenaar071d4272004-06-13 20:20:40 +000010979 {
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000010980 mb_ptr_adv(p2);
Bram Moolenaar071d4272004-06-13 20:20:40 +000010981 if (*p == ';')
10982 {
10983 p = p2;
10984 if (p[0] != NUL)
10985 {
10986 if (p[0] != ',')
10987 {
10988 EMSG2(_("E358: 'langmap': Extra characters after semicolon: %s"), p);
10989 return;
10990 }
10991 ++p;
10992 }
10993 break;
10994 }
10995 }
10996 }
10997 }
10998}
10999#endif
11000
11001/*
11002 * Return TRUE if format option 'x' is in effect.
11003 * Take care of no formatting when 'paste' is set.
11004 */
11005 int
11006has_format_option(x)
11007 int x;
11008{
11009 if (p_paste)
11010 return FALSE;
11011 return (vim_strchr(curbuf->b_p_fo, x) != NULL);
11012}
11013
11014/*
11015 * Return TRUE if "x" is present in 'shortmess' option, or
11016 * 'shortmess' contains 'a' and "x" is present in SHM_A.
11017 */
11018 int
11019shortmess(x)
11020 int x;
11021{
Bram Moolenaar7f29f7a2012-02-29 13:51:37 +010011022 return p_shm != NULL &&
11023 ( vim_strchr(p_shm, x) != NULL
Bram Moolenaar071d4272004-06-13 20:20:40 +000011024 || (vim_strchr(p_shm, 'a') != NULL
11025 && vim_strchr((char_u *)SHM_A, x) != NULL));
11026}
11027
11028/*
11029 * paste_option_changed() - Called after p_paste was set or reset.
11030 */
11031 static void
11032paste_option_changed()
11033{
11034 static int old_p_paste = FALSE;
11035 static int save_sm = 0;
11036#ifdef FEAT_CMDL_INFO
11037 static int save_ru = 0;
11038#endif
11039#ifdef FEAT_RIGHTLEFT
11040 static int save_ri = 0;
11041 static int save_hkmap = 0;
11042#endif
11043 buf_T *buf;
11044
11045 if (p_paste)
11046 {
11047 /*
11048 * Paste switched from off to on.
11049 * Save the current values, so they can be restored later.
11050 */
11051 if (!old_p_paste)
11052 {
11053 /* save options for each buffer */
11054 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11055 {
11056 buf->b_p_tw_nopaste = buf->b_p_tw;
11057 buf->b_p_wm_nopaste = buf->b_p_wm;
11058 buf->b_p_sts_nopaste = buf->b_p_sts;
11059 buf->b_p_ai_nopaste = buf->b_p_ai;
11060 }
11061
11062 /* save global options */
11063 save_sm = p_sm;
11064#ifdef FEAT_CMDL_INFO
11065 save_ru = p_ru;
11066#endif
11067#ifdef FEAT_RIGHTLEFT
11068 save_ri = p_ri;
11069 save_hkmap = p_hkmap;
11070#endif
11071 /* save global values for local buffer options */
11072 p_tw_nopaste = p_tw;
11073 p_wm_nopaste = p_wm;
11074 p_sts_nopaste = p_sts;
11075 p_ai_nopaste = p_ai;
11076 }
11077
11078 /*
11079 * Always set the option values, also when 'paste' is set when it is
11080 * already on.
11081 */
11082 /* set options for each buffer */
11083 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11084 {
11085 buf->b_p_tw = 0; /* textwidth is 0 */
11086 buf->b_p_wm = 0; /* wrapmargin is 0 */
11087 buf->b_p_sts = 0; /* softtabstop is 0 */
11088 buf->b_p_ai = 0; /* no auto-indent */
11089 }
11090
11091 /* set global options */
11092 p_sm = 0; /* no showmatch */
11093#ifdef FEAT_CMDL_INFO
11094# ifdef FEAT_WINDOWS
11095 if (p_ru)
11096 status_redraw_all(); /* redraw to remove the ruler */
11097# endif
11098 p_ru = 0; /* no ruler */
11099#endif
11100#ifdef FEAT_RIGHTLEFT
11101 p_ri = 0; /* no reverse insert */
11102 p_hkmap = 0; /* no Hebrew keyboard */
11103#endif
11104 /* set global values for local buffer options */
11105 p_tw = 0;
11106 p_wm = 0;
11107 p_sts = 0;
11108 p_ai = 0;
11109 }
11110
11111 /*
11112 * Paste switched from on to off: Restore saved values.
11113 */
11114 else if (old_p_paste)
11115 {
11116 /* restore options for each buffer */
11117 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
11118 {
11119 buf->b_p_tw = buf->b_p_tw_nopaste;
11120 buf->b_p_wm = buf->b_p_wm_nopaste;
11121 buf->b_p_sts = buf->b_p_sts_nopaste;
11122 buf->b_p_ai = buf->b_p_ai_nopaste;
11123 }
11124
11125 /* restore global options */
11126 p_sm = save_sm;
11127#ifdef FEAT_CMDL_INFO
11128# ifdef FEAT_WINDOWS
11129 if (p_ru != save_ru)
11130 status_redraw_all(); /* redraw to draw the ruler */
11131# endif
11132 p_ru = save_ru;
11133#endif
11134#ifdef FEAT_RIGHTLEFT
11135 p_ri = save_ri;
11136 p_hkmap = save_hkmap;
11137#endif
11138 /* set global values for local buffer options */
11139 p_tw = p_tw_nopaste;
11140 p_wm = p_wm_nopaste;
11141 p_sts = p_sts_nopaste;
11142 p_ai = p_ai_nopaste;
11143 }
11144
11145 old_p_paste = p_paste;
11146}
11147
11148/*
11149 * vimrc_found() - Called when a ".vimrc" or "VIMINIT" has been found.
11150 *
11151 * Reset 'compatible' and set the values for options that didn't get set yet
11152 * to the Vim defaults.
11153 * Don't do this if the 'compatible' option has been set or reset before.
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011154 * When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011155 */
11156 void
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011157vimrc_found(fname, envname)
11158 char_u *fname;
11159 char_u *envname;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011160{
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011161 int opt_idx;
Bram Moolenaar4c3f5362006-04-11 21:38:50 +000011162 int dofree = FALSE;
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011163 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011164
11165 if (!option_was_set((char_u *)"cp"))
11166 {
11167 p_cp = FALSE;
11168 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11169 if (!(options[opt_idx].flags & (P_WAS_SET|P_VI_DEF)))
11170 set_option_default(opt_idx, OPT_FREE, FALSE);
11171 didset_options();
11172 }
Bram Moolenaar910f66f2006-04-05 20:41:53 +000011173
11174 if (fname != NULL)
11175 {
11176 p = vim_getenv(envname, &dofree);
11177 if (p == NULL)
11178 {
11179 /* Set $MYVIMRC to the first vimrc file found. */
11180 p = FullName_save(fname, FALSE);
11181 if (p != NULL)
11182 {
11183 vim_setenv(envname, p);
11184 vim_free(p);
11185 }
11186 }
11187 else if (dofree)
11188 vim_free(p);
11189 }
Bram Moolenaar071d4272004-06-13 20:20:40 +000011190}
11191
11192/*
11193 * Set 'compatible' on or off. Called for "-C" and "-N" command line arg.
11194 */
11195 void
11196change_compatible(on)
11197 int on;
11198{
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011199 int opt_idx;
11200
Bram Moolenaar071d4272004-06-13 20:20:40 +000011201 if (p_cp != on)
11202 {
11203 p_cp = on;
11204 compatible_set();
11205 }
Bram Moolenaarfc1421e2006-04-20 22:17:20 +000011206 opt_idx = findoption((char_u *)"cp");
11207 if (opt_idx >= 0)
11208 options[opt_idx].flags |= P_WAS_SET;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011209}
11210
11211/*
11212 * Return TRUE when option "name" has been set.
11213 */
11214 int
11215option_was_set(name)
11216 char_u *name;
11217{
11218 int idx;
11219
11220 idx = findoption(name);
11221 if (idx < 0) /* unknown option */
11222 return FALSE;
11223 if (options[idx].flags & P_WAS_SET)
11224 return TRUE;
11225 return FALSE;
11226}
11227
11228/*
Bram Moolenaar15d55de2012-12-05 14:43:02 +010011229 * Reset the flag indicating option "name" was set.
11230 */
11231 void
11232reset_option_was_set(name)
11233 char_u *name;
11234{
11235 int idx = findoption(name);
11236
11237 if (idx >= 0)
11238 options[idx].flags &= ~P_WAS_SET;
11239}
11240
11241/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000011242 * compatible_set() - Called when 'compatible' has been set or unset.
11243 *
11244 * When 'compatible' set: Set all relevant options (those that have the P_VIM)
11245 * flag) to a Vi compatible value.
11246 * When 'compatible' is unset: Set all options that have a different default
11247 * for Vim (without the P_VI_DEF flag) to that default.
11248 */
11249 static void
11250compatible_set()
11251{
11252 int opt_idx;
11253
11254 for (opt_idx = 0; !istermoption(&options[opt_idx]); opt_idx++)
11255 if ( ((options[opt_idx].flags & P_VIM) && p_cp)
11256 || (!(options[opt_idx].flags & P_VI_DEF) && !p_cp))
11257 set_option_default(opt_idx, OPT_FREE, p_cp);
11258 didset_options();
11259}
11260
11261#ifdef FEAT_LINEBREAK
11262
11263# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
11264 /* Borland C++ screws up loop optimisation here (negri) */
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011265 #pragma option -O-l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011266# endif
11267
11268/*
11269 * fill_breakat_flags() -- called when 'breakat' changes value.
11270 */
11271 static void
11272fill_breakat_flags()
11273{
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011274 char_u *p;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011275 int i;
11276
11277 for (i = 0; i < 256; i++)
11278 breakat_flags[i] = FALSE;
11279
11280 if (p_breakat != NULL)
Bram Moolenaarac6e65f2005-08-29 22:25:38 +000011281 for (p = p_breakat; *p; p++)
11282 breakat_flags[*p] = TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011283}
11284
11285# if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
Bram Moolenaar8f999f12005-01-25 22:12:55 +000011286 #pragma option -O.l
Bram Moolenaar071d4272004-06-13 20:20:40 +000011287# endif
11288
11289#endif
11290
11291/*
11292 * Check an option that can be a range of string values.
11293 *
11294 * Return OK for correct value, FAIL otherwise.
11295 * Empty is always OK.
11296 */
11297 static int
11298check_opt_strings(val, values, list)
11299 char_u *val;
11300 char **values;
11301 int list; /* when TRUE: accept a list of values */
11302{
11303 return opt_strings_flags(val, values, NULL, list);
11304}
11305
11306/*
11307 * Handle an option that can be a range of string values.
11308 * Set a flag in "*flagp" for each string present.
11309 *
11310 * Return OK for correct value, FAIL otherwise.
11311 * Empty is always OK.
11312 */
11313 static int
11314opt_strings_flags(val, values, flagp, list)
11315 char_u *val; /* new value */
11316 char **values; /* array of valid string values */
11317 unsigned *flagp;
11318 int list; /* when TRUE: accept a list of values */
11319{
11320 int i;
11321 int len;
11322 unsigned new_flags = 0;
11323
11324 while (*val)
11325 {
11326 for (i = 0; ; ++i)
11327 {
11328 if (values[i] == NULL) /* val not found in values[] */
11329 return FAIL;
11330
11331 len = (int)STRLEN(values[i]);
11332 if (STRNCMP(values[i], val, len) == 0
11333 && ((list && val[len] == ',') || val[len] == NUL))
11334 {
11335 val += len + (val[len] == ',');
11336 new_flags |= (1 << i);
11337 break; /* check next item in val list */
11338 }
11339 }
11340 }
11341 if (flagp != NULL)
11342 *flagp = new_flags;
11343
11344 return OK;
11345}
11346
11347/*
11348 * Read the 'wildmode' option, fill wim_flags[].
11349 */
11350 static int
11351check_opt_wim()
11352{
11353 char_u new_wim_flags[4];
11354 char_u *p;
11355 int i;
11356 int idx = 0;
11357
11358 for (i = 0; i < 4; ++i)
11359 new_wim_flags[i] = 0;
11360
11361 for (p = p_wim; *p; ++p)
11362 {
11363 for (i = 0; ASCII_ISALPHA(p[i]); ++i)
11364 ;
11365 if (p[i] != NUL && p[i] != ',' && p[i] != ':')
11366 return FAIL;
11367 if (i == 7 && STRNCMP(p, "longest", 7) == 0)
11368 new_wim_flags[idx] |= WIM_LONGEST;
11369 else if (i == 4 && STRNCMP(p, "full", 4) == 0)
11370 new_wim_flags[idx] |= WIM_FULL;
11371 else if (i == 4 && STRNCMP(p, "list", 4) == 0)
11372 new_wim_flags[idx] |= WIM_LIST;
11373 else
11374 return FAIL;
11375 p += i;
11376 if (*p == NUL)
11377 break;
11378 if (*p == ',')
11379 {
11380 if (idx == 3)
11381 return FAIL;
11382 ++idx;
11383 }
11384 }
11385
11386 /* fill remaining entries with last flag */
11387 while (idx < 3)
11388 {
11389 new_wim_flags[idx + 1] = new_wim_flags[idx];
11390 ++idx;
11391 }
11392
11393 /* only when there are no errors, wim_flags[] is changed */
11394 for (i = 0; i < 4; ++i)
11395 wim_flags[i] = new_wim_flags[i];
11396 return OK;
11397}
11398
11399/*
11400 * Check if backspacing over something is allowed.
11401 */
11402 int
11403can_bs(what)
11404 int what; /* BS_INDENT, BS_EOL or BS_START */
11405{
11406 switch (*p_bs)
11407 {
11408 case '2': return TRUE;
11409 case '1': return (what != BS_START);
11410 case '0': return FALSE;
11411 }
11412 return vim_strchr(p_bs, what) != NULL;
11413}
11414
11415/*
11416 * Save the current values of 'fileformat' and 'fileencoding', so that we know
11417 * the file must be considered changed when the value is different.
11418 */
11419 void
11420save_file_ff(buf)
11421 buf_T *buf;
11422{
11423 buf->b_start_ffc = *buf->b_p_ff;
11424 buf->b_start_eol = buf->b_p_eol;
11425#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011426 buf->b_start_bomb = buf->b_p_bomb;
11427
Bram Moolenaar071d4272004-06-13 20:20:40 +000011428 /* Only use free/alloc when necessary, they take time. */
11429 if (buf->b_start_fenc == NULL
11430 || STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0)
11431 {
11432 vim_free(buf->b_start_fenc);
11433 buf->b_start_fenc = vim_strsave(buf->b_p_fenc);
11434 }
11435#endif
11436}
11437
11438/*
11439 * Return TRUE if 'fileformat' and/or 'fileencoding' has a different value
11440 * from when editing started (save_file_ff() called).
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011441 * Also when 'endofline' was changed and 'binary' is set, or when 'bomb' was
11442 * changed and 'binary' is not set.
Bram Moolenaar164c60f2011-01-22 00:11:50 +010011443 * When "ignore_empty" is true don't consider a new, empty buffer to be
11444 * changed.
Bram Moolenaar071d4272004-06-13 20:20:40 +000011445 */
11446 int
Bram Moolenaar164c60f2011-01-22 00:11:50 +010011447file_ff_differs(buf, ignore_empty)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011448 buf_T *buf;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010011449 int ignore_empty;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011450{
Bram Moolenaar9cffde92007-07-24 07:51:18 +000011451 /* In a buffer that was never loaded the options are not valid. */
11452 if (buf->b_flags & BF_NEVERLOADED)
11453 return FALSE;
Bram Moolenaar164c60f2011-01-22 00:11:50 +010011454 if (ignore_empty
11455 && (buf->b_flags & BF_NEW)
Bram Moolenaar071d4272004-06-13 20:20:40 +000011456 && buf->b_ml.ml_line_count == 1
11457 && *ml_get_buf(buf, (linenr_T)1, FALSE) == NUL)
11458 return FALSE;
11459 if (buf->b_start_ffc != *buf->b_p_ff)
11460 return TRUE;
11461 if (buf->b_p_bin && buf->b_start_eol != buf->b_p_eol)
11462 return TRUE;
11463#ifdef FEAT_MBYTE
Bram Moolenaar83eb8852007-08-12 13:51:26 +000011464 if (!buf->b_p_bin && buf->b_start_bomb != buf->b_p_bomb)
11465 return TRUE;
Bram Moolenaar071d4272004-06-13 20:20:40 +000011466 if (buf->b_start_fenc == NULL)
11467 return (*buf->b_p_fenc != NUL);
11468 return (STRCMP(buf->b_start_fenc, buf->b_p_fenc) != 0);
11469#else
11470 return FALSE;
11471#endif
11472}
11473
11474/*
11475 * return OK if "p" is a valid fileformat name, FAIL otherwise.
11476 */
11477 int
11478check_ff_value(p)
11479 char_u *p;
11480{
11481 return check_opt_strings(p, p_ff_values, FALSE);
11482}
Bram Moolenaar14f24742012-08-08 18:01:05 +020011483
11484/*
11485 * Return the effective shiftwidth value for current buffer, using the
11486 * 'tabstop' value when 'shiftwidth' is zero.
11487 */
11488 long
11489get_sw_value()
11490{
11491 return curbuf->b_p_sw ? curbuf->b_p_sw : curbuf->b_p_ts;
11492}
Bram Moolenaar9f340fa2012-10-21 00:10:39 +020011493
11494/*
11495 * Return the effective softtabstop value for the current buffer, using the
11496 * 'tabstop' value when 'softtabstop' is negative.
11497 */
11498 long
11499get_sts_value()
11500{
11501 return curbuf->b_p_sts < 0 ? get_sw_value() : curbuf->b_p_sts;
11502}
Bram Moolenaar8c7694a2013-01-17 17:02:05 +010011503
11504/*
11505 * Check matchpairs option for "*initc".
11506 * If there is a match set "*initc" to the matching character and "*findc" to
11507 * the opposite character. Set "*backwards" to the direction.
11508 * When "switchit" is TRUE swap the direction.
11509 */
11510 void
11511find_mps_values(initc, findc, backwards, switchit)
11512 int *initc;
11513 int *findc;
11514 int *backwards;
11515 int switchit;
11516{
11517 char_u *ptr;
11518
11519 ptr = curbuf->b_p_mps;
11520 while (*ptr != NUL)
11521 {
11522#ifdef FEAT_MBYTE
11523 if (has_mbyte)
11524 {
11525 char_u *prev;
11526
11527 if (mb_ptr2char(ptr) == *initc)
11528 {
11529 if (switchit)
11530 {
11531 *findc = *initc;
11532 *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
11533 *backwards = TRUE;
11534 }
11535 else
11536 {
11537 *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1);
11538 *backwards = FALSE;
11539 }
11540 return;
11541 }
11542 prev = ptr;
11543 ptr += mb_ptr2len(ptr) + 1;
11544 if (mb_ptr2char(ptr) == *initc)
11545 {
11546 if (switchit)
11547 {
11548 *findc = *initc;
11549 *initc = mb_ptr2char(prev);
11550 *backwards = FALSE;
11551 }
11552 else
11553 {
11554 *findc = mb_ptr2char(prev);
11555 *backwards = TRUE;
11556 }
11557 return;
11558 }
11559 ptr += mb_ptr2len(ptr);
11560 }
11561 else
11562#endif
11563 {
11564 if (*ptr == *initc)
11565 {
11566 if (switchit)
11567 {
11568 *backwards = TRUE;
11569 *findc = *initc;
11570 *initc = ptr[2];
11571 }
11572 else
11573 {
11574 *backwards = FALSE;
11575 *findc = ptr[2];
11576 }
11577 return;
11578 }
11579 ptr += 2;
11580 if (*ptr == *initc)
11581 {
11582 if (switchit)
11583 {
11584 *backwards = FALSE;
11585 *findc = *initc;
11586 *initc = ptr[-2];
11587 }
11588 else
11589 {
11590 *backwards = TRUE;
11591 *findc = ptr[-2];
11592 }
11593 return;
11594 }
11595 ++ptr;
11596 }
11597 if (*ptr == ',')
11598 ++ptr;
11599 }
11600}